@auto-engineer/generate-react-client 1.64.0 → 1.66.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +140 -0
- package/dist/starter/.storybook/main.ts +17 -22
- package/dist/starter/.storybook/manager-head.html +31 -31
- package/dist/starter/.storybook/manager.ts +133 -133
- package/dist/starter/.storybook/preview-head.html +12 -12
- package/dist/starter/.storybook/preview.tsx +79 -79
- package/dist/starter/biome.json +126 -0
- package/dist/starter/codegen.ts +11 -11
- package/dist/starter/components.json +27 -27
- package/dist/starter/package.json +86 -80
- package/dist/starter/public/mockServiceWorker.js +261 -261
- package/dist/starter/scripts/build-component-db.ts +17 -20
- package/dist/starter/src/App.tsx +15 -17
- package/dist/starter/src/components/ui/Accordion.stories.tsx +35 -35
- package/dist/starter/src/components/ui/Accordion.tsx +33 -33
- package/dist/starter/src/components/ui/Alert.stories.tsx +15 -15
- package/dist/starter/src/components/ui/Alert.tsx +32 -32
- package/dist/starter/src/components/ui/AlertDialog.stories.tsx +50 -50
- package/dist/starter/src/components/ui/AlertDialog.tsx +114 -115
- package/dist/starter/src/components/ui/AspectRatio.stories.tsx +20 -20
- package/dist/starter/src/components/ui/AspectRatio.tsx +1 -1
- package/dist/starter/src/components/ui/Avatar.stories.tsx +27 -27
- package/dist/starter/src/components/ui/Avatar.tsx +63 -63
- package/dist/starter/src/components/ui/Badge.stories.tsx +14 -14
- package/dist/starter/src/components/ui/Badge.tsx +27 -27
- package/dist/starter/src/components/ui/Breadcrumb.stories.tsx +38 -38
- package/dist/starter/src/components/ui/Breadcrumb.tsx +63 -62
- package/dist/starter/src/components/ui/Button.stories.tsx +55 -55
- package/dist/starter/src/components/ui/Button.tsx +49 -49
- package/dist/starter/src/components/ui/ButtonGroup.stories.tsx +17 -17
- package/dist/starter/src/components/ui/ButtonGroup.tsx +52 -53
- package/dist/starter/src/components/ui/Calendar.stories.tsx +20 -19
- package/dist/starter/src/components/ui/Calendar.tsx +142 -143
- package/dist/starter/src/components/ui/Card.stories.tsx +29 -29
- package/dist/starter/src/components/ui/Card.tsx +31 -31
- package/dist/starter/src/components/ui/Carousel.stories.tsx +41 -41
- package/dist/starter/src/components/ui/Carousel.tsx +171 -172
- package/dist/starter/src/components/ui/Chart.stories.tsx +21 -21
- package/dist/starter/src/components/ui/Chart.tsx +244 -247
- package/dist/starter/src/components/ui/Checkbox.stories.tsx +11 -11
- package/dist/starter/src/components/ui/Checkbox.tsx +18 -18
- package/dist/starter/src/components/ui/Collapsible.stories.tsx +40 -40
- package/dist/starter/src/components/ui/Collapsible.tsx +3 -3
- package/dist/starter/src/components/ui/Combobox.stories.tsx +48 -48
- package/dist/starter/src/components/ui/Combobox.tsx +204 -205
- package/dist/starter/src/components/ui/Command.stories.tsx +55 -55
- package/dist/starter/src/components/ui/Command.tsx +102 -103
- package/dist/starter/src/components/ui/ContextMenu.stories.tsx +52 -52
- package/dist/starter/src/components/ui/ContextMenu.tsx +151 -151
- package/dist/starter/src/components/ui/DesignSystem-Colors.stories.tsx +92 -92
- package/dist/starter/src/components/ui/DesignSystem-Layout.stories.tsx +139 -139
- package/dist/starter/src/components/ui/DesignSystem-Overview.stories.tsx +676 -657
- package/dist/starter/src/components/ui/DesignSystem-Typography.stories.tsx +59 -59
- package/dist/starter/src/components/ui/Dialog.stories.tsx +56 -56
- package/dist/starter/src/components/ui/Dialog.tsx +97 -98
- package/dist/starter/src/components/ui/Direction.stories.tsx +20 -20
- package/dist/starter/src/components/ui/Direction.tsx +7 -7
- package/dist/starter/src/components/ui/Drawer.stories.tsx +54 -54
- package/dist/starter/src/components/ui/Drawer.tsx +70 -70
- package/dist/starter/src/components/ui/DropdownMenu.stories.tsx +58 -58
- package/dist/starter/src/components/ui/DropdownMenu.tsx +157 -157
- package/dist/starter/src/components/ui/Empty.stories.tsx +22 -22
- package/dist/starter/src/components/ui/Empty.tsx +58 -58
- package/dist/starter/src/components/ui/Field.stories.tsx +31 -31
- package/dist/starter/src/components/ui/Field.tsx +180 -181
- package/dist/starter/src/components/ui/Form.stories.tsx +29 -29
- package/dist/starter/src/components/ui/Form.tsx +93 -96
- package/dist/starter/src/components/ui/HoverCard.stories.tsx +34 -34
- package/dist/starter/src/components/ui/HoverCard.tsx +21 -21
- package/dist/starter/src/components/ui/Input.stories.tsx +18 -18
- package/dist/starter/src/components/ui/Input.tsx +14 -14
- package/dist/starter/src/components/ui/InputGroup.stories.tsx +34 -34
- package/dist/starter/src/components/ui/InputGroup.tsx +110 -111
- package/dist/starter/src/components/ui/InputOTP.stories.tsx +28 -28
- package/dist/starter/src/components/ui/InputOTP.tsx +43 -43
- package/dist/starter/src/components/ui/Item.stories.tsx +45 -45
- package/dist/starter/src/components/ui/Item.tsx +113 -114
- package/dist/starter/src/components/ui/Kbd.stories.tsx +31 -31
- package/dist/starter/src/components/ui/Kbd.tsx +11 -11
- package/dist/starter/src/components/ui/Label.stories.tsx +62 -62
- package/dist/starter/src/components/ui/Label.tsx +26 -25
- package/dist/starter/src/components/ui/Menubar.stories.tsx +62 -62
- package/dist/starter/src/components/ui/Menubar.tsx +173 -173
- package/dist/starter/src/components/ui/NativeSelect.stories.tsx +26 -26
- package/dist/starter/src/components/ui/NativeSelect.tsx +29 -29
- package/dist/starter/src/components/ui/NavigationMenu.stories.tsx +64 -64
- package/dist/starter/src/components/ui/NavigationMenu.tsx +103 -103
- package/dist/starter/src/components/ui/Pagination.stories.tsx +61 -61
- package/dist/starter/src/components/ui/Pagination.tsx +69 -71
- package/dist/starter/src/components/ui/Popover.stories.tsx +38 -38
- package/dist/starter/src/components/ui/Popover.tsx +25 -25
- package/dist/starter/src/components/ui/Progress.stories.tsx +9 -9
- package/dist/starter/src/components/ui/Progress.tsx +14 -14
- package/dist/starter/src/components/ui/RadioGroup.stories.tsx +35 -35
- package/dist/starter/src/components/ui/RadioGroup.tsx +19 -19
- package/dist/starter/src/components/ui/Resizable.stories.tsx +54 -54
- package/dist/starter/src/components/ui/Resizable.tsx +29 -29
- package/dist/starter/src/components/ui/ScrollArea.stories.tsx +27 -27
- package/dist/starter/src/components/ui/ScrollArea.tsx +34 -34
- package/dist/starter/src/components/ui/Select.stories.tsx +43 -43
- package/dist/starter/src/components/ui/Select.tsx +120 -120
- package/dist/starter/src/components/ui/Separator.stories.tsx +27 -27
- package/dist/starter/src/components/ui/Separator.tsx +17 -17
- package/dist/starter/src/components/ui/Sheet.stories.tsx +53 -53
- package/dist/starter/src/components/ui/Sheet.tsx +69 -69
- package/dist/starter/src/components/ui/Sidebar.stories.tsx +77 -77
- package/dist/starter/src/components/ui/Sidebar.tsx +563 -564
- package/dist/starter/src/components/ui/Skeleton.stories.tsx +25 -25
- package/dist/starter/src/components/ui/Skeleton.tsx +1 -1
- package/dist/starter/src/components/ui/Slider.stories.tsx +5 -5
- package/dist/starter/src/components/ui/Slider.tsx +45 -44
- package/dist/starter/src/components/ui/Sonner.stories.tsx +32 -32
- package/dist/starter/src/components/ui/Sonner.tsx +23 -23
- package/dist/starter/src/components/ui/Spinner.stories.tsx +8 -8
- package/dist/starter/src/components/ui/Spinner.tsx +1 -1
- package/dist/starter/src/components/ui/Switch.stories.tsx +16 -17
- package/dist/starter/src/components/ui/Switch.tsx +24 -24
- package/dist/starter/src/components/ui/Table.stories.tsx +50 -50
- package/dist/starter/src/components/ui/Table.tsx +45 -45
- package/dist/starter/src/components/ui/Tabs.stories.tsx +39 -39
- package/dist/starter/src/components/ui/Tabs.tsx +47 -47
- package/dist/starter/src/components/ui/Textarea.stories.tsx +9 -9
- package/dist/starter/src/components/ui/Textarea.tsx +11 -11
- package/dist/starter/src/components/ui/Toast.stories.tsx +77 -77
- package/dist/starter/src/components/ui/Toast.tsx +75 -75
- package/dist/starter/src/components/ui/Toaster.tsx +17 -19
- package/dist/starter/src/components/ui/Toggle.stories.tsx +20 -20
- package/dist/starter/src/components/ui/Toggle.tsx +26 -26
- package/dist/starter/src/components/ui/ToggleGroup.stories.tsx +41 -41
- package/dist/starter/src/components/ui/ToggleGroup.tsx +61 -62
- package/dist/starter/src/components/ui/Tooltip.stories.tsx +26 -26
- package/dist/starter/src/components/ui/Tooltip.tsx +24 -24
- package/dist/starter/src/gql/execute.ts +1 -1
- package/dist/starter/src/gql/fragment-masking.ts +1 -1
- package/dist/starter/src/gql/graphql.ts +3 -0
- package/dist/starter/src/hooks/use-mobile.ts +11 -11
- package/dist/starter/src/hooks/use-toast.ts +135 -135
- package/dist/starter/src/index.css +105 -105
- package/dist/starter/src/lib/utils.ts +1 -1
- package/dist/starter/src/main.tsx +4 -1
- package/dist/starter/tsconfig.app.json +24 -24
- package/dist/starter/tsconfig.json +8 -8
- package/dist/starter/vite.config.ts +38 -37
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +3 -3
|
@@ -1,38 +1,37 @@
|
|
|
1
1
|
'use client';
|
|
2
2
|
|
|
3
|
-
import * as React from 'react';
|
|
4
3
|
import { AlertDialog as AlertDialogPrimitive } from 'radix-ui';
|
|
5
|
-
|
|
6
|
-
import { cn } from '@/lib/utils';
|
|
4
|
+
import type * as React from 'react';
|
|
7
5
|
import { Button } from '@/components/ui/Button';
|
|
6
|
+
import { cn } from '@/lib/utils';
|
|
8
7
|
|
|
9
8
|
/** A confirmation modal requiring explicit user action. Unlike Dialog, cannot be dismissed by clicking outside. */
|
|
10
9
|
function AlertDialog({ ...props }: React.ComponentProps<typeof AlertDialogPrimitive.Root>) {
|
|
11
|
-
|
|
10
|
+
return <AlertDialogPrimitive.Root data-slot="alert-dialog" {...props} />;
|
|
12
11
|
}
|
|
13
12
|
|
|
14
13
|
/** The element that opens the AlertDialog when clicked. */
|
|
15
14
|
function AlertDialogTrigger({ ...props }: React.ComponentProps<typeof AlertDialogPrimitive.Trigger>) {
|
|
16
|
-
|
|
15
|
+
return <AlertDialogPrimitive.Trigger data-slot="alert-dialog-trigger" {...props} />;
|
|
17
16
|
}
|
|
18
17
|
|
|
19
18
|
/** Portals the dialog content into document.body to avoid z-index and overflow issues. */
|
|
20
19
|
function AlertDialogPortal({ ...props }: React.ComponentProps<typeof AlertDialogPrimitive.Portal>) {
|
|
21
|
-
|
|
20
|
+
return <AlertDialogPrimitive.Portal data-slot="alert-dialog-portal" {...props} />;
|
|
22
21
|
}
|
|
23
22
|
|
|
24
23
|
/** The semi-transparent backdrop rendered behind the dialog content. */
|
|
25
24
|
function AlertDialogOverlay({ className, ...props }: React.ComponentProps<typeof AlertDialogPrimitive.Overlay>) {
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
25
|
+
return (
|
|
26
|
+
<AlertDialogPrimitive.Overlay
|
|
27
|
+
data-slot="alert-dialog-overlay"
|
|
28
|
+
className={cn(
|
|
29
|
+
'data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 fixed inset-0 z-50 bg-black/50',
|
|
30
|
+
className,
|
|
31
|
+
)}
|
|
32
|
+
{...props}
|
|
33
|
+
/>
|
|
34
|
+
);
|
|
36
35
|
}
|
|
37
36
|
|
|
38
37
|
/**
|
|
@@ -40,139 +39,139 @@ function AlertDialogOverlay({ className, ...props }: React.ComponentProps<typeof
|
|
|
40
39
|
* @param size - Controls the max-width: `"default"` for standard dialogs, `"sm"` for compact confirmations.
|
|
41
40
|
*/
|
|
42
41
|
function AlertDialogContent({
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
42
|
+
className,
|
|
43
|
+
size = 'default',
|
|
44
|
+
...props
|
|
46
45
|
}: React.ComponentProps<typeof AlertDialogPrimitive.Content> & {
|
|
47
|
-
|
|
46
|
+
size?: 'default' | 'sm';
|
|
48
47
|
}) {
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
48
|
+
return (
|
|
49
|
+
<AlertDialogPortal>
|
|
50
|
+
<AlertDialogOverlay />
|
|
51
|
+
<AlertDialogPrimitive.Content
|
|
52
|
+
data-slot="alert-dialog-content"
|
|
53
|
+
data-size={size}
|
|
54
|
+
className={cn(
|
|
55
|
+
'bg-background data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 group/alert-dialog-content fixed top-[50%] left-[50%] z-50 grid w-full max-w-[calc(100%-2rem)] translate-x-[-50%] translate-y-[-50%] gap-4 rounded-lg border p-6 shadow-lg duration-200 data-[size=sm]:max-w-xs data-[size=default]:sm:max-w-lg',
|
|
56
|
+
className,
|
|
57
|
+
)}
|
|
58
|
+
{...props}
|
|
59
|
+
/>
|
|
60
|
+
</AlertDialogPortal>
|
|
61
|
+
);
|
|
63
62
|
}
|
|
64
63
|
|
|
65
64
|
/** Layout container for the dialog's title, description, and optional media icon. */
|
|
66
65
|
function AlertDialogHeader({ className, ...props }: React.ComponentProps<'div'>) {
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
66
|
+
return (
|
|
67
|
+
<div
|
|
68
|
+
data-slot="alert-dialog-header"
|
|
69
|
+
className={cn(
|
|
70
|
+
'grid grid-rows-[auto_1fr] place-items-center gap-1.5 text-center has-data-[slot=alert-dialog-media]:grid-rows-[auto_auto_1fr] has-data-[slot=alert-dialog-media]:gap-x-6 sm:group-data-[size=default]/alert-dialog-content:place-items-start sm:group-data-[size=default]/alert-dialog-content:text-left sm:group-data-[size=default]/alert-dialog-content:has-data-[slot=alert-dialog-media]:grid-rows-[auto_1fr]',
|
|
71
|
+
className,
|
|
72
|
+
)}
|
|
73
|
+
{...props}
|
|
74
|
+
/>
|
|
75
|
+
);
|
|
77
76
|
}
|
|
78
77
|
|
|
79
78
|
/** Layout container for the dialog's action buttons, typically Cancel and a primary action. */
|
|
80
79
|
function AlertDialogFooter({ className, ...props }: React.ComponentProps<'div'>) {
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
80
|
+
return (
|
|
81
|
+
<div
|
|
82
|
+
data-slot="alert-dialog-footer"
|
|
83
|
+
className={cn(
|
|
84
|
+
'flex flex-col-reverse gap-2 group-data-[size=sm]/alert-dialog-content:grid group-data-[size=sm]/alert-dialog-content:grid-cols-2 sm:flex-row sm:justify-end',
|
|
85
|
+
className,
|
|
86
|
+
)}
|
|
87
|
+
{...props}
|
|
88
|
+
/>
|
|
89
|
+
);
|
|
91
90
|
}
|
|
92
91
|
|
|
93
92
|
/** The accessible title of the dialog, announced by screen readers when the dialog opens. */
|
|
94
93
|
function AlertDialogTitle({ className, ...props }: React.ComponentProps<typeof AlertDialogPrimitive.Title>) {
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
94
|
+
return (
|
|
95
|
+
<AlertDialogPrimitive.Title
|
|
96
|
+
data-slot="alert-dialog-title"
|
|
97
|
+
className={cn(
|
|
98
|
+
'text-lg font-semibold sm:group-data-[size=default]/alert-dialog-content:group-has-data-[slot=alert-dialog-media]/alert-dialog-content:col-start-2',
|
|
99
|
+
className,
|
|
100
|
+
)}
|
|
101
|
+
{...props}
|
|
102
|
+
/>
|
|
103
|
+
);
|
|
105
104
|
}
|
|
106
105
|
|
|
107
106
|
/** The accessible description providing additional context about the dialog's purpose. */
|
|
108
107
|
function AlertDialogDescription({
|
|
109
|
-
|
|
110
|
-
|
|
108
|
+
className,
|
|
109
|
+
...props
|
|
111
110
|
}: React.ComponentProps<typeof AlertDialogPrimitive.Description>) {
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
111
|
+
return (
|
|
112
|
+
<AlertDialogPrimitive.Description
|
|
113
|
+
data-slot="alert-dialog-description"
|
|
114
|
+
className={cn('text-muted-foreground text-sm', className)}
|
|
115
|
+
{...props}
|
|
116
|
+
/>
|
|
117
|
+
);
|
|
119
118
|
}
|
|
120
119
|
|
|
121
120
|
/** An optional icon or image slot displayed alongside the title in the dialog header. */
|
|
122
121
|
function AlertDialogMedia({ className, ...props }: React.ComponentProps<'div'>) {
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
122
|
+
return (
|
|
123
|
+
<div
|
|
124
|
+
data-slot="alert-dialog-media"
|
|
125
|
+
className={cn(
|
|
126
|
+
"bg-muted mb-2 inline-flex size-16 items-center justify-center rounded-md sm:group-data-[size=default]/alert-dialog-content:row-span-2 *:[svg:not([class*='size-'])]:size-8",
|
|
127
|
+
className,
|
|
128
|
+
)}
|
|
129
|
+
{...props}
|
|
130
|
+
/>
|
|
131
|
+
);
|
|
133
132
|
}
|
|
134
133
|
|
|
135
134
|
/** The primary confirmation button that closes the dialog and triggers the intended action. Renders as a Button. */
|
|
136
135
|
function AlertDialogAction({
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
136
|
+
className,
|
|
137
|
+
variant = 'default',
|
|
138
|
+
size = 'default',
|
|
139
|
+
...props
|
|
141
140
|
}: React.ComponentProps<typeof AlertDialogPrimitive.Action> &
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
141
|
+
Pick<React.ComponentProps<typeof Button>, 'variant' | 'size'>) {
|
|
142
|
+
return (
|
|
143
|
+
<Button variant={variant} size={size} asChild>
|
|
144
|
+
<AlertDialogPrimitive.Action data-slot="alert-dialog-action" className={cn(className)} {...props} />
|
|
145
|
+
</Button>
|
|
146
|
+
);
|
|
148
147
|
}
|
|
149
148
|
|
|
150
149
|
/** The cancel button that dismisses the dialog without taking action. Renders as an outline Button by default. */
|
|
151
150
|
function AlertDialogCancel({
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
151
|
+
className,
|
|
152
|
+
variant = 'outline',
|
|
153
|
+
size = 'default',
|
|
154
|
+
...props
|
|
156
155
|
}: React.ComponentProps<typeof AlertDialogPrimitive.Cancel> &
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
156
|
+
Pick<React.ComponentProps<typeof Button>, 'variant' | 'size'>) {
|
|
157
|
+
return (
|
|
158
|
+
<Button variant={variant} size={size} asChild>
|
|
159
|
+
<AlertDialogPrimitive.Cancel data-slot="alert-dialog-cancel" className={cn(className)} {...props} />
|
|
160
|
+
</Button>
|
|
161
|
+
);
|
|
163
162
|
}
|
|
164
163
|
|
|
165
164
|
export {
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
165
|
+
AlertDialog,
|
|
166
|
+
AlertDialogAction,
|
|
167
|
+
AlertDialogCancel,
|
|
168
|
+
AlertDialogContent,
|
|
169
|
+
AlertDialogDescription,
|
|
170
|
+
AlertDialogFooter,
|
|
171
|
+
AlertDialogHeader,
|
|
172
|
+
AlertDialogMedia,
|
|
173
|
+
AlertDialogOverlay,
|
|
174
|
+
AlertDialogPortal,
|
|
175
|
+
AlertDialogTitle,
|
|
176
|
+
AlertDialogTrigger,
|
|
178
177
|
};
|
|
@@ -2,34 +2,34 @@ import type { Meta, StoryObj } from '@storybook/react-vite';
|
|
|
2
2
|
import { AspectRatio } from '@/components/ui/AspectRatio';
|
|
3
3
|
|
|
4
4
|
const meta: Meta<typeof AspectRatio> = {
|
|
5
|
-
|
|
6
|
-
|
|
5
|
+
title: 'UI Components/AspectRatio',
|
|
6
|
+
component: AspectRatio,
|
|
7
7
|
};
|
|
8
8
|
export default meta;
|
|
9
9
|
type Story = StoryObj<typeof AspectRatio>;
|
|
10
10
|
|
|
11
11
|
/** Shows a 16:9 widescreen aspect ratio container. */
|
|
12
12
|
export const Default: Story = {
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
13
|
+
render: () => (
|
|
14
|
+
<div className="w-[450px]">
|
|
15
|
+
<AspectRatio ratio={16 / 9}>
|
|
16
|
+
<div className="flex h-full w-full items-center justify-center rounded-md bg-slate-200 dark:bg-slate-800">
|
|
17
|
+
<span className="text-sm text-slate-500">16:9 Aspect Ratio</span>
|
|
18
|
+
</div>
|
|
19
|
+
</AspectRatio>
|
|
20
|
+
</div>
|
|
21
|
+
),
|
|
22
22
|
};
|
|
23
23
|
|
|
24
24
|
/** Shows a 1:1 square aspect ratio container. */
|
|
25
25
|
export const Square: Story = {
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
26
|
+
render: () => (
|
|
27
|
+
<div className="w-[300px]">
|
|
28
|
+
<AspectRatio ratio={1}>
|
|
29
|
+
<div className="flex h-full w-full items-center justify-center rounded-md bg-slate-200 dark:bg-slate-800">
|
|
30
|
+
<span className="text-sm text-slate-500">1:1 Square</span>
|
|
31
|
+
</div>
|
|
32
|
+
</AspectRatio>
|
|
33
|
+
</div>
|
|
34
|
+
),
|
|
35
35
|
};
|
|
@@ -7,7 +7,7 @@ import { AspectRatio as AspectRatioPrimitive } from 'radix-ui';
|
|
|
7
7
|
* Useful for responsive images, videos, and media containers that must maintain proportions.
|
|
8
8
|
*/
|
|
9
9
|
function AspectRatio({ ...props }: React.ComponentProps<typeof AspectRatioPrimitive.Root>) {
|
|
10
|
-
|
|
10
|
+
return <AspectRatioPrimitive.Root data-slot="aspect-ratio" {...props} />;
|
|
11
11
|
}
|
|
12
12
|
|
|
13
13
|
export { AspectRatio };
|
|
@@ -1,45 +1,45 @@
|
|
|
1
1
|
import type { Meta, StoryObj } from '@storybook/react-vite';
|
|
2
|
-
import { Avatar,
|
|
2
|
+
import { Avatar, AvatarFallback, AvatarImage } from '@/components/ui/Avatar';
|
|
3
3
|
|
|
4
4
|
const meta: Meta<typeof Avatar> = {
|
|
5
|
-
|
|
6
|
-
|
|
5
|
+
title: 'UI Components/Avatar',
|
|
6
|
+
component: Avatar,
|
|
7
7
|
};
|
|
8
8
|
export default meta;
|
|
9
9
|
type Story = StoryObj<typeof Avatar>;
|
|
10
10
|
|
|
11
11
|
/** Shows an avatar with a loaded profile image and fallback initials. */
|
|
12
12
|
export const WithImage: Story = {
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
13
|
+
render: () => (
|
|
14
|
+
<Avatar>
|
|
15
|
+
<AvatarImage src="https://github.com/shadcn.png" alt="@shadcn" />
|
|
16
|
+
<AvatarFallback>CN</AvatarFallback>
|
|
17
|
+
</Avatar>
|
|
18
|
+
),
|
|
19
19
|
};
|
|
20
20
|
|
|
21
21
|
/** Shows an avatar displaying only fallback initials without an image. */
|
|
22
22
|
export const FallbackOnly: Story = {
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
23
|
+
render: () => (
|
|
24
|
+
<Avatar>
|
|
25
|
+
<AvatarFallback>AB</AvatarFallback>
|
|
26
|
+
</Avatar>
|
|
27
|
+
),
|
|
28
28
|
};
|
|
29
29
|
|
|
30
30
|
/** Demonstrates the three available avatar sizes: sm, default, and lg. */
|
|
31
31
|
export const Sizes: Story = {
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
32
|
+
render: () => (
|
|
33
|
+
<div className="flex items-center gap-4">
|
|
34
|
+
<Avatar size="sm">
|
|
35
|
+
<AvatarFallback>SM</AvatarFallback>
|
|
36
|
+
</Avatar>
|
|
37
|
+
<Avatar size="default">
|
|
38
|
+
<AvatarFallback>MD</AvatarFallback>
|
|
39
|
+
</Avatar>
|
|
40
|
+
<Avatar size="lg">
|
|
41
|
+
<AvatarFallback>LG</AvatarFallback>
|
|
42
|
+
</Avatar>
|
|
43
|
+
</div>
|
|
44
|
+
),
|
|
45
45
|
};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import * as React from 'react';
|
|
2
1
|
import { Avatar as AvatarPrimitive } from 'radix-ui';
|
|
2
|
+
import type * as React from 'react';
|
|
3
3
|
|
|
4
4
|
import { cn } from '@/lib/utils';
|
|
5
5
|
|
|
@@ -9,90 +9,90 @@ import { cn } from '@/lib/utils';
|
|
|
9
9
|
* Use AvatarGroup to render overlapping stacks of avatars.
|
|
10
10
|
*/
|
|
11
11
|
function Avatar({
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
12
|
+
className,
|
|
13
|
+
/** Controls the avatar dimensions: `"sm"` (24px), `"default"` (32px), or `"lg"` (40px). */
|
|
14
|
+
size = 'default',
|
|
15
|
+
...props
|
|
16
16
|
}: React.ComponentProps<typeof AvatarPrimitive.Root> & {
|
|
17
|
-
|
|
17
|
+
size?: 'default' | 'sm' | 'lg';
|
|
18
18
|
}) {
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
19
|
+
return (
|
|
20
|
+
<AvatarPrimitive.Root
|
|
21
|
+
data-slot="avatar"
|
|
22
|
+
data-size={size}
|
|
23
|
+
className={cn(
|
|
24
|
+
'group/avatar relative flex size-8 shrink-0 overflow-hidden rounded-full select-none data-[size=lg]:size-10 data-[size=sm]:size-6',
|
|
25
|
+
className,
|
|
26
|
+
)}
|
|
27
|
+
{...props}
|
|
28
|
+
/>
|
|
29
|
+
);
|
|
30
30
|
}
|
|
31
31
|
|
|
32
32
|
/** The profile image rendered inside an Avatar. Automatically hidden if the image fails to load. */
|
|
33
33
|
function AvatarImage({ className, ...props }: React.ComponentProps<typeof AvatarPrimitive.Image>) {
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
34
|
+
return (
|
|
35
|
+
<AvatarPrimitive.Image data-slot="avatar-image" className={cn('aspect-square size-full', className)} {...props} />
|
|
36
|
+
);
|
|
37
37
|
}
|
|
38
38
|
|
|
39
39
|
/** Fallback content shown when AvatarImage is loading or unavailable, typically initials or an icon. */
|
|
40
40
|
function AvatarFallback({ className, ...props }: React.ComponentProps<typeof AvatarPrimitive.Fallback>) {
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
41
|
+
return (
|
|
42
|
+
<AvatarPrimitive.Fallback
|
|
43
|
+
data-slot="avatar-fallback"
|
|
44
|
+
className={cn(
|
|
45
|
+
'bg-muted text-muted-foreground flex size-full items-center justify-center rounded-full text-sm group-data-[size=sm]/avatar:text-xs',
|
|
46
|
+
className,
|
|
47
|
+
)}
|
|
48
|
+
{...props}
|
|
49
|
+
/>
|
|
50
|
+
);
|
|
51
51
|
}
|
|
52
52
|
|
|
53
53
|
/** A small status indicator (e.g., online/offline dot) positioned at the bottom-right corner of an Avatar. */
|
|
54
54
|
function AvatarBadge({ className, ...props }: React.ComponentProps<'span'>) {
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
55
|
+
return (
|
|
56
|
+
<span
|
|
57
|
+
data-slot="avatar-badge"
|
|
58
|
+
className={cn(
|
|
59
|
+
'bg-primary text-primary-foreground ring-background absolute right-0 bottom-0 z-10 inline-flex items-center justify-center rounded-full ring-2 select-none',
|
|
60
|
+
'group-data-[size=sm]/avatar:size-2 group-data-[size=sm]/avatar:[&>svg]:hidden',
|
|
61
|
+
'group-data-[size=default]/avatar:size-2.5 group-data-[size=default]/avatar:[&>svg]:size-2',
|
|
62
|
+
'group-data-[size=lg]/avatar:size-3 group-data-[size=lg]/avatar:[&>svg]:size-2',
|
|
63
|
+
className,
|
|
64
|
+
)}
|
|
65
|
+
{...props}
|
|
66
|
+
/>
|
|
67
|
+
);
|
|
68
68
|
}
|
|
69
69
|
|
|
70
70
|
/** Renders multiple Avatars in an overlapping horizontal stack with ring borders. */
|
|
71
71
|
function AvatarGroup({ className, ...props }: React.ComponentProps<'div'>) {
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
72
|
+
return (
|
|
73
|
+
<div
|
|
74
|
+
data-slot="avatar-group"
|
|
75
|
+
className={cn(
|
|
76
|
+
'*:data-[slot=avatar]:ring-background group/avatar-group flex -space-x-2 *:data-[slot=avatar]:ring-2',
|
|
77
|
+
className,
|
|
78
|
+
)}
|
|
79
|
+
{...props}
|
|
80
|
+
/>
|
|
81
|
+
);
|
|
82
82
|
}
|
|
83
83
|
|
|
84
84
|
/** Displays a count of additional avatars not shown in the group (e.g., "+5"). */
|
|
85
85
|
function AvatarGroupCount({ className, ...props }: React.ComponentProps<'div'>) {
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
86
|
+
return (
|
|
87
|
+
<div
|
|
88
|
+
data-slot="avatar-group-count"
|
|
89
|
+
className={cn(
|
|
90
|
+
'bg-muted text-muted-foreground ring-background relative flex size-8 shrink-0 items-center justify-center rounded-full text-sm ring-2 group-has-data-[size=lg]/avatar-group:size-10 group-has-data-[size=sm]/avatar-group:size-6 [&>svg]:size-4 group-has-data-[size=lg]/avatar-group:[&>svg]:size-5 group-has-data-[size=sm]/avatar-group:[&>svg]:size-3',
|
|
91
|
+
className,
|
|
92
|
+
)}
|
|
93
|
+
{...props}
|
|
94
|
+
/>
|
|
95
|
+
);
|
|
96
96
|
}
|
|
97
97
|
|
|
98
98
|
export { Avatar, AvatarImage, AvatarFallback, AvatarBadge, AvatarGroup, AvatarGroupCount };
|
|
@@ -2,40 +2,40 @@ import type { Meta, StoryObj } from '@storybook/react-vite';
|
|
|
2
2
|
import { Badge } from '@/components/ui/Badge';
|
|
3
3
|
|
|
4
4
|
const meta: Meta<typeof Badge> = {
|
|
5
|
-
|
|
6
|
-
|
|
5
|
+
title: 'UI Components/Badge',
|
|
6
|
+
component: Badge,
|
|
7
7
|
};
|
|
8
8
|
export default meta;
|
|
9
9
|
type Story = StoryObj<typeof Badge>;
|
|
10
10
|
|
|
11
11
|
/** Shows the primary filled badge variant. */
|
|
12
12
|
export const Default: Story = {
|
|
13
|
-
|
|
13
|
+
render: () => <Badge>Default</Badge>,
|
|
14
14
|
};
|
|
15
15
|
|
|
16
16
|
/** Shows the secondary badge variant with muted background. */
|
|
17
17
|
export const Secondary: Story = {
|
|
18
|
-
|
|
18
|
+
render: () => <Badge variant="secondary">Secondary</Badge>,
|
|
19
19
|
};
|
|
20
20
|
|
|
21
21
|
/** Shows the destructive badge variant for error or warning indicators. */
|
|
22
22
|
export const Destructive: Story = {
|
|
23
|
-
|
|
23
|
+
render: () => <Badge variant="destructive">Destructive</Badge>,
|
|
24
24
|
};
|
|
25
25
|
|
|
26
26
|
/** Shows the outline badge variant with a visible border and no fill. */
|
|
27
27
|
export const Outline: Story = {
|
|
28
|
-
|
|
28
|
+
render: () => <Badge variant="outline">Outline</Badge>,
|
|
29
29
|
};
|
|
30
30
|
|
|
31
31
|
/** Displays all badge variants side by side for visual comparison. */
|
|
32
32
|
export const AllVariants: Story = {
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
33
|
+
render: () => (
|
|
34
|
+
<div className="flex flex-wrap gap-2">
|
|
35
|
+
<Badge variant="default">Default</Badge>
|
|
36
|
+
<Badge variant="secondary">Secondary</Badge>
|
|
37
|
+
<Badge variant="destructive">Destructive</Badge>
|
|
38
|
+
<Badge variant="outline">Outline</Badge>
|
|
39
|
+
</div>
|
|
40
|
+
),
|
|
41
41
|
};
|