mirror of
https://github.com/carbon-design-system/carbon-components-svelte.git
synced 2025-09-16 10:51:06 +00:00
fix(progress-indicator): allow currentIndex to be programmatically updated
This commit is contained in:
parent
80d56f9f5f
commit
c513279751
6 changed files with 110 additions and 36 deletions
|
@ -23,19 +23,29 @@
|
|||
/** Set an id for the top-level element */
|
||||
export let id = "ccs-" + Math.random().toString(36);
|
||||
|
||||
import { getContext } from "svelte";
|
||||
import { onMount, getContext } from "svelte";
|
||||
import CheckmarkOutline16 from "carbon-icons-svelte/lib/CheckmarkOutline16";
|
||||
import Warning16 from "carbon-icons-svelte/lib/Warning16";
|
||||
|
||||
let step = {};
|
||||
|
||||
const { stepsById, add, change } = getContext("ProgressIndicator");
|
||||
|
||||
add({ id, disabled });
|
||||
$: add({ id, complete, disabled });
|
||||
|
||||
$: step = $stepsById[id];
|
||||
$: {
|
||||
current = step.current;
|
||||
complete = step.complete;
|
||||
}
|
||||
const unsubscribe = stepsById.subscribe((value) => {
|
||||
if (value[id]) {
|
||||
step = value[id];
|
||||
current = step.current;
|
||||
complete = step.complete;
|
||||
}
|
||||
});
|
||||
|
||||
onMount(() => {
|
||||
return () => {
|
||||
unsubscribe();
|
||||
};
|
||||
});
|
||||
</script>
|
||||
|
||||
<li
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue