From 2cc12bc5998f8cef092ef518db73c1d8fcf46b92 Mon Sep 17 00:00:00 2001 From: Moment <73689580+xun082@users.noreply.github.com> Date: Fri, 19 Jul 2024 16:49:33 +0800 Subject: [PATCH] =?UTF-8?q?docs:=20=F0=9F=93=9A=20=E6=B7=BB=E5=8A=A0=20ui?= =?UTF-8?q?=20=E7=BB=84=E4=BB=B6=E6=96=87=E6=A1=A3=20(#72)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/components/ui/avatar/index.stories.tsx | 37 +++++++++ src/components/ui/badge/index.stories.tsx | 35 +++++++++ src/components/ui/button/index.stories.tsx | 74 ++++++++++++++++++ src/components/ui/dialog/index.stories.tsx | 54 +++++++++++++ .../ui/dropdown-menu/index.stories.tsx | 75 +++++++++++++++++++ src/components/ui/input/index.stories.tsx | 30 ++++++++ .../ui/scroll-area/index.stories.tsx | 23 ++++++ 7 files changed, 328 insertions(+) create mode 100644 src/components/ui/avatar/index.stories.tsx create mode 100644 src/components/ui/badge/index.stories.tsx create mode 100644 src/components/ui/button/index.stories.tsx create mode 100644 src/components/ui/dialog/index.stories.tsx create mode 100644 src/components/ui/dropdown-menu/index.stories.tsx create mode 100644 src/components/ui/input/index.stories.tsx create mode 100644 src/components/ui/scroll-area/index.stories.tsx diff --git a/src/components/ui/avatar/index.stories.tsx b/src/components/ui/avatar/index.stories.tsx new file mode 100644 index 0000000..1bdac7c --- /dev/null +++ b/src/components/ui/avatar/index.stories.tsx @@ -0,0 +1,37 @@ +import React from 'react'; +import { Meta, StoryFn } from '@storybook/react'; + +import { Avatar, AvatarImage, AvatarFallback } from './index'; + +export default { + title: 'Components/Avatar', + component: Avatar, + subcomponents: { AvatarImage, AvatarFallback }, +} as Meta; + +type AvatarProps = { + src: string; + alt: string; + fallback: string; +}; + +const Template: StoryFn = (args) => ( + + + {args.fallback} + +); + +export const Default = Template.bind({}); +Default.args = { + src: 'https://via.placeholder.com/150', + alt: 'Avatar Image', + fallback: 'AB', +}; + +export const WithFallback = Template.bind({}); +WithFallback.args = { + src: '', + alt: 'Avatar Image', + fallback: 'AB', +}; diff --git a/src/components/ui/badge/index.stories.tsx b/src/components/ui/badge/index.stories.tsx new file mode 100644 index 0000000..bd908ff --- /dev/null +++ b/src/components/ui/badge/index.stories.tsx @@ -0,0 +1,35 @@ +import React from 'react'; +import { Meta, StoryFn } from '@storybook/react'; + +import { Badge, BadgeProps } from './index'; + +export default { + title: 'Components/Badge', + component: Badge, +} as Meta; + +const Template: StoryFn = (args) => ; + +export const Default = Template.bind({}); +Default.args = { + children: 'Default Badge', + variant: 'default', +}; + +export const Secondary = Template.bind({}); +Secondary.args = { + children: 'Secondary Badge', + variant: 'secondary', +}; + +export const Destructive = Template.bind({}); +Destructive.args = { + children: 'Destructive Badge', + variant: 'destructive', +}; + +export const Outline = Template.bind({}); +Outline.args = { + children: 'Outline Badge', + variant: 'outline', +}; diff --git a/src/components/ui/button/index.stories.tsx b/src/components/ui/button/index.stories.tsx new file mode 100644 index 0000000..6207beb --- /dev/null +++ b/src/components/ui/button/index.stories.tsx @@ -0,0 +1,74 @@ +import React from 'react'; +import { Meta, StoryFn } from '@storybook/react'; + +import { Button, ButtonProps } from './index'; + +export default { + title: 'Components/Button', + component: Button, +} as Meta; + +const Template: StoryFn = (args) => + + + + Dialog Title + This is the dialog description + +
Dialog Content
+ + + + + + + Close + +
+ +); + +export const Default = Template.bind({}); +Default.args = {}; diff --git a/src/components/ui/dropdown-menu/index.stories.tsx b/src/components/ui/dropdown-menu/index.stories.tsx new file mode 100644 index 0000000..06d4201 --- /dev/null +++ b/src/components/ui/dropdown-menu/index.stories.tsx @@ -0,0 +1,75 @@ +import React from 'react'; +import { Meta, StoryFn } from '@storybook/react'; + +import { + DropdownMenu, + DropdownMenuTrigger, + DropdownMenuContent, + DropdownMenuItem, + DropdownMenuCheckboxItem, + DropdownMenuRadioItem, + DropdownMenuLabel, + DropdownMenuSeparator, + DropdownMenuShortcut, + DropdownMenuGroup, + DropdownMenuPortal, + DropdownMenuSub, + DropdownMenuSubContent, + DropdownMenuSubTrigger, + DropdownMenuRadioGroup, +} from './index'; + +export default { + title: 'Components/DropdownMenu', + component: DropdownMenu, + subcomponents: { + DropdownMenuTrigger, + DropdownMenuContent, + DropdownMenuItem, + DropdownMenuCheckboxItem, + DropdownMenuRadioItem, + DropdownMenuLabel, + DropdownMenuSeparator, + DropdownMenuShortcut, + DropdownMenuGroup, + DropdownMenuPortal, + DropdownMenuSub, + DropdownMenuSubContent, + DropdownMenuSubTrigger, + DropdownMenuRadioGroup, + }, +} as Meta; + +const Template: StoryFn = (args) => ( + + + + + + Menu + Item 1 + Item 2 + + Checkbox Item + + Radio Item 1 + Radio Item 2 + + + Sub Menu + + Sub Item 1 + Sub Item 2 + + + + + Item with Shortcut + ⌘S + + + +); + +export const Default = Template.bind({}); +Default.args = {}; diff --git a/src/components/ui/input/index.stories.tsx b/src/components/ui/input/index.stories.tsx new file mode 100644 index 0000000..18ef79d --- /dev/null +++ b/src/components/ui/input/index.stories.tsx @@ -0,0 +1,30 @@ +import React from 'react'; +import { Meta, StoryFn } from '@storybook/react'; + +import { Input, InputProps } from './index'; + +export default { + title: 'Components/Input', + component: Input, +} as Meta; + +const Template: StoryFn = (args) => ; + +export const Default = Template.bind({}); +Default.args = { + type: 'text', + placeholder: 'Enter text...', +}; + +export const Disabled = Template.bind({}); +Disabled.args = { + type: 'text', + placeholder: 'Disabled input...', + disabled: true, +}; + +export const WithDefaultValue = Template.bind({}); +WithDefaultValue.args = { + type: 'text', + defaultValue: 'Default value', +}; diff --git a/src/components/ui/scroll-area/index.stories.tsx b/src/components/ui/scroll-area/index.stories.tsx new file mode 100644 index 0000000..6ba68d0 --- /dev/null +++ b/src/components/ui/scroll-area/index.stories.tsx @@ -0,0 +1,23 @@ +import React from 'react'; +import { Meta, StoryFn } from '@storybook/react'; + +import { ScrollArea, ScrollBar } from './index'; + +export default { + title: 'Components/ScrollArea', + component: ScrollArea, + subcomponents: { ScrollBar }, +} as Meta; + +const Template: StoryFn = (args) => ( +
+ +
+ This is a scrollable content area. Add more content here to see the scrollbars in action. +
+
+
+); + +export const Default = Template.bind({}); +Default.args = {};