1- import { Stack } from "@stackflow/demo" ;
1+ import type { StackComponentType } from "@stackflow/react" ;
2+ import { useEffect , useRef , useState } from "react" ;
23import { useSimpleReveal } from "simple-reveal" ;
34
4- const Demo : React . FC = ( ) => {
5+ const SolidRenderer : React . FC = ( ) => {
6+ const ref = useRef < HTMLDivElement > ( null ) ;
7+ useEffect ( ( ) => {
8+ const el = ref . current ;
9+ if ( ! el ) {
10+ return ( ) => { } ;
11+ }
12+ import ( "@stackflow/demo-solid" ) . then ( ( { renderApp } ) => {
13+ renderApp ( el , { theme : "cupertino" } ) ;
14+ } ) ;
15+ return ( ) => {
16+ el . innerHTML = "" ;
17+ } ;
18+ } , [ ] ) ;
19+ return < div ref = { ref } /> ;
20+ } ;
21+
22+ const Demo : React . FC < { variants : ( "react" | "solid" ) [ ] } > = ( {
23+ variants = [ "react" ] ,
24+ } ) => {
25+ const [ Stack , setStack ] = useState < StackComponentType | null > ( null ) ;
526 const { cn, ref, style } = useSimpleReveal ( {
627 delay : 200 ,
728 initialTransform : "scale(0.95)" ,
829 } ) ;
30+
31+ useEffect ( ( ) => {
32+ if ( variants . includes ( "react" ) && ! Stack ) {
33+ import ( "@stackflow/demo" ) . then ( ( { Stack } ) => {
34+ setStack ( Stack ) ;
35+ } ) ;
36+ }
37+ } , [ variants ] ) ;
938 return (
1039 < div
1140 ref = { ref }
@@ -14,30 +43,58 @@ const Demo: React.FC = () => {
1443 position : "relative" ,
1544 width : "100%" ,
1645 display : "flex" ,
17- justifyContent : "center" ,
18- margin : "3rem 0" ,
46+ flexWrap : "wrap" ,
47+ justifyContent : "space-evenly" ,
48+ margin : "2rem 0" ,
1949 ...style ,
2050 } }
2151 >
22- < div
23- style = { {
24- width : "100%" ,
25- maxWidth : "360px" ,
26- height : "640px" ,
27- position : "relative" ,
28- borderRadius : ".5rem" ,
29- overflow : "hidden" ,
30- transform : "translate3d(0, 0, 0)" ,
31- maskImage : "-webkit-radial-gradient(white, black)" ,
32- boxShadow : "0 .25rem 1rem 0 rgba(0, 0, 0, .1)" ,
33- } }
34- >
35- < Stack
36- initialContext = { {
37- theme : "cupertino" ,
52+ { variants . map ( ( variant ) => (
53+ < div
54+ key = { variant }
55+ style = { {
56+ width : "100%" ,
57+ maxWidth : "360px" ,
58+ margin : "1rem 0" ,
59+ display : "flex" ,
60+ flexDirection : "column" ,
61+ alignItems : "center" ,
62+ gap : "1rem" ,
63+ color : "#777" ,
3864 } }
39- />
40- </ div >
65+ >
66+ < div
67+ style = { {
68+ width : "100%" ,
69+ height : "640px" ,
70+ position : "relative" ,
71+ borderRadius : ".5rem" ,
72+ overflow : "hidden" ,
73+ transform : "translate3d(0, 0, 0)" ,
74+ maskImage : "-webkit-radial-gradient(white, black)" ,
75+ boxShadow : "0 .25rem 1rem 0 rgba(0, 0, 0, .1)" ,
76+ } }
77+ >
78+ { variant === "react" ? (
79+ Stack && (
80+ < Stack
81+ initialContext = { {
82+ theme : "cupertino" ,
83+ } }
84+ />
85+ )
86+ ) : (
87+ < SolidRenderer />
88+ ) }
89+ </ div >
90+ {
91+ {
92+ react : "React" ,
93+ solid : "Solid" ,
94+ } [ variant ]
95+ }
96+ </ div >
97+ ) ) }
4198 </ div >
4299 ) ;
43100} ;
0 commit comments