-
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.
Added multi-component demo storybook to test Mui Stepper
- Loading branch information
Showing
1 changed file
with
48 additions
and
0 deletions.
There are no files selected for viewing
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,48 @@ | ||
import type { Meta, StoryObj } from "@storybook/react"; | ||
|
||
import Box from "@mui/material/Box"; | ||
import Stepper from "@mui/material/Stepper"; | ||
import Step from "@mui/material/Step"; | ||
import StepLabel from "@mui/material/StepLabel"; | ||
import CheckCircleIcon from "@mui/icons-material/CheckCircle"; | ||
import TripOriginRoundedIcon from "@mui/icons-material/TripOriginRounded"; | ||
|
||
const meta: Meta<typeof Stepper> = { | ||
component: Stepper, | ||
}; | ||
export default meta; | ||
|
||
type Story = StoryObj<typeof Stepper>; | ||
|
||
const steps = ["Completed", "Active", "Disabled"]; | ||
|
||
export const DemoMuiStepper: Story = { | ||
args: { | ||
activeStep: 0, | ||
}, | ||
/* See here about using "render" to test multiple components: | ||
https://storybook.js.org/docs/writing-stories#stories-for-two-or-more-components */ | ||
render: (args) => ( | ||
/* Mostly copied from the demo in settings.tsx, except using "activeStep" to match Stepper's props so it can be | ||
exposed as in "args" to Storybook */ | ||
<Box sx={{ width: "100%" }}> | ||
<Stepper {...args} alternativeLabel connector={null}> | ||
{steps.map((label, index) => ( | ||
<Step key={label}> | ||
{index !== steps.length && ( | ||
<StepLabel | ||
StepIconComponent={ | ||
index < (args.activeStep ?? 0) | ||
? CheckCircleIcon | ||
: TripOriginRoundedIcon | ||
} | ||
> | ||
{label} | ||
</StepLabel> | ||
)} | ||
</Step> | ||
))} | ||
</Stepper> | ||
</Box> | ||
), | ||
}; |