mirror of
https://github.com/carbon-design-system/carbon-components-svelte.git
synced 2025-09-20 20:33:02 +00:00
docs(radio-button): simplify reactive radio button example
This commit is contained in:
parent
e5f77aa614
commit
f52c217cb7
1 changed files with 13 additions and 16 deletions
|
@ -1,35 +1,32 @@
|
||||||
<script>
|
<script>
|
||||||
import {
|
import {
|
||||||
ButtonSet,
|
|
||||||
Button,
|
Button,
|
||||||
RadioButtonGroup,
|
RadioButtonGroup,
|
||||||
RadioButton,
|
RadioButton,
|
||||||
} from "carbon-components-svelte";
|
} from "carbon-components-svelte";
|
||||||
|
|
||||||
let plan = "standard";
|
const plans = ["Free (1 GB)", "Standard (10 GB)", "Pro (128 GB)"];
|
||||||
|
|
||||||
|
let plan = plans[1];
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<RadioButtonGroup legendText="Storage tier (disk)" bind:selected="{plan}">
|
<RadioButtonGroup legendText="Storage tier (disk)" bind:selected="{plan}">
|
||||||
<RadioButton labelText="Free (1 GB)" value="free" />
|
{#each plans as value}
|
||||||
<RadioButton labelText="Standard (10 GB)" value="standard" />
|
<RadioButton labelText="{value}" value="{value}" />
|
||||||
<RadioButton labelText="Pro (128 GB)" value="pro" />
|
{/each}
|
||||||
</RadioButtonGroup>
|
</RadioButtonGroup>
|
||||||
|
|
||||||
<ButtonSet style="margin-top: var(--cds-layout-03)">
|
<div style="margin: var(--cds-layout-01) 0">
|
||||||
{#each ["free", "standard", "pro"] as value}
|
{#each plans as value}
|
||||||
<Button
|
<Button
|
||||||
disabled="{plan === value}"
|
|
||||||
kind="secondary"
|
kind="secondary"
|
||||||
on:click="{() => {
|
disabled="{plan === value}"
|
||||||
plan = value;
|
on:click="{() => (plan = value)}"
|
||||||
}}"
|
|
||||||
>
|
>
|
||||||
Select "{value}"
|
Select "{value}"
|
||||||
</Button>
|
</Button>
|
||||||
{/each}
|
{/each}
|
||||||
</ButtonSet>
|
</div>
|
||||||
|
|
||||||
<div style="margin: var(--cds-layout-01) 0">
|
|
||||||
Selected plan:
|
Selected plan:
|
||||||
<strong>{plan}</strong>
|
<strong>{plan}</strong>
|
||||||
</div>
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue