feat: optional steps are skippable now

This commit is contained in:
Arman committed 2022-10-10 17:25:56 +02:00
1 parent b5b70d2918
commit f78c5dd64f
4 files changed
+20 -4

No files matched your search

+1 -1
View File
@@ -9,7 +9,7 @@
<li
class:steps-item={!isSub}
class:steps-sub-item={isSub}
aria-label={` ${completed ? 'done' : current ? 'current' : ''} step`}>
aria-label={`${completed ? 'done' : current ? 'current' : ''} step`}>
{#if isSub}
<span class="text">{step.text}</span>
{:else}
+8
View File
@@ -3,18 +3,26 @@
export let steps: {
text: string;
optional: boolean;
substeps?: {
text: string;
}[];
}[];
export let currentStep = 1;
export let currentSub = 1;
$: firstOptional = steps.findIndex((step) => step.optional);
//TODO: remove inline styling
</script>
<ol class="steps">
{#if steps}
{#each steps as step, index}
{@const stepNumber = index + 1}
{#if firstOptional === index}
<span style="margin-block: 1.5rem;">OPTIONAL</span>
{/if}
<Step
bind:currentSub
current={currentStep === stepNumber}
+9 -2
View File
@@ -4,6 +4,7 @@
{
label: string;
component: typeof SvelteComponent;
optional?: boolean;
}
>;
</script>
@@ -70,8 +71,10 @@
<aside class="wizard-side">
<Steps
steps={sortedSteps.map(([, { label }]) => ({
text: label
on:step={submit}
steps={sortedSteps.map(([, { label, optional }]) => ({
text: label,
optional
}))}
{currentStep} />
</aside>
@@ -87,6 +90,10 @@
{/each}
<div class="form-footer">
<div class="u-flex u-main-end u-gap-12">
{#if sortedSteps[currentStep - 1][1].optional}
<Button text on:click={() => (isLastStep = true)} submit
>Skip optional steps</Button>
{/if}
{#if currentStep === 1}
<Button secondary on:click={wizard.hide}>Cancel</Button>
<Button submit>Next</Button>
@@ -72,7 +72,8 @@
});
stepsComponents.set(2, {
label: 'Set permissions',
component: Step2
component: Step2,
optional: true
});
</script>