Skip to content

Commit e9b5814

Browse files
authored
Feat/theme selector (#15)
* feat(playground): add theme selector
1 parent 2e6efad commit e9b5814

File tree

8 files changed

+338
-79
lines changed

8 files changed

+338
-79
lines changed

apps/dev-playground/client/index.html

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,31 @@
77
</head>
88
<body>
99
<div id="root"></div>
10+
<script>
11+
(function() {
12+
const THEME_STORAGE_KEY = "app-kit-playground-theme";
13+
const storedTheme = localStorage.getItem(THEME_STORAGE_KEY);
14+
const root = document.documentElement;
15+
16+
if (storedTheme === "light") {
17+
root.classList.add("light");
18+
root.classList.remove("dark");
19+
} else if (storedTheme === "dark") {
20+
root.classList.add("dark");
21+
root.classList.remove("light");
22+
} else {
23+
// System theme - use media query
24+
const prefersDark = window.matchMedia("(prefers-color-scheme: dark)").matches;
25+
if (prefersDark) {
26+
root.classList.add("dark");
27+
root.classList.remove("light");
28+
} else {
29+
root.classList.add("light");
30+
root.classList.remove("dark");
31+
}
32+
}
33+
})();
34+
</script>
1035
<script type="module" src="/src/main.tsx"></script>
1136
</body>
1237
</html>
Lines changed: 21 additions & 0 deletions
Loading
Lines changed: 21 additions & 0 deletions
Loading

0 commit comments

Comments
 (0)