Skip to content

Commit

Permalink
chore(docs): color-scheme reflects theme
Browse files Browse the repository at this point in the history
  • Loading branch information
metonym committed Dec 30, 2023
1 parent 44d3083 commit 983b20f
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 2 deletions.
6 changes: 6 additions & 0 deletions docs/src/components/index.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,12 @@
);
$: mounted = typeof document !== "undefined";
$: code = `<script>\n import ${moduleName} from "carbon-pictograms-svelte/lib/${moduleName}.svelte";\n<\/script>\n\n<${moduleName} />`;
$: if (mounted) {
document.documentElement.style.setProperty(
"color-scheme",
["white", "g10"].includes(theme) ? "light" : "dark"
);
}
</script>

<FocusKey element={ref} selectText />
Expand Down
2 changes: 1 addition & 1 deletion docs/src/constants.ts
Original file line number Diff line number Diff line change
@@ -1 +1 @@
export const VERSION = __VERSION;
export const VERSION = __VERSION;
2 changes: 1 addition & 1 deletion docs/src/env.d.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
/// <reference types="astro/client" />

declare const __VERSION: string;
declare const __VERSION: string;
1 change: 1 addition & 0 deletions docs/src/pages/index.astro
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ import Home from "../components/index.svelte";

if (["white", "g10", "g80", "g90", "g100"].includes(theme)) {
document.documentElement.setAttribute("theme", theme);
document.documentElement.style.setProperty("color-scheme", ["white", "g10"].includes(theme) ? "light" : "dark");
}
} catch (e) {}
</script>
Expand Down

0 comments on commit 983b20f

Please sign in to comment.