1+ import { signIn } from "next-auth/react" ;
12import dynamic from "next/dynamic" ;
23import { AiFillGithub } from "react-icons/ai" ;
34import { SiStackblitz } from "react-icons/si" ;
45
6+ import CTAButton from "../../components/pages/landing/shared/CTAButton" ;
7+ import { SectionHeader } from "../../components/pages/landing/shared/Headings" ;
58import { examples } from "./generated/exampleComponents.gen" ;
9+
10+ import "../pages/landing/gradients.css" ;
611import "./styles.css" ;
712
813const baseGitHubURL = "https://github.com/TypeCellOS/BlockNote/tree/main/" ;
@@ -20,38 +25,83 @@ export function ExampleBlock(props: {
2025 name : keyof typeof examples ;
2126 path : string ;
2227 children : any ;
28+ isProExample ?: {
29+ userStatus : "business" | "starter" | "free" | undefined ;
30+ } ;
2331} ) {
24- // const example = examplesFlattened.find((e) => e.slug === props.name);
25- // if (!example) {
26- // throw new Error("invalid example");
27- // }
32+ const showCode =
33+ ! props . isProExample ||
34+ props . isProExample . userStatus === "starter" ||
35+ props . isProExample . userStatus === "business" ;
2836
2937 return (
3038 < div className = "demo nx-bg-primary-700/5 dark:nx-bg-primary-300/10 mt-6 rounded-lg p-4" >
31- < div className = { "flex flex-row gap-6 pb-4" } >
32- < a
33- className = {
34- "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"
35- }
36- href = { `${ baseGitHubURL } ${ props . path } /` }
37- target = "_blank" >
38- < AiFillGithub />
39- < div className = { "text-sm" } > GitHub</ div >
40- </ a >
41- < a
42- className = {
43- "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"
44- }
45- href = { `${ baseStackBlitzURL } ${ props . path } /` }
46- target = "_blank" >
47- < SiStackblitz />
48- < div className = { "text-sm" } > StackBlitz</ div >
49- </ a >
50- </ div >
39+ { showCode && (
40+ < div className = { "z-10 flex flex-row gap-6 pb-4" } >
41+ < a
42+ className = {
43+ "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"
44+ }
45+ href = { `${ baseGitHubURL } ${ props . path } /` }
46+ target = "_blank" >
47+ < AiFillGithub />
48+ < div className = { "text-sm" } > GitHub</ div >
49+ </ a >
50+ < a
51+ className = {
52+ "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"
53+ }
54+ href = { `${ baseStackBlitzURL } ${ props . path } /` }
55+ target = "_blank" >
56+ < SiStackblitz />
57+ < div className = { "text-sm" } > StackBlitz</ div >
58+ </ a >
59+ </ div >
60+ ) }
5161 < div className = { "demo-contents h-96 overflow-auto rounded-lg" } >
5262 < ThemedExample name = { props . name } />
5363 </ div >
54- { props . children }
64+ { showCode ? (
65+ props . children
66+ ) : (
67+ < div
68+ className = {
69+ "relative flex h-96 flex-col items-center justify-center gap-2"
70+ } >
71+ < div className = { "absolute h-1/2 w-1/2" } >
72+ < div className = { "cta-glow h-full w-full" } > </ div >
73+ </ div >
74+ < div className = { "z-10 flex w-2/3 flex-col items-center" } >
75+ < SectionHeader > Pro Example</ SectionHeader >
76+ < p className = { "text-center text-[#00000080] dark:text-[#FFFFFFB2]" } >
77+ Get access to the full source code for pro examples by subscribing
78+ to BlockNote Pro
79+ </ p >
80+ < div className = { "mt-8" } >
81+ < CTAButton
82+ href = { "/pricing" }
83+ color = { "pro" }
84+ size = { "large" }
85+ hoverGlow = { true } >
86+ Get BlockNote Pro
87+ </ CTAButton >
88+ </ div >
89+ { ! props . isProExample ?. userStatus && (
90+ < p className = { "mt-1 text-xs" } >
91+ Or{ " " }
92+ < button
93+ className = { "nx-text-primary-600" }
94+ onClick = { async ( ) => {
95+ await signIn ( "github" , { } ) ;
96+ } } >
97+ sign in
98+ </ button > { " " }
99+ via GitHub
100+ </ p >
101+ ) }
102+ </ div >
103+ </ div >
104+ ) }
55105 </ div >
56106 ) ;
57107}
0 commit comments