@inspirare/design-system 0.0.22 → 0.0.24
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/README.md +82 -61
- package/dist/book-logo-filled.svg +55 -0
- package/dist/components/ui/accessibility-improvements.js +26 -23
- package/dist/components/ui/accordion.js +34 -24
- package/dist/components/ui/alert-dialog.js +91 -57
- package/dist/components/ui/alert.js +38 -26
- package/dist/components/ui/aspect-ratio.js +11 -3
- package/dist/components/ui/avatar.js +30 -8
- package/dist/components/ui/badge.js +20 -14
- package/dist/components/ui/breadcrumb.js +69 -56
- package/dist/components/ui/button-group.js +17 -13
- package/dist/components/ui/button.js +19 -15
- package/dist/components/ui/calendar.js +63 -59
- package/dist/components/ui/card.js +11 -9
- package/dist/components/ui/carousel.js +70 -75
- package/dist/components/ui/chart.js +75 -72
- package/dist/components/ui/checkbox.js +4 -5
- package/dist/components/ui/collapsible.js +12 -14
- package/dist/components/ui/color-picker.js +60 -80
- package/dist/components/ui/combobox.js +153 -33
- package/dist/components/ui/command.js +50 -48
- package/dist/components/ui/context-menu.js +129 -68
- package/dist/components/ui/dialog.js +65 -60
- package/dist/components/ui/drawer.js +81 -40
- package/dist/components/ui/dropdown-menu.js +100 -87
- package/dist/components/ui/empty.js +7 -6
- package/dist/components/ui/field.js +44 -47
- package/dist/components/ui/form.js +22 -23
- package/dist/components/ui/hover-card.js +14 -11
- package/dist/components/ui/input-group.js +16 -13
- package/dist/components/ui/input-otp.js +37 -32
- package/dist/components/ui/input.js +9 -7
- package/dist/components/ui/item.js +42 -36
- package/dist/components/ui/kbd.js +2 -1
- package/dist/components/ui/label.js +6 -7
- package/dist/components/ui/menubar.js +124 -93
- package/dist/components/ui/navigation-menu.js +79 -54
- package/dist/components/ui/pagination.js +78 -58
- package/dist/components/ui/popover.js +35 -16
- package/dist/components/ui/progress.js +37 -13
- package/dist/components/ui/radio-group.js +14 -14
- package/dist/components/ui/resizable.js +24 -15
- package/dist/components/ui/scroll-area.js +29 -11
- package/dist/components/ui/select.js +98 -56
- package/dist/components/ui/separator.js +5 -7
- package/dist/components/ui/sheet.js +47 -42
- package/dist/components/ui/sidebar.js +279 -248
- package/dist/components/ui/skeleton.js +4 -40
- package/dist/components/ui/slider.js +27 -29
- package/dist/components/ui/sonner.js +27 -10
- package/dist/components/ui/spinner.js +2 -0
- package/dist/components/ui/switch.js +3 -4
- package/dist/components/ui/table.js +6 -6
- package/dist/components/ui/tabs.js +45 -22
- package/dist/components/ui/textarea.js +3 -2
- package/dist/components/ui/theme-toggle.js +38 -41
- package/dist/components/ui/toggle-group.js +30 -21
- package/dist/components/ui/toggle.js +8 -9
- package/dist/components/ui/tooltip.js +28 -23
- package/dist/index.css +1 -1
- package/dist/index.d.ts +446 -468
- package/dist/index.js +58 -58
- package/package.json +42 -41
- package/src/App.tsx +28 -34
- package/src/components/branding/assets/book-logo-filled.svg +55 -0
- package/src/components/branding/logo/logo.tsx +56 -0
- package/src/components/ui/accessibility-improvements.stories.tsx +18 -0
- package/src/components/ui/accessibility-improvements.test.tsx +13 -0
- package/src/components/ui/accessibility-improvements.tsx +16 -6
- package/src/components/ui/accordion.stories.tsx +19 -0
- package/src/components/ui/accordion.test.tsx +14 -0
- package/src/components/ui/accordion.tsx +28 -20
- package/src/components/ui/alert-dialog.stories.tsx +19 -0
- package/src/components/ui/alert-dialog.test.tsx +14 -0
- package/src/components/ui/alert-dialog.tsx +159 -123
- package/src/components/ui/alert.stories.tsx +19 -0
- package/src/components/ui/alert.test.tsx +14 -0
- package/src/components/ui/alert.tsx +60 -41
- package/src/components/ui/aspect-ratio.stories.tsx +19 -0
- package/src/components/ui/aspect-ratio.test.tsx +14 -0
- package/src/components/ui/aspect-ratio.tsx +19 -2
- package/src/components/ui/attachment.stories.tsx +19 -0
- package/src/components/ui/attachment.test.tsx +14 -0
- package/src/components/ui/attachment.tsx +209 -0
- package/src/components/ui/avatar.stories.tsx +19 -0
- package/src/components/ui/avatar.test.tsx +14 -0
- package/src/components/ui/avatar.tsx +73 -17
- package/src/components/ui/badge.stories.tsx +19 -0
- package/src/components/ui/badge.test.tsx +14 -0
- package/src/components/ui/badge.tsx +33 -25
- package/src/components/ui/breadcrumb.stories.tsx +19 -0
- package/src/components/ui/breadcrumb.test.tsx +14 -0
- package/src/components/ui/breadcrumb.tsx +98 -86
- package/src/components/ui/bubble.stories.tsx +19 -0
- package/src/components/ui/bubble.test.tsx +14 -0
- package/src/components/ui/bubble.tsx +130 -0
- package/src/components/ui/button-group.stories.tsx +19 -0
- package/src/components/ui/button-group.test.tsx +14 -0
- package/src/components/ui/button-group.tsx +26 -20
- package/src/components/ui/button.stories.tsx +19 -0
- package/src/components/ui/button.test.tsx +14 -0
- package/src/components/ui/button.tsx +30 -31
- package/src/components/ui/calendar.stories.tsx +19 -0
- package/src/components/ui/calendar.test.tsx +14 -0
- package/src/components/ui/calendar.tsx +28 -26
- package/src/components/ui/card.stories.tsx +19 -0
- package/src/components/ui/card.test.tsx +14 -0
- package/src/components/ui/card.tsx +30 -17
- package/src/components/ui/carousel.stories.tsx +19 -0
- package/src/components/ui/carousel.test.tsx +14 -0
- package/src/components/ui/carousel.tsx +115 -135
- package/src/components/ui/chart.stories.tsx +18 -0
- package/src/components/ui/chart.test.tsx +13 -0
- package/src/components/ui/chart.tsx +220 -216
- package/src/components/ui/checkbox.stories.tsx +19 -0
- package/src/components/ui/checkbox.test.tsx +14 -0
- package/src/components/ui/checkbox.tsx +7 -10
- package/src/components/ui/collapsible.stories.tsx +19 -0
- package/src/components/ui/collapsible.test.tsx +14 -0
- package/src/components/ui/collapsible.tsx +11 -26
- package/src/components/ui/color-picker.stories.tsx +19 -0
- package/src/components/ui/color-picker.test.tsx +14 -0
- package/src/components/ui/color-picker.tsx +36 -26
- package/src/components/ui/combobox.stories.tsx +19 -0
- package/src/components/ui/combobox.test.tsx +14 -0
- package/src/components/ui/combobox.tsx +281 -96
- package/src/components/ui/command.stories.tsx +19 -0
- package/src/components/ui/command.test.tsx +14 -0
- package/src/components/ui/command.tsx +59 -47
- package/src/components/ui/context-menu.stories.tsx +19 -0
- package/src/components/ui/context-menu.test.tsx +14 -0
- package/src/components/ui/context-menu.tsx +231 -160
- package/src/components/ui/dialog.stories.tsx +19 -0
- package/src/components/ui/dialog.test.tsx +14 -0
- package/src/components/ui/dialog.tsx +81 -72
- package/src/components/ui/direction.stories.tsx +19 -0
- package/src/components/ui/direction.test.tsx +14 -0
- package/src/components/ui/direction.tsx +6 -0
- package/src/components/ui/drawer.stories.tsx +19 -0
- package/src/components/ui/drawer.test.tsx +14 -0
- package/src/components/ui/drawer.tsx +143 -64
- package/src/components/ui/dropdown-menu.stories.tsx +19 -0
- package/src/components/ui/dropdown-menu.test.tsx +14 -0
- package/src/components/ui/dropdown-menu.tsx +199 -153
- package/src/components/ui/empty.stories.tsx +18 -0
- package/src/components/ui/empty.test.tsx +13 -0
- package/src/components/ui/empty.tsx +11 -9
- package/src/components/ui/field.stories.tsx +18 -0
- package/src/components/ui/field.test.tsx +13 -0
- package/src/components/ui/field.tsx +26 -32
- package/src/components/ui/form.stories.tsx +22 -0
- package/src/components/ui/form.test.tsx +15 -0
- package/src/components/ui/form.tsx +1 -2
- package/src/components/ui/hover-card.stories.tsx +19 -0
- package/src/components/ui/hover-card.test.tsx +14 -0
- package/src/components/ui/hover-card.tsx +34 -32
- package/src/components/ui/input-group.stories.tsx +18 -0
- package/src/components/ui/input-group.test.tsx +13 -0
- package/src/components/ui/input-group.tsx +21 -28
- package/src/components/ui/input-otp.stories.tsx +19 -0
- package/src/components/ui/input-otp.test.tsx +14 -0
- package/src/components/ui/input-otp.tsx +58 -42
- package/src/components/ui/input.stories.tsx +19 -0
- package/src/components/ui/input.test.tsx +14 -0
- package/src/components/ui/input.tsx +9 -8
- package/src/components/ui/item.stories.tsx +18 -0
- package/src/components/ui/item.test.tsx +13 -0
- package/src/components/ui/item.tsx +38 -28
- package/src/components/ui/kbd.stories.tsx +18 -0
- package/src/components/ui/kbd.test.tsx +13 -0
- package/src/components/ui/kbd.tsx +3 -3
- package/src/components/ui/label.stories.tsx +18 -0
- package/src/components/ui/label.test.tsx +13 -0
- package/src/components/ui/label.tsx +7 -11
- package/src/components/ui/marker.stories.tsx +19 -0
- package/src/components/ui/marker.test.tsx +14 -0
- package/src/components/ui/marker.tsx +73 -0
- package/src/components/ui/menubar.stories.tsx +19 -0
- package/src/components/ui/menubar.test.tsx +14 -0
- package/src/components/ui/menubar.tsx +226 -202
- package/src/components/ui/message-scroller.stories.tsx +19 -0
- package/src/components/ui/message-scroller.test.tsx +14 -0
- package/src/components/ui/message-scroller.tsx +131 -0
- package/src/components/ui/message.stories.tsx +19 -0
- package/src/components/ui/message.test.tsx +14 -0
- package/src/components/ui/message.tsx +94 -0
- package/src/components/ui/native-select.stories.tsx +18 -0
- package/src/components/ui/native-select.test.tsx +13 -0
- package/src/components/ui/native-select.tsx +63 -0
- package/src/components/ui/navigation-menu.stories.tsx +19 -0
- package/src/components/ui/navigation-menu.test.tsx +14 -0
- package/src/components/ui/navigation-menu.tsx +145 -103
- package/src/components/ui/pagination.stories.tsx +19 -0
- package/src/components/ui/pagination.test.tsx +14 -0
- package/src/components/ui/pagination.tsx +114 -83
- package/src/components/ui/popover.stories.tsx +19 -0
- package/src/components/ui/popover.test.tsx +14 -0
- package/src/components/ui/popover.tsx +68 -33
- package/src/components/ui/progress.stories.tsx +19 -0
- package/src/components/ui/progress.test.tsx +14 -0
- package/src/components/ui/progress.tsx +67 -15
- package/src/components/ui/questionnaire.stories.tsx +19 -0
- package/src/components/ui/questionnaire.test.tsx +14 -0
- package/src/components/ui/questionnaire.tsx +324 -0
- package/src/components/ui/radio-group.stories.tsx +19 -0
- package/src/components/ui/radio-group.test.tsx +14 -0
- package/src/components/ui/radio-group.tsx +15 -20
- package/src/components/ui/resizable.stories.tsx +19 -0
- package/src/components/ui/resizable.test.tsx +14 -0
- package/src/components/ui/resizable.tsx +37 -30
- package/src/components/ui/scroll-area.stories.tsx +19 -0
- package/src/components/ui/scroll-area.test.tsx +14 -0
- package/src/components/ui/scroll-area.tsx +41 -19
- package/src/components/ui/select.stories.tsx +19 -0
- package/src/components/ui/select.test.tsx +14 -0
- package/src/components/ui/select.tsx +145 -78
- package/src/components/ui/separator.stories.tsx +19 -0
- package/src/components/ui/separator.test.tsx +14 -0
- package/src/components/ui/separator.tsx +8 -11
- package/src/components/ui/sheet.stories.tsx +19 -0
- package/src/components/ui/sheet.test.tsx +14 -0
- package/src/components/ui/sheet.tsx +56 -71
- package/src/components/ui/sidebar.stories.tsx +18 -0
- package/src/components/ui/sidebar.test.tsx +13 -0
- package/src/components/ui/sidebar.tsx +469 -513
- package/src/components/ui/skeleton.stories.tsx +19 -0
- package/src/components/ui/skeleton.test.tsx +14 -0
- package/src/components/ui/skeleton.tsx +8 -114
- package/src/components/ui/slider.stories.tsx +19 -0
- package/src/components/ui/slider.test.tsx +14 -0
- package/src/components/ui/slider.tsx +31 -40
- package/src/components/ui/sonner.stories.tsx +19 -0
- package/src/components/ui/sonner.test.tsx +14 -0
- package/src/components/ui/sonner.tsx +39 -7
- package/src/components/ui/spinner.stories.tsx +18 -0
- package/src/components/ui/spinner.test.tsx +13 -0
- package/src/components/ui/spinner.tsx +3 -7
- package/src/components/ui/switch.stories.tsx +19 -0
- package/src/components/ui/switch.test.tsx +14 -0
- package/src/components/ui/switch.tsx +4 -7
- package/src/components/ui/table.stories.tsx +19 -0
- package/src/components/ui/table.test.tsx +14 -0
- package/src/components/ui/table.tsx +17 -17
- package/src/components/ui/tabs.stories.tsx +19 -0
- package/src/components/ui/tabs.test.tsx +14 -0
- package/src/components/ui/tabs.tsx +71 -31
- package/src/components/ui/textarea.stories.tsx +19 -0
- package/src/components/ui/textarea.test.tsx +14 -0
- package/src/components/ui/textarea.tsx +7 -5
- package/src/components/ui/theme-toggle.stories.tsx +18 -0
- package/src/components/ui/theme-toggle.test.tsx +13 -0
- package/src/components/ui/theme-toggle.tsx +35 -37
- package/src/components/ui/toggle-group.stories.tsx +19 -0
- package/src/components/ui/toggle-group.test.tsx +14 -0
- package/src/components/ui/toggle-group.tsx +41 -25
- package/src/components/ui/toggle.stories.tsx +19 -0
- package/src/components/ui/toggle.test.tsx +14 -0
- package/src/components/ui/toggle.tsx +17 -19
- package/src/components/ui/tooltip.stories.tsx +19 -0
- package/src/components/ui/tooltip.test.tsx +14 -0
- package/src/components/ui/tooltip.tsx +53 -44
- package/src/demo/AIDemo.tsx +50 -0
- package/src/demo/ButtonsDemo.tsx +41 -18
- package/src/demo/CalendarDemo.tsx +1 -1
- package/src/demo/FeedbackDemo.tsx +4 -6
- package/src/demo/FormsDemo.tsx +34 -11
- package/src/demo/NavigationDemo.tsx +38 -13
- package/src/demo/OverlaysDemo.tsx +22 -36
- package/src/demo/update-demos.js +82 -0
- package/src/index.css +66 -46
- package/src/lib/utils.ts +3 -3
- package/src/stories/Button.stories.ts +54 -0
- package/src/stories/Button.tsx +36 -0
- package/src/stories/Configure.mdx +388 -0
- package/src/stories/Header.stories.ts +34 -0
- package/src/stories/Header.tsx +55 -0
- package/src/stories/Page.stories.ts +33 -0
- package/src/stories/Page.tsx +73 -0
- package/src/stories/assets/accessibility.png +0 -0
- package/src/stories/assets/accessibility.svg +1 -0
- package/src/stories/assets/addon-library.png +0 -0
- package/src/stories/assets/assets.png +0 -0
- package/src/stories/assets/avif-test-image.avif +0 -0
- package/src/stories/assets/context.png +0 -0
- package/src/stories/assets/discord.svg +1 -0
- package/src/stories/assets/docs.png +0 -0
- package/src/stories/assets/figma-plugin.png +0 -0
- package/src/stories/assets/github.svg +1 -0
- package/src/stories/assets/share.png +0 -0
- package/src/stories/assets/styling.png +0 -0
- package/src/stories/assets/testing.png +0 -0
- package/src/stories/assets/theming.png +0 -0
- package/src/stories/assets/tutorials.svg +1 -0
- package/src/stories/assets/youtube.svg +1 -0
- package/src/stories/button.css +30 -0
- package/src/stories/header.css +32 -0
- package/src/stories/page.css +68 -0
|
@@ -1,31 +1,38 @@
|
|
|
1
|
-
|
|
2
|
-
import { cva, type VariantProps } from "class-variance-authority";
|
|
3
|
-
import * as React from "react";
|
|
1
|
+
"use client"
|
|
4
2
|
|
|
5
|
-
import {
|
|
3
|
+
import { Button as ButtonPrimitive } from "@base-ui/react/button"
|
|
4
|
+
import { cva, type VariantProps } from "class-variance-authority"
|
|
5
|
+
|
|
6
|
+
import { cn } from "@/lib/utils"
|
|
6
7
|
|
|
7
8
|
const buttonVariants = cva(
|
|
8
|
-
"inline-flex items-center justify-center
|
|
9
|
+
"group/button inline-flex shrink-0 items-center justify-center cursor-pointer rounded-lg border border-transparent bg-clip-padding text-sm font-medium whitespace-nowrap transition-all outline-none select-none focus-visible:border-ring focus-visible:ring-3 focus-visible:ring-ring/50 active:not-aria-[haspopup]:translate-y-px disabled:pointer-events-none disabled:opacity-50 aria-invalid:border-destructive aria-invalid:ring-3 aria-invalid:ring-destructive/20 dark:aria-invalid:border-destructive/50 dark:aria-invalid:ring-destructive/40 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4",
|
|
9
10
|
{
|
|
10
11
|
variants: {
|
|
11
12
|
variant: {
|
|
12
|
-
default:
|
|
13
|
-
"bg-primary text-primary-foreground shadow-xs hover:bg-primary/90",
|
|
14
|
-
destructive:
|
|
15
|
-
"bg-destructive text-white shadow-xs hover:bg-destructive/90 focus-visible:ring-destructive/20 dark:focus-visible:ring-destructive/40 dark:bg-destructive/60",
|
|
13
|
+
default: "bg-primary text-primary-foreground hover:bg-primary/80",
|
|
16
14
|
outline:
|
|
17
|
-
"border
|
|
15
|
+
"border-border bg-background hover:bg-muted hover:text-foreground aria-expanded:bg-muted aria-expanded:text-foreground dark:border-input dark:bg-input/30 dark:hover:bg-input/50",
|
|
18
16
|
secondary:
|
|
19
|
-
"bg-secondary text-secondary-foreground
|
|
17
|
+
"bg-secondary text-secondary-foreground hover:bg-[color-mix(in_oklch,var(--secondary),var(--foreground)_5%)] aria-expanded:bg-secondary aria-expanded:text-secondary-foreground",
|
|
20
18
|
ghost:
|
|
21
|
-
"hover:bg-
|
|
19
|
+
"hover:bg-muted hover:text-foreground aria-expanded:bg-muted aria-expanded:text-foreground dark:hover:bg-muted/50",
|
|
20
|
+
destructive:
|
|
21
|
+
"bg-destructive/10 text-destructive hover:bg-destructive/20 focus-visible:border-destructive/40 focus-visible:ring-destructive/20 dark:bg-destructive/20 dark:hover:bg-destructive/30 dark:focus-visible:ring-destructive/40",
|
|
22
22
|
link: "text-primary underline-offset-4 hover:underline",
|
|
23
23
|
},
|
|
24
24
|
size: {
|
|
25
|
-
default:
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
icon:
|
|
25
|
+
default:
|
|
26
|
+
"h-8 gap-1.5 px-2.5 has-data-[icon=inline-end]:pr-2 has-data-[icon=inline-start]:pl-2",
|
|
27
|
+
xs: "h-6 gap-1 rounded-[min(var(--radius-md),10px)] px-2 text-xs in-data-[slot=button-group]:rounded-lg has-data-[icon=inline-end]:pr-1.5 has-data-[icon=inline-start]:pl-1.5 [&_svg:not([class*='size-'])]:size-3",
|
|
28
|
+
sm: "h-7 gap-1 rounded-[min(var(--radius-md),12px)] px-2.5 text-[0.8rem] in-data-[slot=button-group]:rounded-lg has-data-[icon=inline-end]:pr-1.5 has-data-[icon=inline-start]:pl-1.5 [&_svg:not([class*='size-'])]:size-3.5",
|
|
29
|
+
lg: "h-9 gap-1.5 px-2.5 has-data-[icon=inline-end]:pr-2 has-data-[icon=inline-start]:pl-2",
|
|
30
|
+
icon: "size-8",
|
|
31
|
+
"icon-xs":
|
|
32
|
+
"size-6 rounded-[min(var(--radius-md),10px)] in-data-[slot=button-group]:rounded-lg [&_svg:not([class*='size-'])]:size-3",
|
|
33
|
+
"icon-sm":
|
|
34
|
+
"size-7 rounded-[min(var(--radius-md),12px)] in-data-[slot=button-group]:rounded-lg",
|
|
35
|
+
"icon-lg": "size-9",
|
|
29
36
|
},
|
|
30
37
|
},
|
|
31
38
|
defaultVariants: {
|
|
@@ -33,29 +40,21 @@ const buttonVariants = cva(
|
|
|
33
40
|
size: "default",
|
|
34
41
|
},
|
|
35
42
|
}
|
|
36
|
-
)
|
|
43
|
+
)
|
|
37
44
|
|
|
38
45
|
function Button({
|
|
39
46
|
className,
|
|
40
|
-
variant,
|
|
41
|
-
size,
|
|
42
|
-
asChild = false,
|
|
47
|
+
variant = "default",
|
|
48
|
+
size = "default",
|
|
43
49
|
...props
|
|
44
|
-
}:
|
|
45
|
-
VariantProps<typeof buttonVariants> & {
|
|
46
|
-
asChild?: boolean;
|
|
47
|
-
}) {
|
|
48
|
-
const Comp = asChild ? Slot : "button";
|
|
49
|
-
|
|
50
|
+
}: ButtonPrimitive.Props & VariantProps<typeof buttonVariants>) {
|
|
50
51
|
return (
|
|
51
|
-
<
|
|
52
|
+
<ButtonPrimitive
|
|
52
53
|
data-slot="button"
|
|
53
54
|
className={cn(buttonVariants({ variant, size, className }))}
|
|
54
55
|
{...props}
|
|
55
56
|
/>
|
|
56
|
-
)
|
|
57
|
+
)
|
|
57
58
|
}
|
|
58
59
|
|
|
59
|
-
export
|
|
60
|
-
|
|
61
|
-
export { Button, buttonVariants };
|
|
60
|
+
export { Button, buttonVariants }
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import type { Meta, StoryObj } from '@storybook/react-vite';
|
|
2
|
+
import { Calendar } from "./calendar";
|
|
3
|
+
|
|
4
|
+
const meta = {
|
|
5
|
+
title: 'Design System/Calendar',
|
|
6
|
+
parameters: { layout: 'centered' },
|
|
7
|
+
tags: ['autodocs'],
|
|
8
|
+
} satisfies Meta;
|
|
9
|
+
|
|
10
|
+
export default meta;
|
|
11
|
+
type Story = StoryObj<typeof meta>;
|
|
12
|
+
|
|
13
|
+
export const Default: Story = {
|
|
14
|
+
render: () => (
|
|
15
|
+
<div className="p-4 w-full h-full flex items-center justify-center">
|
|
16
|
+
<Calendar mode="single" selected={new Date()} className="rounded-md border shadow" />
|
|
17
|
+
</div>
|
|
18
|
+
)
|
|
19
|
+
};
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { render } from '@testing-library/react';
|
|
2
|
+
import { axe } from 'jest-axe';
|
|
3
|
+
import { Calendar } from "./calendar";
|
|
4
|
+
|
|
5
|
+
describe('Calendar Accessibility', () => {
|
|
6
|
+
it('should have no accessibility violations in basic render', async () => {
|
|
7
|
+
const Wrapper = () => (
|
|
8
|
+
<Calendar mode="single" selected={new Date()} className="rounded-md border shadow" />
|
|
9
|
+
);
|
|
10
|
+
const { container } = render(<Wrapper />);
|
|
11
|
+
const results = await axe(container);
|
|
12
|
+
expect(results).toHaveNoViolations();
|
|
13
|
+
});
|
|
14
|
+
});
|
|
@@ -1,19 +1,17 @@
|
|
|
1
1
|
"use client"
|
|
2
2
|
|
|
3
3
|
import * as React from "react"
|
|
4
|
-
import {
|
|
5
|
-
ChevronDownIcon,
|
|
6
|
-
ChevronLeftIcon,
|
|
7
|
-
ChevronRightIcon,
|
|
8
|
-
} from "lucide-react"
|
|
9
4
|
import {
|
|
10
5
|
DayPicker,
|
|
11
6
|
getDefaultClassNames,
|
|
12
7
|
type DayButton,
|
|
8
|
+
type Locale,
|
|
13
9
|
} from "react-day-picker"
|
|
14
10
|
|
|
15
11
|
import { cn } from "@/lib/utils"
|
|
16
12
|
import { Button, buttonVariants } from "@/components/ui/button"
|
|
13
|
+
import { ChevronLeftIcon, ChevronRightIcon, ChevronDownIcon } from "lucide-react"
|
|
14
|
+
import { ptBR } from "date-fns/locale"
|
|
17
15
|
|
|
18
16
|
function Calendar({
|
|
19
17
|
className,
|
|
@@ -21,6 +19,7 @@ function Calendar({
|
|
|
21
19
|
showOutsideDays = true,
|
|
22
20
|
captionLayout = "label",
|
|
23
21
|
buttonVariant = "ghost",
|
|
22
|
+
locale = ptBR,
|
|
24
23
|
formatters,
|
|
25
24
|
components,
|
|
26
25
|
...props
|
|
@@ -33,15 +32,16 @@ function Calendar({
|
|
|
33
32
|
<DayPicker
|
|
34
33
|
showOutsideDays={showOutsideDays}
|
|
35
34
|
className={cn(
|
|
36
|
-
"group/calendar bg-background p-
|
|
35
|
+
"group/calendar bg-background p-2 [--cell-radius:var(--radius-md)] [--cell-size:--spacing(7)] in-data-[slot=card-content]:bg-transparent in-data-[slot=popover-content]:bg-transparent",
|
|
37
36
|
String.raw`rtl:**:[.rdp-button\_next>svg]:rotate-180`,
|
|
38
37
|
String.raw`rtl:**:[.rdp-button\_previous>svg]:rotate-180`,
|
|
39
38
|
className
|
|
40
39
|
)}
|
|
41
40
|
captionLayout={captionLayout}
|
|
41
|
+
locale={locale}
|
|
42
42
|
formatters={{
|
|
43
43
|
formatMonthDropdown: (date) =>
|
|
44
|
-
date.toLocaleString(
|
|
44
|
+
date.toLocaleString(locale?.code, { month: "short" }),
|
|
45
45
|
...formatters,
|
|
46
46
|
}}
|
|
47
47
|
classNames={{
|
|
@@ -74,7 +74,7 @@ function Calendar({
|
|
|
74
74
|
defaultClassNames.dropdowns
|
|
75
75
|
),
|
|
76
76
|
dropdown_root: cn(
|
|
77
|
-
"relative rounded-
|
|
77
|
+
"relative rounded-(--cell-radius)",
|
|
78
78
|
defaultClassNames.dropdown_root
|
|
79
79
|
),
|
|
80
80
|
dropdown: cn(
|
|
@@ -85,13 +85,13 @@ function Calendar({
|
|
|
85
85
|
"font-medium select-none",
|
|
86
86
|
captionLayout === "label"
|
|
87
87
|
? "text-sm"
|
|
88
|
-
: "flex
|
|
88
|
+
: "flex items-center gap-1 rounded-(--cell-radius) text-sm [&>svg]:size-3.5 [&>svg]:text-muted-foreground",
|
|
89
89
|
defaultClassNames.caption_label
|
|
90
90
|
),
|
|
91
|
-
|
|
91
|
+
month_grid: cn("w-full border-collapse", defaultClassNames.month_grid),
|
|
92
92
|
weekdays: cn("flex", defaultClassNames.weekdays),
|
|
93
93
|
weekday: cn(
|
|
94
|
-
"flex-1 rounded-
|
|
94
|
+
"flex-1 rounded-(--cell-radius) text-[0.8rem] font-normal text-muted-foreground select-none",
|
|
95
95
|
defaultClassNames.weekday
|
|
96
96
|
),
|
|
97
97
|
week: cn("mt-2 flex w-full", defaultClassNames.week),
|
|
@@ -104,20 +104,23 @@ function Calendar({
|
|
|
104
104
|
defaultClassNames.week_number
|
|
105
105
|
),
|
|
106
106
|
day: cn(
|
|
107
|
-
"group/day relative aspect-square h-full w-full p-0 text-center select-none [&:last-child[data-selected=true]_button]:rounded-r-
|
|
107
|
+
"group/day relative aspect-square h-full w-full rounded-(--cell-radius) p-0 text-center select-none [&:last-child[data-selected=true]_button]:rounded-r-(--cell-radius)",
|
|
108
108
|
props.showWeekNumber
|
|
109
|
-
? "[&:nth-child(2)[data-selected=true]_button]:rounded-l-
|
|
110
|
-
: "[&:first-child[data-selected=true]_button]:rounded-l-
|
|
109
|
+
? "[&:nth-child(2)[data-selected=true]_button]:rounded-l-(--cell-radius)"
|
|
110
|
+
: "[&:first-child[data-selected=true]_button]:rounded-l-(--cell-radius)",
|
|
111
111
|
defaultClassNames.day
|
|
112
112
|
),
|
|
113
113
|
range_start: cn(
|
|
114
|
-
"rounded-l-
|
|
114
|
+
"relative isolate z-0 rounded-l-(--cell-radius) bg-muted after:absolute after:inset-y-0 after:right-0 after:w-4 after:bg-muted",
|
|
115
115
|
defaultClassNames.range_start
|
|
116
116
|
),
|
|
117
117
|
range_middle: cn("rounded-none", defaultClassNames.range_middle),
|
|
118
|
-
range_end: cn(
|
|
118
|
+
range_end: cn(
|
|
119
|
+
"relative isolate z-0 rounded-r-(--cell-radius) bg-muted after:absolute after:inset-y-0 after:left-0 after:w-4 after:bg-muted",
|
|
120
|
+
defaultClassNames.range_end
|
|
121
|
+
),
|
|
119
122
|
today: cn(
|
|
120
|
-
"rounded-
|
|
123
|
+
"rounded-(--cell-radius) bg-muted text-foreground data-[selected=true]:rounded-none",
|
|
121
124
|
defaultClassNames.today
|
|
122
125
|
),
|
|
123
126
|
outside: cn(
|
|
@@ -151,10 +154,7 @@ function Calendar({
|
|
|
151
154
|
|
|
152
155
|
if (orientation === "right") {
|
|
153
156
|
return (
|
|
154
|
-
<ChevronRightIcon
|
|
155
|
-
className={cn("size-4", className)}
|
|
156
|
-
{...props}
|
|
157
|
-
/>
|
|
157
|
+
<ChevronRightIcon className={cn("size-4", className)} {...props} />
|
|
158
158
|
)
|
|
159
159
|
}
|
|
160
160
|
|
|
@@ -162,7 +162,9 @@ function Calendar({
|
|
|
162
162
|
<ChevronDownIcon className={cn("size-4", className)} {...props} />
|
|
163
163
|
)
|
|
164
164
|
},
|
|
165
|
-
DayButton:
|
|
165
|
+
DayButton: ({ ...props }) => (
|
|
166
|
+
<CalendarDayButton locale={locale} {...props} />
|
|
167
|
+
),
|
|
166
168
|
WeekNumber: ({ children, ...props }) => {
|
|
167
169
|
return (
|
|
168
170
|
<td {...props}>
|
|
@@ -183,8 +185,9 @@ function CalendarDayButton({
|
|
|
183
185
|
className,
|
|
184
186
|
day,
|
|
185
187
|
modifiers,
|
|
188
|
+
locale,
|
|
186
189
|
...props
|
|
187
|
-
}: React.ComponentProps<typeof DayButton>) {
|
|
190
|
+
}: React.ComponentProps<typeof DayButton> & { locale?: Partial<Locale> }) {
|
|
188
191
|
const defaultClassNames = getDefaultClassNames()
|
|
189
192
|
|
|
190
193
|
const ref = React.useRef<HTMLButtonElement>(null)
|
|
@@ -194,10 +197,9 @@ function CalendarDayButton({
|
|
|
194
197
|
|
|
195
198
|
return (
|
|
196
199
|
<Button
|
|
197
|
-
ref={ref}
|
|
198
200
|
variant="ghost"
|
|
199
201
|
size="icon"
|
|
200
|
-
data-day={day.date.toLocaleDateString()}
|
|
202
|
+
data-day={day.date.toLocaleDateString(locale?.code)}
|
|
201
203
|
data-selected-single={
|
|
202
204
|
modifiers.selected &&
|
|
203
205
|
!modifiers.range_start &&
|
|
@@ -208,7 +210,7 @@ function CalendarDayButton({
|
|
|
208
210
|
data-range-end={modifiers.range_end}
|
|
209
211
|
data-range-middle={modifiers.range_middle}
|
|
210
212
|
className={cn(
|
|
211
|
-
"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:border-ring group-data-[focused=true]/day:ring-[3px] group-data-[focused=true]/day:ring-ring/50 data-[range-end=true]:rounded-
|
|
213
|
+
"relative isolate z-10 flex aspect-square size-auto w-full min-w-(--cell-size) flex-col gap-1 border-0 leading-none font-normal group-data-[focused=true]/day:relative group-data-[focused=true]/day:z-10 group-data-[focused=true]/day:border-ring group-data-[focused=true]/day:ring-[3px] group-data-[focused=true]/day:ring-ring/50 data-[range-end=true]:rounded-(--cell-radius) data-[range-end=true]:rounded-r-(--cell-radius) data-[range-end=true]:bg-primary data-[range-end=true]:text-primary-foreground data-[range-middle=true]:rounded-none data-[range-middle=true]:bg-muted data-[range-middle=true]:text-foreground data-[range-start=true]:rounded-(--cell-radius) data-[range-start=true]:rounded-l-(--cell-radius) data-[range-start=true]:bg-primary data-[range-start=true]:text-primary-foreground data-[selected-single=true]:bg-primary data-[selected-single=true]:text-primary-foreground dark:hover:text-foreground [&>span]:text-xs [&>span]:opacity-70",
|
|
212
214
|
defaultClassNames.day,
|
|
213
215
|
className
|
|
214
216
|
)}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import type { Meta, StoryObj } from '@storybook/react-vite';
|
|
2
|
+
import { Card, CardHeader, CardTitle, CardDescription, CardContent, CardFooter } from "./card"; import { Button } from "./button";
|
|
3
|
+
|
|
4
|
+
const meta = {
|
|
5
|
+
title: 'Design System/Card',
|
|
6
|
+
parameters: { layout: 'centered' },
|
|
7
|
+
tags: ['autodocs'],
|
|
8
|
+
} satisfies Meta;
|
|
9
|
+
|
|
10
|
+
export default meta;
|
|
11
|
+
type Story = StoryObj<typeof meta>;
|
|
12
|
+
|
|
13
|
+
export const Default: Story = {
|
|
14
|
+
render: () => (
|
|
15
|
+
<div className="p-4 w-full h-full flex items-center justify-center">
|
|
16
|
+
<Card className="w-[350px]"><CardHeader><CardTitle>Create project</CardTitle><CardDescription>Deploy your new project in one-click.</CardDescription></CardHeader><CardContent><p>Card Content</p></CardContent><CardFooter className="flex justify-between"><Button variant="outline">Cancel</Button><Button>Deploy</Button></CardFooter></Card>
|
|
17
|
+
</div>
|
|
18
|
+
)
|
|
19
|
+
};
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { render } from '@testing-library/react';
|
|
2
|
+
import { axe } from 'jest-axe';
|
|
3
|
+
import { Card, CardHeader, CardTitle, CardDescription, CardContent, CardFooter } from "./card"; import { Button } from "./button";
|
|
4
|
+
|
|
5
|
+
describe('Card Accessibility', () => {
|
|
6
|
+
it('should have no accessibility violations in basic render', async () => {
|
|
7
|
+
const Wrapper = () => (
|
|
8
|
+
<Card className="w-[350px]"><CardHeader><CardTitle>Create project</CardTitle><CardDescription>Deploy your new project in one-click.</CardDescription></CardHeader><CardContent><p>Card Content</p></CardContent><CardFooter className="flex justify-between"><Button variant="outline">Cancel</Button><Button>Deploy</Button></CardFooter></Card>
|
|
9
|
+
);
|
|
10
|
+
const { container } = render(<Wrapper />);
|
|
11
|
+
const results = await axe(container);
|
|
12
|
+
expect(results).toHaveNoViolations();
|
|
13
|
+
});
|
|
14
|
+
});
|
|
@@ -1,18 +1,25 @@
|
|
|
1
|
-
|
|
1
|
+
"use client"
|
|
2
2
|
|
|
3
|
-
import
|
|
3
|
+
import * as React from "react"
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
import { cn } from "@/lib/utils"
|
|
6
|
+
|
|
7
|
+
function Card({
|
|
8
|
+
className,
|
|
9
|
+
size = "default",
|
|
10
|
+
...props
|
|
11
|
+
}: React.ComponentProps<"div"> & { size?: "default" | "sm" }) {
|
|
6
12
|
return (
|
|
7
13
|
<div
|
|
8
14
|
data-slot="card"
|
|
15
|
+
data-size={size}
|
|
9
16
|
className={cn(
|
|
10
|
-
"
|
|
17
|
+
"group/card flex flex-col gap-(--card-spacing) overflow-hidden rounded-xl bg-card py-(--card-spacing) text-sm text-card-foreground border border-border/50 shadow-sm [--card-spacing:--spacing(4)] has-data-[slot=card-footer]:pb-0 has-[>img:first-child]:pt-0 data-[size=sm]:[--card-spacing:--spacing(3)] data-[size=sm]:has-data-[slot=card-footer]:pb-0 *:[img:first-child]:rounded-t-xl *:[img:last-child]:rounded-b-xl",
|
|
11
18
|
className
|
|
12
19
|
)}
|
|
13
20
|
{...props}
|
|
14
21
|
/>
|
|
15
|
-
)
|
|
22
|
+
)
|
|
16
23
|
}
|
|
17
24
|
|
|
18
25
|
function CardHeader({ className, ...props }: React.ComponentProps<"div">) {
|
|
@@ -20,32 +27,35 @@ function CardHeader({ className, ...props }: React.ComponentProps<"div">) {
|
|
|
20
27
|
<div
|
|
21
28
|
data-slot="card-header"
|
|
22
29
|
className={cn(
|
|
23
|
-
"@container/card-header grid auto-rows-min
|
|
30
|
+
"group/card-header @container/card-header grid auto-rows-min items-start gap-1 rounded-t-xl px-(--card-spacing) has-data-[slot=card-action]:grid-cols-[1fr_auto] has-data-[slot=card-description]:grid-rows-[auto_auto] [.border-b]:pb-(--card-spacing)",
|
|
24
31
|
className
|
|
25
32
|
)}
|
|
26
33
|
{...props}
|
|
27
34
|
/>
|
|
28
|
-
)
|
|
35
|
+
)
|
|
29
36
|
}
|
|
30
37
|
|
|
31
38
|
function CardTitle({ className, ...props }: React.ComponentProps<"div">) {
|
|
32
39
|
return (
|
|
33
40
|
<div
|
|
34
41
|
data-slot="card-title"
|
|
35
|
-
className={cn(
|
|
42
|
+
className={cn(
|
|
43
|
+
"font-heading text-base leading-snug font-medium group-data-[size=sm]/card:text-sm",
|
|
44
|
+
className
|
|
45
|
+
)}
|
|
36
46
|
{...props}
|
|
37
47
|
/>
|
|
38
|
-
)
|
|
48
|
+
)
|
|
39
49
|
}
|
|
40
50
|
|
|
41
51
|
function CardDescription({ className, ...props }: React.ComponentProps<"div">) {
|
|
42
52
|
return (
|
|
43
53
|
<div
|
|
44
54
|
data-slot="card-description"
|
|
45
|
-
className={cn("text-muted-foreground
|
|
55
|
+
className={cn("text-sm text-muted-foreground", className)}
|
|
46
56
|
{...props}
|
|
47
57
|
/>
|
|
48
|
-
)
|
|
58
|
+
)
|
|
49
59
|
}
|
|
50
60
|
|
|
51
61
|
function CardAction({ className, ...props }: React.ComponentProps<"div">) {
|
|
@@ -58,27 +68,30 @@ function CardAction({ className, ...props }: React.ComponentProps<"div">) {
|
|
|
58
68
|
)}
|
|
59
69
|
{...props}
|
|
60
70
|
/>
|
|
61
|
-
)
|
|
71
|
+
)
|
|
62
72
|
}
|
|
63
73
|
|
|
64
74
|
function CardContent({ className, ...props }: React.ComponentProps<"div">) {
|
|
65
75
|
return (
|
|
66
76
|
<div
|
|
67
77
|
data-slot="card-content"
|
|
68
|
-
className={cn("px-
|
|
78
|
+
className={cn("px-(--card-spacing)", className)}
|
|
69
79
|
{...props}
|
|
70
80
|
/>
|
|
71
|
-
)
|
|
81
|
+
)
|
|
72
82
|
}
|
|
73
83
|
|
|
74
84
|
function CardFooter({ className, ...props }: React.ComponentProps<"div">) {
|
|
75
85
|
return (
|
|
76
86
|
<div
|
|
77
87
|
data-slot="card-footer"
|
|
78
|
-
className={cn(
|
|
88
|
+
className={cn(
|
|
89
|
+
"flex items-center rounded-b-xl border-t bg-muted/50 p-(--card-spacing)",
|
|
90
|
+
className
|
|
91
|
+
)}
|
|
79
92
|
{...props}
|
|
80
93
|
/>
|
|
81
|
-
)
|
|
94
|
+
)
|
|
82
95
|
}
|
|
83
96
|
|
|
84
97
|
export {
|
|
@@ -89,4 +102,4 @@ export {
|
|
|
89
102
|
CardAction,
|
|
90
103
|
CardDescription,
|
|
91
104
|
CardContent,
|
|
92
|
-
}
|
|
105
|
+
}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import type { Meta, StoryObj } from '@storybook/react-vite';
|
|
2
|
+
import { Carousel, CarouselContent, CarouselItem, CarouselNext, CarouselPrevious } from "./carousel";
|
|
3
|
+
|
|
4
|
+
const meta = {
|
|
5
|
+
title: 'Design System/Carousel',
|
|
6
|
+
parameters: { layout: 'centered' },
|
|
7
|
+
tags: ['autodocs'],
|
|
8
|
+
} satisfies Meta;
|
|
9
|
+
|
|
10
|
+
export default meta;
|
|
11
|
+
type Story = StoryObj<typeof meta>;
|
|
12
|
+
|
|
13
|
+
export const Default: Story = {
|
|
14
|
+
render: () => (
|
|
15
|
+
<div className="p-4 w-full h-full flex items-center justify-center">
|
|
16
|
+
<Carousel className="w-full max-w-xs"><CarouselContent><CarouselItem><div className="p-1">Item 1</div></CarouselItem><CarouselItem><div className="p-1">Item 2</div></CarouselItem></CarouselContent><CarouselPrevious /><CarouselNext /></Carousel>
|
|
17
|
+
</div>
|
|
18
|
+
)
|
|
19
|
+
};
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { render } from '@testing-library/react';
|
|
2
|
+
import { axe } from 'jest-axe';
|
|
3
|
+
import { Carousel, CarouselContent, CarouselItem, CarouselNext, CarouselPrevious } from "./carousel";
|
|
4
|
+
|
|
5
|
+
describe('Carousel Accessibility', () => {
|
|
6
|
+
it('should have no accessibility violations in basic render', async () => {
|
|
7
|
+
const Wrapper = () => (
|
|
8
|
+
<Carousel className="w-full max-w-xs"><CarouselContent><CarouselItem><div className="p-1">Item 1</div></CarouselItem><CarouselItem><div className="p-1">Item 2</div></CarouselItem></CarouselContent><CarouselPrevious /><CarouselNext /></Carousel>
|
|
9
|
+
);
|
|
10
|
+
const { container } = render(<Wrapper />);
|
|
11
|
+
const results = await axe(container);
|
|
12
|
+
expect(results).toHaveNoViolations();
|
|
13
|
+
});
|
|
14
|
+
});
|