diff --git a/.storybook/preview.tsx b/.storybook/preview.tsx index 8bfe8f603a..8b7c9654e0 100644 --- a/.storybook/preview.tsx +++ b/.storybook/preview.tsx @@ -98,7 +98,7 @@ export const parameters = { ['Select', ['Guideline', '*']], ], ['Feedback', [['Modal', ['Guideline', '*']]]], - 'Progress & loading', + ['Progress & loading', [['Stepper', ['Guideline', '*']]]], 'Styling', 'Deprecated', ], diff --git a/stories/stepper.guideline.mdx b/stories/stepper.guideline.mdx new file mode 100644 index 0000000000..301516e8d4 --- /dev/null +++ b/stories/stepper.guideline.mdx @@ -0,0 +1,60 @@ +import { Meta, Canvas } from '@storybook/addon-docs/blocks'; +import * as StepperStories from './stepper.stories'; + + + + + +# Stepper + +A stepper breaks a process into ordered phases that must be completed in sequence. +Use it when each phase has a distinct nature and the next phase cannot begin before the previous one is done. + + + +## When to use + +- The task has 3 to 5 distinct phases with a clear sequence. +- Each phase requires its own decisions or inputs before moving on. +- Users benefit from knowing how far along they are. + +## When not to use + +- Steps can be completed in any order: use a checklist instead. +- The task is non-linear or revisitable at any time. + +## Typical pattern + +Steps do not need to be of the same nature. A common structure is: + +1. **Form:** the user configures the operation (inputs, selects, options). +2. **Execution:** the system performs actions one by one, shown as a table of tasks with their status. +3. **Summary:** results are displayed and the user can confirm or exit. + +Whether the user can navigate back to a previous step depends on the process. In a sequence of forms, going back is safe and expected. When a step involves system actions (API calls, data mutations), going back may not be possible or meaningful. + +## Step states + +Each step can carry one of the following states: + +- **Pending:** not yet reached, shown with a numbered circle. +- **Active:** the current step, shown with a filled circle. +- **Completed:** passed successfully, shown with a green checkmark. +- **In progress:** the active step is waiting on an async operation, shown with a spinner. +- **Error:** the step failed, shown with a red circle. + +**Completed steps** (steps 1 and 2 done, step 3 active): + + + +**In progress** (step 2 waiting on an async operation): + + + +**Error** (step 2 failed): + + diff --git a/stories/stepper.stories.tsx b/stories/stepper.stories.tsx index 1b64586852..d5b255f3e3 100644 --- a/stories/stepper.stories.tsx +++ b/stories/stepper.stories.tsx @@ -3,9 +3,8 @@ import { Stepper, useStepper, } from '../src/lib/components/steppers/Stepper.component'; +import { Steppers } from '../src/lib/components/steppers/Steppers.component'; import styled from 'styled-components'; -import { Box } from '../src/lib/components/box/Box'; -import { Stack } from '../src/lib/spacing'; import { Button } from '../src/lib/components/buttonv2/Buttonv2.component'; import { Text } from '../src/lib/components/text/Text.component'; import { Wrapper as StoryWrapper } from './common'; @@ -16,26 +15,39 @@ const Wrapper = styled.div` flex-direction: column; align-items: stretch; height: 100%; + min-width: 16rem; + border: 1px solid rgba(128, 128, 128, 0.2); + border-radius: 6px; + padding: 16px; +`; + +const StepBody = styled.div` + flex: 1; + padding: 8px 0; +`; + +const StepActions = styled.div` + display: flex; + justify-content: flex-end; + gap: 8px; + padding-top: 16px; +`; + +const Hidden = styled.span` + visibility: hidden; `; const FirstStepComponent = (props: Record) => { const { next } = useStepper(StepIndexes.Step1, STEPS); return ( - - + First Step -