@mzc-fe/design-system 0.0.1-rc.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.
Files changed (160) hide show
  1. package/.husky/pre-push +21 -0
  2. package/.storybook/main.ts +11 -0
  3. package/.storybook/preview.tsx +30 -0
  4. package/.vscode/settings.json +12 -0
  5. package/.vscode/tailwind.json +105 -0
  6. package/README.md +136 -0
  7. package/bitbucket-pipelines.yml +52 -0
  8. package/components.json +21 -0
  9. package/eslint.config.js +38 -0
  10. package/package.json +98 -0
  11. package/public/vite.svg +1 -0
  12. package/src/components/accordion.stories.tsx +258 -0
  13. package/src/components/accordion.test.tsx +390 -0
  14. package/src/components/accordion.tsx +64 -0
  15. package/src/components/alert-dialog.stories.tsx +213 -0
  16. package/src/components/alert-dialog.test.tsx +80 -0
  17. package/src/components/alert-dialog.tsx +155 -0
  18. package/src/components/alert.stories.tsx +84 -0
  19. package/src/components/alert.test.tsx +35 -0
  20. package/src/components/alert.tsx +66 -0
  21. package/src/components/aspect-ratio.stories.tsx +97 -0
  22. package/src/components/aspect-ratio.test.tsx +47 -0
  23. package/src/components/aspect-ratio.tsx +11 -0
  24. package/src/components/avatar.stories.tsx +76 -0
  25. package/src/components/avatar.test.tsx +50 -0
  26. package/src/components/avatar.tsx +51 -0
  27. package/src/components/badge.stories.tsx +64 -0
  28. package/src/components/badge.test.tsx +34 -0
  29. package/src/components/badge.tsx +46 -0
  30. package/src/components/breadcrumb.stories.tsx +86 -0
  31. package/src/components/breadcrumb.test.tsx +74 -0
  32. package/src/components/breadcrumb.tsx +109 -0
  33. package/src/components/button-group.stories.tsx +62 -0
  34. package/src/components/button-group.tsx +83 -0
  35. package/src/components/button.stories.tsx +118 -0
  36. package/src/components/button.test.tsx +64 -0
  37. package/src/components/button.tsx +62 -0
  38. package/src/components/calendar.stories.tsx +81 -0
  39. package/src/components/calendar.tsx +220 -0
  40. package/src/components/card.stories.tsx +110 -0
  41. package/src/components/card.test.tsx +56 -0
  42. package/src/components/card.tsx +92 -0
  43. package/src/components/carousel.stories.tsx +90 -0
  44. package/src/components/carousel.tsx +239 -0
  45. package/src/components/chart.tsx +357 -0
  46. package/src/components/checkbox.stories.tsx +108 -0
  47. package/src/components/checkbox.test.tsx +67 -0
  48. package/src/components/checkbox.tsx +32 -0
  49. package/src/components/collapsible.stories.tsx +106 -0
  50. package/src/components/collapsible.test.tsx +92 -0
  51. package/src/components/collapsible.tsx +31 -0
  52. package/src/components/command.stories.tsx +90 -0
  53. package/src/components/command.tsx +182 -0
  54. package/src/components/context-menu.stories.tsx +63 -0
  55. package/src/components/context-menu.tsx +252 -0
  56. package/src/components/dialog.stories.tsx +128 -0
  57. package/src/components/dialog.tsx +141 -0
  58. package/src/components/drawer.stories.tsx +104 -0
  59. package/src/components/drawer.tsx +135 -0
  60. package/src/components/dropdown-menu.stories.tsx +97 -0
  61. package/src/components/dropdown-menu.tsx +255 -0
  62. package/src/components/empty.stories.tsx +90 -0
  63. package/src/components/empty.test.tsx +55 -0
  64. package/src/components/empty.tsx +104 -0
  65. package/src/components/field.tsx +246 -0
  66. package/src/components/form.tsx +168 -0
  67. package/src/components/hover-card.stories.tsx +66 -0
  68. package/src/components/hover-card.tsx +44 -0
  69. package/src/components/input-group.stories.tsx +57 -0
  70. package/src/components/input-group.test.tsx +40 -0
  71. package/src/components/input-group.tsx +170 -0
  72. package/src/components/input-otp.stories.tsx +94 -0
  73. package/src/components/input-otp.test.tsx +60 -0
  74. package/src/components/input-otp.tsx +75 -0
  75. package/src/components/input.stories.tsx +94 -0
  76. package/src/components/input.test.tsx +53 -0
  77. package/src/components/input.tsx +21 -0
  78. package/src/components/item.tsx +193 -0
  79. package/src/components/kbd.stories.tsx +100 -0
  80. package/src/components/kbd.test.tsx +28 -0
  81. package/src/components/kbd.tsx +28 -0
  82. package/src/components/label.stories.tsx +48 -0
  83. package/src/components/label.test.tsx +28 -0
  84. package/src/components/label.tsx +24 -0
  85. package/src/components/menubar.tsx +274 -0
  86. package/src/components/navigation-menu.tsx +168 -0
  87. package/src/components/pagination.stories.tsx +107 -0
  88. package/src/components/pagination.tsx +127 -0
  89. package/src/components/popover.stories.tsx +102 -0
  90. package/src/components/popover.tsx +48 -0
  91. package/src/components/progress.stories.tsx +76 -0
  92. package/src/components/progress.test.tsx +36 -0
  93. package/src/components/progress.tsx +29 -0
  94. package/src/components/radio-group.stories.tsx +73 -0
  95. package/src/components/radio-group.test.tsx +74 -0
  96. package/src/components/radio-group.tsx +45 -0
  97. package/src/components/resizable.stories.tsx +120 -0
  98. package/src/components/resizable.tsx +54 -0
  99. package/src/components/scroll-area.stories.tsx +64 -0
  100. package/src/components/scroll-area.test.tsx +46 -0
  101. package/src/components/scroll-area.tsx +58 -0
  102. package/src/components/select.stories.tsx +111 -0
  103. package/src/components/select.test.tsx +90 -0
  104. package/src/components/select.tsx +188 -0
  105. package/src/components/separator.stories.tsx +76 -0
  106. package/src/components/separator.test.tsx +24 -0
  107. package/src/components/separator.tsx +28 -0
  108. package/src/components/sheet.stories.tsx +122 -0
  109. package/src/components/sheet.tsx +137 -0
  110. package/src/components/sidebar.tsx +726 -0
  111. package/src/components/skeleton.stories.tsx +53 -0
  112. package/src/components/skeleton.test.tsx +24 -0
  113. package/src/components/skeleton.tsx +13 -0
  114. package/src/components/slider.stories.tsx +97 -0
  115. package/src/components/slider.test.tsx +49 -0
  116. package/src/components/slider.tsx +63 -0
  117. package/src/components/sonner.stories.tsx +96 -0
  118. package/src/components/sonner.tsx +38 -0
  119. package/src/components/spinner.stories.tsx +54 -0
  120. package/src/components/spinner.test.tsx +30 -0
  121. package/src/components/spinner.tsx +16 -0
  122. package/src/components/switch.stories.tsx +108 -0
  123. package/src/components/switch.test.tsx +62 -0
  124. package/src/components/switch.tsx +31 -0
  125. package/src/components/table.stories.tsx +139 -0
  126. package/src/components/table.test.tsx +85 -0
  127. package/src/components/table.tsx +114 -0
  128. package/src/components/tabs.stories.tsx +99 -0
  129. package/src/components/tabs.test.tsx +64 -0
  130. package/src/components/tabs.tsx +66 -0
  131. package/src/components/textarea.stories.tsx +89 -0
  132. package/src/components/textarea.test.tsx +53 -0
  133. package/src/components/textarea.tsx +18 -0
  134. package/src/components/toggle-group.stories.tsx +108 -0
  135. package/src/components/toggle-group.test.tsx +66 -0
  136. package/src/components/toggle-group.tsx +81 -0
  137. package/src/components/toggle.stories.tsx +98 -0
  138. package/src/components/toggle.test.tsx +42 -0
  139. package/src/components/toggle.tsx +45 -0
  140. package/src/components/tooltip.stories.tsx +111 -0
  141. package/src/components/tooltip.tsx +61 -0
  142. package/src/foundations/README.md +141 -0
  143. package/src/foundations/ThemeProvider.tsx +77 -0
  144. package/src/foundations/color.css +232 -0
  145. package/src/foundations/color.stories.tsx +719 -0
  146. package/src/foundations/palette.css +249 -0
  147. package/src/foundations/spacing.css +8 -0
  148. package/src/foundations/typography.css +143 -0
  149. package/src/foundations/typography.stories.tsx +17 -0
  150. package/src/hooks/use-mobile.ts +19 -0
  151. package/src/index.css +176 -0
  152. package/src/index.ts +336 -0
  153. package/src/lib/utils.ts +6 -0
  154. package/src/test/setup.ts +8 -0
  155. package/src/vite-env.d.ts +1 -0
  156. package/tsconfig.app.json +33 -0
  157. package/tsconfig.json +13 -0
  158. package/tsconfig.node.json +25 -0
  159. package/vite.config.ts +30 -0
  160. package/vitest.config.ts +25 -0
@@ -0,0 +1,109 @@
1
+ import * as React from "react"
2
+ import { Slot } from "@radix-ui/react-slot"
3
+ import { ChevronRight, MoreHorizontal } from "lucide-react"
4
+
5
+ import { cn } from "@/lib/utils"
6
+
7
+ function Breadcrumb({ ...props }: React.ComponentProps<"nav">) {
8
+ return <nav aria-label="breadcrumb" data-slot="breadcrumb" {...props} />
9
+ }
10
+
11
+ function BreadcrumbList({ className, ...props }: React.ComponentProps<"ol">) {
12
+ return (
13
+ <ol
14
+ data-slot="breadcrumb-list"
15
+ className={cn(
16
+ "text-muted-foreground flex flex-wrap items-center gap-1.5 text-sm break-words sm:gap-2.5",
17
+ className
18
+ )}
19
+ {...props}
20
+ />
21
+ )
22
+ }
23
+
24
+ function BreadcrumbItem({ className, ...props }: React.ComponentProps<"li">) {
25
+ return (
26
+ <li
27
+ data-slot="breadcrumb-item"
28
+ className={cn("inline-flex items-center gap-1.5", className)}
29
+ {...props}
30
+ />
31
+ )
32
+ }
33
+
34
+ function BreadcrumbLink({
35
+ asChild,
36
+ className,
37
+ ...props
38
+ }: React.ComponentProps<"a"> & {
39
+ asChild?: boolean
40
+ }) {
41
+ const Comp = asChild ? Slot : "a"
42
+
43
+ return (
44
+ <Comp
45
+ data-slot="breadcrumb-link"
46
+ className={cn("hover:text-foreground transition-colors", className)}
47
+ {...props}
48
+ />
49
+ )
50
+ }
51
+
52
+ function BreadcrumbPage({ className, ...props }: React.ComponentProps<"span">) {
53
+ return (
54
+ <span
55
+ data-slot="breadcrumb-page"
56
+ role="link"
57
+ aria-disabled="true"
58
+ aria-current="page"
59
+ className={cn("text-foreground font-normal", className)}
60
+ {...props}
61
+ />
62
+ )
63
+ }
64
+
65
+ function BreadcrumbSeparator({
66
+ children,
67
+ className,
68
+ ...props
69
+ }: React.ComponentProps<"li">) {
70
+ return (
71
+ <li
72
+ data-slot="breadcrumb-separator"
73
+ role="presentation"
74
+ aria-hidden="true"
75
+ className={cn("[&>svg]:size-3.5", className)}
76
+ {...props}
77
+ >
78
+ {children ?? <ChevronRight />}
79
+ </li>
80
+ )
81
+ }
82
+
83
+ function BreadcrumbEllipsis({
84
+ className,
85
+ ...props
86
+ }: React.ComponentProps<"span">) {
87
+ return (
88
+ <span
89
+ data-slot="breadcrumb-ellipsis"
90
+ role="presentation"
91
+ aria-hidden="true"
92
+ className={cn("flex size-9 items-center justify-center", className)}
93
+ {...props}
94
+ >
95
+ <MoreHorizontal className="size-4" />
96
+ <span className="sr-only">More</span>
97
+ </span>
98
+ )
99
+ }
100
+
101
+ export {
102
+ Breadcrumb,
103
+ BreadcrumbList,
104
+ BreadcrumbItem,
105
+ BreadcrumbLink,
106
+ BreadcrumbPage,
107
+ BreadcrumbSeparator,
108
+ BreadcrumbEllipsis,
109
+ }
@@ -0,0 +1,62 @@
1
+ import type { Meta, StoryObj } from "@storybook/react-vite";
2
+ import { ButtonGroup, ButtonGroupText } from "./button-group";
3
+ import { Button } from "./button";
4
+ import { Input } from "./input";
5
+
6
+ const meta = {
7
+ title: "Components/ButtonGroup",
8
+ component: ButtonGroup,
9
+ parameters: {
10
+ layout: "padded",
11
+ },
12
+ tags: ["autodocs"],
13
+ argTypes: {
14
+ orientation: {
15
+ control: "select",
16
+ options: ["horizontal", "vertical"],
17
+ description: "The orientation of the button group.",
18
+ },
19
+ },
20
+ } satisfies Meta<typeof ButtonGroup>;
21
+
22
+ export default meta;
23
+ type Story = StoryObj<typeof meta>;
24
+
25
+ export const Default: Story = {
26
+ render: () => (
27
+ <ButtonGroup>
28
+ <Button>One</Button>
29
+ <Button>Two</Button>
30
+ <Button>Three</Button>
31
+ </ButtonGroup>
32
+ ),
33
+ };
34
+
35
+ export const WithInput: Story = {
36
+ render: () => (
37
+ <ButtonGroup>
38
+ <Input placeholder="Search..." className="w-[200px]" />
39
+ <Button>Search</Button>
40
+ </ButtonGroup>
41
+ ),
42
+ };
43
+
44
+ export const Vertical: Story = {
45
+ render: () => (
46
+ <ButtonGroup orientation="vertical">
47
+ <Button>One</Button>
48
+ <Button>Two</Button>
49
+ <Button>Three</Button>
50
+ </ButtonGroup>
51
+ ),
52
+ };
53
+
54
+ export const WithText: Story = {
55
+ render: () => (
56
+ <ButtonGroup>
57
+ <ButtonGroupText>Label:</ButtonGroupText>
58
+ <Button>Action</Button>
59
+ </ButtonGroup>
60
+ ),
61
+ };
62
+
@@ -0,0 +1,83 @@
1
+ import { Slot } from "@radix-ui/react-slot";
2
+ import { cva, type VariantProps } from "class-variance-authority";
3
+
4
+ import { cn } from "@/lib/utils";
5
+ import { Separator } from "@/components/separator";
6
+
7
+ const buttonGroupVariants = cva(
8
+ "flex w-fit items-stretch [&>*]:focus-visible:z-10 [&>*]:focus-visible:relative [&>[data-slot=select-trigger]:not([class*='w-'])]:w-fit [&>input]:flex-1 has-[select[aria-hidden=true]:last-child]:[&>[data-slot=select-trigger]:last-of-type]:rounded-r-md has-[>[data-slot=button-group]]:gap-2",
9
+ {
10
+ variants: {
11
+ orientation: {
12
+ horizontal:
13
+ "[&>*:not(:first-child)]:rounded-l-none [&>*:not(:first-child)]:border-l-0 [&>*:not(:last-child)]:rounded-r-none",
14
+ vertical:
15
+ "flex-col [&>*:not(:first-child)]:rounded-t-none [&>*:not(:first-child)]:border-t-0 [&>*:not(:last-child)]:rounded-b-none",
16
+ },
17
+ },
18
+ defaultVariants: {
19
+ orientation: "horizontal",
20
+ },
21
+ }
22
+ );
23
+
24
+ function ButtonGroup({
25
+ className,
26
+ orientation,
27
+ ...props
28
+ }: React.ComponentProps<"div"> & VariantProps<typeof buttonGroupVariants>) {
29
+ return (
30
+ <div
31
+ role="group"
32
+ data-slot="button-group"
33
+ data-orientation={orientation}
34
+ className={cn(buttonGroupVariants({ orientation }), className)}
35
+ {...props}
36
+ />
37
+ );
38
+ }
39
+
40
+ function ButtonGroupText({
41
+ className,
42
+ asChild = false,
43
+ ...props
44
+ }: React.ComponentProps<"div"> & {
45
+ asChild?: boolean;
46
+ }) {
47
+ const Comp = asChild ? Slot : "div";
48
+
49
+ return (
50
+ <Comp
51
+ className={cn(
52
+ "bg-muted flex items-center gap-2 rounded-md border px-4 text-sm font-medium shadow-xs [&_svg]:pointer-events-none [&_svg:not([class*='size-'])]:size-4",
53
+ className
54
+ )}
55
+ {...props}
56
+ />
57
+ );
58
+ }
59
+
60
+ function ButtonGroupSeparator({
61
+ className,
62
+ orientation = "vertical",
63
+ ...props
64
+ }: React.ComponentProps<typeof Separator>) {
65
+ return (
66
+ <Separator
67
+ data-slot="button-group-separator"
68
+ orientation={orientation}
69
+ className={cn(
70
+ "bg-input relative !m-0 self-stretch data-[orientation=vertical]:h-auto",
71
+ className
72
+ )}
73
+ {...props}
74
+ />
75
+ );
76
+ }
77
+
78
+ export {
79
+ ButtonGroup,
80
+ ButtonGroupSeparator,
81
+ ButtonGroupText,
82
+ buttonGroupVariants,
83
+ };
@@ -0,0 +1,118 @@
1
+ import type { Meta, StoryObj } from "@storybook/react-vite";
2
+ import { Button } from "./button";
3
+ import { DownloadIcon } from "lucide-react";
4
+
5
+ const meta = {
6
+ title: "Components/Button",
7
+ component: Button,
8
+ parameters: {
9
+ layout: "padded",
10
+ },
11
+ tags: ["autodocs"],
12
+ argTypes: {
13
+ variant: {
14
+ control: "select",
15
+ options: [
16
+ "default",
17
+ "destructive",
18
+ "outline",
19
+ "secondary",
20
+ "ghost",
21
+ "link",
22
+ ],
23
+ description: "The visual style variant of the button.",
24
+ },
25
+ size: {
26
+ control: "select",
27
+ options: ["default", "sm", "lg", "icon", "icon-sm", "icon-lg"],
28
+ description: "The size of the button.",
29
+ },
30
+ disabled: {
31
+ control: "boolean",
32
+ description: "Whether the button is disabled.",
33
+ },
34
+ asChild: {
35
+ control: "boolean",
36
+ description: "Render as a child component instead of a button element.",
37
+ },
38
+ },
39
+ } satisfies Meta<typeof Button>;
40
+
41
+ export default meta;
42
+ type Story = StoryObj<typeof meta>;
43
+
44
+ export const Default: Story = {
45
+ args: {
46
+ children: "Button",
47
+ variant: "default",
48
+ size: "default",
49
+ },
50
+ };
51
+
52
+ export const Variants: Story = {
53
+ render: () => (
54
+ <div className="flex flex-wrap gap-4">
55
+ <Button variant="default">Default</Button>
56
+ <Button variant="destructive">Destructive</Button>
57
+ <Button variant="outline">Outline</Button>
58
+ <Button variant="secondary">Secondary</Button>
59
+ <Button variant="ghost">Ghost</Button>
60
+ <Button variant="link">Link</Button>
61
+ </div>
62
+ ),
63
+ };
64
+
65
+ export const Sizes: Story = {
66
+ render: () => (
67
+ <div className="flex items-center gap-4">
68
+ <Button size="sm">Small</Button>
69
+ <Button size="default">Default</Button>
70
+ <Button size="lg">Large</Button>
71
+ </div>
72
+ ),
73
+ };
74
+
75
+ export const WithIcon: Story = {
76
+ render: () => (
77
+ <div className="flex flex-wrap gap-4">
78
+ <Button>
79
+ <DownloadIcon />
80
+ Download
81
+ </Button>
82
+ <Button variant="outline">
83
+ <DownloadIcon />
84
+ Download
85
+ </Button>
86
+ </div>
87
+ ),
88
+ };
89
+
90
+ export const IconOnly: Story = {
91
+ render: () => (
92
+ <div className="flex items-center gap-4">
93
+ <Button size="icon-sm" variant="outline">
94
+ <DownloadIcon />
95
+ </Button>
96
+ <Button size="icon" variant="outline">
97
+ <DownloadIcon />
98
+ </Button>
99
+ <Button size="icon-lg" variant="outline">
100
+ <DownloadIcon />
101
+ </Button>
102
+ </div>
103
+ ),
104
+ };
105
+
106
+ export const Disabled: Story = {
107
+ render: () => (
108
+ <div className="flex flex-wrap gap-4">
109
+ <Button disabled>Disabled</Button>
110
+ <Button variant="outline" disabled>
111
+ Disabled Outline
112
+ </Button>
113
+ <Button variant="destructive" disabled>
114
+ Disabled Destructive
115
+ </Button>
116
+ </div>
117
+ ),
118
+ };
@@ -0,0 +1,64 @@
1
+ import { describe, it, expect, vi } from "vitest";
2
+ import { render } from "@testing-library/react";
3
+ import userEvent from "@testing-library/user-event";
4
+ import { Button } from "./button";
5
+
6
+ describe("Button", () => {
7
+ it("should render button with text", () => {
8
+ const { getByText } = render(<Button>Click me</Button>);
9
+ expect(getByText("Click me")).toBeInTheDocument();
10
+ });
11
+
12
+ it("should apply variant classes", () => {
13
+ const { container } = render(<Button variant="destructive">Delete</Button>);
14
+ const button = container.querySelector('[data-slot="button"]');
15
+ expect(button).toHaveAttribute("data-variant", "destructive");
16
+ });
17
+
18
+ it("should apply size classes", () => {
19
+ const { container } = render(<Button size="lg">Large</Button>);
20
+ const button = container.querySelector('[data-slot="button"]');
21
+ expect(button).toHaveAttribute("data-size", "lg");
22
+ });
23
+
24
+ it("should be disabled when disabled prop is true", () => {
25
+ const { container } = render(<Button disabled>Disabled</Button>);
26
+ const button = container.querySelector(
27
+ '[data-slot="button"]'
28
+ ) as HTMLButtonElement;
29
+ expect(button).toBeDisabled();
30
+ });
31
+
32
+ it("should call onClick handler when clicked", async () => {
33
+ const user = userEvent.setup();
34
+ const handleClick = vi.fn();
35
+ const { getByText } = render(
36
+ <Button onClick={handleClick}>Click me</Button>
37
+ );
38
+ await user.click(getByText("Click me"));
39
+ expect(handleClick).toHaveBeenCalledTimes(1);
40
+ });
41
+
42
+ it("should not call onClick when disabled", async () => {
43
+ const user = userEvent.setup();
44
+ const handleClick = vi.fn();
45
+ const { getByText } = render(
46
+ <Button disabled onClick={handleClick}>
47
+ Disabled
48
+ </Button>
49
+ );
50
+ await user.click(getByText("Disabled"));
51
+ expect(handleClick).not.toHaveBeenCalled();
52
+ });
53
+
54
+ it("should render as child component when asChild is true", () => {
55
+ const { container } = render(
56
+ <Button asChild>
57
+ <a href="/test">Link Button</a>
58
+ </Button>
59
+ );
60
+ const link = container.querySelector("a");
61
+ expect(link).toBeInTheDocument();
62
+ expect(link).toHaveTextContent("Link Button");
63
+ });
64
+ });
@@ -0,0 +1,62 @@
1
+ import * as React from "react"
2
+ import { Slot } from "@radix-ui/react-slot"
3
+ import { cva, type VariantProps } from "class-variance-authority"
4
+
5
+ import { cn } from "@/lib/utils"
6
+
7
+ const buttonVariants = cva(
8
+ "inline-flex items-center justify-center gap-2 whitespace-nowrap rounded-md text-sm font-medium transition-all disabled:pointer-events-none disabled:opacity-50 [&_svg]:pointer-events-none [&_svg:not([class*='size-'])]:size-4 shrink-0 [&_svg]:shrink-0 outline-none focus-visible:border-ring focus-visible:ring-ring/50 focus-visible:ring-[3px] aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 aria-invalid:border-destructive",
9
+ {
10
+ variants: {
11
+ variant: {
12
+ default: "bg-primary text-primary-foreground hover:bg-primary/90",
13
+ destructive:
14
+ "bg-destructive text-white hover:bg-destructive/90 focus-visible:ring-destructive/20 dark:focus-visible:ring-destructive/40 dark:bg-destructive/60",
15
+ outline:
16
+ "border bg-background shadow-xs hover:bg-accent hover:text-accent-foreground dark:bg-input/30 dark:border-input dark:hover:bg-input/50",
17
+ secondary:
18
+ "bg-secondary text-secondary-foreground hover:bg-secondary/80",
19
+ ghost:
20
+ "hover:bg-accent hover:text-accent-foreground dark:hover:bg-accent/50",
21
+ link: "text-primary underline-offset-4 hover:underline",
22
+ },
23
+ size: {
24
+ default: "h-9 px-4 py-2 has-[>svg]:px-3",
25
+ sm: "h-8 rounded-md gap-1.5 px-3 has-[>svg]:px-2.5",
26
+ lg: "h-10 rounded-md px-6 has-[>svg]:px-4",
27
+ icon: "size-9",
28
+ "icon-sm": "size-8",
29
+ "icon-lg": "size-10",
30
+ },
31
+ },
32
+ defaultVariants: {
33
+ variant: "default",
34
+ size: "default",
35
+ },
36
+ }
37
+ )
38
+
39
+ function Button({
40
+ className,
41
+ variant = "default",
42
+ size = "default",
43
+ asChild = false,
44
+ ...props
45
+ }: React.ComponentProps<"button"> &
46
+ VariantProps<typeof buttonVariants> & {
47
+ asChild?: boolean
48
+ }) {
49
+ const Comp = asChild ? Slot : "button"
50
+
51
+ return (
52
+ <Comp
53
+ data-slot="button"
54
+ data-variant={variant}
55
+ data-size={size}
56
+ className={cn(buttonVariants({ variant, size, className }))}
57
+ {...props}
58
+ />
59
+ )
60
+ }
61
+
62
+ export { Button, buttonVariants }
@@ -0,0 +1,81 @@
1
+ import type { Meta, StoryObj } from "@storybook/react-vite";
2
+ import { useState } from "react";
3
+ import { Calendar } from "./calendar";
4
+
5
+ const meta = {
6
+ title: "Components/Calendar",
7
+ component: Calendar,
8
+ parameters: {
9
+ layout: "padded",
10
+ },
11
+ tags: ["autodocs"],
12
+ } satisfies Meta<typeof Calendar>;
13
+
14
+ export default meta;
15
+ type Story = StoryObj<typeof meta>;
16
+
17
+ export const Default: Story = {
18
+ render: () => {
19
+ const [date, setDate] = useState<Date | undefined>(new Date());
20
+ return (
21
+ <Calendar
22
+ mode="single"
23
+ selected={date}
24
+ onSelect={setDate}
25
+ className="rounded-md border"
26
+ />
27
+ );
28
+ },
29
+ };
30
+
31
+ export const Range: Story = {
32
+ render: () => {
33
+ const [dateRange, setDateRange] = useState<{
34
+ from: Date | undefined;
35
+ to: Date | undefined;
36
+ }>({ from: undefined, to: undefined });
37
+ return (
38
+ <Calendar
39
+ mode="range"
40
+ selected={dateRange}
41
+ onSelect={(range) =>
42
+ setDateRange({
43
+ from: range?.from,
44
+ to: range?.to,
45
+ })
46
+ }
47
+ className="rounded-md border"
48
+ />
49
+ );
50
+ },
51
+ };
52
+
53
+ export const Multiple: Story = {
54
+ render: () => {
55
+ const [dates, setDates] = useState<Date[] | undefined>([]);
56
+ return (
57
+ <Calendar
58
+ mode="multiple"
59
+ selected={dates}
60
+ onSelect={setDates}
61
+ className="rounded-md border"
62
+ />
63
+ );
64
+ },
65
+ };
66
+
67
+ export const WithDisabledDates: Story = {
68
+ render: () => {
69
+ const [date, setDate] = useState<Date | undefined>(new Date());
70
+ return (
71
+ <Calendar
72
+ mode="single"
73
+ selected={date}
74
+ onSelect={setDate}
75
+ disabled={(date) => date < new Date()}
76
+ className="rounded-md border"
77
+ />
78
+ );
79
+ },
80
+ };
81
+