@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.
- package/LICENSE.md +110 -0
- package/package.json +185 -0
- package/src/components/accordion.tsx +58 -0
- package/src/components/alert-dialog.tsx +133 -0
- package/src/components/alert.tsx +60 -0
- package/src/components/avatar.tsx +94 -0
- package/src/components/badge.tsx +39 -0
- package/src/components/breadcrumb.tsx +102 -0
- package/src/components/button-group.tsx +78 -0
- package/src/components/button.tsx +58 -0
- package/src/components/checkbox.tsx +27 -0
- package/src/components/command.tsx +168 -0
- package/src/components/control-group.tsx +58 -0
- package/src/components/dialog.tsx +127 -0
- package/src/components/dropdown-menu.tsx +226 -0
- package/src/components/floating-toolbar.tsx +17 -0
- package/src/components/frame.tsx +146 -0
- package/src/components/input-base.tsx +189 -0
- package/src/components/input.tsx +21 -0
- package/src/components/kbd.tsx +28 -0
- package/src/components/label.tsx +21 -0
- package/src/components/panel.tsx +78 -0
- package/src/components/popover.tsx +40 -0
- package/src/components/resizable.tsx +46 -0
- package/src/components/select.tsx +169 -0
- package/src/components/separator.tsx +26 -0
- package/src/components/sheet.tsx +130 -0
- package/src/components/skeleton.tsx +13 -0
- package/src/components/spinner.tsx +16 -0
- package/src/components/switch.tsx +26 -0
- package/src/components/tabs.tsx +52 -0
- package/src/components/textarea.tsx +20 -0
- package/src/components/toaster.tsx +22 -0
- package/src/components/toggle.tsx +45 -0
- package/src/components/tooltip.tsx +55 -0
- package/src/hooks/use-mobile.ts +19 -0
- package/src/lib/utils.ts +15 -0
- package/src/styles/globals.css +120 -0
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import * as TogglePrimitive from "@radix-ui/react-toggle";
|
|
2
|
+
import type { VariantProps } from "class-variance-authority";
|
|
3
|
+
import { cva } from "class-variance-authority";
|
|
4
|
+
import * as React from "react";
|
|
5
|
+
|
|
6
|
+
import { cn } from "../lib/utils";
|
|
7
|
+
|
|
8
|
+
const toggleVariants = cva(
|
|
9
|
+
"inline-flex items-center justify-center gap-2 rounded-md text-sm font-medium hover:bg-muted hover:text-muted-foreground disabled:pointer-events-none disabled:opacity-50 data-[state=on]:bg-accent data-[state=on]:text-accent-foreground [&_svg]:pointer-events-none [&_svg:not([class*='size-'])]:size-4 [&_svg]:shrink-0 focus-visible:border-ring focus-visible:ring-ring/50 focus-visible:ring-[3px] outline-none transition-[color,box-shadow] aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 aria-invalid:border-destructive whitespace-nowrap",
|
|
10
|
+
{
|
|
11
|
+
variants: {
|
|
12
|
+
variant: {
|
|
13
|
+
default: "bg-transparent",
|
|
14
|
+
outline:
|
|
15
|
+
"border border-input bg-transparent shadow-xs hover:bg-accent/50 hover:text-accent-foreground",
|
|
16
|
+
},
|
|
17
|
+
size: {
|
|
18
|
+
default: "h-9 px-2 min-w-9",
|
|
19
|
+
sm: "h-8 px-1.5 min-w-8",
|
|
20
|
+
lg: "h-10 px-2.5 min-w-10",
|
|
21
|
+
},
|
|
22
|
+
},
|
|
23
|
+
defaultVariants: {
|
|
24
|
+
variant: "default",
|
|
25
|
+
size: "default",
|
|
26
|
+
},
|
|
27
|
+
},
|
|
28
|
+
);
|
|
29
|
+
|
|
30
|
+
function Toggle({
|
|
31
|
+
className,
|
|
32
|
+
variant,
|
|
33
|
+
size,
|
|
34
|
+
...props
|
|
35
|
+
}: React.ComponentProps<typeof TogglePrimitive.Root> & VariantProps<typeof toggleVariants>) {
|
|
36
|
+
return (
|
|
37
|
+
<TogglePrimitive.Root
|
|
38
|
+
data-slot="toggle"
|
|
39
|
+
className={cn(toggleVariants({ variant, size, className }))}
|
|
40
|
+
{...props}
|
|
41
|
+
/>
|
|
42
|
+
);
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
export { Toggle, toggleVariants };
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
import * as TooltipPrimitive from "@radix-ui/react-tooltip";
|
|
2
|
+
import * as React from "react";
|
|
3
|
+
|
|
4
|
+
import { cn } from "../lib/utils";
|
|
5
|
+
|
|
6
|
+
function TooltipProvider({
|
|
7
|
+
delayDuration = 0,
|
|
8
|
+
...props
|
|
9
|
+
}: React.ComponentProps<typeof TooltipPrimitive.Provider>) {
|
|
10
|
+
return (
|
|
11
|
+
<TooltipPrimitive.Provider
|
|
12
|
+
data-slot="tooltip-provider"
|
|
13
|
+
delayDuration={delayDuration}
|
|
14
|
+
{...props}
|
|
15
|
+
/>
|
|
16
|
+
);
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
function Tooltip({ ...props }: React.ComponentProps<typeof TooltipPrimitive.Root>) {
|
|
20
|
+
return (
|
|
21
|
+
<TooltipProvider>
|
|
22
|
+
<TooltipPrimitive.Root data-slot="tooltip" {...props} />
|
|
23
|
+
</TooltipProvider>
|
|
24
|
+
);
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
function TooltipTrigger({ ...props }: React.ComponentProps<typeof TooltipPrimitive.Trigger>) {
|
|
28
|
+
return <TooltipPrimitive.Trigger data-slot="tooltip-trigger" {...props} />;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
function TooltipContent({
|
|
32
|
+
className,
|
|
33
|
+
sideOffset = 0,
|
|
34
|
+
children,
|
|
35
|
+
...props
|
|
36
|
+
}: React.ComponentProps<typeof TooltipPrimitive.Content>) {
|
|
37
|
+
return (
|
|
38
|
+
<TooltipPrimitive.Portal>
|
|
39
|
+
<TooltipPrimitive.Content
|
|
40
|
+
data-slot="tooltip-content"
|
|
41
|
+
sideOffset={sideOffset}
|
|
42
|
+
className={cn(
|
|
43
|
+
"bg-foreground text-background animate-in fade-in-0 zoom-in-95 data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=closed]:zoom-out-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 z-50 w-fit origin-(--radix-tooltip-content-transform-origin) rounded-md px-3 py-1.5 text-xs text-balance",
|
|
44
|
+
className,
|
|
45
|
+
)}
|
|
46
|
+
{...props}
|
|
47
|
+
>
|
|
48
|
+
{children}
|
|
49
|
+
<TooltipPrimitive.Arrow className="bg-foreground fill-foreground z-50 size-2.5 translate-y-[calc(-50%_-_2px)] rotate-45 rounded-[2px]" />
|
|
50
|
+
</TooltipPrimitive.Content>
|
|
51
|
+
</TooltipPrimitive.Portal>
|
|
52
|
+
);
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
export { Tooltip, TooltipTrigger, TooltipContent, TooltipProvider };
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import * as React from "react";
|
|
2
|
+
|
|
3
|
+
const MOBILE_BREAKPOINT = 768;
|
|
4
|
+
|
|
5
|
+
export function useIsMobile() {
|
|
6
|
+
const [isMobile, setIsMobile] = React.useState<boolean | undefined>(undefined);
|
|
7
|
+
|
|
8
|
+
React.useEffect(() => {
|
|
9
|
+
const mql = window.matchMedia(`(max-width: ${MOBILE_BREAKPOINT - 1}px)`);
|
|
10
|
+
const onChange = () => {
|
|
11
|
+
setIsMobile(window.innerWidth < MOBILE_BREAKPOINT);
|
|
12
|
+
};
|
|
13
|
+
mql.addEventListener("change", onChange);
|
|
14
|
+
setIsMobile(window.innerWidth < MOBILE_BREAKPOINT);
|
|
15
|
+
return () => mql.removeEventListener("change", onChange);
|
|
16
|
+
}, []);
|
|
17
|
+
|
|
18
|
+
return !!isMobile;
|
|
19
|
+
}
|
package/src/lib/utils.ts
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import type { ClassValue } from "clsx";
|
|
2
|
+
import { clsx } from "clsx";
|
|
3
|
+
import { twMerge } from "tailwind-merge";
|
|
4
|
+
|
|
5
|
+
export function cn(...inputs: Array<ClassValue>) {
|
|
6
|
+
return twMerge(clsx(inputs));
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
/** Shared focus-ring + validation styles for all input-like elements (Input, Textarea, ContentEditable, etc.) */
|
|
10
|
+
export const INPUT_FOCUS_STYLES =
|
|
11
|
+
"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";
|
|
12
|
+
|
|
13
|
+
/** Shared base styles for input-like elements (border, text, shadow, transition, outline) */
|
|
14
|
+
export const INPUT_BASE_STYLES =
|
|
15
|
+
"border-input placeholder:text-muted-foreground rounded-md border bg-transparent text-base shadow-xs transition-[color,box-shadow] outline-none disabled:cursor-not-allowed disabled:opacity-50 md:text-sm";
|
|
@@ -0,0 +1,120 @@
|
|
|
1
|
+
@custom-variant dark (&:is(.dark *));
|
|
2
|
+
|
|
3
|
+
:root {
|
|
4
|
+
--background: oklch(1 0 0);
|
|
5
|
+
--foreground: theme(--color-zinc-950);
|
|
6
|
+
--card: oklch(1 0 0);
|
|
7
|
+
--card-foreground: theme(--color-zinc-950);
|
|
8
|
+
--popover: oklch(1 0 0);
|
|
9
|
+
--popover-foreground: theme(--color-zinc-950);
|
|
10
|
+
--primary: theme(--color-emerald-500);
|
|
11
|
+
--primary-foreground: theme(--color-emerald-50);
|
|
12
|
+
--secondary: theme(--color-zinc-100);
|
|
13
|
+
--secondary-foreground: theme(--color-zinc-900);
|
|
14
|
+
--muted: theme(--color-zinc-100);
|
|
15
|
+
--muted-foreground: theme(--color-zinc-500);
|
|
16
|
+
--accent: oklch(0.95 0.01 252);
|
|
17
|
+
--accent-foreground: theme(--color-slate-900);
|
|
18
|
+
--destructive: theme(--color-red-600);
|
|
19
|
+
--destructive-foreground: theme(--color-red-600);
|
|
20
|
+
--border: theme(--color-zinc-200);
|
|
21
|
+
--input: theme(--color-zinc-200);
|
|
22
|
+
--ring: theme(--color-zinc-400);
|
|
23
|
+
--chart-1: theme(--color-orange-600);
|
|
24
|
+
--chart-2: theme(--color-teal-600);
|
|
25
|
+
--chart-3: theme(--color-cyan-900);
|
|
26
|
+
--chart-4: theme(--color-amber-400);
|
|
27
|
+
--chart-5: theme(--color-amber-500);
|
|
28
|
+
--radius: 0.7rem;
|
|
29
|
+
--sidebar: theme(--color-zinc-50);
|
|
30
|
+
--sidebar-foreground: theme(--color-zinc-950);
|
|
31
|
+
--sidebar-primary: theme(--color-zinc-900);
|
|
32
|
+
--sidebar-primary-foreground: theme(--color-zinc-50);
|
|
33
|
+
--sidebar-accent: theme(--color-zinc-100);
|
|
34
|
+
--sidebar-accent-foreground: theme(--color-zinc-900);
|
|
35
|
+
--sidebar-border: theme(--color-zinc-200);
|
|
36
|
+
--sidebar-ring: theme(--color-zinc-400);
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
.dark {
|
|
40
|
+
--background: theme(--color-zinc-950);
|
|
41
|
+
--foreground: theme(--color-zinc-50);
|
|
42
|
+
--card: theme(--color-zinc-900);
|
|
43
|
+
--card-foreground: theme(--color-zinc-50);
|
|
44
|
+
--popover: theme(--color-zinc-900);
|
|
45
|
+
--popover-foreground: theme(--color-zinc-50);
|
|
46
|
+
--primary: theme(--color-emerald-600);
|
|
47
|
+
--primary-foreground: theme(--color-emerald-50);
|
|
48
|
+
--secondary: theme(--color-zinc-800);
|
|
49
|
+
--secondary-foreground: theme(--color-zinc-50);
|
|
50
|
+
--muted: theme(--color-zinc-800);
|
|
51
|
+
--muted-foreground: theme(--color-zinc-400);
|
|
52
|
+
--accent: theme(--color-slate-800);
|
|
53
|
+
--accent-foreground: theme(--color-slate-50);
|
|
54
|
+
--destructive: theme(--color-red-400);
|
|
55
|
+
--destructive-foreground: theme(--color-red-500);
|
|
56
|
+
--border: oklch(1 0 0 / 10%);
|
|
57
|
+
--input: oklch(1 0 0 / 15%);
|
|
58
|
+
--ring: theme(--color-zinc-500);
|
|
59
|
+
--chart-1: theme(--color-blue-700);
|
|
60
|
+
--chart-2: theme(--color-emerald-500);
|
|
61
|
+
--chart-3: theme(--color-amber-500);
|
|
62
|
+
--chart-4: theme(--color-purple-500);
|
|
63
|
+
--chart-5: theme(--color-rose-600);
|
|
64
|
+
--sidebar: theme(--color-zinc-900);
|
|
65
|
+
--sidebar-foreground: theme(--color-zinc-50);
|
|
66
|
+
--sidebar-primary: theme(--color-blue-700);
|
|
67
|
+
--sidebar-primary-foreground: theme(--color-zinc-50);
|
|
68
|
+
--sidebar-accent: theme(--color-zinc-800);
|
|
69
|
+
--sidebar-accent-foreground: theme(--color-zinc-50);
|
|
70
|
+
--sidebar-border: oklch(1 0 0 / 10%);
|
|
71
|
+
--sidebar-ring: theme(--color-zinc-500);
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
@theme inline {
|
|
75
|
+
--color-background: var(--background);
|
|
76
|
+
--color-foreground: var(--foreground);
|
|
77
|
+
--color-card: var(--card);
|
|
78
|
+
--color-card-foreground: var(--card-foreground);
|
|
79
|
+
--color-popover: var(--popover);
|
|
80
|
+
--color-popover-foreground: var(--popover-foreground);
|
|
81
|
+
--color-primary: var(--primary);
|
|
82
|
+
--color-primary-foreground: var(--primary-foreground);
|
|
83
|
+
--color-secondary: var(--secondary);
|
|
84
|
+
--color-secondary-foreground: var(--secondary-foreground);
|
|
85
|
+
--color-muted: var(--muted);
|
|
86
|
+
--color-muted-foreground: var(--muted-foreground);
|
|
87
|
+
--color-accent: var(--accent);
|
|
88
|
+
--color-accent-foreground: var(--accent-foreground);
|
|
89
|
+
--color-destructive: var(--destructive);
|
|
90
|
+
--color-destructive-foreground: var(--destructive-foreground);
|
|
91
|
+
--color-border: var(--border);
|
|
92
|
+
--color-input: var(--input);
|
|
93
|
+
--color-ring: var(--ring);
|
|
94
|
+
--color-chart-1: var(--chart-1);
|
|
95
|
+
--color-chart-2: var(--chart-2);
|
|
96
|
+
--color-chart-3: var(--chart-3);
|
|
97
|
+
--color-chart-4: var(--chart-4);
|
|
98
|
+
--color-chart-5: var(--chart-5);
|
|
99
|
+
--radius-sm: calc(var(--radius) - 4px);
|
|
100
|
+
--radius-md: calc(var(--radius) - 2px);
|
|
101
|
+
--radius-lg: var(--radius);
|
|
102
|
+
--radius-xl: calc(var(--radius) + 4px);
|
|
103
|
+
--color-sidebar: var(--sidebar);
|
|
104
|
+
--color-sidebar-foreground: var(--sidebar-foreground);
|
|
105
|
+
--color-sidebar-primary: var(--sidebar-primary);
|
|
106
|
+
--color-sidebar-primary-foreground: var(--sidebar-primary-foreground);
|
|
107
|
+
--color-sidebar-accent: var(--sidebar-accent);
|
|
108
|
+
--color-sidebar-accent-foreground: var(--sidebar-accent-foreground);
|
|
109
|
+
--color-sidebar-border: var(--sidebar-border);
|
|
110
|
+
--color-sidebar-ring: var(--sidebar-ring);
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
@layer base {
|
|
114
|
+
* {
|
|
115
|
+
@apply border-border outline-ring/50;
|
|
116
|
+
}
|
|
117
|
+
body {
|
|
118
|
+
@apply bg-background text-foreground;
|
|
119
|
+
}
|
|
120
|
+
}
|