react-groundwork 0.0.0-stage → 0.1.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/.env.example +6 -0
- package/.gitattributes +2 -0
- package/.prettierignore +7 -0
- package/.prettierrc.json +12 -0
- package/README.md +24 -2
- package/cli/index.js +119 -0
- package/components.json +25 -0
- package/eslint.config.js +17 -0
- package/index.html +13 -0
- package/jsconfig.json +8 -0
- package/package.json +111 -4
- package/public/.htaccess +11 -0
- package/public/logo.png +0 -0
- package/src/App.jsx +14 -0
- package/src/api/api.routes.js +12 -0
- package/src/api/api.services.js +8 -0
- package/src/api/apiCall.js +128 -0
- package/src/api/apiHelpers.js +20 -0
- package/src/assets/css/index.css +173 -0
- package/src/assets/images/placeholders/placeholder-170x166.png +0 -0
- package/src/assets/images/placeholders/placeholder-360x260.png +0 -0
- package/src/assets/images/placeholders/placeholder-372x225.png +0 -0
- package/src/assets/images/placeholders/placeholder-40x40.png +0 -0
- package/src/assets/images/placeholders/placeholder-451x392.png +0 -0
- package/src/components/common/AppChart.jsx +56 -0
- package/src/components/common/Breadcrumbs.jsx +90 -0
- package/src/components/common/DataTable.jsx +203 -0
- package/src/components/common/DatePicker.jsx +275 -0
- package/src/components/common/DialogComponent.jsx +308 -0
- package/src/components/common/ErrorStateComponent.jsx +46 -0
- package/src/components/common/FullscreenToggle.jsx +54 -0
- package/src/components/common/HeadingComponent.jsx +29 -0
- package/src/components/common/LoadingComponent.jsx +33 -0
- package/src/components/common/NetworkStatus.jsx +103 -0
- package/src/components/common/NoDataComponent.jsx +45 -0
- package/src/components/common/Pagination.jsx +128 -0
- package/src/components/common/ParagraphComponent.jsx +14 -0
- package/src/components/common/PhoneInputComponent.jsx +242 -0
- package/src/components/common/ReactSelect.jsx +145 -0
- package/src/components/common/SearchSelect.jsx +176 -0
- package/src/components/common/SeeMore.jsx +26 -0
- package/src/components/common/SortableHeader.jsx +23 -0
- package/src/components/common/theme-toggle.jsx +39 -0
- package/src/components/layout/AuthLayout.jsx +90 -0
- package/src/components/layout/PageLayout.jsx +32 -0
- package/src/components/layout/SidebarLayout.jsx +233 -0
- package/src/components/ui/avatar.jsx +84 -0
- package/src/components/ui/badge.jsx +43 -0
- package/src/components/ui/button.jsx +44 -0
- package/src/components/ui/card.jsx +69 -0
- package/src/components/ui/checkbox.jsx +25 -0
- package/src/components/ui/dialog.jsx +149 -0
- package/src/components/ui/empty.jsx +82 -0
- package/src/components/ui/input.jsx +19 -0
- package/src/components/ui/label.jsx +19 -0
- package/src/components/ui/select.jsx +156 -0
- package/src/components/ui/skeleton.jsx +7 -0
- package/src/components/ui/sonner.jsx +37 -0
- package/src/components/ui/switch.jsx +23 -0
- package/src/components/ui/table.jsx +74 -0
- package/src/components/ui/textarea.jsx +16 -0
- package/src/constants/constant.js +16 -0
- package/src/context/theme-provider.jsx +48 -0
- package/src/features/components/ComponentFormDialog.jsx +162 -0
- package/src/features/components/ComponentsTable.jsx +219 -0
- package/src/features/components/componentStyles.js +16 -0
- package/src/features/components/mockData.js +407 -0
- package/src/features/playground/BasicsSection.jsx +122 -0
- package/src/features/playground/DataSection.jsx +210 -0
- package/src/features/playground/DemoCard.jsx +21 -0
- package/src/features/playground/FeedbackSection.jsx +309 -0
- package/src/features/playground/FormsSection.jsx +188 -0
- package/src/features/playground/UtilitiesSection.jsx +200 -0
- package/src/hooks/useApiHandler.jsx +82 -0
- package/src/hooks/useDebounce.js +12 -0
- package/src/lib/utils.js +1 -0
- package/src/main.jsx +16 -0
- package/src/pages/auth/ForgotPasswordPage.jsx +101 -0
- package/src/pages/auth/LoginPage.jsx +120 -0
- package/src/pages/auth/SignupPage.jsx +135 -0
- package/src/pages/views/ComponentsPage.jsx +316 -0
- package/src/pages/views/DashboardPage.jsx +260 -0
- package/src/pages/views/LandingPage.jsx +772 -0
- package/src/pages/views/NotFoundPage.jsx +30 -0
- package/src/pages/views/PlaygroundPage.jsx +50 -0
- package/src/routes/AppRoutes.jsx +29 -0
- package/src/routes/ProtectedRoute.jsx +18 -0
- package/src/utils/exportCsv.js +17 -0
- package/src/utils/formatCurrency.js +19 -0
- package/src/utils/formatDateTime.js +34 -0
- package/src/utils/handleSessionExpire.js +22 -0
- package/src/utils/logger.js +34 -0
- package/vite.config.js +23 -0
|
@@ -0,0 +1,233 @@
|
|
|
1
|
+
import React, { useState } from "react";
|
|
2
|
+
import { createPortal } from "react-dom";
|
|
3
|
+
import { Link, useLocation, useNavigate } from "react-router-dom";
|
|
4
|
+
import { motion } from "framer-motion";
|
|
5
|
+
import { cn } from "@/lib/utils";
|
|
6
|
+
import { Menu, X, PanelLeftClose, PanelLeftOpen, LayoutDashboard, Boxes, LogOut, Shapes } from "lucide-react";
|
|
7
|
+
import { handleSessionExpire } from "@/utils/handleSessionExpire";
|
|
8
|
+
import FullscreenToggle from "@/components/common/FullscreenToggle";
|
|
9
|
+
import DialogComponent from "@/components/common/DialogComponent";
|
|
10
|
+
import Breadcrumbs from "@/components/common/Breadcrumbs";
|
|
11
|
+
import { ThemeToggle } from "@/components/common/theme-toggle";
|
|
12
|
+
import { APP_NAME, getUserName, getUserRole, getUserSymbol } from "@/constants/constant";
|
|
13
|
+
|
|
14
|
+
const LOGO = APP_NAME;
|
|
15
|
+
|
|
16
|
+
const navItems = [
|
|
17
|
+
{ label: "Dashboard", path: "/dashboard", icon: LayoutDashboard },
|
|
18
|
+
{ label: "Components", path: "/components", icon: Boxes },
|
|
19
|
+
{ label: "Playground", path: "/playground", icon: Shapes },
|
|
20
|
+
];
|
|
21
|
+
|
|
22
|
+
const NAV_SPRING = { type: "spring", stiffness: 400, damping: 32 };
|
|
23
|
+
|
|
24
|
+
const SidebarLayout = ({ children }) => {
|
|
25
|
+
const [collapsed, setCollapsed] = useState(false);
|
|
26
|
+
const [mobileOpen, setMobileOpen] = useState(false);
|
|
27
|
+
const [tooltip, setTooltip] = useState(null);
|
|
28
|
+
const [hoveredPath, setHoveredPath] = useState(null);
|
|
29
|
+
const [logoutOpen, setLogoutOpen] = useState(false);
|
|
30
|
+
const location = useLocation();
|
|
31
|
+
const navigate = useNavigate();
|
|
32
|
+
|
|
33
|
+
const isActive = (path) => location.pathname === path;
|
|
34
|
+
|
|
35
|
+
return (
|
|
36
|
+
<div className="relative flex h-screen w-full overflow-hidden bg-background">
|
|
37
|
+
{mobileOpen && (
|
|
38
|
+
<div
|
|
39
|
+
className="fixed inset-0 z-40 bg-black/60 backdrop-blur-sm md:hidden"
|
|
40
|
+
onClick={() => setMobileOpen(false)}
|
|
41
|
+
/>
|
|
42
|
+
)}
|
|
43
|
+
|
|
44
|
+
<aside
|
|
45
|
+
className={cn(
|
|
46
|
+
"fixed inset-y-0 left-0 z-50 flex h-full flex-col border-r border-sidebar-border bg-sidebar text-sidebar-foreground transition-all duration-300 ease-in-out",
|
|
47
|
+
"md:static md:translate-x-0",
|
|
48
|
+
collapsed ? "w-[72px]" : "w-64",
|
|
49
|
+
mobileOpen ? "translate-x-0" : "-translate-x-full",
|
|
50
|
+
)}
|
|
51
|
+
>
|
|
52
|
+
<Link to="/dashboard" className="block">
|
|
53
|
+
<div className="flex h-12 shrink-0 items-center justify-between border-b border-sidebar-border px-4">
|
|
54
|
+
{!collapsed ? (
|
|
55
|
+
<div className="flex items-center gap-2 overflow-hidden">
|
|
56
|
+
<div className="flex h-8 w-8 shrink-0 items-center justify-center rounded-lg bg-sidebar-primary text-sm font-bold text-sidebar-primary-foreground">
|
|
57
|
+
{LOGO.charAt(0)}
|
|
58
|
+
</div>
|
|
59
|
+
<span className="truncate text-base font-semibold">{LOGO}</span>
|
|
60
|
+
</div>
|
|
61
|
+
) : (
|
|
62
|
+
<div className="mx-auto flex h-8 w-8 shrink-0 items-center justify-center rounded-lg bg-sidebar-primary text-sm font-bold text-sidebar-primary-foreground">
|
|
63
|
+
{LOGO.charAt(0)}
|
|
64
|
+
</div>
|
|
65
|
+
)}
|
|
66
|
+
|
|
67
|
+
<button
|
|
68
|
+
onClick={(e) => {
|
|
69
|
+
e.preventDefault();
|
|
70
|
+
setMobileOpen(false);
|
|
71
|
+
}}
|
|
72
|
+
aria-label="Close navigation"
|
|
73
|
+
className="rounded-md p-1.5 text-sidebar-foreground/70 hover:bg-sidebar-accent hover:text-sidebar-accent-foreground md:hidden"
|
|
74
|
+
>
|
|
75
|
+
<X className="h-4 w-4" />
|
|
76
|
+
</button>
|
|
77
|
+
</div>
|
|
78
|
+
</Link>
|
|
79
|
+
|
|
80
|
+
<nav
|
|
81
|
+
className="flex-1 space-y-1 overflow-y-auto overflow-x-hidden px-3 py-4"
|
|
82
|
+
onMouseLeave={() => setHoveredPath(null)}
|
|
83
|
+
>
|
|
84
|
+
{navItems.map((item) => {
|
|
85
|
+
const active = isActive(item.path);
|
|
86
|
+
const hovered = hoveredPath === item.path;
|
|
87
|
+
return (
|
|
88
|
+
<Link
|
|
89
|
+
key={item.path}
|
|
90
|
+
to={item.path}
|
|
91
|
+
title={collapsed ? item.label : undefined}
|
|
92
|
+
className={cn(
|
|
93
|
+
"group relative flex items-center gap-3 rounded-lg px-3 py-2.5 text-sm font-medium transition-colors duration-200",
|
|
94
|
+
active ? "text-primary" : "text-sidebar-foreground/70 hover:text-sidebar-accent-foreground",
|
|
95
|
+
collapsed && "justify-center px-0",
|
|
96
|
+
)}
|
|
97
|
+
onClick={() => setMobileOpen(false)}
|
|
98
|
+
onMouseEnter={(e) => {
|
|
99
|
+
setHoveredPath(item.path);
|
|
100
|
+
if (!collapsed) return;
|
|
101
|
+
const rect = e.currentTarget.getBoundingClientRect();
|
|
102
|
+
setTooltip({ label: item.label, top: rect.top + rect.height / 2, left: rect.right });
|
|
103
|
+
}}
|
|
104
|
+
onMouseLeave={() => {
|
|
105
|
+
if (!collapsed) return;
|
|
106
|
+
setTooltip(null);
|
|
107
|
+
}}
|
|
108
|
+
>
|
|
109
|
+
{hovered && !active && (
|
|
110
|
+
<motion.span
|
|
111
|
+
layoutId="sidebar-hover"
|
|
112
|
+
className="absolute inset-0 rounded-lg bg-sidebar-accent"
|
|
113
|
+
transition={NAV_SPRING}
|
|
114
|
+
/>
|
|
115
|
+
)}
|
|
116
|
+
{active && (
|
|
117
|
+
<>
|
|
118
|
+
<motion.span
|
|
119
|
+
layoutId="sidebar-active"
|
|
120
|
+
className="absolute inset-0 rounded-lg bg-primary/10"
|
|
121
|
+
transition={NAV_SPRING}
|
|
122
|
+
/>
|
|
123
|
+
<motion.span
|
|
124
|
+
layoutId="sidebar-active-bar"
|
|
125
|
+
className="absolute top-1/2 -left-3 h-5 w-1 -translate-y-1/2 rounded-r-full bg-primary"
|
|
126
|
+
transition={NAV_SPRING}
|
|
127
|
+
/>
|
|
128
|
+
</>
|
|
129
|
+
)}
|
|
130
|
+
<motion.span
|
|
131
|
+
className="relative flex"
|
|
132
|
+
animate={active ? { scale: [1, 1.2, 1] } : { scale: 1 }}
|
|
133
|
+
transition={{ duration: 0.35, ease: "easeOut" }}
|
|
134
|
+
>
|
|
135
|
+
<item.icon className="h-4.5 w-4.5 shrink-0 transition-transform duration-200 group-hover:scale-110" />
|
|
136
|
+
</motion.span>
|
|
137
|
+
{!collapsed && (
|
|
138
|
+
<span className="relative truncate transition-transform duration-200 group-hover:translate-x-0.5">
|
|
139
|
+
{item.label}
|
|
140
|
+
</span>
|
|
141
|
+
)}
|
|
142
|
+
</Link>
|
|
143
|
+
);
|
|
144
|
+
})}
|
|
145
|
+
</nav>
|
|
146
|
+
|
|
147
|
+
{collapsed &&
|
|
148
|
+
tooltip &&
|
|
149
|
+
createPortal(
|
|
150
|
+
<span
|
|
151
|
+
className="pointer-events-none fixed z-50 -translate-y-1/2 whitespace-nowrap rounded-md border border-border bg-popover px-2 py-1 text-xs text-popover-foreground shadow-md"
|
|
152
|
+
style={{ top: tooltip.top, left: tooltip.left + 8 }}
|
|
153
|
+
>
|
|
154
|
+
{tooltip.label}
|
|
155
|
+
</span>,
|
|
156
|
+
document.body,
|
|
157
|
+
)}
|
|
158
|
+
|
|
159
|
+
<div
|
|
160
|
+
className={cn(
|
|
161
|
+
"flex items-center gap-3 border-t border-sidebar-border p-3",
|
|
162
|
+
collapsed && "justify-center px-0",
|
|
163
|
+
)}
|
|
164
|
+
>
|
|
165
|
+
<span
|
|
166
|
+
title={collapsed ? getUserName() : undefined}
|
|
167
|
+
className="flex h-9 w-9 shrink-0 items-center justify-center rounded-full bg-sidebar-primary text-xs font-semibold text-sidebar-primary-foreground"
|
|
168
|
+
>
|
|
169
|
+
{getUserSymbol()}
|
|
170
|
+
</span>
|
|
171
|
+
{!collapsed && (
|
|
172
|
+
<div className="min-w-0 flex-1">
|
|
173
|
+
<p className="truncate text-sm font-medium">{getUserName()}</p>
|
|
174
|
+
<p className="truncate text-xs text-sidebar-foreground/60">{getUserRole()}</p>
|
|
175
|
+
</div>
|
|
176
|
+
)}
|
|
177
|
+
</div>
|
|
178
|
+
</aside>
|
|
179
|
+
|
|
180
|
+
<div className="flex h-full min-w-0 flex-1 flex-col">
|
|
181
|
+
<header className="flex h-12 shrink-0 items-center gap-3 border-b border-border bg-card pr-4 pl-1 md:pr-6 md:pl-1">
|
|
182
|
+
<button
|
|
183
|
+
onClick={() => setMobileOpen(true)}
|
|
184
|
+
aria-label="Open navigation"
|
|
185
|
+
className="rounded-md p-1.5 text-foreground/70 hover:bg-accent hover:text-accent-foreground md:hidden"
|
|
186
|
+
>
|
|
187
|
+
<Menu className="h-5 w-5" />
|
|
188
|
+
</button>
|
|
189
|
+
<button
|
|
190
|
+
onClick={() => setCollapsed((prev) => !prev)}
|
|
191
|
+
title={collapsed ? "Expand sidebar" : "Collapse sidebar"}
|
|
192
|
+
aria-label={collapsed ? "Expand sidebar" : "Collapse sidebar"}
|
|
193
|
+
className="hidden rounded-md p-1.5 text-foreground/70 hover:bg-accent hover:text-accent-foreground md:inline-flex"
|
|
194
|
+
>
|
|
195
|
+
{collapsed ? <PanelLeftOpen className="h-4.5 w-4.5" /> : <PanelLeftClose className="h-4.5 w-4.5" />}
|
|
196
|
+
</button>
|
|
197
|
+
|
|
198
|
+
<Breadcrumbs />
|
|
199
|
+
|
|
200
|
+
<div className="ml-auto flex items-center gap-1">
|
|
201
|
+
<FullscreenToggle className="text-foreground/70 hover:text-foreground" />
|
|
202
|
+
<ThemeToggle variant="ghost" size="icon-sm" className="text-foreground/70 hover:text-foreground" />
|
|
203
|
+
<button
|
|
204
|
+
title="Log out"
|
|
205
|
+
aria-label="Log out"
|
|
206
|
+
className="rounded-md p-1.5 text-foreground/70 transition-colors hover:bg-destructive/10 hover:text-destructive"
|
|
207
|
+
onClick={() => setLogoutOpen(true)}
|
|
208
|
+
>
|
|
209
|
+
<LogOut className="h-4 w-4" />
|
|
210
|
+
</button>
|
|
211
|
+
</div>
|
|
212
|
+
</header>
|
|
213
|
+
|
|
214
|
+
<DialogComponent.Confirm
|
|
215
|
+
open={logoutOpen}
|
|
216
|
+
onOpenChange={setLogoutOpen}
|
|
217
|
+
title="Log out?"
|
|
218
|
+
description="You'll need to log in again to use the app."
|
|
219
|
+
icon={LogOut}
|
|
220
|
+
confirmLabel="Log out"
|
|
221
|
+
onConfirm={() => {
|
|
222
|
+
setLogoutOpen(false);
|
|
223
|
+
handleSessionExpire({ navigate, message: "You've been logged out." });
|
|
224
|
+
}}
|
|
225
|
+
/>
|
|
226
|
+
|
|
227
|
+
{children}
|
|
228
|
+
</div>
|
|
229
|
+
</div>
|
|
230
|
+
);
|
|
231
|
+
};
|
|
232
|
+
|
|
233
|
+
export default SidebarLayout;
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
import * as React from "react";
|
|
2
|
+
import { Avatar as AvatarPrimitive } from "@base-ui/react/avatar";
|
|
3
|
+
import { cn } from "cn";
|
|
4
|
+
|
|
5
|
+
function Avatar({ className, size = "default", ...props }) {
|
|
6
|
+
return (
|
|
7
|
+
<AvatarPrimitive.Root
|
|
8
|
+
data-slot="avatar"
|
|
9
|
+
data-size={size}
|
|
10
|
+
className={cn(
|
|
11
|
+
"group/avatar relative flex size-8 shrink-0 rounded-full select-none after:absolute after:inset-0 after:rounded-full after:border after:border-border after:mix-blend-darken data-[size=lg]:size-10 data-[size=sm]:size-6 dark:after:mix-blend-lighten",
|
|
12
|
+
className,
|
|
13
|
+
)}
|
|
14
|
+
{...props}
|
|
15
|
+
/>
|
|
16
|
+
);
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
function AvatarImage({ className, ...props }) {
|
|
20
|
+
return (
|
|
21
|
+
<AvatarPrimitive.Image
|
|
22
|
+
data-slot="avatar-image"
|
|
23
|
+
className={cn("aspect-square size-full rounded-full object-cover", className)}
|
|
24
|
+
{...props}
|
|
25
|
+
/>
|
|
26
|
+
);
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
function AvatarFallback({ className, ...props }) {
|
|
30
|
+
return (
|
|
31
|
+
<AvatarPrimitive.Fallback
|
|
32
|
+
data-slot="avatar-fallback"
|
|
33
|
+
className={cn(
|
|
34
|
+
"flex size-full items-center justify-center rounded-full bg-muted text-sm text-muted-foreground group-data-[size=sm]/avatar:text-xs",
|
|
35
|
+
className,
|
|
36
|
+
)}
|
|
37
|
+
{...props}
|
|
38
|
+
/>
|
|
39
|
+
);
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
function AvatarBadge({ className, ...props }) {
|
|
43
|
+
return (
|
|
44
|
+
<span
|
|
45
|
+
data-slot="avatar-badge"
|
|
46
|
+
className={cn(
|
|
47
|
+
"absolute right-0 bottom-0 z-10 inline-flex items-center justify-center rounded-full bg-primary text-primary-foreground bg-blend-color ring-2 ring-background select-none",
|
|
48
|
+
"group-data-[size=sm]/avatar:size-2 group-data-[size=sm]/avatar:[&>svg]:hidden",
|
|
49
|
+
"group-data-[size=default]/avatar:size-2.5 group-data-[size=default]/avatar:[&>svg]:size-2",
|
|
50
|
+
"group-data-[size=lg]/avatar:size-3 group-data-[size=lg]/avatar:[&>svg]:size-2",
|
|
51
|
+
className,
|
|
52
|
+
)}
|
|
53
|
+
{...props}
|
|
54
|
+
/>
|
|
55
|
+
);
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
function AvatarGroup({ className, ...props }) {
|
|
59
|
+
return (
|
|
60
|
+
<div
|
|
61
|
+
data-slot="avatar-group"
|
|
62
|
+
className={cn(
|
|
63
|
+
"group/avatar-group flex -space-x-2 *:data-[slot=avatar]:ring-2 *:data-[slot=avatar]:ring-background",
|
|
64
|
+
className,
|
|
65
|
+
)}
|
|
66
|
+
{...props}
|
|
67
|
+
/>
|
|
68
|
+
);
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
function AvatarGroupCount({ className, ...props }) {
|
|
72
|
+
return (
|
|
73
|
+
<div
|
|
74
|
+
data-slot="avatar-group-count"
|
|
75
|
+
className={cn(
|
|
76
|
+
"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",
|
|
77
|
+
className,
|
|
78
|
+
)}
|
|
79
|
+
{...props}
|
|
80
|
+
/>
|
|
81
|
+
);
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
export { Avatar, AvatarImage, AvatarFallback, AvatarGroup, AvatarGroupCount, AvatarBadge };
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import { mergeProps } from "@base-ui/react/merge-props";
|
|
2
|
+
import { useRender } from "@base-ui/react/use-render";
|
|
3
|
+
import { cva } from "class-variance-authority";
|
|
4
|
+
import { cn } from "cn";
|
|
5
|
+
|
|
6
|
+
const badgeVariants = cva(
|
|
7
|
+
"group/badge inline-flex h-5 w-fit shrink-0 items-center justify-center gap-1 overflow-hidden rounded-4xl border border-transparent px-2 py-0.5 text-xs font-medium whitespace-nowrap transition-all focus-visible:border-ring focus-visible:ring-[3px] focus-visible:ring-ring/50 has-data-[icon=inline-end]:pr-1.5 has-data-[icon=inline-start]:pl-1.5 aria-invalid:border-destructive aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 [&>svg]:pointer-events-none [&>svg]:size-3!",
|
|
8
|
+
{
|
|
9
|
+
variants: {
|
|
10
|
+
variant: {
|
|
11
|
+
default: "bg-primary text-primary-foreground [a]:hover:bg-primary-hover",
|
|
12
|
+
secondary: "bg-secondary text-secondary-foreground [a]:hover:bg-secondary/80",
|
|
13
|
+
destructive:
|
|
14
|
+
"bg-destructive/10 text-destructive focus-visible:ring-destructive/20 dark:bg-destructive/20 dark:focus-visible:ring-destructive/40 [a]:hover:bg-destructive/20",
|
|
15
|
+
outline: "border-border text-foreground [a]:hover:bg-muted [a]:hover:text-muted-foreground",
|
|
16
|
+
ghost: "hover:bg-muted hover:text-muted-foreground dark:hover:bg-muted/50",
|
|
17
|
+
link: "text-primary underline-offset-4 hover:underline",
|
|
18
|
+
},
|
|
19
|
+
},
|
|
20
|
+
defaultVariants: {
|
|
21
|
+
variant: "default",
|
|
22
|
+
},
|
|
23
|
+
},
|
|
24
|
+
);
|
|
25
|
+
|
|
26
|
+
function Badge({ className, variant = "default", render, ...props }) {
|
|
27
|
+
return useRender({
|
|
28
|
+
defaultTagName: "span",
|
|
29
|
+
props: mergeProps(
|
|
30
|
+
{
|
|
31
|
+
className: cn(badgeVariants({ variant }), className),
|
|
32
|
+
},
|
|
33
|
+
props,
|
|
34
|
+
),
|
|
35
|
+
render,
|
|
36
|
+
state: {
|
|
37
|
+
slot: "badge",
|
|
38
|
+
variant,
|
|
39
|
+
},
|
|
40
|
+
});
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
export { Badge, badgeVariants };
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import { Button as ButtonPrimitive } from "@base-ui/react/button";
|
|
2
|
+
import { cva } from "class-variance-authority";
|
|
3
|
+
import { cn } from "cn";
|
|
4
|
+
|
|
5
|
+
const buttonVariants = cva(
|
|
6
|
+
"group/button inline-flex shrink-0 items-center justify-center 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",
|
|
7
|
+
{
|
|
8
|
+
variants: {
|
|
9
|
+
variant: {
|
|
10
|
+
default: "bg-primary text-primary-foreground hover:bg-primary-hover",
|
|
11
|
+
outline:
|
|
12
|
+
"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",
|
|
13
|
+
secondary:
|
|
14
|
+
"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",
|
|
15
|
+
ghost:
|
|
16
|
+
"hover:bg-muted hover:text-foreground aria-expanded:bg-muted aria-expanded:text-foreground dark:hover:bg-muted/50",
|
|
17
|
+
destructive:
|
|
18
|
+
"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",
|
|
19
|
+
link: "text-primary underline-offset-4 hover:underline",
|
|
20
|
+
},
|
|
21
|
+
size: {
|
|
22
|
+
default: "h-8 gap-1.5 px-2.5 has-data-[icon=inline-end]:pr-2 has-data-[icon=inline-start]:pl-2",
|
|
23
|
+
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",
|
|
24
|
+
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",
|
|
25
|
+
lg: "h-9 gap-1.5 px-2.5 has-data-[icon=inline-end]:pr-2 has-data-[icon=inline-start]:pl-2",
|
|
26
|
+
icon: "size-8",
|
|
27
|
+
"icon-xs":
|
|
28
|
+
"size-6 rounded-[min(var(--radius-md),10px)] in-data-[slot=button-group]:rounded-lg [&_svg:not([class*='size-'])]:size-3",
|
|
29
|
+
"icon-sm": "size-7 rounded-[min(var(--radius-md),12px)] in-data-[slot=button-group]:rounded-lg",
|
|
30
|
+
"icon-lg": "size-9",
|
|
31
|
+
},
|
|
32
|
+
},
|
|
33
|
+
defaultVariants: {
|
|
34
|
+
variant: "default",
|
|
35
|
+
size: "default",
|
|
36
|
+
},
|
|
37
|
+
},
|
|
38
|
+
);
|
|
39
|
+
|
|
40
|
+
function Button({ className, variant = "default", size = "default", ...props }) {
|
|
41
|
+
return <ButtonPrimitive data-slot="button" className={cn(buttonVariants({ variant, size, className }))} {...props} />;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
export { Button, buttonVariants };
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
import * as React from "react";
|
|
2
|
+
import { cn } from "cn";
|
|
3
|
+
|
|
4
|
+
function Card({ className, size = "default", ...props }) {
|
|
5
|
+
return (
|
|
6
|
+
<div
|
|
7
|
+
data-slot="card"
|
|
8
|
+
data-size={size}
|
|
9
|
+
className={cn(
|
|
10
|
+
"group/card flex flex-col gap-(--card-spacing) overflow-hidden rounded-xl bg-card py-(--card-spacing) text-sm text-card-foreground ring-1 ring-foreground/10 [--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
|
+
className,
|
|
12
|
+
)}
|
|
13
|
+
{...props}
|
|
14
|
+
/>
|
|
15
|
+
);
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
function CardHeader({ className, ...props }) {
|
|
19
|
+
return (
|
|
20
|
+
<div
|
|
21
|
+
data-slot="card-header"
|
|
22
|
+
className={cn(
|
|
23
|
+
"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
|
+
className,
|
|
25
|
+
)}
|
|
26
|
+
{...props}
|
|
27
|
+
/>
|
|
28
|
+
);
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
function CardTitle({ className, ...props }) {
|
|
32
|
+
return (
|
|
33
|
+
<div
|
|
34
|
+
data-slot="card-title"
|
|
35
|
+
className={cn("font-heading text-base leading-snug font-medium group-data-[size=sm]/card:text-sm", className)}
|
|
36
|
+
{...props}
|
|
37
|
+
/>
|
|
38
|
+
);
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
function CardDescription({ className, ...props }) {
|
|
42
|
+
return <div data-slot="card-description" className={cn("text-sm text-muted-foreground", className)} {...props} />;
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
function CardAction({ className, ...props }) {
|
|
46
|
+
return (
|
|
47
|
+
<div
|
|
48
|
+
data-slot="card-action"
|
|
49
|
+
className={cn("col-start-2 row-span-2 row-start-1 self-start justify-self-end", className)}
|
|
50
|
+
{...props}
|
|
51
|
+
/>
|
|
52
|
+
);
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
function CardContent({ className, ...props }) {
|
|
56
|
+
return <div data-slot="card-content" className={cn("px-(--card-spacing)", className)} {...props} />;
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
function CardFooter({ className, ...props }) {
|
|
60
|
+
return (
|
|
61
|
+
<div
|
|
62
|
+
data-slot="card-footer"
|
|
63
|
+
className={cn("flex items-center rounded-b-xl border-t bg-muted/50 p-(--card-spacing)", className)}
|
|
64
|
+
{...props}
|
|
65
|
+
/>
|
|
66
|
+
);
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
export { Card, CardHeader, CardFooter, CardTitle, CardAction, CardDescription, CardContent };
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { Checkbox as CheckboxPrimitive } from "@base-ui/react/checkbox";
|
|
2
|
+
import { cn } from "cn";
|
|
3
|
+
import { CheckIcon } from "lucide-react";
|
|
4
|
+
|
|
5
|
+
function Checkbox({ className, ...props }) {
|
|
6
|
+
return (
|
|
7
|
+
<CheckboxPrimitive.Root
|
|
8
|
+
data-slot="checkbox"
|
|
9
|
+
className={cn(
|
|
10
|
+
"peer relative flex size-4 shrink-0 items-center justify-center rounded-[4px] border border-input transition-colors outline-none group-has-disabled/field:opacity-50 group-has-[:focus-visible]/field-label:ring-0 group-has-[:focus-visible]/field-label:not-data-checked:border-input after:absolute after:-inset-x-3 after:-inset-y-2 focus-visible:border-ring focus-visible:ring-3 focus-visible:ring-ring/50 disabled:cursor-not-allowed disabled:opacity-50 aria-invalid:border-destructive aria-invalid:ring-3 aria-invalid:ring-destructive/20 aria-invalid:aria-checked:border-primary dark:bg-input/30 dark:aria-invalid:border-destructive/50 dark:aria-invalid:ring-destructive/40 data-checked:border-primary data-checked:bg-primary data-checked:text-primary-foreground group-has-[:focus-visible]/field-label:data-checked:border-primary dark:data-checked:bg-primary",
|
|
11
|
+
className,
|
|
12
|
+
)}
|
|
13
|
+
{...props}
|
|
14
|
+
>
|
|
15
|
+
<CheckboxPrimitive.Indicator
|
|
16
|
+
data-slot="checkbox-indicator"
|
|
17
|
+
className="grid place-content-center text-current transition-none [&>svg]:size-3.5"
|
|
18
|
+
>
|
|
19
|
+
<CheckIcon />
|
|
20
|
+
</CheckboxPrimitive.Indicator>
|
|
21
|
+
</CheckboxPrimitive.Root>
|
|
22
|
+
);
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
export { Checkbox };
|
|
@@ -0,0 +1,149 @@
|
|
|
1
|
+
import * as React from "react";
|
|
2
|
+
import { Dialog as DialogPrimitive } from "@base-ui/react/dialog";
|
|
3
|
+
import { AnimatePresence, motion } from "framer-motion";
|
|
4
|
+
import { cn } from "cn";
|
|
5
|
+
|
|
6
|
+
import { Button } from "@/components/ui/button";
|
|
7
|
+
import { XIcon } from "lucide-react";
|
|
8
|
+
|
|
9
|
+
const DialogOpenContext = React.createContext(undefined);
|
|
10
|
+
|
|
11
|
+
const OVERLAY_MOTION = {
|
|
12
|
+
initial: { opacity: 0 },
|
|
13
|
+
animate: { opacity: 1 },
|
|
14
|
+
exit: { opacity: 0 },
|
|
15
|
+
transition: { duration: 0.2, ease: "easeOut" },
|
|
16
|
+
};
|
|
17
|
+
|
|
18
|
+
const POPUP_MOTION = {
|
|
19
|
+
initial: { opacity: 0, scale: 0.95, y: 16 },
|
|
20
|
+
animate: { opacity: 1, scale: 1, y: 0 },
|
|
21
|
+
exit: { opacity: 0, scale: 0.97, y: 8 },
|
|
22
|
+
transition: { type: "spring", stiffness: 380, damping: 30, mass: 0.8 },
|
|
23
|
+
};
|
|
24
|
+
|
|
25
|
+
function Dialog({ open, ...props }) {
|
|
26
|
+
return (
|
|
27
|
+
<DialogOpenContext.Provider value={open}>
|
|
28
|
+
<DialogPrimitive.Root data-slot="dialog" open={open} {...props} />
|
|
29
|
+
</DialogOpenContext.Provider>
|
|
30
|
+
);
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
function DialogTrigger({ ...props }) {
|
|
34
|
+
return <DialogPrimitive.Trigger data-slot="dialog-trigger" {...props} />;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
function DialogPortal({ ...props }) {
|
|
38
|
+
return <DialogPrimitive.Portal data-slot="dialog-portal" {...props} />;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
function DialogClose({ ...props }) {
|
|
42
|
+
return <DialogPrimitive.Close data-slot="dialog-close" {...props} />;
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
function DialogOverlay({ className, ...props }) {
|
|
46
|
+
return (
|
|
47
|
+
<DialogPrimitive.Backdrop
|
|
48
|
+
data-slot="dialog-overlay"
|
|
49
|
+
className={cn("fixed inset-0 isolate z-50 bg-black/40 supports-backdrop-filter:backdrop-blur-sm", className)}
|
|
50
|
+
{...props}
|
|
51
|
+
/>
|
|
52
|
+
);
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
function DialogContent({ className, children, showCloseButton = true, ...props }) {
|
|
56
|
+
const open = React.useContext(DialogOpenContext);
|
|
57
|
+
const isControlled = typeof open === "boolean";
|
|
58
|
+
|
|
59
|
+
const content = (
|
|
60
|
+
<DialogPortal keepMounted={isControlled}>
|
|
61
|
+
<DialogOverlay render={isControlled ? <motion.div {...OVERLAY_MOTION} /> : undefined} />
|
|
62
|
+
<DialogPrimitive.Popup
|
|
63
|
+
data-slot="dialog-content"
|
|
64
|
+
render={isControlled ? <motion.div {...POPUP_MOTION} /> : undefined}
|
|
65
|
+
className={cn(
|
|
66
|
+
"fixed top-1/2 left-1/2 z-50 grid w-full max-w-[calc(100%-2rem)] -translate-x-1/2 -translate-y-1/2 gap-4 rounded-2xl bg-popover p-4 text-sm text-popover-foreground shadow-2xl shadow-black/15 ring-1 ring-foreground/10 outline-none sm:max-w-sm",
|
|
67
|
+
className,
|
|
68
|
+
)}
|
|
69
|
+
{...props}
|
|
70
|
+
>
|
|
71
|
+
{children}
|
|
72
|
+
{showCloseButton && (
|
|
73
|
+
<DialogPrimitive.Close
|
|
74
|
+
data-slot="dialog-close"
|
|
75
|
+
render={
|
|
76
|
+
<Button
|
|
77
|
+
variant="ghost"
|
|
78
|
+
className="absolute top-3 right-3 rounded-full text-muted-foreground transition-transform duration-200 hover:rotate-90 hover:text-foreground"
|
|
79
|
+
size="icon-sm"
|
|
80
|
+
/>
|
|
81
|
+
}
|
|
82
|
+
>
|
|
83
|
+
<XIcon />
|
|
84
|
+
<span className="sr-only">Close</span>
|
|
85
|
+
</DialogPrimitive.Close>
|
|
86
|
+
)}
|
|
87
|
+
</DialogPrimitive.Popup>
|
|
88
|
+
</DialogPortal>
|
|
89
|
+
);
|
|
90
|
+
|
|
91
|
+
if (!isControlled) return content;
|
|
92
|
+
return <AnimatePresence>{open && content}</AnimatePresence>;
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
function DialogHeader({ className, ...props }) {
|
|
96
|
+
return <div data-slot="dialog-header" className={cn("flex flex-col gap-2", className)} {...props} />;
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
function DialogFooter({ className, showCloseButton = false, children, ...props }) {
|
|
100
|
+
return (
|
|
101
|
+
<div
|
|
102
|
+
data-slot="dialog-footer"
|
|
103
|
+
className={cn(
|
|
104
|
+
"-mx-4 -mb-4 flex flex-col-reverse gap-2 rounded-b-xl border-t bg-muted/50 p-4 sm:flex-row sm:justify-end",
|
|
105
|
+
className,
|
|
106
|
+
)}
|
|
107
|
+
{...props}
|
|
108
|
+
>
|
|
109
|
+
{children}
|
|
110
|
+
{showCloseButton && <DialogPrimitive.Close render={<Button variant="outline" />}>Close</DialogPrimitive.Close>}
|
|
111
|
+
</div>
|
|
112
|
+
);
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
function DialogTitle({ className, ...props }) {
|
|
116
|
+
return (
|
|
117
|
+
<DialogPrimitive.Title
|
|
118
|
+
data-slot="dialog-title"
|
|
119
|
+
className={cn("font-heading text-base leading-none font-medium", className)}
|
|
120
|
+
{...props}
|
|
121
|
+
/>
|
|
122
|
+
);
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
function DialogDescription({ className, ...props }) {
|
|
126
|
+
return (
|
|
127
|
+
<DialogPrimitive.Description
|
|
128
|
+
data-slot="dialog-description"
|
|
129
|
+
className={cn(
|
|
130
|
+
"text-sm text-muted-foreground *:[a]:underline *:[a]:underline-offset-3 *:[a]:hover:text-foreground",
|
|
131
|
+
className,
|
|
132
|
+
)}
|
|
133
|
+
{...props}
|
|
134
|
+
/>
|
|
135
|
+
);
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
export {
|
|
139
|
+
Dialog,
|
|
140
|
+
DialogClose,
|
|
141
|
+
DialogContent,
|
|
142
|
+
DialogDescription,
|
|
143
|
+
DialogFooter,
|
|
144
|
+
DialogHeader,
|
|
145
|
+
DialogOverlay,
|
|
146
|
+
DialogPortal,
|
|
147
|
+
DialogTitle,
|
|
148
|
+
DialogTrigger,
|
|
149
|
+
};
|