Skip to content

Commit

Permalink
feat: added steps
Browse files Browse the repository at this point in the history
  • Loading branch information
benjitrosch committed Mar 11, 2022
1 parent ee98b3a commit c3c290b
Show file tree
Hide file tree
Showing 7 changed files with 121 additions and 2 deletions.
2 changes: 1 addition & 1 deletion README.md
Expand Up @@ -144,7 +144,7 @@ Use tools like the official <a href="https://daisyui.com/theme-generator/">daisy
- [X] Menu
- [X] Navbar
- [ ] Pagination
- [ ] Steps
- [X] Steps
- [X] Tab
</details>

Expand Down
2 changes: 1 addition & 1 deletion src/Divider/Divider.tsx
Expand Up @@ -9,7 +9,7 @@ export type DividerProps =
& IComponentBaseProps
& {
children?: string
vertical?: Boolean
vertical?: boolean
}

const Divider = ({
Expand Down
46 changes: 46 additions & 0 deletions src/Steps/Step.tsx
@@ -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
23 changes: 23 additions & 0 deletions src/Steps/Steps.stories.tsx
@@ -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 = {}
43 changes: 43 additions & 0 deletions src/Steps/Steps.tsx
@@ -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
5 changes: 5 additions & 0 deletions src/Steps/index.ts
@@ -0,0 +1,5 @@
export * from './Steps';

import Steps, { StepsProps as TStepsProps } from './Steps'
export type StepsProps = TStepsProps
export default Steps
2 changes: 2 additions & 0 deletions src/index.ts
Expand Up @@ -34,6 +34,7 @@ import Rating from './Rating'
import Select from './Select'
import Stack from './Stack'
import Stats from './Stats'
import Steps from './Steps'
import Swap from './Swap'
import Table from './Table'
import Tabs from './Tabs'
Expand Down Expand Up @@ -77,6 +78,7 @@ export {
Select,
Stack,
Stats,
Steps,
Swap,
Table,
Tabs,
Expand Down

0 comments on commit c3c290b

Please sign in to comment.