import { Meta, StoryObj } from '@storybook/react-webpack5'; import { useState } from 'react'; import { Button } from '@@/buttons'; import { Step, Stepper } from './Stepper'; export default { component: Stepper, title: 'Components/Stepper', } as Meta; interface Args { totalSteps: number; } function Template({ totalSteps = 5 }: Args) { const steps: Array = Array.from({ length: totalSteps }).map( (_, index) => ({ label: `Step ${index + 1}`, }) ); const [currentStepIndex, setCurrentStepIndex] = useState(0); return (
); } export { Template }; function ClickableTemplate({ totalSteps = 4 }: Args) { const steps: Array = [ { label: 'Select Environment' }, { label: 'Configure' }, { label: 'Review' }, { label: 'Deploy' }, ].slice(0, totalSteps); const [currentStepIndex, setCurrentStepIndex] = useState(2); return (
setCurrentStepIndex(stepIndex)} />

Click on completed or current steps to navigate. Current step:{' '} {currentStepIndex + 1}

); } export const Clickable: StoryObj = { render: ClickableTemplate, args: { totalSteps: 4, }, };