forked from TypeCellOS/BlockNote
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathExampleBlock.tsx
More file actions
57 lines (51 loc) · 1.84 KB
/
ExampleBlock.tsx
File metadata and controls
57 lines (51 loc) · 1.84 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
import dynamic from "next/dynamic";
import { AiFillGithub } from "react-icons/ai";
import { SiStackblitz } from "react-icons/si";
import { examples } from "./generated/exampleComponents.gen";
import "./styles.css";
const baseGitHubURL = "https://github.com/TypeCellOS/BlockNote/tree/main/";
// const baseCodeSandboxURL =
// "https://githubbox.com/TypeCellOS/BlockNote/tree/main/";
const baseStackBlitzURL =
"https://www.stackblitz.com/github/TypeCellOS/BlockNote/tree/main/";
const ThemedExample = dynamic(() => import("./ThemedExample"), {
ssr: false,
});
export function ExampleBlock(props: {
name: keyof typeof examples;
path: string;
children: any;
}) {
// const example = examplesFlattened.find((e) => e.slug === props.name);
// if (!example) {
// throw new Error("invalid example");
// }
return (
<div className="demo nx-bg-primary-700/5 dark:nx-bg-primary-300/10 mt-6 rounded-lg p-4">
<div className={"flex flex-row gap-6 pb-4"}>
<a
className={
"nx-select-none nx-text-gray-600 hover:nx-text-black dark:nx-text-gray-200 dark:hover:nx-text-white flex flex-row items-center gap-1"
}
href={`${baseGitHubURL}${props.path}/`}
target="_blank">
<AiFillGithub />
<div className={"text-sm"}>GitHub</div>
</a>
<a
className={
"nx-select-none nx-text-gray-600 hover:nx-text-black dark:nx-text-gray-200 dark:hover:nx-text-white flex flex-row items-center gap-1"
}
href={`${baseStackBlitzURL}${props.path}/`}
target="_blank">
<SiStackblitz />
<div className={"text-sm"}>StackBlitz</div>
</a>
</div>
<div className={"demo-contents h-96 overflow-auto rounded-lg"}>
<ThemedExample name={props.name} />
</div>
{props.children}
</div>
);
}