Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

docs: avoid FOUC for theme #178

Merged
merged 1 commit into from
Dec 13, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion docs/src/components/index.svelte
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
<script>
/** @type {{ iconModuleNames?: string[]; byModuleName: Record<string, string>; bySize?: { order: string[]; sizes: Record<string, string>; }; total?: number; }} */
import data from "../build-info.json";
import "carbon-components-svelte/css/all.css";
import {
Search,
CodeSnippet,
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 @@ -13,8 +14,17 @@ import Home from "../components/index.svelte";
content="Carbon Design System icons as Svelte components"
/>
<title>Carbon Icons 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>
Loading