Skip to content

Commit 1e2a026

Browse files
committed
Refactor home demos
1 parent 92209a2 commit 1e2a026

23 files changed

+940
-1597
lines changed

web/app/demo.js

Lines changed: 0 additions & 139 deletions
This file was deleted.

web/app/demo/client-demo.js

Lines changed: 0 additions & 39 deletions
This file was deleted.

web/app/demo/page.mdx

Lines changed: 0 additions & 41 deletions
This file was deleted.

web/app/demos/code.tsx

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
import { NewDemo } from "./new-demo"
2+
3+
const sourceCode = `
4+
import { Code } from "bright"
5+
6+
export default function Page() {
7+
return (
8+
<Code lang="py">print("hello brightness")</Code>
9+
)
10+
}
11+
`.trim()
12+
13+
export default function Demo() {
14+
return (
15+
<NewDemo
16+
filename="app/page.js"
17+
sourceProps={{ children: sourceCode, lang: "jsx" }}
18+
demoProps={{
19+
lang: "py",
20+
code: `print("hello brightness")`,
21+
}}
22+
/>
23+
)
24+
}

web/app/demos/custom-theme.tsx

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
import { NewDemo } from "./new-demo"
2+
3+
const sourceCode = `
4+
import { Code } from "bright"
5+
6+
// focus(1:6)
7+
// you can make your own theme
8+
// or extend any VS Code theme
9+
// link[9:42] https://themes.codehike.org/editor
10+
// with https://themes.codehike.org/editor
11+
import myTheme from "./my-theme.json"
12+
13+
Code.theme = myTheme
14+
15+
const myCode = \`
16+
theFuture, bright = 10, 10
17+
print(theFuture is bright)
18+
\`.trim()
19+
20+
export default function Page() {
21+
return (
22+
<Code lang="py">{myCode}</Code>
23+
)
24+
}
25+
`.trim()
26+
27+
export default function Demo() {
28+
return (
29+
<>
30+
<div style={{ height: "1rem" }} />
31+
<NewDemo
32+
filename="app/page.js"
33+
sourceProps={{ children: sourceCode, lang: "jsx" }}
34+
/>
35+
</>
36+
)
37+
}
Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -28,11 +28,6 @@ export function useMDXComponents(components) {
2828
}
2929
`.trim()
3030

31-
const demoCode = `
32-
# title monthy.py
33-
print("the bright side of life")
34-
`.trim()
35-
3631
const demoProps = {
3732
extensions: [tabs, fileIcons, focus],
3833
// theme: "github-light",
@@ -92,10 +87,7 @@ export default function Demo() {
9287
<div style={{ height: "1rem" }} />
9388
<NewDemo
9489
filename="mdx-components.js"
95-
sourceProps={{
96-
children: sourceCode,
97-
lang: "jsx",
98-
}}
90+
sourceProps={{ children: sourceCode, lang: "jsx" }}
9991
demoProps={demoProps}
10092
/>
10193
</>

web/app/demos/dark-mode.tsx

Lines changed: 88 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,88 @@
1+
import { NewDemo } from "./new-demo"
2+
import { Code } from "bright"
3+
4+
const sourceCode = `
5+
import { Code } from "bright"
6+
7+
const myCode = \`
8+
theFuture, bright = 10, 10
9+
print(theFuture is bright)
10+
\`.trim()
11+
12+
// focus(1:7)
13+
Code.theme = {
14+
dark: "github-dark",
15+
light: "github-light",
16+
// using a different CSS selector:
17+
// lightSelector: '[data-theme="light"]',
18+
// lightSelector: 'html.light',
19+
}
20+
21+
// focus(4,6,7,9)
22+
export default function Page() {
23+
return (
24+
<>
25+
<div data-theme="dark">
26+
<Code lang="py">{myCode}</Code>
27+
</div>
28+
<div data-theme="light">
29+
<Code lang="py">{myCode}</Code>
30+
</div>
31+
</>
32+
)
33+
}
34+
`.trim()
35+
36+
const preview = (
37+
<>
38+
<div>
39+
{/* @ts-expect-error Server Component */}
40+
<Code
41+
lang="py"
42+
theme={{
43+
dark: "github-dark",
44+
light: "github-light",
45+
}}
46+
style={{
47+
fontSize: "1.2rem",
48+
margin: "-2rem auto 0",
49+
position: "relative",
50+
border: "1px solid #444",
51+
width: "80%",
52+
}}
53+
>{`theFuture, bright = 10, 10
54+
print(theFuture is bright)`}</Code>
55+
</div>
56+
<div data-theme="light">
57+
{/* @ts-expect-error Server Component */}
58+
<Code
59+
lang="py"
60+
theme={{
61+
dark: "github-dark",
62+
light: "github-light",
63+
}}
64+
style={{
65+
fontSize: "1.2rem",
66+
margin: "0.5rem auto 0",
67+
position: "relative",
68+
border: "1px solid #444",
69+
width: "80%",
70+
}}
71+
>{`theFuture, bright = 10, 10
72+
print(theFuture is bright)`}</Code>
73+
</div>
74+
</>
75+
)
76+
77+
export default function Demo() {
78+
return (
79+
<>
80+
<div style={{ height: "1rem" }} />
81+
<NewDemo
82+
filename="app/page.js"
83+
sourceProps={{ children: sourceCode, lang: "jsx" }}
84+
preview={preview}
85+
/>
86+
</>
87+
)
88+
}

0 commit comments

Comments
 (0)