@camox/ui 0.1.1-alpha.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 (38) hide show
  1. package/LICENSE.md +110 -0
  2. package/package.json +185 -0
  3. package/src/components/accordion.tsx +58 -0
  4. package/src/components/alert-dialog.tsx +133 -0
  5. package/src/components/alert.tsx +60 -0
  6. package/src/components/avatar.tsx +94 -0
  7. package/src/components/badge.tsx +39 -0
  8. package/src/components/breadcrumb.tsx +102 -0
  9. package/src/components/button-group.tsx +78 -0
  10. package/src/components/button.tsx +58 -0
  11. package/src/components/checkbox.tsx +27 -0
  12. package/src/components/command.tsx +168 -0
  13. package/src/components/control-group.tsx +58 -0
  14. package/src/components/dialog.tsx +127 -0
  15. package/src/components/dropdown-menu.tsx +226 -0
  16. package/src/components/floating-toolbar.tsx +17 -0
  17. package/src/components/frame.tsx +146 -0
  18. package/src/components/input-base.tsx +189 -0
  19. package/src/components/input.tsx +21 -0
  20. package/src/components/kbd.tsx +28 -0
  21. package/src/components/label.tsx +21 -0
  22. package/src/components/panel.tsx +78 -0
  23. package/src/components/popover.tsx +40 -0
  24. package/src/components/resizable.tsx +46 -0
  25. package/src/components/select.tsx +169 -0
  26. package/src/components/separator.tsx +26 -0
  27. package/src/components/sheet.tsx +130 -0
  28. package/src/components/skeleton.tsx +13 -0
  29. package/src/components/spinner.tsx +16 -0
  30. package/src/components/switch.tsx +26 -0
  31. package/src/components/tabs.tsx +52 -0
  32. package/src/components/textarea.tsx +20 -0
  33. package/src/components/toaster.tsx +22 -0
  34. package/src/components/toggle.tsx +45 -0
  35. package/src/components/tooltip.tsx +55 -0
  36. package/src/hooks/use-mobile.ts +19 -0
  37. package/src/lib/utils.ts +15 -0
  38. package/src/styles/globals.css +120 -0
package/LICENSE.md ADDED
@@ -0,0 +1,110 @@
1
+ # Functional Source License, Version 1.1, MIT Future License
2
+
3
+ ## Abbreviation
4
+
5
+ FSL-1.1-MIT
6
+
7
+ ## Notice
8
+
9
+ Copyright 2026 Rémi de Juvigny
10
+
11
+ ## Terms and Conditions
12
+
13
+ ### Licensor ("We")
14
+
15
+ The party offering the Software under these Terms and Conditions.
16
+
17
+ ### The Software
18
+
19
+ The "Software" is each version of the software that we make available under
20
+ these Terms and Conditions, as indicated by our inclusion of these Terms and
21
+ Conditions with the Software.
22
+
23
+ ### License Grant
24
+
25
+ Subject to your compliance with this License Grant and the Patents,
26
+ Redistribution and Trademark clauses below, we hereby grant you the right to
27
+ use, copy, modify, create derivative works, publicly perform, publicly display
28
+ and redistribute the Software for any Permitted Purpose identified below.
29
+
30
+ ### Permitted Purpose
31
+
32
+ A Permitted Purpose is any purpose other than a Competing Use. A Competing Use
33
+ means making the Software available to others in a commercial product or
34
+ service that:
35
+
36
+ 1. substitutes for the Software;
37
+
38
+ 2. substitutes for any other product or service we offer using the Software
39
+ that exists as of the date we make the Software available; or
40
+
41
+ 3. offers the same or substantially similar functionality as the Software.
42
+
43
+ Permitted Purposes specifically include using the Software:
44
+
45
+ 1. for your internal use and access;
46
+
47
+ 2. for non-commercial education;
48
+
49
+ 3. for non-commercial research; and
50
+
51
+ 4. in connection with professional services that you provide to a licensee
52
+ using the Software in accordance with these Terms and Conditions.
53
+
54
+ ### Patents
55
+
56
+ To the extent your use for a Permitted Purpose would necessarily infringe our
57
+ patents, the license grant above includes a license under our patents. If you
58
+ make a claim against any party that the Software infringes or contributes to
59
+ the infringement of any patent, then your patent license to the Software ends
60
+ immediately.
61
+
62
+ ### Redistribution
63
+
64
+ The Terms and Conditions apply to all copies, modifications and derivatives of
65
+ the Software.
66
+
67
+ If you redistribute any copies, modifications or derivatives of the Software,
68
+ you must include a copy of or a link to these Terms and Conditions and not
69
+ remove any copyright notices provided in or with the Software.
70
+
71
+ ### Disclaimer
72
+
73
+ THE SOFTWARE IS PROVIDED "AS IS" AND WITHOUT WARRANTIES OF ANY KIND, EXPRESS OR
74
+ IMPLIED, INCLUDING WITHOUT LIMITATION WARRANTIES OF FITNESS FOR A PARTICULAR
75
+ PURPOSE, MERCHANTABILITY, TITLE OR NON-INFRINGEMENT.
76
+
77
+ IN NO EVENT WILL WE HAVE ANY LIABILITY TO YOU ARISING OUT OF OR RELATED TO THE
78
+ SOFTWARE, INCLUDING INDIRECT, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES,
79
+ EVEN IF WE HAVE BEEN INFORMED OF THEIR POSSIBILITY IN ADVANCE.
80
+
81
+ ### Trademarks
82
+
83
+ Except for displaying the License Details and identifying us as the origin of
84
+ the Software, you have no right under these Terms and Conditions to use our
85
+ trademarks, trade names, service marks or product names.
86
+
87
+ ## Grant of Future License
88
+
89
+ We hereby irrevocably grant you an additional license to use the Software under
90
+ the MIT license that is effective on the second anniversary of the date we make
91
+ the Software available. On or after that date, you may use the Software under
92
+ the MIT license, in which case the following will apply:
93
+
94
+ Permission is hereby granted, free of charge, to any person obtaining a copy of
95
+ this software and associated documentation files (the "Software"), to deal in
96
+ the Software without restriction, including without limitation the rights to
97
+ use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
98
+ of the Software, and to permit persons to whom the Software is furnished to do
99
+ so, subject to the following conditions:
100
+
101
+ The above copyright notice and this permission notice shall be included in all
102
+ copies or substantial portions of the Software.
103
+
104
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
105
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
106
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
107
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
108
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
109
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
110
+ SOFTWARE.
package/package.json ADDED
@@ -0,0 +1,185 @@
1
+ {
2
+ "name": "@camox/ui",
3
+ "version": "0.1.1-alpha.0",
4
+ "files": [
5
+ "src"
6
+ ],
7
+ "type": "module",
8
+ "exports": {
9
+ "./utils": {
10
+ "types": "./src/lib/utils.ts",
11
+ "default": "./src/lib/utils.ts"
12
+ },
13
+ "./accordion": {
14
+ "types": "./src/components/accordion.tsx",
15
+ "default": "./src/components/accordion.tsx"
16
+ },
17
+ "./alert-dialog": {
18
+ "types": "./src/components/alert-dialog.tsx",
19
+ "default": "./src/components/alert-dialog.tsx"
20
+ },
21
+ "./alert": {
22
+ "types": "./src/components/alert.tsx",
23
+ "default": "./src/components/alert.tsx"
24
+ },
25
+ "./avatar": {
26
+ "types": "./src/components/avatar.tsx",
27
+ "default": "./src/components/avatar.tsx"
28
+ },
29
+ "./badge": {
30
+ "types": "./src/components/badge.tsx",
31
+ "default": "./src/components/badge.tsx"
32
+ },
33
+ "./breadcrumb": {
34
+ "types": "./src/components/breadcrumb.tsx",
35
+ "default": "./src/components/breadcrumb.tsx"
36
+ },
37
+ "./button-group": {
38
+ "types": "./src/components/button-group.tsx",
39
+ "default": "./src/components/button-group.tsx"
40
+ },
41
+ "./button": {
42
+ "types": "./src/components/button.tsx",
43
+ "default": "./src/components/button.tsx"
44
+ },
45
+ "./checkbox": {
46
+ "types": "./src/components/checkbox.tsx",
47
+ "default": "./src/components/checkbox.tsx"
48
+ },
49
+ "./command": {
50
+ "types": "./src/components/command.tsx",
51
+ "default": "./src/components/command.tsx"
52
+ },
53
+ "./control-group": {
54
+ "types": "./src/components/control-group.tsx",
55
+ "default": "./src/components/control-group.tsx"
56
+ },
57
+ "./dialog": {
58
+ "types": "./src/components/dialog.tsx",
59
+ "default": "./src/components/dialog.tsx"
60
+ },
61
+ "./dropdown-menu": {
62
+ "types": "./src/components/dropdown-menu.tsx",
63
+ "default": "./src/components/dropdown-menu.tsx"
64
+ },
65
+ "./floating-toolbar": {
66
+ "types": "./src/components/floating-toolbar.tsx",
67
+ "default": "./src/components/floating-toolbar.tsx"
68
+ },
69
+ "./frame": {
70
+ "types": "./src/components/frame.tsx",
71
+ "default": "./src/components/frame.tsx"
72
+ },
73
+ "./input-base": {
74
+ "types": "./src/components/input-base.tsx",
75
+ "default": "./src/components/input-base.tsx"
76
+ },
77
+ "./input": {
78
+ "types": "./src/components/input.tsx",
79
+ "default": "./src/components/input.tsx"
80
+ },
81
+ "./kbd": {
82
+ "types": "./src/components/kbd.tsx",
83
+ "default": "./src/components/kbd.tsx"
84
+ },
85
+ "./label": {
86
+ "types": "./src/components/label.tsx",
87
+ "default": "./src/components/label.tsx"
88
+ },
89
+ "./panel": {
90
+ "types": "./src/components/panel.tsx",
91
+ "default": "./src/components/panel.tsx"
92
+ },
93
+ "./popover": {
94
+ "types": "./src/components/popover.tsx",
95
+ "default": "./src/components/popover.tsx"
96
+ },
97
+ "./resizable": {
98
+ "types": "./src/components/resizable.tsx",
99
+ "default": "./src/components/resizable.tsx"
100
+ },
101
+ "./select": {
102
+ "types": "./src/components/select.tsx",
103
+ "default": "./src/components/select.tsx"
104
+ },
105
+ "./separator": {
106
+ "types": "./src/components/separator.tsx",
107
+ "default": "./src/components/separator.tsx"
108
+ },
109
+ "./sheet": {
110
+ "types": "./src/components/sheet.tsx",
111
+ "default": "./src/components/sheet.tsx"
112
+ },
113
+ "./skeleton": {
114
+ "types": "./src/components/skeleton.tsx",
115
+ "default": "./src/components/skeleton.tsx"
116
+ },
117
+ "./spinner": {
118
+ "types": "./src/components/spinner.tsx",
119
+ "default": "./src/components/spinner.tsx"
120
+ },
121
+ "./switch": {
122
+ "types": "./src/components/switch.tsx",
123
+ "default": "./src/components/switch.tsx"
124
+ },
125
+ "./tabs": {
126
+ "types": "./src/components/tabs.tsx",
127
+ "default": "./src/components/tabs.tsx"
128
+ },
129
+ "./textarea": {
130
+ "types": "./src/components/textarea.tsx",
131
+ "default": "./src/components/textarea.tsx"
132
+ },
133
+ "./toaster": {
134
+ "types": "./src/components/toaster.tsx",
135
+ "default": "./src/components/toaster.tsx"
136
+ },
137
+ "./toggle": {
138
+ "types": "./src/components/toggle.tsx",
139
+ "default": "./src/components/toggle.tsx"
140
+ },
141
+ "./tooltip": {
142
+ "types": "./src/components/tooltip.tsx",
143
+ "default": "./src/components/tooltip.tsx"
144
+ },
145
+ "./use-mobile": {
146
+ "types": "./src/hooks/use-mobile.ts",
147
+ "default": "./src/hooks/use-mobile.ts"
148
+ }
149
+ },
150
+ "dependencies": {
151
+ "@radix-ui/primitive": "1.1.2",
152
+ "@radix-ui/react-accordion": "^1.2.12",
153
+ "@radix-ui/react-alert-dialog": "^1.1.15",
154
+ "@radix-ui/react-checkbox": "^1.3.3",
155
+ "@radix-ui/react-compose-refs": "1.1.2",
156
+ "@radix-ui/react-dialog": "^1.1.15",
157
+ "@radix-ui/react-dropdown-menu": "^2.1.16",
158
+ "@radix-ui/react-label": "^2.1.7",
159
+ "@radix-ui/react-popover": "^1.1.15",
160
+ "@radix-ui/react-primitive": "2.1.2",
161
+ "@radix-ui/react-select": "^2.2.6",
162
+ "@radix-ui/react-separator": "^1.1.7",
163
+ "@radix-ui/react-slot": "^1.2.3",
164
+ "@radix-ui/react-switch": "^1.2.6",
165
+ "@radix-ui/react-tabs": "^1.1.13",
166
+ "@radix-ui/react-toggle": "^1.1.10",
167
+ "@radix-ui/react-tooltip": "^1.2.8",
168
+ "@window-splitter/react": "^1.1.2",
169
+ "class-variance-authority": "^0.7.1",
170
+ "clsx": "^2.1.1",
171
+ "cmdk": "^1.1.1",
172
+ "lucide-react": "^0.476.0",
173
+ "radix-ui": "^1.4.3",
174
+ "sonner": "^2.0.7",
175
+ "tailwind-merge": "^3.0.2"
176
+ },
177
+ "devDependencies": {
178
+ "@types/react": "^19.0.8",
179
+ "@types/react-dom": "^19.0.3"
180
+ },
181
+ "peerDependencies": {
182
+ "react": ">=18",
183
+ "react-dom": ">=18"
184
+ }
185
+ }
@@ -0,0 +1,58 @@
1
+ import * as AccordionPrimitive from "@radix-ui/react-accordion";
2
+ import * as React from "react";
3
+
4
+ import { cn } from "../lib/utils";
5
+
6
+ function Accordion({ ...props }: React.ComponentProps<typeof AccordionPrimitive.Root>) {
7
+ return <AccordionPrimitive.Root data-slot="accordion" {...props} />;
8
+ }
9
+
10
+ function AccordionItem({
11
+ className,
12
+ ...props
13
+ }: React.ComponentProps<typeof AccordionPrimitive.Item>) {
14
+ return (
15
+ <AccordionPrimitive.Item
16
+ data-slot="accordion-item"
17
+ className={cn("border-b last:border-b-0", className)}
18
+ {...props}
19
+ />
20
+ );
21
+ }
22
+
23
+ interface AccordionTriggerProps extends React.ComponentProps<typeof AccordionPrimitive.Trigger> {}
24
+
25
+ function AccordionTrigger({ className, children, ...props }: AccordionTriggerProps) {
26
+ return (
27
+ <AccordionPrimitive.Header className="flex">
28
+ <AccordionPrimitive.Trigger
29
+ data-slot="accordion-trigger"
30
+ className={cn(
31
+ "focus-visible:border-ring focus-visible:ring-ring/50 flex flex-1 items-start justify-between gap-4 rounded-md py-4 text-left text-sm font-medium transition-all outline-none focus-visible:ring-[3px] disabled:pointer-events-none disabled:opacity-50 [&[data-state=open]>svg]:rotate-180",
32
+ className,
33
+ )}
34
+ {...props}
35
+ >
36
+ {children}
37
+ </AccordionPrimitive.Trigger>
38
+ </AccordionPrimitive.Header>
39
+ );
40
+ }
41
+
42
+ function AccordionContent({
43
+ className,
44
+ children,
45
+ ...props
46
+ }: React.ComponentProps<typeof AccordionPrimitive.Content>) {
47
+ return (
48
+ <AccordionPrimitive.Content
49
+ data-slot="accordion-content"
50
+ className="data-[state=closed]:animate-accordion-up data-[state=open]:animate-accordion-down overflow-hidden text-sm"
51
+ {...props}
52
+ >
53
+ <div className={cn("pt-0 pb-4", className)}>{children}</div>
54
+ </AccordionPrimitive.Content>
55
+ );
56
+ }
57
+
58
+ export { Accordion, AccordionItem, AccordionTrigger, AccordionContent };
@@ -0,0 +1,133 @@
1
+ import * as AlertDialogPrimitive from "@radix-ui/react-alert-dialog";
2
+ import * as React from "react";
3
+
4
+ import { cn } from "../lib/utils";
5
+ import { buttonVariants } from "./button";
6
+
7
+ function AlertDialog({ ...props }: React.ComponentProps<typeof AlertDialogPrimitive.Root>) {
8
+ return <AlertDialogPrimitive.Root data-slot="alert-dialog" {...props} />;
9
+ }
10
+
11
+ function AlertDialogTrigger({
12
+ ...props
13
+ }: React.ComponentProps<typeof AlertDialogPrimitive.Trigger>) {
14
+ return <AlertDialogPrimitive.Trigger data-slot="alert-dialog-trigger" {...props} />;
15
+ }
16
+
17
+ function AlertDialogPortal({ ...props }: React.ComponentProps<typeof AlertDialogPrimitive.Portal>) {
18
+ return <AlertDialogPrimitive.Portal data-slot="alert-dialog-portal" {...props} />;
19
+ }
20
+
21
+ function AlertDialogOverlay({
22
+ className,
23
+ ...props
24
+ }: React.ComponentProps<typeof AlertDialogPrimitive.Overlay>) {
25
+ return (
26
+ <AlertDialogPrimitive.Overlay
27
+ data-slot="alert-dialog-overlay"
28
+ className={cn(
29
+ "data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 fixed inset-0 z-50 bg-black/50",
30
+ className,
31
+ )}
32
+ {...props}
33
+ />
34
+ );
35
+ }
36
+
37
+ function AlertDialogContent({
38
+ className,
39
+ ...props
40
+ }: React.ComponentProps<typeof AlertDialogPrimitive.Content>) {
41
+ return (
42
+ <AlertDialogPortal>
43
+ <AlertDialogOverlay />
44
+ <AlertDialogPrimitive.Content
45
+ data-slot="alert-dialog-content"
46
+ className={cn(
47
+ "bg-background data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 fixed top-[50%] left-[50%] z-50 grid w-full max-w-[calc(100%-2rem)] translate-x-[-50%] translate-y-[-50%] gap-4 rounded-lg border p-6 shadow-lg duration-200 sm:max-w-lg",
48
+ className,
49
+ )}
50
+ {...props}
51
+ />
52
+ </AlertDialogPortal>
53
+ );
54
+ }
55
+
56
+ function AlertDialogHeader({ className, ...props }: React.ComponentProps<"div">) {
57
+ return (
58
+ <div
59
+ data-slot="alert-dialog-header"
60
+ className={cn("flex flex-col gap-2 text-center sm:text-left", className)}
61
+ {...props}
62
+ />
63
+ );
64
+ }
65
+
66
+ function AlertDialogFooter({ className, ...props }: React.ComponentProps<"div">) {
67
+ return (
68
+ <div
69
+ data-slot="alert-dialog-footer"
70
+ className={cn("flex flex-col-reverse gap-2 sm:flex-row sm:justify-end", className)}
71
+ {...props}
72
+ />
73
+ );
74
+ }
75
+
76
+ function AlertDialogTitle({
77
+ className,
78
+ ...props
79
+ }: React.ComponentProps<typeof AlertDialogPrimitive.Title>) {
80
+ return (
81
+ <AlertDialogPrimitive.Title
82
+ data-slot="alert-dialog-title"
83
+ className={cn("text-lg font-semibold", className)}
84
+ {...props}
85
+ />
86
+ );
87
+ }
88
+
89
+ function AlertDialogDescription({
90
+ className,
91
+ ...props
92
+ }: React.ComponentProps<typeof AlertDialogPrimitive.Description>) {
93
+ return (
94
+ <AlertDialogPrimitive.Description
95
+ data-slot="alert-dialog-description"
96
+ className={cn("text-muted-foreground text-sm", className)}
97
+ {...props}
98
+ />
99
+ );
100
+ }
101
+
102
+ function AlertDialogAction({
103
+ className,
104
+ ...props
105
+ }: React.ComponentProps<typeof AlertDialogPrimitive.Action>) {
106
+ return <AlertDialogPrimitive.Action className={cn(buttonVariants(), className)} {...props} />;
107
+ }
108
+
109
+ function AlertDialogCancel({
110
+ className,
111
+ ...props
112
+ }: React.ComponentProps<typeof AlertDialogPrimitive.Cancel>) {
113
+ return (
114
+ <AlertDialogPrimitive.Cancel
115
+ className={cn(buttonVariants({ variant: "outline" }), className)}
116
+ {...props}
117
+ />
118
+ );
119
+ }
120
+
121
+ export {
122
+ AlertDialog,
123
+ AlertDialogPortal,
124
+ AlertDialogOverlay,
125
+ AlertDialogTrigger,
126
+ AlertDialogContent,
127
+ AlertDialogHeader,
128
+ AlertDialogFooter,
129
+ AlertDialogTitle,
130
+ AlertDialogDescription,
131
+ AlertDialogAction,
132
+ AlertDialogCancel,
133
+ };
@@ -0,0 +1,60 @@
1
+ import { cva, type VariantProps } from "class-variance-authority";
2
+ import * as React from "react";
3
+
4
+ import { cn } from "../lib/utils";
5
+
6
+ const alertVariants = cva(
7
+ "relative w-full rounded-lg border px-4 py-3 text-sm grid has-[>svg]:grid-cols-[calc(var(--spacing)*4)_1fr] grid-cols-[0_1fr] has-[>svg]:gap-x-3 gap-y-0.5 items-start [&>svg]:size-4 [&>svg]:translate-y-0.5 [&>svg]:text-current",
8
+ {
9
+ variants: {
10
+ variant: {
11
+ default: "bg-card text-card-foreground",
12
+ destructive:
13
+ "text-destructive bg-card [&>svg]:text-current *:data-[slot=alert-description]:text-destructive/90",
14
+ },
15
+ },
16
+ defaultVariants: {
17
+ variant: "default",
18
+ },
19
+ },
20
+ );
21
+
22
+ function Alert({
23
+ className,
24
+ variant,
25
+ ...props
26
+ }: React.ComponentProps<"div"> & VariantProps<typeof alertVariants>) {
27
+ return (
28
+ <div
29
+ data-slot="alert"
30
+ role="alert"
31
+ className={cn(alertVariants({ variant }), className)}
32
+ {...props}
33
+ />
34
+ );
35
+ }
36
+
37
+ function AlertTitle({ className, ...props }: React.ComponentProps<"div">) {
38
+ return (
39
+ <div
40
+ data-slot="alert-title"
41
+ className={cn("col-start-2 line-clamp-1 min-h-4 font-medium tracking-tight", className)}
42
+ {...props}
43
+ />
44
+ );
45
+ }
46
+
47
+ function AlertDescription({ className, ...props }: React.ComponentProps<"div">) {
48
+ return (
49
+ <div
50
+ data-slot="alert-description"
51
+ className={cn(
52
+ "text-muted-foreground col-start-2 grid justify-items-start gap-1 text-sm [&_p]:leading-relaxed",
53
+ className,
54
+ )}
55
+ {...props}
56
+ />
57
+ );
58
+ }
59
+
60
+ export { Alert, AlertTitle, AlertDescription };
@@ -0,0 +1,94 @@
1
+ import { Avatar as AvatarPrimitive } from "radix-ui";
2
+ import * as React from "react";
3
+
4
+ import { cn } from "../lib/utils";
5
+
6
+ function Avatar({
7
+ className,
8
+ size = "default",
9
+ ...props
10
+ }: React.ComponentProps<typeof AvatarPrimitive.Root> & {
11
+ size?: "default" | "sm" | "lg";
12
+ }) {
13
+ return (
14
+ <AvatarPrimitive.Root
15
+ data-slot="avatar"
16
+ data-size={size}
17
+ className={cn(
18
+ "group/avatar relative flex size-8 shrink-0 overflow-hidden rounded-full select-none data-[size=lg]:size-10 data-[size=sm]:size-6",
19
+ className,
20
+ )}
21
+ {...props}
22
+ />
23
+ );
24
+ }
25
+
26
+ function AvatarImage({ className, ...props }: React.ComponentProps<typeof AvatarPrimitive.Image>) {
27
+ return (
28
+ <AvatarPrimitive.Image
29
+ data-slot="avatar-image"
30
+ className={cn("aspect-square size-full", className)}
31
+ {...props}
32
+ />
33
+ );
34
+ }
35
+
36
+ function AvatarFallback({
37
+ className,
38
+ ...props
39
+ }: React.ComponentProps<typeof AvatarPrimitive.Fallback>) {
40
+ return (
41
+ <AvatarPrimitive.Fallback
42
+ data-slot="avatar-fallback"
43
+ className={cn(
44
+ "flex size-full items-center justify-center rounded-full bg-muted text-sm text-muted-foreground group-data-[size=sm]/avatar:text-xs",
45
+ className,
46
+ )}
47
+ {...props}
48
+ />
49
+ );
50
+ }
51
+
52
+ function AvatarBadge({ className, ...props }: React.ComponentProps<"span">) {
53
+ return (
54
+ <span
55
+ data-slot="avatar-badge"
56
+ className={cn(
57
+ "absolute right-0 bottom-0 z-10 inline-flex items-center justify-center rounded-full bg-primary text-primary-foreground ring-2 ring-background select-none",
58
+ "group-data-[size=sm]/avatar:size-2 group-data-[size=sm]/avatar:[&>svg]:hidden",
59
+ "group-data-[size=default]/avatar:size-2.5 group-data-[size=default]/avatar:[&>svg]:size-2",
60
+ "group-data-[size=lg]/avatar:size-3 group-data-[size=lg]/avatar:[&>svg]:size-2",
61
+ className,
62
+ )}
63
+ {...props}
64
+ />
65
+ );
66
+ }
67
+
68
+ function AvatarGroup({ className, ...props }: React.ComponentProps<"div">) {
69
+ return (
70
+ <div
71
+ data-slot="avatar-group"
72
+ className={cn(
73
+ "group/avatar-group flex -space-x-2 *:data-[slot=avatar]:ring-2 *:data-[slot=avatar]:ring-background",
74
+ className,
75
+ )}
76
+ {...props}
77
+ />
78
+ );
79
+ }
80
+
81
+ function AvatarGroupCount({ className, ...props }: React.ComponentProps<"div">) {
82
+ return (
83
+ <div
84
+ data-slot="avatar-group-count"
85
+ className={cn(
86
+ "relative flex size-8 shrink-0 items-center justify-center rounded-full bg-muted text-sm text-muted-foreground ring-2 ring-background group-has-data-[size=lg]/avatar-group:size-10 group-has-data-[size=sm]/avatar-group:size-6 [&>svg]:size-4 group-has-data-[size=lg]/avatar-group:[&>svg]:size-5 group-has-data-[size=sm]/avatar-group:[&>svg]:size-3",
87
+ className,
88
+ )}
89
+ {...props}
90
+ />
91
+ );
92
+ }
93
+
94
+ export { Avatar, AvatarImage, AvatarFallback, AvatarBadge, AvatarGroup, AvatarGroupCount };
@@ -0,0 +1,39 @@
1
+ import { Slot } from "@radix-ui/react-slot";
2
+ import { cva, type VariantProps } from "class-variance-authority";
3
+ import * as React from "react";
4
+
5
+ import { cn } from "../lib/utils";
6
+
7
+ const badgeVariants = cva(
8
+ "inline-flex items-center justify-center rounded-full border px-2 py-0.5 text-xs font-medium w-fit whitespace-nowrap shrink-0 [&>svg]:size-3 gap-1 [&>svg]:pointer-events-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 transition-[color,box-shadow] overflow-hidden",
9
+ {
10
+ variants: {
11
+ variant: {
12
+ default: "border-transparent bg-primary text-primary-foreground [a&]:hover:bg-primary/90",
13
+ secondary:
14
+ "border-transparent bg-secondary text-secondary-foreground [a&]:hover:bg-secondary/90",
15
+ destructive:
16
+ "border-transparent bg-destructive text-white [a&]:hover:bg-destructive/90 focus-visible:ring-destructive/20 dark:focus-visible:ring-destructive/40 dark:bg-destructive/60",
17
+ outline: "text-foreground [a&]:hover:bg-accent [a&]:hover:text-accent-foreground",
18
+ },
19
+ },
20
+ defaultVariants: {
21
+ variant: "default",
22
+ },
23
+ },
24
+ );
25
+
26
+ function Badge({
27
+ className,
28
+ variant,
29
+ asChild = false,
30
+ ...props
31
+ }: React.ComponentProps<"span"> & VariantProps<typeof badgeVariants> & { asChild?: boolean }) {
32
+ const Comp = asChild ? Slot : "span";
33
+
34
+ return (
35
+ <Comp data-slot="badge" className={cn(badgeVariants({ variant }), className)} {...props} />
36
+ );
37
+ }
38
+
39
+ export { Badge, badgeVariants };