From 02351ad0e5bdb42b2a3f557d76122ec55ad104cf Mon Sep 17 00:00:00 2001 From: Eric Liu Date: Sat, 30 Dec 2023 10:24:49 -0800 Subject: [PATCH] style(docs): `color-scheme` reflects theme --- docs/index.html | 10 ++++++++++ docs/src/layouts/ComponentLayout.svelte | 7 ++++--- docs/src/pages/_layout.svelte | 9 ++++++++- docs/src/pages/framed/_reset.svelte | 15 ++++++++++++--- 4 files changed, 34 insertions(+), 7 deletions(-) diff --git a/docs/index.html b/docs/index.html index 153bb52f..967bda15 100644 --- a/docs/index.html +++ b/docs/index.html @@ -5,6 +5,16 @@ Carbon Components Svelte + diff --git a/docs/src/layouts/ComponentLayout.svelte b/docs/src/layouts/ComponentLayout.svelte index 5801441a..75fde5c0 100644 --- a/docs/src/layouts/ComponentLayout.svelte +++ b/docs/src/layouts/ComponentLayout.svelte @@ -34,10 +34,11 @@ $: multiple = api_components.length > 1; onMount(() => { - const currentTheme = window.location.search.split("?theme=")[1]; + const searchParams = new URLSearchParams(window.location.search); + const current_theme = searchParams.get("theme"); - if (["white", "g10", "g80", "g90", "g100"].includes(currentTheme)) { - theme.set(currentTheme); + if (["white", "g10", "g80", "g90", "g100"].includes(current_theme)) { + theme.set(current_theme); } }); diff --git a/docs/src/pages/_layout.svelte b/docs/src/pages/_layout.svelte index 6ab62ab8..7dd0f43d 100644 --- a/docs/src/pages/_layout.svelte +++ b/docs/src/pages/_layout.svelte @@ -80,7 +80,14 @@ } }}" /> - +