mirror of
https://github.com/carbon-design-system/carbon-components-svelte.git
synced 2025-09-15 18:31:06 +00:00
docs: support theme setting through window search params
This commit is contained in:
parent
7c865a6e1f
commit
170d9993f4
1 changed files with 9 additions and 0 deletions
|
@ -10,6 +10,7 @@
|
||||||
} from "carbon-components-svelte";
|
} from "carbon-components-svelte";
|
||||||
import Code16 from "carbon-icons-svelte/lib/Code16";
|
import Code16 from "carbon-icons-svelte/lib/Code16";
|
||||||
import { page, metatags } from "@sveltech/routify";
|
import { page, metatags } from "@sveltech/routify";
|
||||||
|
import { onMount } from "svelte";
|
||||||
import { theme } from "../store";
|
import { theme } from "../store";
|
||||||
|
|
||||||
export let component = $page.title;
|
export let component = $page.title;
|
||||||
|
@ -17,6 +18,14 @@
|
||||||
|
|
||||||
metatags.title = $page.title;
|
metatags.title = $page.title;
|
||||||
|
|
||||||
|
onMount(() => {
|
||||||
|
const currentTheme = window.location.search.split("?theme=")[1];
|
||||||
|
|
||||||
|
if (["white", "g10", "g90", "g100"].includes(currentTheme)) {
|
||||||
|
theme.set(currentTheme);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
// TODO: [refactor] read from package.json value
|
// TODO: [refactor] read from package.json value
|
||||||
$: sourceCode = `https://github.com/IBM/carbon-components-svelte/tree/master/src/${
|
$: sourceCode = `https://github.com/IBM/carbon-components-svelte/tree/master/src/${
|
||||||
source || `${$page.title}/${$page.title}.svelte`
|
source || `${$page.title}/${$page.title}.svelte`
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue