Skip to content

Commit

Permalink
fix types
Browse files Browse the repository at this point in the history
  • Loading branch information
mcnuttandrew committed Jan 13, 2024
1 parent b480921 commit 6e5e5f9
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 2 deletions.
10 changes: 8 additions & 2 deletions src/content-modules/Examples.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -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);
</script>

<div class="flex items-center bg-slate-200 px-4">
Expand All @@ -50,7 +55,8 @@
<input
id={`${group}-checkbox`}
type="checkbox"
bind:checked={$exampleStore.sections[group]}
checked={sections[group]}
on:change={(e) => onToggle(group)}
/>
</div>
{/each}
Expand Down Expand Up @@ -113,7 +119,7 @@
<TextBlock />
{/if}
{#each charts as { chart, group }}
{#if $exampleStore.sections[group]}
{#if sections[group]}
<div class="flex flex-col border-2 border-dashed rounded w-min mr-4">
<Vega spec={chart($colorStore.currentPal)} />
</div>
Expand Down
5 changes: 5 additions & 0 deletions src/stores/example-store.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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];
Expand Down

0 comments on commit 6e5e5f9

Please sign in to comment.