From 30931062bd5defe7b541e2d47835610458a7c3f9 Mon Sep 17 00:00:00 2001 From: Jonathan Summers-Muir Date: Sun, 25 Jun 2023 19:22:39 +0800 Subject: [PATCH] add stories --- packages/ui/.storybook/main.ts | 2 +- .../shadcn/stories/Accordion.stories.tsx | 7 +- .../shadcn/stories/Alert.stories.tsx | 30 ++ .../shadcn/stories/AlertDialog.stories.tsx | 38 +++ .../shadcn/stories/AspectRatio.stories.tsx | 32 ++ .../shadcn/stories/Avatar.stories.tsx | 19 ++ .../shadcn/stories/Badge.stories.tsx | 25 ++ .../shadcn/stories/Button.stories.tsx | 81 +++++ .../shadcn/stories/Calendar.stories.tsx | 114 +++++++ .../shadcn/stories/Card.stories.tsx | 145 ++++++++ .../shadcn/stories/Checkbox.stories.tsx | 233 +++++++++++++ .../shadcn/stories/Collapsible.stories.tsx | 39 +++ .../shadcn/stories/Command.stories.tsx | 130 ++++++++ .../shadcn/stories/ContextMenu.stories.tsx | 73 ++++ .../stories/DataTable.storiesFIX LATER.tsx | 311 ++++++++++++++++++ .../shadcn/stories/DatePicker.stories.tsx | 235 +++++++++++++ .../shadcn/stories/Dialog.stories.tsx | 55 ++++ .../shadcn/stories/Form.stories.tsx | 9 +- .../shadcn/stories/HoverCard.stories.tsx | 38 +++ .../shadcn/stories/Input.stories.tsx | 103 ++++++ .../shadcn/stories/Label.stories.tsx | 22 ++ .../shadcn/stories/MenuBar.stories.tsx | 114 +++++++ .../shadcn/stories/NavigationMenu.stories.tsx | 155 +++++++++ .../shadcn/stories/Popover.stories.tsx | 49 +++ .../shadcn/stories/Progress.stories.tsx | 21 ++ .../shadcn/stories/RadioGroup.stories.tsx | 109 ++++++ .../shadcn/stories/ScrollArea.stories.tsx | 30 ++ .../shadcn/stories/Select.stories.tsx | 138 ++++++++ .../shadcn/stories/Seperator.stories.tsx | 28 ++ .../shadcn/stories/Sheet.stories.tsx | 103 ++++++ .../shadcn/stories/Skeleton.stories.tsx | 21 ++ .../shadcn/stories/Slider.stories.tsx | 24 ++ .../shadcn/stories/Switch.stories.tsx | 107 ++++++ .../shadcn/stories/Table.stories.tsx | 88 +++++ .../shadcn/stories/Tabs.stories.tsx | 77 +++++ .../shadcn/stories/TextArea.stories.tsx | 117 +++++++ .../shadcn/stories/Toast.stories.tsx | 104 ++++++ .../shadcn/stories/Toggle.stories.tsx | 60 ++++ .../shadcn/stories/Tooltip.stories.tsx | 30 ++ .../shadcn/stories/_TEMPLATE.stories_.tsx | 27 ++ 40 files changed, 3136 insertions(+), 7 deletions(-) create mode 100644 packages/ui/src/components/shadcn/stories/Alert.stories.tsx create mode 100644 packages/ui/src/components/shadcn/stories/AlertDialog.stories.tsx create mode 100644 packages/ui/src/components/shadcn/stories/AspectRatio.stories.tsx create mode 100644 packages/ui/src/components/shadcn/stories/Avatar.stories.tsx create mode 100644 packages/ui/src/components/shadcn/stories/Badge.stories.tsx create mode 100644 packages/ui/src/components/shadcn/stories/Button.stories.tsx create mode 100644 packages/ui/src/components/shadcn/stories/Calendar.stories.tsx create mode 100644 packages/ui/src/components/shadcn/stories/Card.stories.tsx create mode 100644 packages/ui/src/components/shadcn/stories/Checkbox.stories.tsx create mode 100644 packages/ui/src/components/shadcn/stories/Collapsible.stories.tsx create mode 100644 packages/ui/src/components/shadcn/stories/Command.stories.tsx create mode 100644 packages/ui/src/components/shadcn/stories/ContextMenu.stories.tsx create mode 100644 packages/ui/src/components/shadcn/stories/DataTable.storiesFIX LATER.tsx create mode 100644 packages/ui/src/components/shadcn/stories/DatePicker.stories.tsx create mode 100644 packages/ui/src/components/shadcn/stories/Dialog.stories.tsx create mode 100644 packages/ui/src/components/shadcn/stories/HoverCard.stories.tsx create mode 100644 packages/ui/src/components/shadcn/stories/Input.stories.tsx create mode 100644 packages/ui/src/components/shadcn/stories/Label.stories.tsx create mode 100644 packages/ui/src/components/shadcn/stories/MenuBar.stories.tsx create mode 100644 packages/ui/src/components/shadcn/stories/NavigationMenu.stories.tsx create mode 100644 packages/ui/src/components/shadcn/stories/Popover.stories.tsx create mode 100644 packages/ui/src/components/shadcn/stories/Progress.stories.tsx create mode 100644 packages/ui/src/components/shadcn/stories/RadioGroup.stories.tsx create mode 100644 packages/ui/src/components/shadcn/stories/ScrollArea.stories.tsx create mode 100644 packages/ui/src/components/shadcn/stories/Select.stories.tsx create mode 100644 packages/ui/src/components/shadcn/stories/Seperator.stories.tsx create mode 100644 packages/ui/src/components/shadcn/stories/Sheet.stories.tsx create mode 100644 packages/ui/src/components/shadcn/stories/Skeleton.stories.tsx create mode 100644 packages/ui/src/components/shadcn/stories/Slider.stories.tsx create mode 100644 packages/ui/src/components/shadcn/stories/Switch.stories.tsx create mode 100644 packages/ui/src/components/shadcn/stories/Table.stories.tsx create mode 100644 packages/ui/src/components/shadcn/stories/Tabs.stories.tsx create mode 100644 packages/ui/src/components/shadcn/stories/TextArea.stories.tsx create mode 100644 packages/ui/src/components/shadcn/stories/Toast.stories.tsx create mode 100644 packages/ui/src/components/shadcn/stories/Toggle.stories.tsx create mode 100644 packages/ui/src/components/shadcn/stories/Tooltip.stories.tsx create mode 100644 packages/ui/src/components/shadcn/stories/_TEMPLATE.stories_.tsx diff --git a/packages/ui/.storybook/main.ts b/packages/ui/.storybook/main.ts index 4fa3c2f60e0..f72e1eed2b2 100644 --- a/packages/ui/.storybook/main.ts +++ b/packages/ui/.storybook/main.ts @@ -14,7 +14,7 @@ const config: any = { '../src/components/Dropdown/Dropdown.stories.tsx', // '../src/components/Form/Form.stories.tsx', - '../src/components/shadcn/stories/**/*.tsx', + '../src/components/shadcn/stories/**/*.stories.tsx', ], addons: [ 'storybook-dark-mode', diff --git a/packages/ui/src/components/shadcn/stories/Accordion.stories.tsx b/packages/ui/src/components/shadcn/stories/Accordion.stories.tsx index 472df1b07ac..f4bdc6d91d0 100644 --- a/packages/ui/src/components/shadcn/stories/Accordion.stories.tsx +++ b/packages/ui/src/components/shadcn/stories/Accordion.stories.tsx @@ -1,4 +1,3 @@ -import { Button } from './../../Button' import { Accordion, AccordionContent, @@ -9,13 +8,13 @@ import { import type { Meta, StoryObj } from '@storybook/react' -const meta: Meta = { +const meta: Meta = { /* 👇 The title prop is optional. * See https://storybook.js.org/docs/react/configure/overview#configure-story-loading * to learn how to generate automatic titles */ title: 'shadcn/Accordian', - component: Button, + component: Accordion, } export const Neutral = (args: any) => ( @@ -41,7 +40,7 @@ export const Neutral = (args: any) => ( export default meta -type Story = StoryObj +type Story = StoryObj /* *👇 Render functions are a framework specific feature to allow you control on how the component renders. diff --git a/packages/ui/src/components/shadcn/stories/Alert.stories.tsx b/packages/ui/src/components/shadcn/stories/Alert.stories.tsx new file mode 100644 index 00000000000..2e20a17eb63 --- /dev/null +++ b/packages/ui/src/components/shadcn/stories/Alert.stories.tsx @@ -0,0 +1,30 @@ +import { Alert, AlertDescription, AlertTitle } from '@ui/components/shadcn/ui/alert' +import { AlertCircle, Terminal } from 'lucide-react' +import { Meta } from '@storybook/react' + +const meta: Meta = { + title: 'shadcn/Alert', + component: Alert, +} + +export const Default = () => ( + + + Heads up! + You can add components to your app using the cli. + +) + +Default.storyName = 'Default' + +export const Destructive = () => ( + + + Error + Your session has expired. Please log in again. + +) + +Destructive.storyName = 'Destructive' + +export default meta diff --git a/packages/ui/src/components/shadcn/stories/AlertDialog.stories.tsx b/packages/ui/src/components/shadcn/stories/AlertDialog.stories.tsx new file mode 100644 index 00000000000..c12c22ea551 --- /dev/null +++ b/packages/ui/src/components/shadcn/stories/AlertDialog.stories.tsx @@ -0,0 +1,38 @@ +import React from 'react' +import { Meta } from '@storybook/react' +import { + AlertDialog, + AlertDialogTrigger, + AlertDialogContent, + AlertDialogHeader, + AlertDialogTitle, + AlertDialogDescription, + AlertDialogFooter, + AlertDialogAction, + AlertDialogCancel, +} from '@ui/components/shadcn/ui/alert-dialog' + +const meta: Meta = { + title: 'shadcn/AlertDialog', + component: AlertDialog, +} + +export const Default = () => ( + + Open Dialog + + + Dialog Title + + This is the dialog description. + + Cancel + OK + + + +) + +Default.storyName = 'Default' + +export default meta diff --git a/packages/ui/src/components/shadcn/stories/AspectRatio.stories.tsx b/packages/ui/src/components/shadcn/stories/AspectRatio.stories.tsx new file mode 100644 index 00000000000..b312437d955 --- /dev/null +++ b/packages/ui/src/components/shadcn/stories/AspectRatio.stories.tsx @@ -0,0 +1,32 @@ +import React from 'react' +import { Meta } from '@storybook/react' +import { AspectRatio } from '@ui/components/shadcn/ui/aspect-ratio' + +const meta: Meta = { + title: 'shadcn/AspectRatio', + component: AspectRatio, +} + +export const Default = () => ( + + Photo by Drew Beamer + {/* + + You could also use Next/Image in here like this: + + Photo by Drew Beamer + + */} + +) + +export default meta diff --git a/packages/ui/src/components/shadcn/stories/Avatar.stories.tsx b/packages/ui/src/components/shadcn/stories/Avatar.stories.tsx new file mode 100644 index 00000000000..ffe5d39e902 --- /dev/null +++ b/packages/ui/src/components/shadcn/stories/Avatar.stories.tsx @@ -0,0 +1,19 @@ +import React from 'react' +import { Meta } from '@storybook/react' +import { Avatar, AvatarFallback, AvatarImage } from '@ui/components/shadcn/ui/avatar' + +const meta: Meta = { + title: 'Shadcn/Avatar', + component: Avatar, +} + +export const Default = () => ( + + + CN + +) + +Default.storyName = 'Default' + +export default meta diff --git a/packages/ui/src/components/shadcn/stories/Badge.stories.tsx b/packages/ui/src/components/shadcn/stories/Badge.stories.tsx new file mode 100644 index 00000000000..60bfc6e1b55 --- /dev/null +++ b/packages/ui/src/components/shadcn/stories/Badge.stories.tsx @@ -0,0 +1,25 @@ +import { Badge } from '@ui/components/shadcn/ui/badge' +import { Meta } from '@storybook/react' + +const meta: Meta = { + title: 'shadcn/Badge', + component: Badge, +} + +export const Default = () => Badge + +Default.storyName = 'Default' + +export const Secondary = () => Secondary + +Secondary.storyName = 'Secondary' + +export const Outline = () => Outline + +Outline.storyName = 'Outline' + +export const Destructive = () => Destructive + +Destructive.storyName = 'Destructive' + +export default meta diff --git a/packages/ui/src/components/shadcn/stories/Button.stories.tsx b/packages/ui/src/components/shadcn/stories/Button.stories.tsx new file mode 100644 index 00000000000..c4f3ccc7b84 --- /dev/null +++ b/packages/ui/src/components/shadcn/stories/Button.stories.tsx @@ -0,0 +1,81 @@ +import { Button } from '@ui/components/shadcn/ui/button' +import { Meta } from '@storybook/react' +import { ChevronRight, Loader2, Mail } from 'lucide-react' +import Link from 'next/link' + +const meta: Meta = { + title: 'Button', + component: Button, +} + +export const Default = () => + +Default.storyName = 'Default' + +export const Secondary = () => + +Secondary.storyName = 'Secondary' + +export const Destructive = () => + +Destructive.storyName = 'Destructive' + +export const Outline = () => + +Outline.storyName = 'Outline' + +export const Ghost = () => + +Ghost.storyName = 'Ghost' + +export const LinkButton = () => ( + + + +) + +LinkButton.storyName = 'Link' + +export const Icon = () => ( + +) + +Icon.storyName = 'Icon' + +export const IconOnly = () => ( + +) + +IconOnly.storyName = 'Icon Only' + +export const Loading = () => ( + +) + +Loading.storyName = 'Loading' + +export const WithIcon = () => ( + +) + +WithIcon.storyName = 'With Icon' + +export const AsChild = () => ( + +) + +AsChild.storyName = 'As Child' + +export default meta diff --git a/packages/ui/src/components/shadcn/stories/Calendar.stories.tsx b/packages/ui/src/components/shadcn/stories/Calendar.stories.tsx new file mode 100644 index 00000000000..1c4172a11d0 --- /dev/null +++ b/packages/ui/src/components/shadcn/stories/Calendar.stories.tsx @@ -0,0 +1,114 @@ +import { zodResolver } from '@hookform/resolvers/zod' +import { Meta } from '@storybook/react' +import { Button } from '@ui/components/shadcn/ui/button' +import { Calendar } from '@ui/components/shadcn/ui/calendar' +import { + Form, + FormControl, + FormDescription, + FormField, + FormItem, + FormLabel, + FormMessage, +} from '@ui/components/shadcn/ui/form' +import { Popover, PopoverContent, PopoverTrigger } from '@ui/components/shadcn/ui/popover' +import { toast } from '@ui/components/shadcn/ui/use-toast' +import { cn } from '@ui/lib/utils' +import { format } from 'date-fns' +import { CalendarIcon } from 'lucide-react' +import * as React from 'react' +import { useForm } from 'react-hook-form' +import * as z from 'zod' + +const meta: Meta = { + title: 'shadcn/Calendar', + component: Calendar, +} + +export const Default = () => { + const [date, setDate] = React.useState(new Date()) + + return ( +
+ +
+ ) +} + +// export const withForm = () => { +// const FormSchema = z.object({ +// dob: z.date({ +// required_error: 'A date of birth is required.', +// }), +// }) + +// const form = useForm>({ +// resolver: zodResolver(FormSchema), +// }) + +// function onSubmit(data: z.infer) { +// toast({ +// title: 'You submitted the following values:', +// description: ( +//
+//           {JSON.stringify(data, null, 2)}
+//         
+// ), +// }) +// } + +// return ( +//
+// +// ( +// +// Date of birth +// +// +// +// +// +// +// +// { +// // @mildtomato - guard in case returns undefined +// if (e) { +// field.onChange(e) +// } +// }} +// disabled={(date) => date > new Date() || date < new Date('1900-01-01')} +// initialFocus +// /> +// +// +// Your date of birth is used to calculate your age. +// +// +// )} +// /> +// +// +// +// ) +// } + +// withForm.storyName = 'With Form' + +export default meta diff --git a/packages/ui/src/components/shadcn/stories/Card.stories.tsx b/packages/ui/src/components/shadcn/stories/Card.stories.tsx new file mode 100644 index 00000000000..21808a8ca7e --- /dev/null +++ b/packages/ui/src/components/shadcn/stories/Card.stories.tsx @@ -0,0 +1,145 @@ +import { Meta } from '@storybook/react' +import { Button } from '@ui/components/shadcn/ui/button' +import { + Card, + CardContent, + CardDescription, + CardFooter, + CardHeader, + CardTitle, +} from '@ui/components/shadcn/ui/card' +import { Input } from '@ui/components/shadcn/ui/input' +import { Label } from '@ui/components/shadcn/ui/label' +import { + Select, + SelectContent, + SelectItem, + SelectTrigger, + SelectValue, +} from '@ui/components/shadcn/ui/select' +import { Switch } from '@ui/components/shadcn/ui/switch' +import { cn } from '@ui/lib/utils' +import { BellRing, Check } from 'lucide-react' + +const meta: Meta = { + title: 'shadcn/Card', + component: Card, +} + +export const Default = () => { + return ( + + + Card Title + Card Description + + +

Card Content

+
+ +

Card Footer

+
+
+ ) +} + +export const CardWithForm = () => { + return ( + + + Create project + Deploy your new project in one-click. + + +
+
+
+ + +
+
+ + +
+
+
+
+ + + + +
+ ) +} + +type CardProps = React.ComponentProps + +export const CardDemo = ({ className, ...props }: CardProps) => { + const notifications = [ + { + title: 'Your call has been confirmed.', + description: '1 hour ago', + }, + { + title: 'You have a new message!', + description: '1 hour ago', + }, + { + title: 'Your subscription is expiring soon!', + description: '2 hours ago', + }, + ] + + return ( + + + Notifications + You have 3 unread messages. + + +
+ +
+

Push Notifications

+

Send notifications to device.

+
+ +
+
+ {notifications.map((notification, index) => ( +
+ +
+

{notification.title}

+

{notification.description}

+
+
+ ))} +
+
+ + + +
+ ) +} + +CardWithForm.storyName = 'Card with form' +CardDemo.storyName = 'Card demo' + +export default meta diff --git a/packages/ui/src/components/shadcn/stories/Checkbox.stories.tsx b/packages/ui/src/components/shadcn/stories/Checkbox.stories.tsx new file mode 100644 index 00000000000..02dde24906a --- /dev/null +++ b/packages/ui/src/components/shadcn/stories/Checkbox.stories.tsx @@ -0,0 +1,233 @@ +import { zodResolver } from '@hookform/resolvers/zod' +import { Meta } from '@storybook/react' +import { Button } from '@ui/components/shadcn/ui/button' +import { Checkbox } from '@ui/components/shadcn/ui/checkbox' +import { + Form, + FormControl, + FormDescription, + FormField, + FormItem, + FormLabel, + FormMessage, +} from '@ui/components/shadcn/ui/form' +import { toast } from '@ui/components/shadcn/ui/use-toast' +import Link from 'next/link' +import { useForm } from 'react-hook-form' +import * as z from 'zod' + +const meta: Meta = { + title: 'shadcn/Checkbox', + component: Checkbox, +} + +export const Default = () => { + return ( +
+ + +
+ ) +} + +export function CheckboxWithText() { + return ( +
+ +
+ +

+ You agree to our Terms of Service and Privacy Policy. +

+
+
+ ) +} + +export function CheckboxDisabled() { + return ( +
+ + +
+ ) +} + +export function CheckboxReactHookFormSingle() { + const FormSchema = z.object({ + mobile: z.boolean().default(false).optional(), + }) + + const form = useForm>({ + resolver: zodResolver(FormSchema), + defaultValues: { + mobile: true, + }, + }) + + function onSubmit(data: z.infer) { + toast({ + title: 'You submitted the following values:', + description: ( +
+          {JSON.stringify(data, null, 2)}
+        
+ ), + }) + } + + return ( +
+ + ( + + + { + if (e) { + field.onChange + } + }} + /> + +
+ Use different settings for my mobile devices + + You can manage your mobile notifications in the{' '} + mobile settings page. + +
+
+ )} + /> + + + + ) +} + +export function CheckboxReactHookFormMultiple() { + const FormSchema = z.object({ + items: z.array(z.string()).refine((value) => value.some((item) => item), { + message: 'You have to select at least one item.', + }), + }) + const items = [ + { + id: 'recents', + label: 'Recents', + }, + { + id: 'home', + label: 'Home', + }, + { + id: 'applications', + label: 'Applications', + }, + { + id: 'desktop', + label: 'Desktop', + }, + { + id: 'downloads', + label: 'Downloads', + }, + { + id: 'documents', + label: 'Documents', + }, + ] as const + const form = useForm>({ + resolver: zodResolver(FormSchema), + defaultValues: { + items: ['recents', 'home'], + }, + }) + + function onSubmit(data: z.infer) { + toast({ + title: 'You submitted the following values:', + description: ( +
+          {JSON.stringify(data, null, 2)}
+        
+ ), + }) + } + + return ( +
+ + ( + +
+ Sidebar + + Select the items you want to display in the sidebar. + +
+ {items.map((item) => ( + { + return ( + + + { + return checked + ? field.onChange([...field.value, item.id]) + : field.onChange(field.value?.filter((value) => value !== item.id)) + }} + /> + + {item.label} + + ) + }} + /> + ))} + +
+ )} + /> + + + + ) +} + +CheckboxWithText.storyName = 'Checkbox with text' +CheckboxDisabled.storyName = 'Checkbox disabled' +CheckboxReactHookFormSingle.storyName = 'Checkbox react hook form single' +CheckboxReactHookFormMultiple.storyName = ' Checkbox react hook form multiple' +export default meta diff --git a/packages/ui/src/components/shadcn/stories/Collapsible.stories.tsx b/packages/ui/src/components/shadcn/stories/Collapsible.stories.tsx new file mode 100644 index 00000000000..a3f0991f7a8 --- /dev/null +++ b/packages/ui/src/components/shadcn/stories/Collapsible.stories.tsx @@ -0,0 +1,39 @@ +import { Meta } from '@storybook/react' +import { Button } from '@ui/components/shadcn/ui/button' +import { + Collapsible, + CollapsibleContent, + CollapsibleTrigger, +} from '@ui/components/shadcn/ui/collapsible' +import { ChevronsUpDown } from 'lucide-react' +import * as React from 'react' + +const meta: Meta = { + title: 'shadcn/Collapsible', + component: Collapsible, +} + +export const Default = () => { + const [isOpen, setIsOpen] = React.useState(false) + + return ( + +
+

@peduarte starred 3 repositories

+ + + +
+
@radix-ui/primitives
+ +
@radix-ui/colors
+
@stitches/react
+
+
+ ) +} + +export default meta diff --git a/packages/ui/src/components/shadcn/stories/Command.stories.tsx b/packages/ui/src/components/shadcn/stories/Command.stories.tsx new file mode 100644 index 00000000000..17c3ffab749 --- /dev/null +++ b/packages/ui/src/components/shadcn/stories/Command.stories.tsx @@ -0,0 +1,130 @@ +import { Meta } from '@storybook/react' +import { + Command, + CommandDialog, + CommandEmpty, + CommandGroup, + CommandInput, + CommandItem, + CommandList, + CommandSeparator, + CommandShortcut, +} from '@ui/components/shadcn/ui/command' +import { Calculator, Calendar, CreditCard, Settings, Smile, User } from 'lucide-react' +import * as React from 'react' + +const meta: Meta = { + title: 'shadcn/Command', + component: Command, +} + +export function Default() { + return ( + + + + No results found. + + + + Calendar + + + + Search Emoji + + + + Calculator + + + + + + + Profile + ⌘P + + + + Billing + ⌘B + + + + Settings + ⌘S + + + + + ) +} + +export function CommandDialogDemo() { + const [open, setOpen] = React.useState(false) + + React.useEffect(() => { + const down = (e: KeyboardEvent) => { + if (e.key === 'k' && e.metaKey) { + setOpen((open) => !open) + } + } + + document.addEventListener('keydown', down) + return () => document.removeEventListener('keydown', down) + }, []) + + return ( + <> +

+ Press{' '} + + ⌘K + +

+ + + + No results found. + + + + Calendar + + + + Search Emoji + + + + Calculator + + + + + + + Profile + ⌘P + + + + Billing + ⌘B + + + + Settings + ⌘S + + + + + + ) +} + +CommandDialogDemo.storyName = 'Command in dialog' + +export default meta diff --git a/packages/ui/src/components/shadcn/stories/ContextMenu.stories.tsx b/packages/ui/src/components/shadcn/stories/ContextMenu.stories.tsx new file mode 100644 index 00000000000..c383b290fdb --- /dev/null +++ b/packages/ui/src/components/shadcn/stories/ContextMenu.stories.tsx @@ -0,0 +1,73 @@ +import { Meta } from '@storybook/react' +import { + ContextMenu, + ContextMenuCheckboxItem, + ContextMenuContent, + ContextMenuItem, + ContextMenuLabel, + ContextMenuRadioGroup, + ContextMenuRadioItem, + ContextMenuSeparator, + ContextMenuShortcut, + ContextMenuSub, + ContextMenuSubContent, + ContextMenuSubTrigger, + ContextMenuTrigger, +} from '@ui/components/shadcn/ui/context-menu' + +const meta: Meta = { + title: 'shadcn/ContextMenu', + component: ContextMenu, +} + +export const Default = () => { + return ( + + + Right click here + + + + Back + ⌘[ + + + Forward + ⌘] + + + Reload + ⌘R + + + More Tools + + + Save Page As... + ⇧⌘S + + Create Shortcut... + Name Window... + + Developer Tools + + + + + Show Bookmarks Bar + ⌘⇧B + + Show Full URLs + + + People + + Pedro Duarte + Colm Tuite + + + + ) +} + +export default meta diff --git a/packages/ui/src/components/shadcn/stories/DataTable.storiesFIX LATER.tsx b/packages/ui/src/components/shadcn/stories/DataTable.storiesFIX LATER.tsx new file mode 100644 index 00000000000..cb149023b5e --- /dev/null +++ b/packages/ui/src/components/shadcn/stories/DataTable.storiesFIX LATER.tsx @@ -0,0 +1,311 @@ +import { Meta } from '@storybook/react' +import { Card } from '@ui/components/shadcn/ui/card' +;('use client') +import * as React from 'react' +import { + ColumnDef, + ColumnFiltersState, + SortingState, + VisibilityState, + flexRender, + getCoreRowModel, + getFilteredRowModel, + getPaginationRowModel, + getSortedRowModel, + useReactTable, +} from '@tanstack/react-table' +import { ArrowUpDown, ChevronDown, MoreHorizontal } from 'lucide-react' +import { Button } from '@/components/ui/button' +import { Checkbox } from '@/components/ui/checkbox' +import { + DropdownMenu, + DropdownMenuCheckboxItem, + DropdownMenuContent, + DropdownMenuItem, + DropdownMenuLabel, + DropdownMenuSeparator, + DropdownMenuTrigger, +} from '@/components/ui/dropdown-menu' +import { Input } from '@/components/ui/input' +import { + Table, + TableBody, + TableCell, + TableHead, + TableHeader, + TableRow, +} from '@/components/ui/table' + +const data: Payment[] = [ + { + id: 'm5gr84i9', + amount: 316, + status: 'success', + email: 'ken99@yahoo.com', + }, + { + id: '3u1reuv4', + amount: 242, + status: 'success', + email: 'Abe45@gmail.com', + }, + { + id: 'derv1ws0', + amount: 837, + status: 'processing', + email: 'Monserrat44@gmail.com', + }, + { + id: '5kma53ae', + amount: 874, + status: 'success', + email: 'Silas22@gmail.com', + }, + { + id: 'bhqecj4p', + amount: 721, + status: 'failed', + email: 'carmella@hotmail.com', + }, +] + +export type Payment = { + id: string + amount: number + status: 'pending' | 'processing' | 'success' | 'failed' + email: string +} + +export const columns: ColumnDef[] = [ + { + id: 'select', + header: ({ table }) => ( + table.toggleAllPageRowsSelected(!!value)} + aria-label="Select all" + /> + ), + cell: ({ row }) => ( + row.toggleSelected(!!value)} + aria-label="Select row" + /> + ), + enableSorting: false, + enableHiding: false, + }, + { + accessorKey: 'status', + header: 'Status', + cell: ({ row }) =>
{row.getValue('status')}
, + }, + { + accessorKey: 'email', + header: ({ column }) => { + return ( + + ) + }, + cell: ({ row }) =>
{row.getValue('email')}
, + }, + { + accessorKey: 'amount', + header: () =>
Amount
, + cell: ({ row }) => { + const amount = parseFloat(row.getValue('amount')) + + // Format the amount as a dollar amount + const formatted = new Intl.NumberFormat('en-US', { + style: 'currency', + currency: 'USD', + }).format(amount) + + return
{formatted}
+ }, + }, + { + id: 'actions', + enableHiding: false, + cell: ({ row }) => { + const payment = row.original + + return ( + + + + + + Actions + navigator.clipboard.writeText(payment.id)}> + Copy payment ID + + + View customer + View payment details + + + ) + }, + }, +] + +export function DataTableDemo() { + const [sorting, setSorting] = React.useState([]) + const [columnFilters, setColumnFilters] = React.useState([]) + const [columnVisibility, setColumnVisibility] = React.useState({}) + const [rowSelection, setRowSelection] = React.useState({}) + + const table = useReactTable({ + data, + columns, + onSortingChange: setSorting, + onColumnFiltersChange: setColumnFilters, + getCoreRowModel: getCoreRowModel(), + getPaginationRowModel: getPaginationRowModel(), + getSortedRowModel: getSortedRowModel(), + getFilteredRowModel: getFilteredRowModel(), + onColumnVisibilityChange: setColumnVisibility, + onRowSelectionChange: setRowSelection, + state: { + sorting, + columnFilters, + columnVisibility, + rowSelection, + }, + }) + + return ( +
+
+ table.getColumn('email')?.setFilterValue(event.target.value)} + className="max-w-sm" + /> + + + + + + {table + .getAllColumns() + .filter((column) => column.getCanHide()) + .map((column) => { + return ( + column.toggleVisibility(!!value)} + > + {column.id} + + ) + })} + + +
+
+ + + {table.getHeaderGroups().map((headerGroup) => ( + + {headerGroup.headers.map((header) => { + return ( + + {header.isPlaceholder + ? null + : flexRender(header.column.columnDef.header, header.getContext())} + + ) + })} + + ))} + + + {table.getRowModel().rows?.length ? ( + table.getRowModel().rows.map((row) => ( + + {row.getVisibleCells().map((cell) => ( + + {flexRender(cell.column.columnDef.cell, cell.getContext())} + + ))} + + )) + ) : ( + + + No results. + + + )} + +
+
+
+
+ {table.getFilteredSelectedRowModel().rows.length} of{' '} + {table.getFilteredRowModel().rows.length} row(s) selected. +
+
+ + +
+
+
+ ) +} + +const meta: Meta = { + title: 'shadcn/Card', + component: Card, +} + +export const Default = () => { + return ( +
+
+
+ ) +} + +export const CardWithForm = () => { + return ( +
+
+
+ ) +} + +CardWithForm.storyName = 'Card with form' + +export default meta diff --git a/packages/ui/src/components/shadcn/stories/DatePicker.stories.tsx b/packages/ui/src/components/shadcn/stories/DatePicker.stories.tsx new file mode 100644 index 00000000000..44238215ede --- /dev/null +++ b/packages/ui/src/components/shadcn/stories/DatePicker.stories.tsx @@ -0,0 +1,235 @@ +import { + Form, + FormControl, + FormDescription, + FormField, + FormItem, + FormLabel, + FormMessage, +} from '@ui/components/shadcn/ui/form' +import { toast } from '@ui/components/shadcn/ui/use-toast' +import { zodResolver } from '@hookform/resolvers/zod' +import { Meta } from '@storybook/react' +import { Button } from '@ui/components/shadcn/ui/button' +import { Calendar } from '@ui/components/shadcn/ui/calendar' +import { Popover, PopoverContent, PopoverTrigger } from '@ui/components/shadcn/ui/popover' +import { + Select, + SelectContent, + SelectItem, + SelectTrigger, + SelectValue, +} from '@ui/components/shadcn/ui/select' +import { cn } from '@ui/lib/utils' +import { addDays, format } from 'date-fns' +import { Calendar as CalendarIcon } from 'lucide-react' +import * as React from 'react' +import { DateRange } from 'react-day-picker' +import { useForm } from 'react-hook-form' +import * as z from 'zod' + +const meta: Meta = { + title: 'shadcn/DatePicker', + // component: Card, +} + +export function Default() { + const [date, setDate] = React.useState() + + return ( + + + + + + + + + ) +} + +export function DatePickerWithRange({ className }: React.HTMLAttributes) { + const [date, setDate] = React.useState({ + from: new Date(2022, 0, 20), + to: addDays(new Date(2022, 0, 20), 20), + }) + + return ( +
+ + + + + + + + +
+ ) +} + +// 'use client' + +// import * as React from 'react' +// import { addDays, format } from 'date-fns' +// import { Calendar as CalendarIcon } from 'lucide-react' + +// import { cn } from '@/lib/utils' +// import { Button } from '@/components/ui/button' +// import { Calendar } from '@/components/ui/calendar' +// import { Popover, PopoverContent, PopoverTrigger } from '@/components/ui/popover' +// import { +// Select, +// SelectContent, +// SelectItem, +// SelectTrigger, +// SelectValue, +// } from '@/components/ui/select' + +export function DatePickerWithPresets() { + const [date, setDate] = React.useState() + + return ( + + + + + + +
+ +
+
+
+ ) +} + +const FormSchema = z.object({ + dob: z.date({ + required_error: 'A date of birth is required.', + }), +}) + +export function DatePickerForm() { + const form = useForm>({ + resolver: zodResolver(FormSchema), + }) + + function onSubmit(data: z.infer) { + toast({ + title: 'You submitted the following values:', + description: ( +
+          {JSON.stringify(data, null, 2)}
+        
+ ), + }) + } + + return ( +
+ + ( + + Date of birth + + + + + + + + { + if (e) { + field.onChange(e) + } + }} + disabled={(date) => date > new Date() || date < new Date('1900-01-01')} + initialFocus + /> + + + Your date of birth is used to calculate your age. + + + )} + /> + + + + ) +} + +// CardWithForm.storyName = 'Card with form' + +export default meta diff --git a/packages/ui/src/components/shadcn/stories/Dialog.stories.tsx b/packages/ui/src/components/shadcn/stories/Dialog.stories.tsx new file mode 100644 index 00000000000..0a30b12f489 --- /dev/null +++ b/packages/ui/src/components/shadcn/stories/Dialog.stories.tsx @@ -0,0 +1,55 @@ +import { Meta } from '@storybook/react' +import { Button } from '@ui/components/shadcn/ui/button' +import { + Dialog, + DialogContent, + DialogDescription, + DialogFooter, + DialogHeader, + DialogTitle, + DialogTrigger, +} from '@ui/components/shadcn/ui/dialog' +import { Input } from '@ui/components/shadcn/ui/input' +import { Label } from '@ui/components/shadcn/ui/label' + +const meta: Meta = { + title: 'shadcn/Dialog', + component: Dialog, +} + +export function Default() { + return ( + + + + + + + Edit profile + + Make changes to your profile here. Click save when you're done. + + +
+
+ + +
+
+ + +
+
+ + + +
+
+ ) +} + +export default meta diff --git a/packages/ui/src/components/shadcn/stories/Form.stories.tsx b/packages/ui/src/components/shadcn/stories/Form.stories.tsx index aa8e9349a8b..ec142cb6cbb 100644 --- a/packages/ui/src/components/shadcn/stories/Form.stories.tsx +++ b/packages/ui/src/components/shadcn/stories/Form.stories.tsx @@ -29,7 +29,7 @@ const meta: Meta = { * See https://storybook.js.org/docs/react/configure/overview#configure-story-loading * to learn how to generate automatic titles */ - title: 'Shadcn/Form', + title: 'shadcn/Form', component: Form, } @@ -173,7 +173,12 @@ export const CalendarExample = { { + if (e) { + // @mildtomato: guard in case returns undefined + field.onChange + } + }} disabled={(date) => date > new Date() || date < new Date('1900-01-01')} initialFocus /> diff --git a/packages/ui/src/components/shadcn/stories/HoverCard.stories.tsx b/packages/ui/src/components/shadcn/stories/HoverCard.stories.tsx new file mode 100644 index 00000000000..ddf64542977 --- /dev/null +++ b/packages/ui/src/components/shadcn/stories/HoverCard.stories.tsx @@ -0,0 +1,38 @@ +import { Meta } from '@storybook/react' +import { Avatar, AvatarFallback, AvatarImage } from '@ui/components/shadcn/ui/avatar' +import { Button } from '@ui/components/shadcn/ui/button' +import { HoverCard, HoverCardContent, HoverCardTrigger } from '@ui/components/shadcn/ui/hover-card' +import { CalendarDays } from 'lucide-react' + +const meta: Meta = { + title: 'shadcn/HoverCard', + component: HoverCard, +} + +export function Default() { + return ( + + + + + +
+ + + VC + +
+

@nextjs

+

The React Framework – created and maintained by @vercel.

+
+ {' '} + Joined December 2021 +
+
+
+
+
+ ) +} + +export default meta diff --git a/packages/ui/src/components/shadcn/stories/Input.stories.tsx b/packages/ui/src/components/shadcn/stories/Input.stories.tsx new file mode 100644 index 00000000000..7a8c9220ba1 --- /dev/null +++ b/packages/ui/src/components/shadcn/stories/Input.stories.tsx @@ -0,0 +1,103 @@ +import { + Form, + FormControl, + FormDescription, + FormField, + FormItem, + FormLabel, + FormMessage, +} from '@ui/components/shadcn/ui/form' +import { toast } from '@ui/components/shadcn/ui/use-toast' +import { zodResolver } from '@hookform/resolvers/zod' +import { Meta } from '@storybook/react' +import { Button } from '@ui/components/shadcn/ui/button' +import { Input } from '@ui/components/shadcn/ui/input' +import { Label } from '@ui/components/shadcn/ui/label' +import { useForm } from 'react-hook-form' +import * as z from 'zod' + +const FormSchema = z.object({ + username: z.string().min(2, { + message: 'Username must be at least 2 characters.', + }), +}) + +const meta: Meta = { + title: 'shadcn/Input', + component: Input, +} + +export function Default() { + return +} + +export function InputFile() { + return ( +
+ + +
+ ) +} + +export function InputDisabled() { + return +} + +export function InputWithLabel() { + return ( +
+ + +
+ ) +} + +export function InputWithButton() { + return ( +
+ + +
+ ) +} + +export function InputForm() { + const form = useForm>({ + resolver: zodResolver(FormSchema), + }) + + function onSubmit(data: z.infer) { + toast({ + title: 'You submitted the following values:', + description: ( +
+          {JSON.stringify(data, null, 2)}
+        
+ ), + }) + } + + return ( +
+ + ( + + Username + + + + This is your public display name. + + + )} + /> + + + + ) +} +export default meta diff --git a/packages/ui/src/components/shadcn/stories/Label.stories.tsx b/packages/ui/src/components/shadcn/stories/Label.stories.tsx new file mode 100644 index 00000000000..1945f0302a8 --- /dev/null +++ b/packages/ui/src/components/shadcn/stories/Label.stories.tsx @@ -0,0 +1,22 @@ +import { Meta } from '@storybook/react' + +import { Checkbox } from '@ui/components/shadcn/ui/checkbox' +import { Label } from '@ui/components/shadcn/ui/label' + +const meta: Meta = { + title: 'shadcn/Label', + component: Label, +} + +export function Default() { + return ( +
+
+ + +
+
+ ) +} + +export default meta diff --git a/packages/ui/src/components/shadcn/stories/MenuBar.stories.tsx b/packages/ui/src/components/shadcn/stories/MenuBar.stories.tsx new file mode 100644 index 00000000000..62f5c33b438 --- /dev/null +++ b/packages/ui/src/components/shadcn/stories/MenuBar.stories.tsx @@ -0,0 +1,114 @@ +import { Meta } from '@storybook/react' +import { Card } from '@ui/components/shadcn/ui/card' +import { + Menubar, + MenubarCheckboxItem, + MenubarContent, + MenubarItem, + MenubarMenu, + MenubarRadioGroup, + MenubarRadioItem, + MenubarSeparator, + MenubarShortcut, + MenubarSub, + MenubarSubContent, + MenubarSubTrigger, + MenubarTrigger, +} from '@ui/components/shadcn/ui/menubar' + +const meta: Meta = { + title: 'shadcn/Menubar', + component: Menubar, +} + +export function Default() { + return ( + + + File + + + New Tab ⌘T + + + New Window ⌘N + + New Incognito Window + + + Share + + Email link + Messages + Notes + + + + + Print... ⌘P + + + + + Edit + + + Undo ⌘Z + + + Redo ⇧⌘Z + + + + Find + + Search the web + + Find... + Find Next + Find Previous + + + + Cut + Copy + Paste + + + + View + + Always Show Bookmarks Bar + Always Show Full URLs + + + Reload ⌘R + + + Force Reload ⇧⌘R + + + Toggle Fullscreen + + Hide Sidebar + + + + Profiles + + + Andy + Benoit + Luis + + + Edit... + + Add Profile... + + + + ) +} + +export default meta diff --git a/packages/ui/src/components/shadcn/stories/NavigationMenu.stories.tsx b/packages/ui/src/components/shadcn/stories/NavigationMenu.stories.tsx new file mode 100644 index 00000000000..cdc823a2bc3 --- /dev/null +++ b/packages/ui/src/components/shadcn/stories/NavigationMenu.stories.tsx @@ -0,0 +1,155 @@ +import { Meta } from '@storybook/react' +import { Card } from '@ui/components/shadcn/ui/card' +import * as React from 'react' +import Link from 'next/link' +import { cn } from '@ui/lib/utils' +import { + NavigationMenu, + NavigationMenuContent, + NavigationMenuItem, + NavigationMenuLink, + NavigationMenuList, + NavigationMenuTrigger, + navigationMenuTriggerStyle, +} from '@ui/components/shadcn/ui/navigation-menu' + +const meta: Meta = { + title: 'shadcn/NavigationMenu', + component: NavigationMenu, +} + +export function Default() { + const components: { title: string; href: string; description: string }[] = [ + { + title: 'Alert Dialog', + href: '/docs/primitives/alert-dialog', + description: + 'A modal dialog that interrupts the user with important content and expects a response.', + }, + { + title: 'Hover Card', + href: '/docs/primitives/hover-card', + description: 'For sighted users to preview content available behind a link.', + }, + { + title: 'Progress', + href: '/docs/primitives/progress', + description: + 'Displays an indicator showing the completion progress of a task, typically displayed as a progress bar.', + }, + { + title: 'Scroll-area', + href: '/docs/primitives/scroll-area', + description: 'Visually or semantically separates content.', + }, + { + title: 'Tabs', + href: '/docs/primitives/tabs', + description: + 'A set of layered sections of content—known as tab panels—that are displayed one at a time.', + }, + { + title: 'Tooltip', + href: '/docs/primitives/tooltip', + description: + 'A popup that displays information related to an element when the element receives keyboard focus or the mouse hovers over it.', + }, + ] + + const ListItem = React.forwardRef, React.ComponentPropsWithoutRef<'a'>>( + ({ className, title, children, ...props }, ref) => { + return ( +
  • + + +
    {title}
    +

    {children}

    +
    +
    +
  • + + /** + * if using Next.js + * + * import { navigationMenuTriggerStyle } from "@/components/ui/navigation-menu" + * + * + * + * + * Documentation + * + * + * + */ + ) + } + ) + ListItem.displayName = 'ListItem' + + return ( +
    + + + + Getting started + + + + + + Components + +
      + {components.map((component) => ( + + {component.description} + + ))} +
    +
    +
    + + + + Documentation + + + +
    +
    +
    + ) +} + +export default meta diff --git a/packages/ui/src/components/shadcn/stories/Popover.stories.tsx b/packages/ui/src/components/shadcn/stories/Popover.stories.tsx new file mode 100644 index 00000000000..56afa83f966 --- /dev/null +++ b/packages/ui/src/components/shadcn/stories/Popover.stories.tsx @@ -0,0 +1,49 @@ +import { Meta } from '@storybook/react' +import { Card } from '@ui/components/shadcn/ui/card' +import { Button } from '@ui/components/shadcn/ui/button' +import { Input } from '@ui/components/shadcn/ui/input' +import { Label } from '@ui/components/shadcn/ui/label' +import { Popover, PopoverContent, PopoverTrigger } from '@ui/components/shadcn/ui/popover' + +const meta: Meta = { + title: 'shadcn/Popover', + component: Popover, +} + +export function PopoverDemo() { + return ( + + + + + +
    +
    +

    Dimensions

    +

    Set the dimensions for the layer.

    +
    +
    +
    + + +
    +
    + + +
    +
    + + +
    +
    + + +
    +
    +
    +
    +
    + ) +} + +export default meta diff --git a/packages/ui/src/components/shadcn/stories/Progress.stories.tsx b/packages/ui/src/components/shadcn/stories/Progress.stories.tsx new file mode 100644 index 00000000000..e6f76f4ad32 --- /dev/null +++ b/packages/ui/src/components/shadcn/stories/Progress.stories.tsx @@ -0,0 +1,21 @@ +import { Progress } from '@ui/components/shadcn/ui/progress' +import { Meta } from '@storybook/react' +import * as React from 'react' + +const meta: Meta = { + title: 'shadcn/Progress', + component: Progress, +} + +export function Default() { + const [progress, setProgress] = React.useState(13) + + React.useEffect(() => { + const timer = setTimeout(() => setProgress(66), 500) + return () => clearTimeout(timer) + }, []) + + return +} + +export default meta diff --git a/packages/ui/src/components/shadcn/stories/RadioGroup.stories.tsx b/packages/ui/src/components/shadcn/stories/RadioGroup.stories.tsx new file mode 100644 index 00000000000..86ae15ecd36 --- /dev/null +++ b/packages/ui/src/components/shadcn/stories/RadioGroup.stories.tsx @@ -0,0 +1,109 @@ +import { Button } from '@ui/components/shadcn/ui/button' +import { + Form, + FormControl, + FormField, + FormItem, + FormLabel, + FormMessage, +} from '@ui/components/shadcn/ui/form' +import { Label } from '@ui/components/shadcn/ui/label' +import { RadioGroup, RadioGroupItem } from '@ui/components/shadcn/ui/radio-group' +import { toast } from '@ui/components/shadcn/ui/use-toast' +import { zodResolver } from '@hookform/resolvers/zod' +import { Meta } from '@storybook/react' +import { useForm } from 'react-hook-form' +import * as z from 'zod' + +const meta: Meta = { + title: 'shadcn/RadioGroup', + component: RadioGroup, +} + +export function Default() { + return ( + +
    + + +
    +
    + + +
    +
    + + +
    +
    + ) +} + +export function RadioGroupForm() { + const FormSchema = z.object({ + type: z.enum(['all', 'mentions', 'none'], { + required_error: 'You need to select a notification type.', + }), + }) + const form = useForm>({ + resolver: zodResolver(FormSchema), + }) + + function onSubmit(data: z.infer) { + toast({ + title: 'You submitted the following values:', + description: ( +
    +          {JSON.stringify(data, null, 2)}
    +        
    + ), + }) + } + + return ( +
    + + ( + + Notify me about... + + + + + + + All new messages + + + + + + Direct messages and mentions + + + + + + Nothing + + + + + + )} + /> + + + + ) +} + +export default meta diff --git a/packages/ui/src/components/shadcn/stories/ScrollArea.stories.tsx b/packages/ui/src/components/shadcn/stories/ScrollArea.stories.tsx new file mode 100644 index 00000000000..fe0d18bd186 --- /dev/null +++ b/packages/ui/src/components/shadcn/stories/ScrollArea.stories.tsx @@ -0,0 +1,30 @@ +import { Meta } from '@storybook/react' +import { ScrollArea } from '@ui/components/shadcn/ui/scroll-area' +import { Separator } from '@ui/components/shadcn/ui/separator' +import * as React from 'react' + +const meta: Meta = { + title: 'shadcn/ScrollArea', + component: ScrollArea, +} + +export function Default() { + const tags = Array.from({ length: 50 }).map((_, i, a) => `v1.2.0-beta.${a.length - i}`) + return ( + +
    +

    Tags

    + {tags.map((tag) => ( + +
    + {tag} +
    + +
    + ))} +
    +
    + ) +} + +export default meta diff --git a/packages/ui/src/components/shadcn/stories/Select.stories.tsx b/packages/ui/src/components/shadcn/stories/Select.stories.tsx new file mode 100644 index 00000000000..8397fcddf77 --- /dev/null +++ b/packages/ui/src/components/shadcn/stories/Select.stories.tsx @@ -0,0 +1,138 @@ +import { zodResolver } from '@hookform/resolvers/zod' +import { Meta } from '@storybook/react' +import { Button } from '@ui/components/shadcn/ui/button' +import { Card } from '@ui/components/shadcn/ui/card' +import { + Form, + FormControl, + FormDescription, + FormField, + FormItem, + FormLabel, + FormMessage, +} from '@ui/components/shadcn/ui/form' +import { + Select, + SelectContent, + SelectGroup, + SelectItem, + SelectLabel, + SelectTrigger, + SelectValue, +} from '@ui/components/shadcn/ui/select' +import { toast } from '@ui/components/shadcn/ui/use-toast' +import Link from 'next/link' +import { useForm } from 'react-hook-form' +import * as z from 'zod' +import { SelectSeparator } from '../select' + +const meta: Meta = { + title: 'shadcn/Select', + component: Select, +} + +export function Default() { + return ( + + ) +} + +export function withSeperators() { + return ( + + ) +} + +export function SelectForm() { + const FormSchema = z.object({ + email: z + .string({ + required_error: 'Please select an email to display.', + }) + .email(), + }) + + const form = useForm>({ + resolver: zodResolver(FormSchema), + }) + + function onSubmit(data: z.infer) { + toast({ + title: 'You submitted the following values:', + description: ( +
    +          {JSON.stringify(data, null, 2)}
    +        
    + ), + }) + } + + return ( +
    + + ( + + Email + + + You can manage email addresses in your{' '} + email settings. + + + + )} + /> + + + + ) +} + +export default meta diff --git a/packages/ui/src/components/shadcn/stories/Seperator.stories.tsx b/packages/ui/src/components/shadcn/stories/Seperator.stories.tsx new file mode 100644 index 00000000000..652f0965a7c --- /dev/null +++ b/packages/ui/src/components/shadcn/stories/Seperator.stories.tsx @@ -0,0 +1,28 @@ +import { Meta } from '@storybook/react' +import { Separator } from '@ui/components/shadcn/ui/separator' + +const meta: Meta = { + title: 'shadcn/Separator', + component: Separator, +} + +export function Default() { + return ( +
    +
    +

    Radix Primitives

    +

    An open-source UI component library.

    +
    + +
    +
    Blog
    + +
    Docs
    + +
    Source
    +
    +
    + ) +} + +export default meta diff --git a/packages/ui/src/components/shadcn/stories/Sheet.stories.tsx b/packages/ui/src/components/shadcn/stories/Sheet.stories.tsx new file mode 100644 index 00000000000..e0fd3224eaf --- /dev/null +++ b/packages/ui/src/components/shadcn/stories/Sheet.stories.tsx @@ -0,0 +1,103 @@ +import { Meta } from '@storybook/react' +import { Button } from '@ui/components/shadcn/ui/button' +import { Input } from '@ui/components/shadcn/ui/input' +import { Label } from '@ui/components/shadcn/ui/label' +import { + Sheet, + SheetClose, + SheetContent, + SheetDescription, + SheetFooter, + SheetHeader, + SheetTitle, + SheetTrigger, +} from '@ui/components/shadcn/ui/sheet' + +const meta: Meta = { + title: 'shadcn/Sheet', + component: Sheet, +} + +export function Default() { + return ( + + + + + + + Edit profile + + Make changes to your profile here. Click save when you're done. + + +
    +
    + + +
    +
    + + +
    +
    + + + + + +
    +
    + ) +} + +export function SheetSide() { + const SHEET_SIDES = ['top', 'right', 'bottom', 'left'] as const + + type SheetSide = (typeof SHEET_SIDES)[number] + + return ( +
    + {SHEET_SIDES.map((side) => ( + + + + + + + Edit profile + + Make changes to your profile here. Click save when you're done. + + +
    +
    + + +
    +
    + + +
    +
    + + + + + +
    +
    + ))} +
    + ) +} + +export default meta diff --git a/packages/ui/src/components/shadcn/stories/Skeleton.stories.tsx b/packages/ui/src/components/shadcn/stories/Skeleton.stories.tsx new file mode 100644 index 00000000000..4e7feae8c1b --- /dev/null +++ b/packages/ui/src/components/shadcn/stories/Skeleton.stories.tsx @@ -0,0 +1,21 @@ +import { Meta } from '@storybook/react' +import { Skeleton } from '@ui/components/shadcn/ui/skeleton' + +const meta: Meta = { + title: 'shadcn/Skeleton', + component: Skeleton, +} + +export function Default() { + return ( +
    + +
    + + +
    +
    + ) +} + +export default meta diff --git a/packages/ui/src/components/shadcn/stories/Slider.stories.tsx b/packages/ui/src/components/shadcn/stories/Slider.stories.tsx new file mode 100644 index 00000000000..050fe327f76 --- /dev/null +++ b/packages/ui/src/components/shadcn/stories/Slider.stories.tsx @@ -0,0 +1,24 @@ +import { Meta } from '@storybook/react' +import { Slider } from '@ui/components/shadcn/ui/slider' +import { cn } from '@ui/lib/utils' + +const meta: Meta = { + title: 'shadcn/Slider', + component: Slider, +} + +type SliderProps = React.ComponentProps + +export function SliderDemo({ className, ...props }: SliderProps) { + return ( + + ) +} + +export default meta diff --git a/packages/ui/src/components/shadcn/stories/Switch.stories.tsx b/packages/ui/src/components/shadcn/stories/Switch.stories.tsx new file mode 100644 index 00000000000..f7b41d6a014 --- /dev/null +++ b/packages/ui/src/components/shadcn/stories/Switch.stories.tsx @@ -0,0 +1,107 @@ +import { Button } from '@ui/components/shadcn/ui/button' +import { + Form, + FormControl, + FormDescription, + FormField, + FormItem, + FormLabel, +} from '@ui/components/shadcn/ui/form' +import { toast } from '@ui/components/shadcn/ui/use-toast' +import { zodResolver } from '@hookform/resolvers/zod' +import { Meta } from '@storybook/react' +import { Label } from '@ui/components/shadcn/ui/label' +import { Switch } from '@ui/components/shadcn/ui/switch' +import { useForm } from 'react-hook-form' +import * as z from 'zod' + +const meta: Meta = { + title: 'shadcn/Switch', + component: Switch, +} + +export function Default() { + return ( +
    + + +
    + ) +} + +export function SwitchForm() { + const FormSchema = z.object({ + marketing_emails: z.boolean().default(false).optional(), + security_emails: z.boolean(), + }) + + const form = useForm>({ + resolver: zodResolver(FormSchema), + defaultValues: { + security_emails: true, + }, + }) + + function onSubmit(data: z.infer) { + toast({ + title: 'You submitted the following values:', + description: ( +
    +          {JSON.stringify(data, null, 2)}
    +        
    + ), + }) + } + + return ( +
    + +
    +

    Email Notifications

    +
    + ( + +
    + Marketing emails + + Receive emails about new products, features, and more. + +
    + + + +
    + )} + /> + ( + +
    + Security emails + Receive emails about your account security. +
    + + + +
    + )} + /> +
    +
    + +
    + + ) +} + +export default meta diff --git a/packages/ui/src/components/shadcn/stories/Table.stories.tsx b/packages/ui/src/components/shadcn/stories/Table.stories.tsx new file mode 100644 index 00000000000..2d54c227ab8 --- /dev/null +++ b/packages/ui/src/components/shadcn/stories/Table.stories.tsx @@ -0,0 +1,88 @@ +import { Meta } from '@storybook/react' +import { + Table, + TableBody, + TableCaption, + TableCell, + TableHead, + TableHeader, + TableRow, +} from '@ui/components/shadcn/ui/table' + +const invoices = [ + { + invoice: 'INV001', + paymentStatus: 'Paid', + totalAmount: '$250.00', + paymentMethod: 'Credit Card', + }, + { + invoice: 'INV002', + paymentStatus: 'Pending', + totalAmount: '$150.00', + paymentMethod: 'PayPal', + }, + { + invoice: 'INV003', + paymentStatus: 'Unpaid', + totalAmount: '$350.00', + paymentMethod: 'Bank Transfer', + }, + { + invoice: 'INV004', + paymentStatus: 'Paid', + totalAmount: '$450.00', + paymentMethod: 'Credit Card', + }, + { + invoice: 'INV005', + paymentStatus: 'Paid', + totalAmount: '$550.00', + paymentMethod: 'PayPal', + }, + { + invoice: 'INV006', + paymentStatus: 'Pending', + totalAmount: '$200.00', + paymentMethod: 'Bank Transfer', + }, + { + invoice: 'INV007', + paymentStatus: 'Unpaid', + totalAmount: '$300.00', + paymentMethod: 'Credit Card', + }, +] + +const meta: Meta = { + title: 'shadcn/Table', + component: Table, +} + +export function TableDemo() { + return ( + + A list of your recent invoices. + + + Invoice + Status + Method + Amount + + + + {invoices.map((invoice) => ( + + {invoice.invoice} + {invoice.paymentStatus} + {invoice.paymentMethod} + {invoice.totalAmount} + + ))} + +
    + ) +} + +export default meta diff --git a/packages/ui/src/components/shadcn/stories/Tabs.stories.tsx b/packages/ui/src/components/shadcn/stories/Tabs.stories.tsx new file mode 100644 index 00000000000..3eab30eb33f --- /dev/null +++ b/packages/ui/src/components/shadcn/stories/Tabs.stories.tsx @@ -0,0 +1,77 @@ +import { Meta } from '@storybook/react' +import { Button } from '@ui/components/shadcn/ui/button' +import { + Card, + CardContent, + CardDescription, + CardFooter, + CardHeader, + CardTitle, +} from '@ui/components/shadcn/ui/card' +import { Input } from '@ui/components/shadcn/ui/input' +import { Label } from '@ui/components/shadcn/ui/label' +import { Tabs, TabsContent, TabsList, TabsTrigger } from '@ui/components/shadcn/ui/tabs' + +const meta: Meta = { + title: 'shadcn/Tabs', + component: Tabs, +} + +export function TabsDemo() { + return ( + + + Account + Password + + + + + Account + + Make changes to your account here. Click save when you're done. + + + +
    + + +
    +
    + + +
    +
    + + + +
    +
    + + + + Password + + Change your password here. After saving, you'll be logged out. + + + +
    + + +
    +
    + + +
    +
    + + + +
    +
    +
    + ) +} + +export default meta diff --git a/packages/ui/src/components/shadcn/stories/TextArea.stories.tsx b/packages/ui/src/components/shadcn/stories/TextArea.stories.tsx new file mode 100644 index 00000000000..f6d9bb18c67 --- /dev/null +++ b/packages/ui/src/components/shadcn/stories/TextArea.stories.tsx @@ -0,0 +1,117 @@ +import { Button } from '@ui/components/shadcn/ui/button' +import { + Form, + FormControl, + FormDescription, + FormField, + FormItem, + FormLabel, + FormMessage, +} from '@ui/components/shadcn/ui/form' +import { toast } from '@ui/components/shadcn/ui/use-toast' +import { zodResolver } from '@hookform/resolvers/zod' +import { Meta } from '@storybook/react' +import { Textarea } from '@ui/components/shadcn/ui/textarea' +import { useForm } from 'react-hook-form' +import * as z from 'zod' + +const meta: Meta = { + title: 'shadcn/Textarea', + component: Textarea, +} + +export function Default() { + return