@a2v2ai/uikit 0.0.36 → 0.0.38
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/Alert/Alert.stories.tsx +121 -0
- package/Alert/Alert.tsx +71 -0
- package/AlertDialog/AlertDialog.stories.tsx +665 -0
- package/AlertDialog/AlertDialog.tsx +241 -0
- package/Avatar/Avatar.stories.tsx +128 -0
- package/Avatar/Avatar.tsx +71 -0
- package/Badge/Badge.stories.tsx +76 -0
- package/Badge/Badge.tsx +39 -0
- package/Breadcrumb/Breadcrumb.stories.tsx +231 -0
- package/Breadcrumb/Breadcrumb.tsx +114 -0
- package/Button/Button.stories.tsx +684 -0
- package/Button/Button.tsx +107 -0
- package/Calendar/Calendar.stories.tsx +291 -0
- package/Calendar/Calendar.tsx +246 -0
- package/Card/Card.stories.tsx +136 -0
- package/Card/Card.tsx +96 -0
- package/Carousel/Carousel.stories.tsx +256 -0
- package/Carousel/Carousel.tsx +301 -0
- package/ChatBubble/ChatBubble.stories.tsx +339 -0
- package/ChatBubble/ChatBubble.tsx +179 -0
- package/Checkbox/Checkbox.stories.tsx +137 -0
- package/Checkbox/Checkbox.tsx +53 -0
- package/DataTable/DataTable.stories.tsx +400 -0
- package/DataTable/DataTable.tsx +207 -0
- package/Drawer/Drawer.stories.tsx +721 -0
- package/Drawer/Drawer.tsx +201 -0
- package/DropdownMenu/DropdownMenu.stories.tsx +251 -0
- package/DropdownMenu/DropdownMenu.tsx +199 -0
- package/ErrorMessage/ErrorMessage.stories.tsx +159 -0
- package/ErrorMessage/ErrorMessage.tsx +55 -0
- package/Flex/Flex.stories.tsx +390 -0
- package/Flex/Flex.tsx +102 -0
- package/IconButton/IconButton.stories.tsx +566 -0
- package/IconButton/IconButton.tsx +95 -0
- package/Input/Input.stories.tsx +566 -0
- package/Input/Input.tsx +168 -0
- package/InputOTP/InputOTP.stories.tsx +246 -0
- package/InputOTP/InputOTP.tsx +127 -0
- package/Label/Label.stories.tsx +110 -0
- package/Label/Label.tsx +44 -0
- package/Loader/Loader.stories.tsx +170 -0
- package/Loader/Loader.tsx +62 -0
- package/Menubar/Menubar.stories.tsx +382 -0
- package/Menubar/Menubar.tsx +274 -0
- package/Menubar/index.ts +18 -0
- package/Pagination/Pagination.stories.tsx +196 -0
- package/Pagination/Pagination.tsx +122 -0
- package/Popover/Popover.stories.tsx +133 -0
- package/Popover/Popover.tsx +31 -0
- package/Progress/Progress.stories.tsx +146 -0
- package/Progress/Progress.tsx +67 -0
- package/RadioGroup/RadioGroup.stories.tsx +159 -0
- package/RadioGroup/RadioGroup.tsx +68 -0
- package/ScrollArea/ScrollArea.stories.tsx +136 -0
- package/ScrollArea/ScrollArea.tsx +46 -0
- package/Select/Select.stories.tsx +378 -0
- package/Select/Select.tsx +230 -0
- package/Separator/Separator.stories.tsx +110 -0
- package/Separator/Separator.tsx +29 -0
- package/Sidebar/Sidebar.stories.tsx +340 -0
- package/Sidebar/Sidebar.tsx +414 -0
- package/Sidebar/index.ts +28 -0
- package/Skeleton/Skeleton.stories.tsx +117 -0
- package/Skeleton/Skeleton.tsx +16 -0
- package/Slider/Slider.stories.tsx +216 -0
- package/Slider/Slider.tsx +29 -0
- package/Spinner/Spinner.stories.tsx +210 -0
- package/Spinner/Spinner.tsx +78 -0
- package/Switch/Switch.stories.tsx +146 -0
- package/Switch/Switch.tsx +59 -0
- package/Table/Table.stories.tsx +510 -0
- package/Table/Table.tsx +114 -0
- package/Tabs/Tabs.stories.tsx +197 -0
- package/Tabs/Tabs.tsx +74 -0
- package/Textarea/Textarea.stories.tsx +187 -0
- package/Textarea/Textarea.tsx +73 -0
- package/Toast/Toast.stories.tsx +285 -0
- package/Toast/Toast.tsx +59 -0
- package/Tooltip/Tooltip.stories.tsx +463 -0
- package/Tooltip/Tooltip.tsx +96 -0
- package/Typography/Typography.stories.tsx +425 -0
- package/Typography/Typography.tsx +106 -0
- package/helpers.ts +5 -0
- package/{icons.js → icons.ts} +1 -1
- package/index.ts +217 -0
- package/lib/typography-types.ts +223 -0
- package/lib/utils.ts +15 -0
- package/package.json +36 -33
- package/tsconfig.json +22 -0
- package/Alert/Alert.d.ts +0 -13
- package/Alert/Alert.js +0 -25
- package/AlertDialog/AlertDialog.d.ts +0 -43
- package/AlertDialog/AlertDialog.js +0 -71
- package/Avatar/Avatar.d.ts +0 -14
- package/Avatar/Avatar.js +0 -25
- package/Badge/Badge.d.ts +0 -11
- package/Badge/Badge.js +0 -23
- package/Breadcrumb/Breadcrumb.d.ts +0 -19
- package/Breadcrumb/Breadcrumb.js +0 -23
- package/Button/Button.d.ts +0 -23
- package/Button/Button.js +0 -52
- package/Calendar/Calendar.d.ts +0 -20
- package/Calendar/Calendar.js +0 -78
- package/Card/Card.d.ts +0 -16
- package/Card/Card.js +0 -28
- package/Carousel/Carousel.d.ts +0 -37
- package/Carousel/Carousel.js +0 -132
- package/ChatBubble/ChatBubble.d.ts +0 -33
- package/ChatBubble/ChatBubble.js +0 -107
- package/Checkbox/Checkbox.d.ts +0 -12
- package/Checkbox/Checkbox.js +0 -20
- package/DataTable/DataTable.d.ts +0 -35
- package/DataTable/DataTable.js +0 -51
- package/Dialog/Dialog.d.ts +0 -35
- package/Dialog/Dialog.js +0 -130
- package/Drawer/Drawer.d.ts +0 -33
- package/Drawer/Drawer.js +0 -55
- package/DropdownMenu/DropdownMenu.d.ts +0 -27
- package/DropdownMenu/DropdownMenu.js +0 -35
- package/ErrorMessage/ErrorMessage.d.ts +0 -27
- package/ErrorMessage/ErrorMessage.js +0 -14
- package/Flex/Flex.d.ts +0 -31
- package/Flex/Flex.js +0 -64
- package/IconButton/IconButton.d.ts +0 -23
- package/IconButton/IconButton.js +0 -48
- package/Input/Input.d.ts +0 -27
- package/Input/Input.js +0 -42
- package/InputOTP/InputOTP.d.ts +0 -20
- package/InputOTP/InputOTP.js +0 -44
- package/Label/Label.d.ts +0 -13
- package/Label/Label.js +0 -19
- package/Loader/Loader.d.ts +0 -21
- package/Loader/Loader.js +0 -30
- package/Menubar/Menubar.d.ts +0 -26
- package/Menubar/Menubar.js +0 -54
- package/Menubar/index.d.ts +0 -1
- package/Menubar/index.js +0 -1
- package/Pagination/Pagination.d.ts +0 -35
- package/Pagination/Pagination.js +0 -37
- package/Popover/Popover.d.ts +0 -7
- package/Popover/Popover.js +0 -10
- package/Progress/Progress.d.ts +0 -17
- package/Progress/Progress.js +0 -33
- package/RadioGroup/RadioGroup.d.ts +0 -13
- package/RadioGroup/RadioGroup.js +0 -26
- package/ScrollArea/ScrollArea.d.ts +0 -5
- package/ScrollArea/ScrollArea.js +0 -11
- package/Select/Select.d.ts +0 -29
- package/Select/Select.js +0 -50
- package/Separator/Separator.d.ts +0 -4
- package/Separator/Separator.js +0 -7
- package/Sidebar/Sidebar.d.ts +0 -48
- package/Sidebar/Sidebar.js +0 -116
- package/Sidebar/index.d.ts +0 -2
- package/Sidebar/index.js +0 -1
- package/Skeleton/Skeleton.d.ts +0 -4
- package/Skeleton/Skeleton.js +0 -7
- package/Slider/Slider.d.ts +0 -6
- package/Slider/Slider.js +0 -7
- package/Spinner/Spinner.d.ts +0 -19
- package/Spinner/Spinner.js +0 -31
- package/Switch/Switch.d.ts +0 -12
- package/Switch/Switch.js +0 -30
- package/Table/Table.d.ts +0 -10
- package/Table/Table.js +0 -20
- package/Tabs/Tabs.d.ts +0 -15
- package/Tabs/Tabs.js +0 -24
- package/Textarea/Textarea.d.ts +0 -19
- package/Textarea/Textarea.js +0 -31
- package/Toast/Toast.d.ts +0 -12
- package/Toast/Toast.js +0 -25
- package/Tooltip/Tooltip.d.ts +0 -17
- package/Tooltip/Tooltip.js +0 -29
- package/Typography/Typography.d.ts +0 -20
- package/Typography/Typography.js +0 -43
- package/helpers.d.ts +0 -4
- package/helpers.js +0 -5
- package/icons.d.ts +0 -1
- package/index.d.ts +0 -42
- package/index.js +0 -45
- package/lib/typography-types.d.ts +0 -4
- package/lib/typography-types.js +0 -90
- package/lib/utils.d.ts +0 -3
- package/lib/utils.js +0 -14
- package/tmpclaude-2407-cwd +0 -1
|
@@ -0,0 +1,133 @@
|
|
|
1
|
+
import type { Meta, StoryObj } from "@storybook/react"
|
|
2
|
+
|
|
3
|
+
import { Button } from "../Button/Button"
|
|
4
|
+
import { Input } from "../Input/Input"
|
|
5
|
+
import { Label } from "../Label/Label"
|
|
6
|
+
import { Flex } from "../Flex/Flex"
|
|
7
|
+
import { Typography } from "../Typography/Typography"
|
|
8
|
+
import { Popover, PopoverTrigger, PopoverContent } from "./Popover"
|
|
9
|
+
|
|
10
|
+
const meta: Meta<typeof Popover> = {
|
|
11
|
+
title: "Components/Popover",
|
|
12
|
+
component: Popover,
|
|
13
|
+
parameters: {
|
|
14
|
+
layout: "centered",
|
|
15
|
+
},
|
|
16
|
+
tags: ["autodocs"],
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
export default meta
|
|
20
|
+
type Story = StoryObj<typeof meta>
|
|
21
|
+
|
|
22
|
+
export const Default: Story = {
|
|
23
|
+
render: () => (
|
|
24
|
+
<Popover>
|
|
25
|
+
<PopoverTrigger asChild>
|
|
26
|
+
<Button variant="outline">Open popover</Button>
|
|
27
|
+
</PopoverTrigger>
|
|
28
|
+
<PopoverContent>
|
|
29
|
+
<Flex gap={2}>
|
|
30
|
+
<Typography variant="body1" className="font-medium">Dimensions</Typography>
|
|
31
|
+
<Typography variant="body2" color="grey-500">Set the dimensions for the layer.</Typography>
|
|
32
|
+
</Flex>
|
|
33
|
+
<Flex gap={4} className="mt-4">
|
|
34
|
+
<Flex gap={2}>
|
|
35
|
+
<Label htmlFor="width">Width</Label>
|
|
36
|
+
<Input id="width" defaultValue="100%" />
|
|
37
|
+
</Flex>
|
|
38
|
+
<Flex gap={2}>
|
|
39
|
+
<Label htmlFor="height">Height</Label>
|
|
40
|
+
<Input id="height" defaultValue="25px" />
|
|
41
|
+
</Flex>
|
|
42
|
+
</Flex>
|
|
43
|
+
</PopoverContent>
|
|
44
|
+
</Popover>
|
|
45
|
+
),
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
export const Simple: Story = {
|
|
49
|
+
render: () => (
|
|
50
|
+
<Popover>
|
|
51
|
+
<PopoverTrigger asChild>
|
|
52
|
+
<Button variant="outline">Info</Button>
|
|
53
|
+
</PopoverTrigger>
|
|
54
|
+
<PopoverContent className="w-80">
|
|
55
|
+
<Typography variant="body2">
|
|
56
|
+
This is a simple popover with some informational text.
|
|
57
|
+
</Typography>
|
|
58
|
+
</PopoverContent>
|
|
59
|
+
</Popover>
|
|
60
|
+
),
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
export const WithForm: Story = {
|
|
64
|
+
render: () => (
|
|
65
|
+
<Popover>
|
|
66
|
+
<PopoverTrigger asChild>
|
|
67
|
+
<Button>Update email</Button>
|
|
68
|
+
</PopoverTrigger>
|
|
69
|
+
<PopoverContent className="w-80">
|
|
70
|
+
<Flex gap={4}>
|
|
71
|
+
<Flex gap={1}>
|
|
72
|
+
<Typography variant="body1" className="font-medium">Update email</Typography>
|
|
73
|
+
<Typography variant="caption" color="grey-500">Change your account email address.</Typography>
|
|
74
|
+
</Flex>
|
|
75
|
+
<Flex gap={2}>
|
|
76
|
+
<Label htmlFor="new-email">New email</Label>
|
|
77
|
+
<Input id="new-email" type="email" placeholder="Enter new email" />
|
|
78
|
+
</Flex>
|
|
79
|
+
<Button size="small">Save changes</Button>
|
|
80
|
+
</Flex>
|
|
81
|
+
</PopoverContent>
|
|
82
|
+
</Popover>
|
|
83
|
+
),
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
export const AllVariants: Story = {
|
|
87
|
+
render: () => (
|
|
88
|
+
<Flex gap={6}>
|
|
89
|
+
<Typography variant="h4" className="text-white">Popover Examples</Typography>
|
|
90
|
+
|
|
91
|
+
<Flex direction="row" gap={4}>
|
|
92
|
+
<Popover>
|
|
93
|
+
<PopoverTrigger asChild>
|
|
94
|
+
<Button variant="outline">Simple</Button>
|
|
95
|
+
</PopoverTrigger>
|
|
96
|
+
<PopoverContent>
|
|
97
|
+
<Typography variant="body2">A simple popover content.</Typography>
|
|
98
|
+
</PopoverContent>
|
|
99
|
+
</Popover>
|
|
100
|
+
|
|
101
|
+
<Popover>
|
|
102
|
+
<PopoverTrigger asChild>
|
|
103
|
+
<Button variant="outline">With Title</Button>
|
|
104
|
+
</PopoverTrigger>
|
|
105
|
+
<PopoverContent className="w-80">
|
|
106
|
+
<Flex gap={2}>
|
|
107
|
+
<Typography variant="body1" className="font-medium">Popover Title</Typography>
|
|
108
|
+
<Typography variant="body2" color="grey-500">
|
|
109
|
+
This popover has a title and description.
|
|
110
|
+
</Typography>
|
|
111
|
+
</Flex>
|
|
112
|
+
</PopoverContent>
|
|
113
|
+
</Popover>
|
|
114
|
+
|
|
115
|
+
<Popover>
|
|
116
|
+
<PopoverTrigger asChild>
|
|
117
|
+
<Button variant="outline">With Form</Button>
|
|
118
|
+
</PopoverTrigger>
|
|
119
|
+
<PopoverContent className="w-80">
|
|
120
|
+
<Flex gap={3}>
|
|
121
|
+
<Typography variant="body1" className="font-medium">Settings</Typography>
|
|
122
|
+
<Flex gap={2}>
|
|
123
|
+
<Label htmlFor="setting-name">Name</Label>
|
|
124
|
+
<Input id="setting-name" placeholder="Enter name" />
|
|
125
|
+
</Flex>
|
|
126
|
+
<Button size="small">Save</Button>
|
|
127
|
+
</Flex>
|
|
128
|
+
</PopoverContent>
|
|
129
|
+
</Popover>
|
|
130
|
+
</Flex>
|
|
131
|
+
</Flex>
|
|
132
|
+
),
|
|
133
|
+
}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import * as React from "react"
|
|
2
|
+
import * as PopoverPrimitive from "@radix-ui/react-popover"
|
|
3
|
+
|
|
4
|
+
import { cn } from "../lib/utils"
|
|
5
|
+
|
|
6
|
+
const Popover = PopoverPrimitive.Root
|
|
7
|
+
|
|
8
|
+
const PopoverTrigger = PopoverPrimitive.Trigger
|
|
9
|
+
|
|
10
|
+
const PopoverAnchor = PopoverPrimitive.Anchor
|
|
11
|
+
|
|
12
|
+
const PopoverContent = React.forwardRef<
|
|
13
|
+
React.ElementRef<typeof PopoverPrimitive.Content>,
|
|
14
|
+
React.ComponentPropsWithoutRef<typeof PopoverPrimitive.Content>
|
|
15
|
+
>(({ className, align = "center", sideOffset = 4, ...props }, ref) => (
|
|
16
|
+
<PopoverPrimitive.Portal>
|
|
17
|
+
<PopoverPrimitive.Content
|
|
18
|
+
ref={ref}
|
|
19
|
+
align={align}
|
|
20
|
+
sideOffset={sideOffset}
|
|
21
|
+
className={cn(
|
|
22
|
+
"z-50 w-72 rounded-lg border border-grey-200 bg-white p-4 text-main-950 shadow-md outline-none 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 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2",
|
|
23
|
+
className
|
|
24
|
+
)}
|
|
25
|
+
{...props}
|
|
26
|
+
/>
|
|
27
|
+
</PopoverPrimitive.Portal>
|
|
28
|
+
))
|
|
29
|
+
PopoverContent.displayName = PopoverPrimitive.Content.displayName
|
|
30
|
+
|
|
31
|
+
export { Popover, PopoverTrigger, PopoverContent, PopoverAnchor }
|
|
@@ -0,0 +1,146 @@
|
|
|
1
|
+
import type { Meta, StoryObj } from "@storybook/react"
|
|
2
|
+
import { useState, useEffect } from "react"
|
|
3
|
+
|
|
4
|
+
import { Flex } from "../Flex/Flex"
|
|
5
|
+
import { Typography } from "../Typography/Typography"
|
|
6
|
+
import { Progress } from "./Progress"
|
|
7
|
+
|
|
8
|
+
function AnimatedProgress() {
|
|
9
|
+
const [progress, setProgress] = useState(13)
|
|
10
|
+
|
|
11
|
+
useEffect(() => {
|
|
12
|
+
const timer = setTimeout(() => setProgress(66), 500)
|
|
13
|
+
return () => clearTimeout(timer)
|
|
14
|
+
}, [])
|
|
15
|
+
|
|
16
|
+
return <Progress value={progress} className="w-[300px]" />
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
const meta: Meta<typeof Progress> = {
|
|
20
|
+
title: "Components/Progress",
|
|
21
|
+
component: Progress,
|
|
22
|
+
parameters: {
|
|
23
|
+
layout: "centered",
|
|
24
|
+
},
|
|
25
|
+
argTypes: {
|
|
26
|
+
value: {
|
|
27
|
+
control: { type: "range", min: 0, max: 100 },
|
|
28
|
+
description: "The progress value (0-100)",
|
|
29
|
+
},
|
|
30
|
+
size: {
|
|
31
|
+
control: "select",
|
|
32
|
+
options: ["small", "regular", "large"],
|
|
33
|
+
description: "The size of the progress bar",
|
|
34
|
+
},
|
|
35
|
+
variant: {
|
|
36
|
+
control: "select",
|
|
37
|
+
options: ["default", "success", "warning", "destructive"],
|
|
38
|
+
description: "The visual variant",
|
|
39
|
+
},
|
|
40
|
+
},
|
|
41
|
+
tags: ["autodocs"],
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
export default meta
|
|
45
|
+
type Story = StoryObj<typeof meta>
|
|
46
|
+
|
|
47
|
+
export const Default: Story = {
|
|
48
|
+
render: () => <Progress value={33} className="w-[300px]" />,
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
export const Complete: Story = {
|
|
52
|
+
render: () => <Progress value={100} className="w-[300px]" />,
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
export const Animated: Story = {
|
|
56
|
+
render: () => <AnimatedProgress />,
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
export const Small: Story = {
|
|
60
|
+
render: () => <Progress value={60} size="small" className="w-[300px]" />,
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
export const Large: Story = {
|
|
64
|
+
render: () => <Progress value={60} size="large" className="w-[300px]" />,
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
export const Success: Story = {
|
|
68
|
+
render: () => <Progress value={100} variant="success" className="w-[300px]" />,
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
export const Warning: Story = {
|
|
72
|
+
render: () => <Progress value={75} variant="warning" className="w-[300px]" />,
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
export const Destructive: Story = {
|
|
76
|
+
render: () => <Progress value={90} variant="destructive" className="w-[300px]" />,
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
export const AllVariants: Story = {
|
|
80
|
+
render: () => (
|
|
81
|
+
<Flex gap={6} className="w-[400px]">
|
|
82
|
+
<Typography variant="h4" className="text-white">Progress Sizes</Typography>
|
|
83
|
+
|
|
84
|
+
<Flex gap={4}>
|
|
85
|
+
<Flex gap={2}>
|
|
86
|
+
<Typography variant="caption" className="text-grey-400">Small</Typography>
|
|
87
|
+
<Progress value={40} size="small" />
|
|
88
|
+
</Flex>
|
|
89
|
+
|
|
90
|
+
<Flex gap={2}>
|
|
91
|
+
<Typography variant="caption" className="text-grey-400">Regular</Typography>
|
|
92
|
+
<Progress value={60} size="regular" />
|
|
93
|
+
</Flex>
|
|
94
|
+
|
|
95
|
+
<Flex gap={2}>
|
|
96
|
+
<Typography variant="caption" className="text-grey-400">Large</Typography>
|
|
97
|
+
<Progress value={80} size="large" />
|
|
98
|
+
</Flex>
|
|
99
|
+
</Flex>
|
|
100
|
+
|
|
101
|
+
<Typography variant="h4" className="text-white mt-4">Progress Variants</Typography>
|
|
102
|
+
|
|
103
|
+
<Flex gap={4}>
|
|
104
|
+
<Flex gap={2}>
|
|
105
|
+
<Typography variant="caption" className="text-grey-400">Default (25%)</Typography>
|
|
106
|
+
<Progress value={25} />
|
|
107
|
+
</Flex>
|
|
108
|
+
|
|
109
|
+
<Flex gap={2}>
|
|
110
|
+
<Typography variant="caption" className="text-grey-400">Success (100%)</Typography>
|
|
111
|
+
<Progress value={100} variant="success" />
|
|
112
|
+
</Flex>
|
|
113
|
+
|
|
114
|
+
<Flex gap={2}>
|
|
115
|
+
<Typography variant="caption" className="text-grey-400">Warning (75%)</Typography>
|
|
116
|
+
<Progress value={75} variant="warning" />
|
|
117
|
+
</Flex>
|
|
118
|
+
|
|
119
|
+
<Flex gap={2}>
|
|
120
|
+
<Typography variant="caption" className="text-grey-400">Destructive (90%)</Typography>
|
|
121
|
+
<Progress value={90} variant="destructive" />
|
|
122
|
+
</Flex>
|
|
123
|
+
</Flex>
|
|
124
|
+
|
|
125
|
+
<Typography variant="h4" className="text-white mt-4">Use Cases</Typography>
|
|
126
|
+
|
|
127
|
+
<Flex gap={4}>
|
|
128
|
+
<Flex gap={2}>
|
|
129
|
+
<Flex justify="between">
|
|
130
|
+
<Typography variant="body2">Upload progress</Typography>
|
|
131
|
+
<Typography variant="body2" color="grey-500">67%</Typography>
|
|
132
|
+
</Flex>
|
|
133
|
+
<Progress value={67} />
|
|
134
|
+
</Flex>
|
|
135
|
+
|
|
136
|
+
<Flex gap={2}>
|
|
137
|
+
<Flex justify="between">
|
|
138
|
+
<Typography variant="body2">Storage used</Typography>
|
|
139
|
+
<Typography variant="body2" color="grey-500">8.2 GB / 10 GB</Typography>
|
|
140
|
+
</Flex>
|
|
141
|
+
<Progress value={82} variant="warning" />
|
|
142
|
+
</Flex>
|
|
143
|
+
</Flex>
|
|
144
|
+
</Flex>
|
|
145
|
+
),
|
|
146
|
+
}
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
import * as React from "react"
|
|
2
|
+
import * as ProgressPrimitive from "@radix-ui/react-progress"
|
|
3
|
+
import { cva } from "class-variance-authority"
|
|
4
|
+
|
|
5
|
+
import { cn } from "../lib/utils"
|
|
6
|
+
|
|
7
|
+
type ProgressSize = "small" | "regular" | "large"
|
|
8
|
+
type ProgressVariant = "default" | "success" | "warning" | "destructive"
|
|
9
|
+
|
|
10
|
+
const progressVariants = cva(
|
|
11
|
+
"relative w-full overflow-hidden rounded-full bg-grey-100",
|
|
12
|
+
{
|
|
13
|
+
variants: {
|
|
14
|
+
size: {
|
|
15
|
+
small: "h-1",
|
|
16
|
+
regular: "h-2",
|
|
17
|
+
large: "h-3",
|
|
18
|
+
},
|
|
19
|
+
},
|
|
20
|
+
defaultVariants: {
|
|
21
|
+
size: "regular",
|
|
22
|
+
},
|
|
23
|
+
}
|
|
24
|
+
)
|
|
25
|
+
|
|
26
|
+
const progressIndicatorVariants = cva(
|
|
27
|
+
"h-full w-full flex-1 transition-all",
|
|
28
|
+
{
|
|
29
|
+
variants: {
|
|
30
|
+
variant: {
|
|
31
|
+
default: "bg-accent-600",
|
|
32
|
+
success: "bg-success-600",
|
|
33
|
+
warning: "bg-warning-500",
|
|
34
|
+
destructive: "bg-error-600",
|
|
35
|
+
},
|
|
36
|
+
},
|
|
37
|
+
defaultVariants: {
|
|
38
|
+
variant: "default",
|
|
39
|
+
},
|
|
40
|
+
}
|
|
41
|
+
)
|
|
42
|
+
|
|
43
|
+
export interface ProgressProps
|
|
44
|
+
extends React.ComponentPropsWithoutRef<typeof ProgressPrimitive.Root> {
|
|
45
|
+
size?: ProgressSize
|
|
46
|
+
variant?: ProgressVariant
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
const Progress = React.forwardRef<
|
|
50
|
+
React.ElementRef<typeof ProgressPrimitive.Root>,
|
|
51
|
+
ProgressProps
|
|
52
|
+
>(({ className, value, size, variant, ...props }, ref) => (
|
|
53
|
+
<ProgressPrimitive.Root
|
|
54
|
+
ref={ref}
|
|
55
|
+
className={cn(progressVariants({ size }), className)}
|
|
56
|
+
{...props}
|
|
57
|
+
>
|
|
58
|
+
<ProgressPrimitive.Indicator
|
|
59
|
+
className={cn(progressIndicatorVariants({ variant }))}
|
|
60
|
+
style={{ transform: `translateX(-${100 - (value || 0)}%)` }}
|
|
61
|
+
/>
|
|
62
|
+
</ProgressPrimitive.Root>
|
|
63
|
+
))
|
|
64
|
+
Progress.displayName = ProgressPrimitive.Root.displayName
|
|
65
|
+
|
|
66
|
+
export { Progress, progressVariants, progressIndicatorVariants }
|
|
67
|
+
export type { ProgressSize, ProgressVariant }
|
|
@@ -0,0 +1,159 @@
|
|
|
1
|
+
import type { Meta, StoryObj } from "@storybook/react"
|
|
2
|
+
|
|
3
|
+
import { Label } from "../Label/Label"
|
|
4
|
+
import { Flex } from "../Flex/Flex"
|
|
5
|
+
import { Typography } from "../Typography/Typography"
|
|
6
|
+
import { RadioGroup, RadioGroupItem } from "./RadioGroup"
|
|
7
|
+
|
|
8
|
+
const meta: Meta<typeof RadioGroup> = {
|
|
9
|
+
title: "Components/RadioGroup",
|
|
10
|
+
component: RadioGroup,
|
|
11
|
+
parameters: {
|
|
12
|
+
layout: "centered",
|
|
13
|
+
},
|
|
14
|
+
tags: ["autodocs"],
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
export default meta
|
|
18
|
+
type Story = StoryObj<typeof meta>
|
|
19
|
+
|
|
20
|
+
export const Default: Story = {
|
|
21
|
+
render: () => (
|
|
22
|
+
<RadioGroup defaultValue="comfortable">
|
|
23
|
+
<Flex direction="row" align="center" gap={2}>
|
|
24
|
+
<RadioGroupItem value="default" id="r1" />
|
|
25
|
+
<Label htmlFor="r1">Default</Label>
|
|
26
|
+
</Flex>
|
|
27
|
+
<Flex direction="row" align="center" gap={2}>
|
|
28
|
+
<RadioGroupItem value="comfortable" id="r2" />
|
|
29
|
+
<Label htmlFor="r2">Comfortable</Label>
|
|
30
|
+
</Flex>
|
|
31
|
+
<Flex direction="row" align="center" gap={2}>
|
|
32
|
+
<RadioGroupItem value="compact" id="r3" />
|
|
33
|
+
<Label htmlFor="r3">Compact</Label>
|
|
34
|
+
</Flex>
|
|
35
|
+
</RadioGroup>
|
|
36
|
+
),
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
export const Small: Story = {
|
|
40
|
+
render: () => (
|
|
41
|
+
<RadioGroup defaultValue="option1">
|
|
42
|
+
<Flex direction="row" align="center" gap={2}>
|
|
43
|
+
<RadioGroupItem value="option1" id="s1" size="small" />
|
|
44
|
+
<Label htmlFor="s1" className="text-sm">Option 1</Label>
|
|
45
|
+
</Flex>
|
|
46
|
+
<Flex direction="row" align="center" gap={2}>
|
|
47
|
+
<RadioGroupItem value="option2" id="s2" size="small" />
|
|
48
|
+
<Label htmlFor="s2" className="text-sm">Option 2</Label>
|
|
49
|
+
</Flex>
|
|
50
|
+
</RadioGroup>
|
|
51
|
+
),
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
export const Disabled: Story = {
|
|
55
|
+
render: () => (
|
|
56
|
+
<RadioGroup defaultValue="option1" disabled>
|
|
57
|
+
<Flex direction="row" align="center" gap={2}>
|
|
58
|
+
<RadioGroupItem value="option1" id="d1" />
|
|
59
|
+
<Label htmlFor="d1" className="opacity-50">Option 1</Label>
|
|
60
|
+
</Flex>
|
|
61
|
+
<Flex direction="row" align="center" gap={2}>
|
|
62
|
+
<RadioGroupItem value="option2" id="d2" />
|
|
63
|
+
<Label htmlFor="d2" className="opacity-50">Option 2</Label>
|
|
64
|
+
</Flex>
|
|
65
|
+
</RadioGroup>
|
|
66
|
+
),
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
export const Horizontal: Story = {
|
|
70
|
+
render: () => (
|
|
71
|
+
<RadioGroup defaultValue="left" className="flex flex-row gap-4">
|
|
72
|
+
<Flex direction="row" align="center" gap={2}>
|
|
73
|
+
<RadioGroupItem value="left" id="h1" />
|
|
74
|
+
<Label htmlFor="h1">Left</Label>
|
|
75
|
+
</Flex>
|
|
76
|
+
<Flex direction="row" align="center" gap={2}>
|
|
77
|
+
<RadioGroupItem value="center" id="h2" />
|
|
78
|
+
<Label htmlFor="h2">Center</Label>
|
|
79
|
+
</Flex>
|
|
80
|
+
<Flex direction="row" align="center" gap={2}>
|
|
81
|
+
<RadioGroupItem value="right" id="h3" />
|
|
82
|
+
<Label htmlFor="h3">Right</Label>
|
|
83
|
+
</Flex>
|
|
84
|
+
</RadioGroup>
|
|
85
|
+
),
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
export const AllVariants: Story = {
|
|
89
|
+
render: () => (
|
|
90
|
+
<Flex gap={6}>
|
|
91
|
+
<Typography variant="h4" className="text-white">Radio Group</Typography>
|
|
92
|
+
|
|
93
|
+
<Flex gap={4}>
|
|
94
|
+
<Typography variant="body2" className="text-grey-400">Plan Selection</Typography>
|
|
95
|
+
<RadioGroup defaultValue="pro">
|
|
96
|
+
<Flex direction="row" align="center" gap={2}>
|
|
97
|
+
<RadioGroupItem value="free" id="plan1" />
|
|
98
|
+
<Label htmlFor="plan1">Free - $0/month</Label>
|
|
99
|
+
</Flex>
|
|
100
|
+
<Flex direction="row" align="center" gap={2}>
|
|
101
|
+
<RadioGroupItem value="pro" id="plan2" />
|
|
102
|
+
<Label htmlFor="plan2">Pro - $9/month</Label>
|
|
103
|
+
</Flex>
|
|
104
|
+
<Flex direction="row" align="center" gap={2}>
|
|
105
|
+
<RadioGroupItem value="enterprise" id="plan3" />
|
|
106
|
+
<Label htmlFor="plan3">Enterprise - $29/month</Label>
|
|
107
|
+
</Flex>
|
|
108
|
+
</RadioGroup>
|
|
109
|
+
</Flex>
|
|
110
|
+
|
|
111
|
+
<Flex gap={4}>
|
|
112
|
+
<Typography variant="body2" className="text-grey-400">Size Comparison</Typography>
|
|
113
|
+
<Flex direction="row" gap={8}>
|
|
114
|
+
<Flex gap={2}>
|
|
115
|
+
<Typography variant="caption" className="text-grey-500">Small</Typography>
|
|
116
|
+
<RadioGroup defaultValue="a" className="gap-3">
|
|
117
|
+
<Flex direction="row" align="center" gap={2}>
|
|
118
|
+
<RadioGroupItem value="a" id="size-s1" size="small" />
|
|
119
|
+
<Label htmlFor="size-s1" className="text-sm">Option A</Label>
|
|
120
|
+
</Flex>
|
|
121
|
+
<Flex direction="row" align="center" gap={2}>
|
|
122
|
+
<RadioGroupItem value="b" id="size-s2" size="small" />
|
|
123
|
+
<Label htmlFor="size-s2" className="text-sm">Option B</Label>
|
|
124
|
+
</Flex>
|
|
125
|
+
</RadioGroup>
|
|
126
|
+
</Flex>
|
|
127
|
+
|
|
128
|
+
<Flex gap={2}>
|
|
129
|
+
<Typography variant="caption" className="text-grey-500">Regular</Typography>
|
|
130
|
+
<RadioGroup defaultValue="a" className="gap-3">
|
|
131
|
+
<Flex direction="row" align="center" gap={2}>
|
|
132
|
+
<RadioGroupItem value="a" id="size-r1" />
|
|
133
|
+
<Label htmlFor="size-r1">Option A</Label>
|
|
134
|
+
</Flex>
|
|
135
|
+
<Flex direction="row" align="center" gap={2}>
|
|
136
|
+
<RadioGroupItem value="b" id="size-r2" />
|
|
137
|
+
<Label htmlFor="size-r2">Option B</Label>
|
|
138
|
+
</Flex>
|
|
139
|
+
</RadioGroup>
|
|
140
|
+
</Flex>
|
|
141
|
+
</Flex>
|
|
142
|
+
</Flex>
|
|
143
|
+
|
|
144
|
+
<Flex gap={4}>
|
|
145
|
+
<Typography variant="body2" className="text-grey-400">Horizontal Layout</Typography>
|
|
146
|
+
<RadioGroup defaultValue="monthly" className="flex flex-row gap-6">
|
|
147
|
+
<Flex direction="row" align="center" gap={2}>
|
|
148
|
+
<RadioGroupItem value="monthly" id="billing1" />
|
|
149
|
+
<Label htmlFor="billing1">Monthly</Label>
|
|
150
|
+
</Flex>
|
|
151
|
+
<Flex direction="row" align="center" gap={2}>
|
|
152
|
+
<RadioGroupItem value="yearly" id="billing2" />
|
|
153
|
+
<Label htmlFor="billing2">Yearly</Label>
|
|
154
|
+
</Flex>
|
|
155
|
+
</RadioGroup>
|
|
156
|
+
</Flex>
|
|
157
|
+
</Flex>
|
|
158
|
+
),
|
|
159
|
+
}
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
import * as React from "react"
|
|
2
|
+
import * as RadioGroupPrimitive from "@radix-ui/react-radio-group"
|
|
3
|
+
import { Circle } from "lucide-react"
|
|
4
|
+
import { cva } from "class-variance-authority"
|
|
5
|
+
|
|
6
|
+
import { cn } from "../lib/utils"
|
|
7
|
+
|
|
8
|
+
type RadioGroupItemSize = "small" | "regular"
|
|
9
|
+
|
|
10
|
+
const RadioGroup = React.forwardRef<
|
|
11
|
+
React.ElementRef<typeof RadioGroupPrimitive.Root>,
|
|
12
|
+
React.ComponentPropsWithoutRef<typeof RadioGroupPrimitive.Root>
|
|
13
|
+
>(({ className, ...props }, ref) => {
|
|
14
|
+
return (
|
|
15
|
+
<RadioGroupPrimitive.Root
|
|
16
|
+
className={cn("grid gap-2", className)}
|
|
17
|
+
{...props}
|
|
18
|
+
ref={ref}
|
|
19
|
+
/>
|
|
20
|
+
)
|
|
21
|
+
})
|
|
22
|
+
RadioGroup.displayName = RadioGroupPrimitive.Root.displayName
|
|
23
|
+
|
|
24
|
+
const radioGroupItemVariants = cva(
|
|
25
|
+
"aspect-square rounded-full border border-grey-300 bg-white text-main-950 ring-offset-white focus:outline-none focus-visible:ring-2 focus-visible:ring-main-950 focus-visible:ring-offset-2 cursor-pointer disabled:cursor-not-allowed disabled:opacity-50 data-[state=checked]:border-main-950",
|
|
26
|
+
{
|
|
27
|
+
variants: {
|
|
28
|
+
size: {
|
|
29
|
+
small: "size-4",
|
|
30
|
+
regular: "size-5",
|
|
31
|
+
},
|
|
32
|
+
},
|
|
33
|
+
defaultVariants: {
|
|
34
|
+
size: "regular",
|
|
35
|
+
},
|
|
36
|
+
}
|
|
37
|
+
)
|
|
38
|
+
|
|
39
|
+
export interface RadioGroupItemProps
|
|
40
|
+
extends React.ComponentPropsWithoutRef<typeof RadioGroupPrimitive.Item> {
|
|
41
|
+
size?: RadioGroupItemSize
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
const RadioGroupItem = React.forwardRef<
|
|
45
|
+
React.ElementRef<typeof RadioGroupPrimitive.Item>,
|
|
46
|
+
RadioGroupItemProps
|
|
47
|
+
>(({ className, size, ...props }, ref) => {
|
|
48
|
+
return (
|
|
49
|
+
<RadioGroupPrimitive.Item
|
|
50
|
+
ref={ref}
|
|
51
|
+
className={cn(radioGroupItemVariants({ size }), className)}
|
|
52
|
+
{...props}
|
|
53
|
+
>
|
|
54
|
+
<RadioGroupPrimitive.Indicator className="flex items-center justify-center">
|
|
55
|
+
<Circle
|
|
56
|
+
className={cn(
|
|
57
|
+
"fill-main-950 text-main-950",
|
|
58
|
+
size === "small" ? "size-2" : "size-2.5"
|
|
59
|
+
)}
|
|
60
|
+
/>
|
|
61
|
+
</RadioGroupPrimitive.Indicator>
|
|
62
|
+
</RadioGroupPrimitive.Item>
|
|
63
|
+
)
|
|
64
|
+
})
|
|
65
|
+
RadioGroupItem.displayName = RadioGroupPrimitive.Item.displayName
|
|
66
|
+
|
|
67
|
+
export { RadioGroup, RadioGroupItem, radioGroupItemVariants }
|
|
68
|
+
export type { RadioGroupItemSize }
|