@mzc-fe/design-system 0.0.1 → 0.0.2

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 (219) hide show
  1. package/dist/components/accordion.d.ts +7 -0
  2. package/dist/components/alert-dialog.d.ts +14 -0
  3. package/dist/components/alert.d.ts +9 -0
  4. package/dist/components/aspect-ratio.d.ts +3 -0
  5. package/dist/components/avatar.d.ts +6 -0
  6. package/dist/components/badge.d.ts +9 -0
  7. package/dist/components/breadcrumb.d.ts +11 -0
  8. package/dist/components/button-group.d.ts +11 -0
  9. package/dist/components/button.d.ts +10 -0
  10. package/dist/components/calendar.d.ts +8 -0
  11. package/dist/components/card.d.ts +9 -0
  12. package/dist/components/carousel.d.ts +19 -0
  13. package/dist/components/chart.d.ts +40 -0
  14. package/dist/components/checkbox.d.ts +4 -0
  15. package/dist/components/collapsible.d.ts +5 -0
  16. package/dist/components/command.d.ts +18 -0
  17. package/dist/components/context-menu.d.ts +25 -0
  18. package/dist/components/dialog.d.ts +15 -0
  19. package/dist/components/drawer.d.ts +13 -0
  20. package/dist/components/dropdown-menu.d.ts +25 -0
  21. package/dist/components/empty.d.ts +11 -0
  22. package/dist/components/field.d.ts +24 -0
  23. package/dist/components/form.d.ts +24 -0
  24. package/dist/components/hover-card.d.ts +6 -0
  25. package/dist/components/input-group.d.ts +16 -0
  26. package/dist/components/input-otp.d.ts +11 -0
  27. package/dist/components/input.d.ts +3 -0
  28. package/dist/components/item.d.ts +23 -0
  29. package/dist/components/kbd.d.ts +3 -0
  30. package/dist/components/label.d.ts +4 -0
  31. package/dist/components/menubar.d.ts +26 -0
  32. package/dist/components/navigation-menu.d.ts +14 -0
  33. package/dist/components/pagination.d.ts +13 -0
  34. package/dist/components/popover.d.ts +7 -0
  35. package/dist/components/progress.d.ts +4 -0
  36. package/dist/components/radio-group.d.ts +5 -0
  37. package/dist/components/resizable.d.ts +8 -0
  38. package/dist/components/scroll-area.d.ts +5 -0
  39. package/dist/components/select.d.ts +15 -0
  40. package/dist/components/separator.d.ts +4 -0
  41. package/dist/components/sheet.d.ts +13 -0
  42. package/dist/components/sidebar.d.ts +69 -0
  43. package/dist/components/skeleton.d.ts +2 -0
  44. package/dist/components/slider.d.ts +4 -0
  45. package/dist/components/sonner.d.ts +3 -0
  46. package/dist/components/spinner.d.ts +2 -0
  47. package/dist/components/switch.d.ts +4 -0
  48. package/dist/components/table.d.ts +10 -0
  49. package/dist/components/tabs.d.ts +7 -0
  50. package/dist/components/textarea.d.ts +3 -0
  51. package/dist/components/toggle-group.d.ts +9 -0
  52. package/dist/components/toggle.d.ts +9 -0
  53. package/dist/components/tooltip.d.ts +7 -0
  54. package/dist/design-system.css +1 -0
  55. package/dist/design-system.es.js +30200 -0
  56. package/dist/design-system.umd.js +260 -0
  57. package/dist/foundations/ThemeProvider.d.ts +13 -0
  58. package/dist/hooks/use-mobile.d.ts +1 -0
  59. package/dist/index.d.ts +54 -0
  60. package/dist/lib/utils.d.ts +2 -0
  61. package/package.json +14 -1
  62. package/.husky/pre-push +0 -21
  63. package/.storybook/main.ts +0 -11
  64. package/.storybook/preview.tsx +0 -30
  65. package/.vscode/settings.json +0 -12
  66. package/.vscode/tailwind.json +0 -105
  67. package/bitbucket-pipelines.yml +0 -50
  68. package/components.json +0 -21
  69. package/eslint.config.js +0 -38
  70. package/src/components/accordion.stories.tsx +0 -258
  71. package/src/components/accordion.test.tsx +0 -390
  72. package/src/components/accordion.tsx +0 -64
  73. package/src/components/alert-dialog.stories.tsx +0 -213
  74. package/src/components/alert-dialog.test.tsx +0 -80
  75. package/src/components/alert-dialog.tsx +0 -155
  76. package/src/components/alert.stories.tsx +0 -84
  77. package/src/components/alert.test.tsx +0 -35
  78. package/src/components/alert.tsx +0 -66
  79. package/src/components/aspect-ratio.stories.tsx +0 -97
  80. package/src/components/aspect-ratio.test.tsx +0 -47
  81. package/src/components/aspect-ratio.tsx +0 -11
  82. package/src/components/avatar.stories.tsx +0 -76
  83. package/src/components/avatar.test.tsx +0 -50
  84. package/src/components/avatar.tsx +0 -51
  85. package/src/components/badge.stories.tsx +0 -64
  86. package/src/components/badge.test.tsx +0 -34
  87. package/src/components/badge.tsx +0 -46
  88. package/src/components/breadcrumb.stories.tsx +0 -86
  89. package/src/components/breadcrumb.test.tsx +0 -74
  90. package/src/components/breadcrumb.tsx +0 -109
  91. package/src/components/button-group.stories.tsx +0 -62
  92. package/src/components/button-group.tsx +0 -83
  93. package/src/components/button.stories.tsx +0 -118
  94. package/src/components/button.test.tsx +0 -64
  95. package/src/components/button.tsx +0 -62
  96. package/src/components/calendar.stories.tsx +0 -81
  97. package/src/components/calendar.tsx +0 -220
  98. package/src/components/card.stories.tsx +0 -110
  99. package/src/components/card.test.tsx +0 -56
  100. package/src/components/card.tsx +0 -92
  101. package/src/components/carousel.stories.tsx +0 -90
  102. package/src/components/carousel.tsx +0 -239
  103. package/src/components/chart.tsx +0 -357
  104. package/src/components/checkbox.stories.tsx +0 -108
  105. package/src/components/checkbox.test.tsx +0 -67
  106. package/src/components/checkbox.tsx +0 -32
  107. package/src/components/collapsible.stories.tsx +0 -106
  108. package/src/components/collapsible.test.tsx +0 -92
  109. package/src/components/collapsible.tsx +0 -31
  110. package/src/components/command.stories.tsx +0 -90
  111. package/src/components/command.tsx +0 -182
  112. package/src/components/context-menu.stories.tsx +0 -63
  113. package/src/components/context-menu.tsx +0 -252
  114. package/src/components/dialog.stories.tsx +0 -128
  115. package/src/components/dialog.tsx +0 -141
  116. package/src/components/drawer.stories.tsx +0 -104
  117. package/src/components/drawer.tsx +0 -135
  118. package/src/components/dropdown-menu.stories.tsx +0 -97
  119. package/src/components/dropdown-menu.tsx +0 -255
  120. package/src/components/empty.stories.tsx +0 -90
  121. package/src/components/empty.test.tsx +0 -55
  122. package/src/components/empty.tsx +0 -104
  123. package/src/components/field.tsx +0 -246
  124. package/src/components/form.tsx +0 -168
  125. package/src/components/hover-card.stories.tsx +0 -66
  126. package/src/components/hover-card.tsx +0 -44
  127. package/src/components/input-group.stories.tsx +0 -57
  128. package/src/components/input-group.test.tsx +0 -40
  129. package/src/components/input-group.tsx +0 -170
  130. package/src/components/input-otp.stories.tsx +0 -94
  131. package/src/components/input-otp.test.tsx +0 -60
  132. package/src/components/input-otp.tsx +0 -75
  133. package/src/components/input.stories.tsx +0 -94
  134. package/src/components/input.test.tsx +0 -53
  135. package/src/components/input.tsx +0 -21
  136. package/src/components/item.tsx +0 -193
  137. package/src/components/kbd.stories.tsx +0 -100
  138. package/src/components/kbd.test.tsx +0 -28
  139. package/src/components/kbd.tsx +0 -28
  140. package/src/components/label.stories.tsx +0 -48
  141. package/src/components/label.test.tsx +0 -28
  142. package/src/components/label.tsx +0 -24
  143. package/src/components/menubar.tsx +0 -274
  144. package/src/components/navigation-menu.tsx +0 -168
  145. package/src/components/pagination.stories.tsx +0 -107
  146. package/src/components/pagination.tsx +0 -127
  147. package/src/components/popover.stories.tsx +0 -102
  148. package/src/components/popover.tsx +0 -48
  149. package/src/components/progress.stories.tsx +0 -76
  150. package/src/components/progress.test.tsx +0 -36
  151. package/src/components/progress.tsx +0 -29
  152. package/src/components/radio-group.stories.tsx +0 -73
  153. package/src/components/radio-group.test.tsx +0 -74
  154. package/src/components/radio-group.tsx +0 -45
  155. package/src/components/resizable.stories.tsx +0 -120
  156. package/src/components/resizable.tsx +0 -54
  157. package/src/components/scroll-area.stories.tsx +0 -64
  158. package/src/components/scroll-area.test.tsx +0 -46
  159. package/src/components/scroll-area.tsx +0 -58
  160. package/src/components/select.stories.tsx +0 -111
  161. package/src/components/select.test.tsx +0 -90
  162. package/src/components/select.tsx +0 -188
  163. package/src/components/separator.stories.tsx +0 -76
  164. package/src/components/separator.test.tsx +0 -24
  165. package/src/components/separator.tsx +0 -28
  166. package/src/components/sheet.stories.tsx +0 -122
  167. package/src/components/sheet.tsx +0 -137
  168. package/src/components/sidebar.tsx +0 -726
  169. package/src/components/skeleton.stories.tsx +0 -53
  170. package/src/components/skeleton.test.tsx +0 -24
  171. package/src/components/skeleton.tsx +0 -13
  172. package/src/components/slider.stories.tsx +0 -97
  173. package/src/components/slider.test.tsx +0 -49
  174. package/src/components/slider.tsx +0 -63
  175. package/src/components/sonner.stories.tsx +0 -96
  176. package/src/components/sonner.tsx +0 -38
  177. package/src/components/spinner.stories.tsx +0 -54
  178. package/src/components/spinner.test.tsx +0 -30
  179. package/src/components/spinner.tsx +0 -16
  180. package/src/components/switch.stories.tsx +0 -108
  181. package/src/components/switch.test.tsx +0 -62
  182. package/src/components/switch.tsx +0 -31
  183. package/src/components/table.stories.tsx +0 -139
  184. package/src/components/table.test.tsx +0 -85
  185. package/src/components/table.tsx +0 -114
  186. package/src/components/tabs.stories.tsx +0 -99
  187. package/src/components/tabs.test.tsx +0 -64
  188. package/src/components/tabs.tsx +0 -66
  189. package/src/components/textarea.stories.tsx +0 -89
  190. package/src/components/textarea.test.tsx +0 -53
  191. package/src/components/textarea.tsx +0 -18
  192. package/src/components/toggle-group.stories.tsx +0 -108
  193. package/src/components/toggle-group.test.tsx +0 -66
  194. package/src/components/toggle-group.tsx +0 -81
  195. package/src/components/toggle.stories.tsx +0 -98
  196. package/src/components/toggle.test.tsx +0 -42
  197. package/src/components/toggle.tsx +0 -45
  198. package/src/components/tooltip.stories.tsx +0 -111
  199. package/src/components/tooltip.tsx +0 -61
  200. package/src/foundations/README.md +0 -141
  201. package/src/foundations/ThemeProvider.tsx +0 -77
  202. package/src/foundations/color.css +0 -232
  203. package/src/foundations/color.stories.tsx +0 -719
  204. package/src/foundations/palette.css +0 -249
  205. package/src/foundations/spacing.css +0 -8
  206. package/src/foundations/typography.css +0 -143
  207. package/src/foundations/typography.stories.tsx +0 -17
  208. package/src/hooks/use-mobile.ts +0 -19
  209. package/src/index.css +0 -176
  210. package/src/index.ts +0 -336
  211. package/src/lib/utils.ts +0 -6
  212. package/src/test/setup.ts +0 -8
  213. package/src/vite-env.d.ts +0 -1
  214. package/tsconfig.app.json +0 -33
  215. package/tsconfig.json +0 -13
  216. package/tsconfig.node.json +0 -25
  217. package/vite.config.ts +0 -30
  218. package/vitest.config.ts +0 -25
  219. /package/{public → dist}/vite.svg +0 -0
@@ -1,118 +0,0 @@
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
- };
@@ -1,64 +0,0 @@
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
- });
@@ -1,62 +0,0 @@
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 }
@@ -1,81 +0,0 @@
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
-
@@ -1,220 +0,0 @@
1
- "use client";
2
-
3
- import * as React from "react";
4
- import {
5
- ChevronDownIcon,
6
- ChevronLeftIcon,
7
- ChevronRightIcon,
8
- } from "lucide-react";
9
- import {
10
- DayPicker,
11
- getDefaultClassNames,
12
- type DayButton,
13
- } from "react-day-picker";
14
-
15
- import { cn } from "@/lib/utils";
16
- import { Button, buttonVariants } from "@/components/button";
17
-
18
- function Calendar({
19
- className,
20
- classNames,
21
- showOutsideDays = true,
22
- captionLayout = "label",
23
- buttonVariant = "ghost",
24
- formatters,
25
- components,
26
- ...props
27
- }: React.ComponentProps<typeof DayPicker> & {
28
- buttonVariant?: React.ComponentProps<typeof Button>["variant"];
29
- }) {
30
- const defaultClassNames = getDefaultClassNames();
31
-
32
- return (
33
- <DayPicker
34
- showOutsideDays={showOutsideDays}
35
- className={cn(
36
- "bg-background group/calendar p-3 [--cell-size:--spacing(8)] [[data-slot=card-content]_&]:bg-transparent [[data-slot=popover-content]_&]:bg-transparent",
37
- String.raw`rtl:**:[.rdp-button\_next>svg]:rotate-180`,
38
- String.raw`rtl:**:[.rdp-button\_previous>svg]:rotate-180`,
39
- className
40
- )}
41
- captionLayout={captionLayout}
42
- formatters={{
43
- formatMonthDropdown: (date) =>
44
- date.toLocaleString("default", { month: "short" }),
45
- ...formatters,
46
- }}
47
- classNames={{
48
- root: cn("w-fit", defaultClassNames.root),
49
- months: cn(
50
- "flex gap-4 flex-col md:flex-row relative",
51
- defaultClassNames.months
52
- ),
53
- month: cn("flex flex-col w-full gap-4", defaultClassNames.month),
54
- nav: cn(
55
- "flex items-center gap-1 w-full absolute top-0 inset-x-0 justify-between",
56
- defaultClassNames.nav
57
- ),
58
- button_previous: cn(
59
- buttonVariants({ variant: buttonVariant }),
60
- "size-(--cell-size) aria-disabled:opacity-50 p-0 select-none",
61
- defaultClassNames.button_previous
62
- ),
63
- button_next: cn(
64
- buttonVariants({ variant: buttonVariant }),
65
- "size-(--cell-size) aria-disabled:opacity-50 p-0 select-none",
66
- defaultClassNames.button_next
67
- ),
68
- month_caption: cn(
69
- "flex items-center justify-center h-(--cell-size) w-full px-(--cell-size)",
70
- defaultClassNames.month_caption
71
- ),
72
- dropdowns: cn(
73
- "w-full flex items-center text-sm font-medium justify-center h-(--cell-size) gap-1.5",
74
- defaultClassNames.dropdowns
75
- ),
76
- dropdown_root: cn(
77
- "relative has-focus:border-ring border border-input shadow-xs has-focus:ring-ring/50 has-focus:ring-[3px] rounded-md",
78
- defaultClassNames.dropdown_root
79
- ),
80
- dropdown: cn(
81
- "absolute bg-popover inset-0 opacity-0",
82
- defaultClassNames.dropdown
83
- ),
84
- caption_label: cn(
85
- "select-none font-medium",
86
- captionLayout === "label"
87
- ? "text-sm"
88
- : "rounded-md pl-2 pr-1 flex items-center gap-1 text-sm h-8 [&>svg]:text-muted-foreground [&>svg]:size-3.5",
89
- defaultClassNames.caption_label
90
- ),
91
- table: "w-full border-collapse",
92
- weekdays: cn("flex", defaultClassNames.weekdays),
93
- weekday: cn(
94
- "text-muted-foreground rounded-md flex-1 font-normal text-[0.8rem] select-none",
95
- defaultClassNames.weekday
96
- ),
97
- week: cn("flex w-full mt-2", defaultClassNames.week),
98
- week_number_header: cn(
99
- "select-none w-(--cell-size)",
100
- defaultClassNames.week_number_header
101
- ),
102
- week_number: cn(
103
- "text-[0.8rem] select-none text-muted-foreground",
104
- defaultClassNames.week_number
105
- ),
106
- day: cn(
107
- "relative w-full h-full p-0 text-center [&:last-child[data-selected=true]_button]:rounded-r-md group/day aspect-square select-none",
108
- props.showWeekNumber
109
- ? "[&:nth-child(2)[data-selected=true]_button]:rounded-l-md"
110
- : "[&:first-child[data-selected=true]_button]:rounded-l-md",
111
- defaultClassNames.day
112
- ),
113
- range_start: cn(
114
- "rounded-l-md bg-accent",
115
- defaultClassNames.range_start
116
- ),
117
- range_middle: cn("rounded-none", defaultClassNames.range_middle),
118
- range_end: cn("rounded-r-md bg-accent", defaultClassNames.range_end),
119
- today: cn(
120
- "bg-accent text-accent-foreground rounded-md data-[selected=true]:rounded-none",
121
- defaultClassNames.today
122
- ),
123
- outside: cn(
124
- "text-muted-foreground aria-selected:text-muted-foreground",
125
- defaultClassNames.outside
126
- ),
127
- disabled: cn(
128
- "text-muted-foreground opacity-50",
129
- defaultClassNames.disabled
130
- ),
131
- hidden: cn("invisible", defaultClassNames.hidden),
132
- ...classNames,
133
- }}
134
- components={{
135
- Root: ({ className, rootRef, ...props }) => {
136
- return (
137
- <div
138
- data-slot="calendar"
139
- ref={rootRef}
140
- className={cn(className)}
141
- {...props}
142
- />
143
- );
144
- },
145
- Chevron: ({ className, orientation, ...props }) => {
146
- if (orientation === "left") {
147
- return (
148
- <ChevronLeftIcon className={cn("size-4", className)} {...props} />
149
- );
150
- }
151
-
152
- if (orientation === "right") {
153
- return (
154
- <ChevronRightIcon
155
- className={cn("size-4", className)}
156
- {...props}
157
- />
158
- );
159
- }
160
-
161
- return (
162
- <ChevronDownIcon className={cn("size-4", className)} {...props} />
163
- );
164
- },
165
- DayButton: CalendarDayButton,
166
- WeekNumber: ({ children, ...props }) => {
167
- return (
168
- <td {...props}>
169
- <div className="flex size-(--cell-size) items-center justify-center text-center">
170
- {children}
171
- </div>
172
- </td>
173
- );
174
- },
175
- ...components,
176
- }}
177
- {...props}
178
- />
179
- );
180
- }
181
-
182
- function CalendarDayButton({
183
- className,
184
- day,
185
- modifiers,
186
- ...props
187
- }: React.ComponentProps<typeof DayButton>) {
188
- const defaultClassNames = getDefaultClassNames();
189
-
190
- const ref = React.useRef<HTMLButtonElement>(null);
191
- React.useEffect(() => {
192
- if (modifiers.focused) ref.current?.focus();
193
- }, [modifiers.focused]);
194
-
195
- return (
196
- <Button
197
- ref={ref}
198
- variant="ghost"
199
- size="icon"
200
- data-day={day.date.toLocaleDateString()}
201
- data-selected-single={
202
- modifiers.selected &&
203
- !modifiers.range_start &&
204
- !modifiers.range_end &&
205
- !modifiers.range_middle
206
- }
207
- data-range-start={modifiers.range_start}
208
- data-range-end={modifiers.range_end}
209
- data-range-middle={modifiers.range_middle}
210
- className={cn(
211
- "data-[selected-single=true]:bg-primary data-[selected-single=true]:text-primary-foreground data-[range-middle=true]:bg-accent data-[range-middle=true]:text-accent-foreground data-[range-start=true]:bg-primary data-[range-start=true]:text-primary-foreground data-[range-end=true]:bg-primary data-[range-end=true]:text-primary-foreground group-data-[focused=true]/day:border-ring group-data-[focused=true]/day:ring-ring/50 dark:hover:text-accent-foreground flex aspect-square size-auto w-full min-w-(--cell-size) flex-col gap-1 leading-none font-normal group-data-[focused=true]/day:relative group-data-[focused=true]/day:z-10 group-data-[focused=true]/day:ring-[3px] data-[range-end=true]:rounded-md data-[range-end=true]:rounded-r-md data-[range-middle=true]:rounded-none data-[range-start=true]:rounded-md data-[range-start=true]:rounded-l-md [&>span]:text-xs [&>span]:opacity-70",
212
- defaultClassNames.day,
213
- className
214
- )}
215
- {...props}
216
- />
217
- );
218
- }
219
-
220
- export { Calendar, CalendarDayButton };
@@ -1,110 +0,0 @@
1
- import type { Meta, StoryObj } from "@storybook/react-vite";
2
- import {
3
- Card,
4
- CardHeader,
5
- CardFooter,
6
- CardTitle,
7
- CardDescription,
8
- CardContent,
9
- } from "./card";
10
- import { Button } from "./button";
11
-
12
- const meta = {
13
- title: "Components/Card",
14
- component: Card,
15
- parameters: {
16
- layout: "padded",
17
- },
18
- tags: ["autodocs"],
19
- } satisfies Meta<typeof Card>;
20
-
21
- export default meta;
22
- type Story = StoryObj<typeof meta>;
23
-
24
- export const Default: Story = {
25
- render: () => (
26
- <Card className="w-[350px]">
27
- <CardHeader>
28
- <CardTitle>Card Title</CardTitle>
29
- <CardDescription>Card description goes here.</CardDescription>
30
- </CardHeader>
31
- <CardContent>
32
- <p>Card content area. You can put any content here.</p>
33
- </CardContent>
34
- <CardFooter>
35
- <Button>Action</Button>
36
- </CardFooter>
37
- </Card>
38
- ),
39
- };
40
-
41
- export const WithoutFooter: Story = {
42
- render: () => (
43
- <Card className="w-[350px]">
44
- <CardHeader>
45
- <CardTitle>Simple Card</CardTitle>
46
- <CardDescription>This card doesn't have a footer.</CardDescription>
47
- </CardHeader>
48
- <CardContent>
49
- <p>Just the header and content sections.</p>
50
- </CardContent>
51
- </Card>
52
- ),
53
- };
54
-
55
- export const LongContent: Story = {
56
- render: () => (
57
- <Card className="w-[400px]">
58
- <CardHeader>
59
- <CardTitle>Article Title</CardTitle>
60
- <CardDescription>Published on January 1, 2024</CardDescription>
61
- </CardHeader>
62
- <CardContent>
63
- <div className="space-y-2">
64
- <p>
65
- This is a longer card content that demonstrates how the card
66
- component handles extended text and multiple paragraphs.
67
- </p>
68
- <p>
69
- The card maintains proper spacing and layout even with longer
70
- content. You can include images, lists, or any other content within
71
- the card content area.
72
- </p>
73
- </div>
74
- </CardContent>
75
- <CardFooter className="flex justify-between">
76
- <Button variant="outline">Cancel</Button>
77
- <Button>Save</Button>
78
- </CardFooter>
79
- </Card>
80
- ),
81
- };
82
-
83
- export const MultipleCards: Story = {
84
- render: () => (
85
- <div className="grid grid-cols-3 gap-4">
86
- <Card>
87
- <CardHeader>
88
- <CardTitle>Card 1</CardTitle>
89
- <CardDescription>First card</CardDescription>
90
- </CardHeader>
91
- <CardContent>Content for card 1</CardContent>
92
- </Card>
93
- <Card>
94
- <CardHeader>
95
- <CardTitle>Card 2</CardTitle>
96
- <CardDescription>Second card</CardDescription>
97
- </CardHeader>
98
- <CardContent>Content for card 2</CardContent>
99
- </Card>
100
- <Card>
101
- <CardHeader>
102
- <CardTitle>Card 3</CardTitle>
103
- <CardDescription>Third card</CardDescription>
104
- </CardHeader>
105
- <CardContent>Content for card 3</CardContent>
106
- </Card>
107
- </div>
108
- ),
109
- };
110
-