Skip to content

Commit

Permalink
creating Multistep component
Browse files Browse the repository at this point in the history
  • Loading branch information
brenocastelo committed Dec 14, 2022
1 parent c1e86fc commit 67807fd
Show file tree
Hide file tree
Showing 4 changed files with 79 additions and 0 deletions.
23 changes: 23 additions & 0 deletions packages/docs/src/stories/Multistep.stories.tsx
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> = {};
23 changes: 23 additions & 0 deletions packages/react/src/components/Multistep/index.tsx
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>
);
}
32 changes: 32 additions & 0 deletions packages/react/src/components/Multistep/styles.ts
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',
},
},
},
});
1 change: 1 addition & 0 deletions packages/react/src/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,4 @@ export * from './components/Button';
export * from './components/TextInput';
export * from './components/TextArea';
export * from './components/Checkbox';
export * from './components/Multistep';

0 comments on commit 67807fd

Please sign in to comment.