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
107 lines (100 loc) · 3.55 KB
/
ExampleBlock.tsx
File metadata and controls
107 lines (100 loc) · 3.55 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
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
import { signIn } from "next-auth/react";
import dynamic from "next/dynamic";
import { AiFillGithub } from "react-icons/ai";
import { SiStackblitz } from "react-icons/si";
import CTAButton from "../../components/pages/landing/shared/CTAButton";
import { SectionHeader } from "../../components/pages/landing/shared/Headings";
import { examples } from "./generated/exampleComponents.gen";
import "../pages/landing/gradients.css";
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;
isProExample?: {
userStatus: "business" | "starter" | "free" | undefined;
};
}) {
const showCode =
!props.isProExample ||
props.isProExample.userStatus === "starter" ||
props.isProExample.userStatus === "business";
return (
<div className="demo nx-bg-primary-700/5 dark:nx-bg-primary-300/10 mt-6 rounded-lg p-4">
{showCode && (
<div className={"z-10 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>
{showCode ? (
props.children
) : (
<div
className={
"relative flex h-96 flex-col items-center justify-center gap-2"
}>
<div className={"absolute h-1/2 w-1/2"}>
<div className={"cta-glow h-full w-full"}></div>
</div>
<div className={"z-10 flex w-2/3 flex-col items-center"}>
<SectionHeader>Pro Example</SectionHeader>
<p className={"text-center text-[#00000080] dark:text-[#FFFFFFB2]"}>
Get access to the full source code for pro examples by subscribing
to BlockNote Pro
</p>
<div className={"mt-8"}>
<CTAButton
href={"/pricing"}
color={"pro"}
size={"large"}
hoverGlow={true}>
Get BlockNote Pro
</CTAButton>
</div>
{!props.isProExample?.userStatus && (
<p className={"mt-1 text-xs"}>
Or{" "}
<button
className={"nx-text-primary-600"}
onClick={async () => {
await signIn("github", {});
}}>
sign in
</button>{" "}
via GitHub
</p>
)}
</div>
</div>
)}
</div>
);
}