From 6e5e5f97a2383a3f2a953d06bcb1106626718a80 Mon Sep 17 00:00:00 2001 From: Andrew Michael McNutt Date: Sat, 13 Jan 2024 11:42:56 -0800 Subject: [PATCH] fix types --- src/content-modules/Examples.svelte | 10 ++++++++-- src/stores/example-store.ts | 5 +++++ 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/src/content-modules/Examples.svelte b/src/content-modules/Examples.svelte index 40310996..32528b0b 100644 --- a/src/content-modules/Examples.svelte +++ b/src/content-modules/Examples.svelte @@ -41,6 +41,11 @@ } $: detectedColors = [] as string[]; + $: sections = $exampleStore.sections as any; + function onToggle(group: string) { + exampleStore.toggleSection(group as keyof typeof $exampleStore.sections); + } + $: console.log(sections);
@@ -50,7 +55,8 @@ onToggle(group)} />
{/each} @@ -113,7 +119,7 @@ {/if} {#each charts as { chart, group }} - {#if $exampleStore.sections[group]} + {#if sections[group]}
diff --git a/src/stores/example-store.ts b/src/stores/example-store.ts index 35afea8c..68f9a910 100644 --- a/src/stores/example-store.ts +++ b/src/stores/example-store.ts @@ -44,6 +44,11 @@ function createStore() { subscribe, set: (newStore: StoreData) => persistUpdate(() => newStore), reset: () => persistUpdate(() => ({ ...InitialStore })), + toggleSection: (section: keyof typeof InitialSections) => + persistUpdate((old) => ({ + ...old, + sections: { ...old.sections, [section]: !old.sections[section] }, + })), updateExample: (example: Example, idx: number) => persistUpdate((old) => { const newExamples = [...old.examples];