Skip to content

Commit

Permalink
docs: avoid FOUC for theme
Browse files Browse the repository at this point in the history
  • Loading branch information
metonym committed Dec 13, 2023
1 parent d099e74 commit 35d84e3
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 2 deletions.
1 change: 0 additions & 1 deletion docs/src/components/index.svelte
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
<script>
import "carbon-components-svelte/css/all.css";
import {
ClickableTile,
Search,
Expand Down
12 changes: 11 additions & 1 deletion docs/src/pages/index.astro
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
---
import "carbon-components-svelte/css/all.css";
import Home from "../components/index.svelte";
---

Expand All @@ -12,8 +13,17 @@ import Home from "../components/index.svelte";
content="Carbon Design System pictograms as Svelte components"
/>
<title>Carbon Pictograms Svelte</title>
<script is:inline>
try {
const theme = localStorage.getItem("theme");

if (["white", "g10", "g80", "g90", "g100"].includes(theme)) {
document.documentElement.setAttribute("theme", theme);
}
} catch (e) {}
</script>
</head>
<body>
<Home client:load />
<Home client:idle />
</body>
</html>

0 comments on commit 35d84e3

Please sign in to comment.