|
1 |
| -import { Suspense } from "react"; |
| 1 | +import { Suspense, useState } from "react"; |
2 | 2 | import { RouterProvider } from "react-router-dom";
|
3 | 3 | import { router } from "./router.js";
|
| 4 | +import { Switch } from "./lib/index.js"; |
| 5 | +import { Moon as IconMoon, Sun as IconSun } from "lucide-react"; |
4 | 6 |
|
5 | 7 | function App() {
|
6 |
| - return ( |
7 |
| - <div |
8 |
| - className="h-screen grid grid-cols-[320px_minmax(0,_1fr)]" |
9 |
| - data-testid="app" |
10 |
| - > |
11 |
| - {/* Nav */} |
12 |
| - <div className="bg-surface-100-900 p-8 overflow-y-auto space-y-8"> |
13 |
| - <a |
14 |
| - className="bg-blue-500 text-white p-2 type-scale-3 font-bold font-mono" |
15 |
| - href="/" |
16 |
| - > |
17 |
| - skeleton-react |
18 |
| - </a> |
19 |
| - <hr className="hr" /> |
20 |
| - {/* Components */} |
21 |
| - <div className="space-y-8"> |
22 |
| - <span className="font-bold">Components</span> |
23 |
| - <nav className="flex flex-col gap-2 type-scale-2"> |
24 |
| - {/* <a className="anchor" href="/components/test"> |
25 |
| - Test |
26 |
| - </a> */} |
27 |
| - <a className="anchor" href="/components/accordions"> |
28 |
| - Accordions |
29 |
| - </a> |
30 |
| - <a className="anchor" href="/components/avatars"> |
31 |
| - Avatars |
32 |
| - </a> |
33 |
| - <a className="anchor" href="/components/app-bars"> |
34 |
| - App Bars |
35 |
| - </a> |
36 |
| - <a className="anchor" href="/components/progress"> |
37 |
| - Progress |
38 |
| - </a> |
39 |
| - <a className="anchor" href="/components/tabs"> |
40 |
| - Tabs |
41 |
| - </a> |
42 |
| - </nav> |
43 |
| - </div> |
44 |
| - </div> |
45 |
| - {/* Page */} |
46 |
| - <main className="p-8 overflow-y-auto"> |
47 |
| - {/* --- Route Slot --- */} |
48 |
| - <Suspense fallback={<div>Loading...</div>}> |
49 |
| - <RouterProvider router={router} /> |
50 |
| - </Suspense> |
51 |
| - {/* --- / --- */} |
52 |
| - </main> |
53 |
| - </div> |
54 |
| - ); |
| 8 | + const [lightswitch, setLightswitch] = useState(false); |
| 9 | + |
| 10 | + function onModeChange(newValue: boolean) { |
| 11 | + setLightswitch(newValue); |
| 12 | + document.documentElement.classList.toggle("dark"); |
| 13 | + } |
| 14 | + |
| 15 | + return ( |
| 16 | + <div |
| 17 | + className="h-screen grid grid-cols-[320px_minmax(0,_1fr)]" |
| 18 | + data-testid="app" |
| 19 | + > |
| 20 | + {/* Nav */} |
| 21 | + <div className="bg-surface-100-900 p-8 overflow-y-auto space-y-8"> |
| 22 | + <a |
| 23 | + className="bg-blue-500 text-white p-2 type-scale-3 font-bold font-mono" |
| 24 | + href="/" |
| 25 | + > |
| 26 | + skeleton-react |
| 27 | + </a> |
| 28 | + <hr className="hr" /> |
| 29 | + <label className="label flex justify-between items-center gap-4"> |
| 30 | + <p>Set Mode</p> |
| 31 | + <Switch |
| 32 | + id="mode" |
| 33 | + name="mode" |
| 34 | + stateActive="bg-surface-200" |
| 35 | + checked={lightswitch} |
| 36 | + onCheckedChange={onModeChange} |
| 37 | + inactiveChild={<IconMoon size="14" />} |
| 38 | + activeChild={<IconSun size="14" />} |
| 39 | + /> |
| 40 | + </label> |
| 41 | + <hr className="hr" /> |
| 42 | + {/* Components */} |
| 43 | + <div className="space-y-8"> |
| 44 | + <span className="font-bold">Components</span> |
| 45 | + <nav className="flex flex-col gap-2 type-scale-2"> |
| 46 | + <a className="anchor" href="/components/accordions"> |
| 47 | + Accordions |
| 48 | + </a> |
| 49 | + <a className="anchor" href="/components/avatars"> |
| 50 | + Avatars |
| 51 | + </a> |
| 52 | + <a className="anchor" href="/components/app-bars"> |
| 53 | + App Bars |
| 54 | + </a> |
| 55 | + <a className="anchor" href="/components/progress"> |
| 56 | + Progress |
| 57 | + </a> |
| 58 | + <a className="anchor" href="/components/switch"> |
| 59 | + Switch |
| 60 | + </a> |
| 61 | + <a className="anchor" href="/components/tabs"> |
| 62 | + Tabs |
| 63 | + </a> |
| 64 | + </nav> |
| 65 | + </div> |
| 66 | + </div> |
| 67 | + {/* Page */} |
| 68 | + <main className="p-8 overflow-y-auto"> |
| 69 | + {/* --- Route Slot --- */} |
| 70 | + <Suspense fallback={<div>Loading...</div>}> |
| 71 | + <RouterProvider router={router} /> |
| 72 | + </Suspense> |
| 73 | + {/* --- / --- */} |
| 74 | + </main> |
| 75 | + </div> |
| 76 | + ); |
55 | 77 | }
|
56 | 78 |
|
57 | 79 | export default App;
|
0 commit comments