Skip to content

Commit

Permalink
Added multi-component demo storybook to test Mui Stepper
Browse files Browse the repository at this point in the history
  • Loading branch information
mrabbitt committed Sep 18, 2024
1 parent e010c78 commit a19cbd3
Showing 1 changed file with 48 additions and 0 deletions.
48 changes: 48 additions & 0 deletions src/stories/MuiStepper.stories.tsx
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>
),
};

0 comments on commit a19cbd3

Please sign in to comment.