docs(code-snippet): add "Reactive example" (#1296)

* docs(code-snippet): add description to "Hidden copy button"

* docs(code-snippet): add "Reactive example"
This commit is contained in:
metonym 2022-05-13 19:18:14 -07:00 committed by GitHub
commit 7c4842f506
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 33 additions and 0 deletions

View file

@ -0,0 +1,19 @@
<script>
import { CodeSnippet, Button } from "carbon-components-svelte";
let expanded = false;
</script>
<Button on:click="{() => (expanded = !expanded)}">Toggle expansion</Button>
<CodeSnippet
type="multi"
code="{Array.from({ length: 30 }, (_, i) => i + 1).join('\n')}"
bind:expanded
on:expand="{() => {
console.log('on:expand');
}}"
on:collapse="{() => {
console.log('on:collapse');
}}"
/>