-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
c1e86fc
commit 67807fd
Showing
4 changed files
with
79 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,23 @@ | ||
import { Box, Multistep, MultistepProps } from '@ignite-ui/react'; | ||
import { Meta, StoryObj } from '@storybook/react'; | ||
import { StoryFnReactReturnType } from '@storybook/react/dist/ts3.9/client/preview/types'; | ||
|
||
export default { | ||
title: 'Form/Multistep', | ||
component: Multistep, | ||
args: { | ||
size: 4, | ||
currentStep: 2, | ||
}, | ||
decorators: [ | ||
(Story: () => StoryFnReactReturnType) => { | ||
return ( | ||
<Box css={{ display: 'flex', flexDirection: 'column', gap: '$2' }}> | ||
{Story()} | ||
</Box> | ||
); | ||
}, | ||
], | ||
} as Meta<MultistepProps>; | ||
|
||
export const Primary: StoryObj<MultistepProps> = {}; |
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,23 @@ | ||
import { MultistepContainer, MultistepLabel, Steps, Step } from './styles'; | ||
|
||
export type MultistepProps = { | ||
size: number; | ||
currentStep?: number; | ||
}; | ||
|
||
export function Multistep({ size, currentStep = 0 }: MultistepProps) { | ||
const steps = Array.from({ length: size }, (_, index) => index + 1); | ||
|
||
return ( | ||
<MultistepContainer> | ||
<MultistepLabel> | ||
Step {currentStep} of {size} | ||
</MultistepLabel> | ||
<Steps css={{ '--steps-size': size }}> | ||
{steps.map((step) => { | ||
return <Step key={step} active={currentStep >= step} />; | ||
})} | ||
</Steps> | ||
</MultistepContainer> | ||
); | ||
} |
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 { styled } from '../../styles'; | ||
import { Text } from '../Text'; | ||
|
||
export const MultistepContainer = styled('div', {}); | ||
|
||
export const MultistepLabel = styled(Text, { | ||
color: '$gray200', | ||
defaultVariants: { | ||
size: 'xs', | ||
}, | ||
}); | ||
|
||
export const Steps = styled('div', { | ||
display: 'grid', | ||
gridTemplateColumns: 'repeat(var(--steps-size),1fr)', | ||
gap: '$2', | ||
marginTop: '$1', | ||
}); | ||
|
||
export const Step = styled('div', { | ||
height: '$1', | ||
borderRadius: '$px', | ||
backgroundColor: '$gray600', | ||
|
||
variants: { | ||
active: { | ||
true: { | ||
backgroundColor: '$gray100', | ||
}, | ||
}, | ||
}, | ||
}); |
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