mirror of
https://github.com/carbon-design-system/carbon-components-svelte.git
synced 2025-09-15 18:31:06 +00:00
docs(progress-indicator): add programmatic usage example
This commit is contained in:
parent
c513279751
commit
365c16a0d1
2 changed files with 15 additions and 12 deletions
|
@ -53,6 +53,12 @@ Set `preventChangeOnClick` to `true` to prevent this behavior.
|
||||||
/>
|
/>
|
||||||
</ProgressIndicator>
|
</ProgressIndicator>
|
||||||
|
|
||||||
|
### Programmatic usage
|
||||||
|
|
||||||
|
When programmatically updating the `currentIndex`, keep in mind that only completed steps should be selectable.
|
||||||
|
|
||||||
|
<FileSource src="/framed/ProgressIndicator/ProgrammaticProgressIndicator" />
|
||||||
|
|
||||||
### Spaced-equally
|
### Spaced-equally
|
||||||
|
|
||||||
<ProgressIndicator spaceEqually>
|
<ProgressIndicator spaceEqually>
|
||||||
|
|
|
@ -6,7 +6,7 @@
|
||||||
} from "carbon-components-svelte";
|
} from "carbon-components-svelte";
|
||||||
|
|
||||||
let currentIndex = 1;
|
let currentIndex = 1;
|
||||||
let thirdStepComplete = false;
|
let thirdStepCurrent = false;
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<ProgressIndicator bind:currentIndex>
|
<ProgressIndicator bind:currentIndex>
|
||||||
|
@ -21,7 +21,8 @@
|
||||||
description="The progress indicator will listen for clicks on the steps"
|
description="The progress indicator will listen for clicks on the steps"
|
||||||
/>
|
/>
|
||||||
<ProgressStep
|
<ProgressStep
|
||||||
complete="{thirdStepComplete}"
|
complete
|
||||||
|
bind:current="{thirdStepCurrent}"
|
||||||
label="Step 3"
|
label="Step 3"
|
||||||
description="The progress indicator will listen for clicks on the steps"
|
description="The progress indicator will listen for clicks on the steps"
|
||||||
/>
|
/>
|
||||||
|
@ -33,20 +34,16 @@
|
||||||
|
|
||||||
<div style="margin: var(--cds-layout-02) 0">
|
<div style="margin: var(--cds-layout-02) 0">
|
||||||
<Button
|
<Button
|
||||||
|
kind="{currentIndex === 2 ? 'secondary' : 'primary'}"
|
||||||
on:click="{() => {
|
on:click="{() => {
|
||||||
currentIndex = 2;
|
currentIndex = currentIndex === 2 ? 0 : 2;
|
||||||
}}"
|
}}"
|
||||||
>
|
>
|
||||||
Set index to 2
|
Set currentIndex to
|
||||||
</Button>
|
{currentIndex === 2 ? 0 : 2}
|
||||||
<Button
|
|
||||||
kind="ghost"
|
|
||||||
on:click="{() => {
|
|
||||||
thirdStepComplete = !thirdStepComplete;
|
|
||||||
}}"
|
|
||||||
>
|
|
||||||
Toggle step 3
|
|
||||||
</Button>
|
</Button>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<h3>Current index: {currentIndex}</h3>
|
<h3>Current index: {currentIndex}</h3>
|
||||||
|
|
||||||
|
<div>Is the third step currently selected? {thirdStepCurrent}</div>
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue