Skip to content

Commit

Permalink
Added stories
Browse files Browse the repository at this point in the history
  • Loading branch information
miksrv committed Oct 2, 2024
1 parent 7817240 commit 0b7e4a1
Show file tree
Hide file tree
Showing 2 changed files with 101 additions and 0 deletions.
76 changes: 76 additions & 0 deletions storybook/stories/Button.stories.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
import React from 'react'

import Button from '@/button'
import {iconNames} from '@/icon'
import { Meta, StoryFn } from '@storybook/react'

const meta: Meta<typeof Button> = {
title: 'Components/Button',
component: Button,
argTypes: {
mode: {
control: { type: 'select' },
options: ['primary', 'secondary', 'outline', 'link'],
description: 'Visual style of the button',
table: {
defaultValue: {
summary: 'primary'
},
type: {
summary: '"primary", "secondary", "outline", "link"'
}
}
},
size: {
control: { type: 'inline-radio' },
options: ['small', 'medium']
},
variant: {
control: { type: 'select' },
options: ['positive', 'negative', 'neutral']
},
icon: {
control: { type: 'select' },
options: Object.keys(iconNames).map((name) => name)
},
loading: {
control: { type: 'boolean' }
},
content: {
control: { type: 'text' }
}
}
}

export default meta

type ButtonProps = React.ComponentProps<typeof Button>

const Template: StoryFn<ButtonProps> = (args: ButtonProps) => <Button {...args}>Click me</Button>

export const Primary = Template.bind({})
Primary.args = {
mode: 'primary',
size: 'medium'
}

export const Secondary = Template.bind({})
Secondary.args = {
mode: 'secondary',
size: 'medium'
}

export const WithIcon = Template.bind({})
WithIcon.args = {
mode: 'primary',
icon: 'Camera',
size: 'medium'
}

export const Loading = Template.bind({})
Loading.args = {
mode: 'primary',
size: 'medium',
loading: true,
content: 'Loading...'
}
25 changes: 25 additions & 0 deletions storybook/stories/Icon.stories.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
import React from 'react'

import Icon, { iconNames, IconTypes } from '@/icon'
import { Meta, StoryFn } from '@storybook/react'

export default {
title: 'Components/Icon',
component: Icon
} as Meta

export const AllIcons: StoryFn = () => (
<div style={{ display: 'flex', flexWrap: 'wrap', gap: '16px' }}>
{Object.keys(iconNames).map((name) => (
<div
key={name}
style={{ textAlign: 'center' }}
>
<Icon
name={name as IconTypes}
style={{ width: 24, height: 24 }}
/>
</div>
))}
</div>
)

0 comments on commit 0b7e4a1

Please sign in to comment.