-
Notifications
You must be signed in to change notification settings - Fork 103
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
ee98b3a
commit c3c290b
Showing
7 changed files
with
121 additions
and
2 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
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
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,46 @@ | ||
import React from 'react' | ||
import clsx from 'clsx' | ||
import { twMerge } from 'tailwind-merge' | ||
|
||
import { | ||
IComponentBaseProps, | ||
ComponentColor | ||
} from '../types' | ||
|
||
export type StepProps = | ||
& React.LiHTMLAttributes<HTMLLIElement> | ||
& IComponentBaseProps | ||
& { | ||
value?: string | ||
color?: ComponentColor | ||
} | ||
|
||
const Step = ({ | ||
children, | ||
value, | ||
color, | ||
dataTheme, | ||
className, | ||
...props | ||
}: StepProps): JSX.Element => { | ||
const classes = twMerge( | ||
'step', | ||
className, | ||
clsx({ | ||
[`step-${color}`]: color, | ||
}) | ||
) | ||
|
||
return ( | ||
<li | ||
{...props} | ||
data-theme={dataTheme} | ||
data-content={value} | ||
className={classes} | ||
> | ||
{children} | ||
</li> | ||
) | ||
} | ||
|
||
export default Step |
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 React from 'react' | ||
import { Story, Meta } from '@storybook/react' | ||
|
||
import Steps, { StepsProps } from '.' | ||
|
||
export default { | ||
title: 'Navigation/Steps', | ||
component: Steps, | ||
} as Meta | ||
|
||
export const Default: Story<StepsProps> = (args) => { | ||
return ( | ||
<Steps {...args}> | ||
<Steps.Step color="info">Fly to moon</Steps.Step> | ||
<Steps.Step color="info">Shrink the moon</Steps.Step> | ||
<Steps.Step color="info">Grab the moon</Steps.Step> | ||
|
||
<Steps.Step value="?" color="error">Sit on toilet</Steps.Step> | ||
</Steps> | ||
) | ||
} | ||
|
||
Default.args = {} |
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,43 @@ | ||
import React, { LegacyRef } from 'react' | ||
import { twMerge } from 'tailwind-merge' | ||
|
||
import { IComponentBaseProps } from '../types' | ||
|
||
import Step from './Step' | ||
|
||
export type StepsProps = | ||
& React.HTMLAttributes<HTMLUListElement> | ||
& IComponentBaseProps | ||
& { | ||
ref?: LegacyRef<HTMLUListElement> | ||
vertical?: boolean | ||
horizontal?: boolean | ||
} | ||
|
||
const Steps = ({ | ||
children, | ||
ref, | ||
dataTheme, | ||
className, | ||
...props | ||
}: StepsProps): JSX.Element => { | ||
const classes = twMerge( | ||
'steps', | ||
className | ||
) | ||
|
||
return ( | ||
<ul | ||
{...props} | ||
ref={ref} | ||
data-theme={dataTheme} | ||
className={classes} | ||
> | ||
{children} | ||
</ul> | ||
) | ||
} | ||
|
||
Steps.Step = Step | ||
|
||
export default 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,5 @@ | ||
export * from './Steps'; | ||
|
||
import Steps, { StepsProps as TStepsProps } from './Steps' | ||
export type StepsProps = TStepsProps | ||
export default 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