From 0b7e4a1a924905d4f3846a06384b325a07f0665d Mon Sep 17 00:00:00 2001 From: Misha Topchilo <20854498+miksrv@users.noreply.github.com> Date: Tue, 1 Oct 2024 22:41:58 -0700 Subject: [PATCH] Added stories --- storybook/stories/Button.stories.tsx | 76 ++++++++++++++++++++++++++++ storybook/stories/Icon.stories.tsx | 25 +++++++++ 2 files changed, 101 insertions(+) diff --git a/storybook/stories/Button.stories.tsx b/storybook/stories/Button.stories.tsx index e69de29..22ff16e 100644 --- a/storybook/stories/Button.stories.tsx +++ b/storybook/stories/Button.stories.tsx @@ -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 = { + 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 + +const Template: StoryFn = (args: ButtonProps) => + +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...' +} diff --git a/storybook/stories/Icon.stories.tsx b/storybook/stories/Icon.stories.tsx index e69de29..d406dba 100644 --- a/storybook/stories/Icon.stories.tsx +++ b/storybook/stories/Icon.stories.tsx @@ -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 = () => ( +
+ {Object.keys(iconNames).map((name) => ( +
+ +
+ ))} +
+)