Skip to content

Commit d999211

Browse files
committed
docs: embed solid demo
1 parent 7a9a851 commit d999211

File tree

9 files changed

+99
-27
lines changed

9 files changed

+99
-27
lines changed

.pnp.cjs

Lines changed: 2 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

demo-solid/esbuild.config.js

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import { context } from "esbuild";
22
import config from "@stackflow/esbuild-config";
3+
import { solidPlugin } from "esbuild-plugin-solid";
34
import pkg from "./package.json" assert { type: "json" };
45

56
const watch = process.argv.includes("--watch");
@@ -11,8 +12,9 @@ const external = Object.keys({
1112
Promise.all([
1213
context({
1314
...config({
14-
entryPoints: ["./src/stackflow-docs.ts"],
15+
entryPoints: ["./src/stackflow-docs.tsx"],
1516
vanillaExtractExternal: ["@seed-design"],
17+
plugins: [solidPlugin({ solid: { generate: "dom" } })],
1618
}),
1719
format: "cjs",
1820
external,
@@ -21,8 +23,9 @@ Promise.all([
2123
),
2224
context({
2325
...config({
24-
entryPoints: ["./src/stackflow-docs.ts"],
26+
entryPoints: ["./src/stackflow-docs.tsx"],
2527
vanillaExtractExternal: ["@seed-design"],
28+
plugins: [solidPlugin({ solid: { generate: "dom" } })],
2629
}),
2730
format: "esm",
2831
outExtension: {

demo-solid/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,7 @@
6464
"@vanilla-extract/css": "^1.15.3",
6565
"@vanilla-extract/vite-plugin": "^4.0.12",
6666
"esbuild": "^0.23.0",
67+
"esbuild-plugin-solid": "^0.6.0",
6768
"rimraf": "^3.0.2",
6869
"typescript": "^5.5.3",
6970
"vite-plugin-solid": "^2.10.2"
Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,11 @@ import { vars } from "@seed-design/design-token";
22
import { basicUIPlugin } from "@stackflow/plugin-basic-ui/solid";
33
import { basicRendererPlugin } from "@stackflow/plugin-renderer-basic-solid";
44
import { stackflow } from "@stackflow/solid";
5+
import { render } from "solid-js/web";
56

67
import { activities } from "./stackflow";
78

8-
export const { Stack } = stackflow({
9+
const { Stack } = stackflow({
910
transitionDuration: 350,
1011
activities,
1112
initialActivity: () => "Main",
@@ -22,3 +23,7 @@ export const { Stack } = stackflow({
2223
}),
2324
],
2425
});
26+
27+
export const renderApp = (el: HTMLElement, initialContext?: any) => {
28+
render(() => <Stack initialContext={initialContext} />, el);
29+
};

docs/components/Demo.tsx

Lines changed: 79 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,40 @@
1-
import { Stack } from "@stackflow/demo";
1+
import type { StackComponentType } from "@stackflow/react";
2+
import { useEffect, useRef, useState } from "react";
23
import { 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
};

docs/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
"@mdx-js/react": "^3.0.1",
1414
"@stackflow/core": "^1.0.10",
1515
"@stackflow/demo": "^1.2.21",
16+
"@stackflow/demo-solid": "^1.2.21",
1617
"@stackflow/eslint-config": "^1.0.2",
1718
"@stackflow/plugin-basic-ui": "^1.7.0",
1819
"@stackflow/plugin-history-sync": "^1.5.0",

docs/pages/_app.mdx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import "nextra-theme-docs/style.css";
22
import "@stackflow/demo/style.css";
3+
import "@stackflow/demo-solid/style.css";
34
import "@stackflow/plugin-basic-ui/index.css";
45
import "@seed-design/stylesheet/global.css";
56
import "react-lazy-load-image-component/src/effects/opacity.css";

docs/pages/index.mdx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import Demo from "../components/Demo.tsx";
33

44
# Stackflow 시작하기
55

6-
<Demo />
6+
<Demo variants={["react", "solid"]} />
77

88
**Stackflow**는 모바일 디바이스(iOS/Android 등)에서 주로 활용되는 Stack Navigation UX를 JavaScript 환경에서 구현하고, 이를 통해 하이브리드 앱과 웹뷰 개발을 쉽게 할 수 있도록 돕는 프로젝트에요.
99

yarn.lock

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2427,7 +2427,7 @@ __metadata:
24272427
languageName: unknown
24282428
linkType: soft
24292429

2430-
"@stackflow/demo-solid@workspace:demo-solid":
2430+
"@stackflow/demo-solid@npm:^1.2.21, @stackflow/demo-solid@workspace:demo-solid":
24312431
version: 0.0.0-use.local
24322432
resolution: "@stackflow/demo-solid@workspace:demo-solid"
24332433
dependencies:
@@ -2451,6 +2451,7 @@ __metadata:
24512451
"@vanilla-extract/css": "npm:^1.15.3"
24522452
"@vanilla-extract/vite-plugin": "npm:^4.0.12"
24532453
esbuild: "npm:^0.23.0"
2454+
esbuild-plugin-solid: "npm:^0.6.0"
24542455
eslint: "npm:^8.57.0"
24552456
eslint-config-airbnb-base: "npm:^15.0.0"
24562457
eslint-config-prettier: "npm:^9.1.0"
@@ -2527,6 +2528,7 @@ __metadata:
25272528
"@seed-design/stylesheet": "npm:^1.0.4"
25282529
"@stackflow/core": "npm:^1.0.10"
25292530
"@stackflow/demo": "npm:^1.2.21"
2531+
"@stackflow/demo-solid": "npm:^1.2.21"
25302532
"@stackflow/eslint-config": "npm:^1.0.2"
25312533
"@stackflow/plugin-basic-ui": "npm:^1.7.0"
25322534
"@stackflow/plugin-history-sync": "npm:^1.5.0"

0 commit comments

Comments
 (0)