mirror of
https://github.com/carbon-design-system/carbon-components-svelte.git
synced 2025-09-18 03:26:36 +00:00
docs(local-storage): simplify clear example
This commit is contained in:
parent
6c478b8193
commit
20577a0132
1 changed files with 2 additions and 28 deletions
|
@ -3,41 +3,15 @@
|
|||
|
||||
let storage;
|
||||
let toggled = false;
|
||||
let events = [];
|
||||
|
||||
$: document.documentElement.setAttribute("theme", toggled ? "g100" : "white");
|
||||
</script>
|
||||
|
||||
<LocalStorage
|
||||
bind:this="{storage}"
|
||||
key="dark-mode"
|
||||
bind:value="{toggled}"
|
||||
on:save="{() => {
|
||||
events = [...events, { event: 'on:save' }];
|
||||
}}"
|
||||
on:update="{({ detail }) => {
|
||||
events = [...events, { event: 'on:update', detail }];
|
||||
}}"
|
||||
/>
|
||||
<LocalStorage bind:this="{storage}" bind:value="{toggled}" />
|
||||
|
||||
<Toggle size="sm" labelText="Dark mode" bind:toggled />
|
||||
|
||||
<br />
|
||||
<br />
|
||||
|
||||
<Button
|
||||
size="small"
|
||||
on:click="{() => {
|
||||
events = [];
|
||||
storage.clearAll();
|
||||
}}"
|
||||
>
|
||||
Clear local storage
|
||||
</Button>
|
||||
|
||||
<br />
|
||||
<br />
|
||||
|
||||
<pre>
|
||||
{JSON.stringify(events, null, 2)}
|
||||
</pre>
|
||||
<Button size="small" on:click="{storage.clearAll}">Clear local storage</Button>
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue