-
Notifications
You must be signed in to change notification settings - Fork 14
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Experiment: Refactor stepper block into component and add storybook f…
…or it
- Loading branch information
Showing
3 changed files
with
54 additions
and
30 deletions.
There are no files selected for viewing
19 changes: 19 additions & 0 deletions
19
src/components/design_system/stepper/BenchmarkStepper.stories.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
import type { Meta, StoryObj } from "@storybook/react"; | ||
|
||
import BenchmarkStepper from "./stepper"; | ||
|
||
const meta = { | ||
component: BenchmarkStepper, | ||
} satisfies Meta<typeof BenchmarkStepper>; | ||
|
||
export default meta; | ||
|
||
type Story = StoryObj<typeof meta>; | ||
|
||
const STEPS = ["Instructional Guidelines", "Data Collection Guidelines"]; | ||
|
||
export const DefaultBenchmarkStepper: Story = { | ||
args: { | ||
steps: STEPS, | ||
}, | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
import { CheckCircle, TripOriginRounded } from "@mui/icons-material"; | ||
import { Step, StepLabel, Stepper, StepIconProps } from "@mui/material"; | ||
|
||
export const BenchmarkStepperIcon = (stepIconProps: StepIconProps) => { | ||
const { completed = false } = stepIconProps; | ||
|
||
if (completed) { | ||
return <CheckCircle />; | ||
} else { | ||
return <TripOriginRounded />; | ||
} | ||
}; | ||
|
||
export interface BenchmarkStepperProps { | ||
activeStep?: number; | ||
steps: string[]; | ||
} | ||
|
||
const BenchmarkStepper = ({ activeStep, steps }: BenchmarkStepperProps) => { | ||
return ( | ||
<Stepper activeStep={activeStep} alternativeLabel connector={null}> | ||
{steps.map((label) => ( | ||
<Step key={label}> | ||
<StepLabel StepIconComponent={BenchmarkStepperIcon}> | ||
{label} | ||
</StepLabel> | ||
</Step> | ||
))} | ||
</Stepper> | ||
); | ||
}; | ||
export default BenchmarkStepper; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters