Skip to content

Commit 96c5284

Browse files
committed
Update the examples to use writable stores instead of arrays for groups
1 parent 5fd6bdf commit 96c5284

File tree

2 files changed

+13
-19
lines changed

2 files changed

+13
-19
lines changed
Lines changed: 4 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,12 @@
11
<script lang="ts">
2+
import { writable } from 'svelte/store';
3+
24
import CodeContainer from '$docs/components/CodeContainer.svelte';
35
import Facets from '$lib/components/Facets/Facets.svelte';
46
import { facetsNoGroupSelectionData, facetsGroupSelectionSvelte } from '../data/codeBlocks';
57
import { groups } from '../data/data';
68
7-
let selected = {
8-
Mediums: [],
9-
Genres: [],
10-
Authors: []
11-
};
12-
13-
let selectedGroups = {
14-
Mediums: true,
15-
Genres: false,
16-
Authors: false
17-
};
9+
const groupsStore = writable(groups);
1810
</script>
1911

2012
<div id="facetsGroupSelection">
@@ -23,6 +15,6 @@
2315
svelte={facetsGroupSelectionSvelte}
2416
data={facetsNoGroupSelectionData}
2517
>
26-
<Facets {groups} bind:selected bind:selectedGroups groupSelection open />
18+
<Facets groups={groupsStore} groupSelection open on:change={(e) => console.log(e)} />
2719
</CodeContainer>
2820
</div>
Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,20 @@
11
<script lang="ts">
2+
import { writable } from 'svelte/store';
3+
24
import CodeContainer from '$docs/components/CodeContainer.svelte';
35
import Facets from '$lib/components/Facets/Facets.svelte';
46
import { facetsNoGroupSelectionData, facetsNoGroupSelectionSvelte } from '../data/codeBlocks';
57
import { groups } from '../data/data';
68
7-
let selected = {
8-
Mediums: [],
9-
Genres: [],
10-
Authors: []
11-
};
9+
const groupsStore = writable(groups);
1210
</script>
1311

1412
<div id="facetsNoGroupSelection">
15-
<CodeContainer title="No group selection, closed by default and all options displayed in UI" svelte={facetsNoGroupSelectionSvelte} data={facetsNoGroupSelectionData}>
16-
<Facets {groups} bind:selected showAll />
13+
<CodeContainer
14+
title="No group selection, closed by default and all options displayed in UI"
15+
svelte={facetsNoGroupSelectionSvelte}
16+
data={facetsNoGroupSelectionData}
17+
>
18+
<Facets groups={groupsStore} showAll on:change={(e) => console.log(e)} />
1719
</CodeContainer>
1820
</div>

0 commit comments

Comments
 (0)