mirror of
https://github.com/carbon-design-system/carbon-components-svelte.git
synced 2025-09-19 03:49:34 +00:00
docs(accordion): move expandable accordion recipe
This commit is contained in:
parent
77c8fcfb6d
commit
f0ee364f57
3 changed files with 11 additions and 27 deletions
|
@ -10,8 +10,6 @@ components: ["Accordion", "AccordionItem", "AccordionSkeleton"]
|
||||||
import Preview from "../../components/Preview.svelte";
|
import Preview from "../../components/Preview.svelte";
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
See the [ExpandableAccordion recipe](/recipes/ExpandableAccordion) for a toggleable accordion component.
|
|
||||||
|
|
||||||
### Default
|
### Default
|
||||||
|
|
||||||
<Accordion>
|
<Accordion>
|
||||||
|
@ -84,6 +82,12 @@ See the [ExpandableAccordion recipe](/recipes/ExpandableAccordion) for a togglea
|
||||||
</AccordionItem>
|
</AccordionItem>
|
||||||
</Accordion>
|
</Accordion>
|
||||||
|
|
||||||
|
### Programmatic example
|
||||||
|
|
||||||
|
This example demonstrates how a list of items can be programmatically expanded and collapsed.
|
||||||
|
|
||||||
|
<FileSource src="/framed/Accordion/ExpandableAccordion" />
|
||||||
|
|
||||||
### Extra-large size
|
### Extra-large size
|
||||||
|
|
||||||
<Accordion size="xl">
|
<Accordion size="xl">
|
||||||
|
|
|
@ -1,5 +1,7 @@
|
||||||
<script>
|
<script>
|
||||||
export let items = [
|
import { Accordion, AccordionItem, Button } from "carbon-components-svelte";
|
||||||
|
|
||||||
|
const items = [
|
||||||
{
|
{
|
||||||
title: "Natural Language Classifier",
|
title: "Natural Language Classifier",
|
||||||
description:
|
description:
|
||||||
|
@ -17,26 +19,17 @@
|
||||||
},
|
},
|
||||||
];
|
];
|
||||||
|
|
||||||
import { Accordion, AccordionItem, Button } from "carbon-components-svelte";
|
|
||||||
|
|
||||||
let open = false;
|
let open = false;
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<Button
|
<Button kind="ghost" size="field" on:click="{() => (open = !open)}">
|
||||||
kind="ghost"
|
|
||||||
size="field"
|
|
||||||
on:click="{() => {
|
|
||||||
open = !open;
|
|
||||||
}}"
|
|
||||||
>
|
|
||||||
{open ? "Collapse" : "Expand"}
|
{open ? "Collapse" : "Expand"}
|
||||||
all
|
all
|
||||||
</Button>
|
</Button>
|
||||||
|
|
||||||
<Accordion>
|
<Accordion>
|
||||||
{#each items as item}
|
{#each items as item}
|
||||||
<AccordionItem open="{open}">
|
<AccordionItem title="{item.title}" open="{open}">
|
||||||
<h5 slot="title">{item.title}</h5>
|
|
||||||
<p>{item.description}</p>
|
<p>{item.description}</p>
|
||||||
</AccordionItem>
|
</AccordionItem>
|
||||||
{/each}
|
{/each}
|
||||||
|
|
|
@ -1,13 +0,0 @@
|
||||||
---
|
|
||||||
layout: recipe
|
|
||||||
---
|
|
||||||
|
|
||||||
<script>
|
|
||||||
import Preview from "../../components/Preview.svelte";
|
|
||||||
</script>
|
|
||||||
|
|
||||||
## Expandable accordion
|
|
||||||
|
|
||||||
This example expands and collapses all accordion items.
|
|
||||||
|
|
||||||
<FileSource src="/framed/Accordion/ExpandableAccordion" />
|
|
Loading…
Add table
Add a link
Reference in a new issue