create-bdpamke-react-scaffold 1.0.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 +21 -0
- package/README.md +62 -0
- package/bin/create-bdpamke-react-scaffold.js +101 -0
- package/package.json +39 -0
- package/template/.env.example +6 -0
- package/template/FUNCTIONS_EXAMPLES.md +480 -0
- package/template/HOWTOadd a page.md +166 -0
- package/template/REACT_PROPS_USEEFFECT.md +210 -0
- package/template/REGISTRATION_FLOW.md +268 -0
- package/template/USESTATE_EXAMPLES.md +451 -0
- package/template/components.json +20 -0
- package/template/index.html +13 -0
- package/template/jsconfig.json +19 -0
- package/template/package-lock.json +5988 -0
- package/template/package.json +73 -0
- package/template/postcss.config.cjs +6 -0
- package/template/public/images/BDPA_edited.png +0 -0
- package/template/server/server.js +86 -0
- package/template/server/utils/apiClient.js +59 -0
- package/template/server/utils/password.js +60 -0
- package/template/src/App.jsx +10 -0
- package/template/src/components/layout/Container.jsx +7 -0
- package/template/src/components/layout/Section.jsx +7 -0
- package/template/src/components/ui/accordion.jsx +41 -0
- package/template/src/components/ui/alert-dialog.jsx +99 -0
- package/template/src/components/ui/alert.jsx +47 -0
- package/template/src/components/ui/aspect-ratio.jsx +5 -0
- package/template/src/components/ui/avatar.jsx +35 -0
- package/template/src/components/ui/badge.jsx +34 -0
- package/template/src/components/ui/button.jsx +47 -0
- package/template/src/components/ui/calendar.jsx +173 -0
- package/template/src/components/ui/card.jsx +50 -0
- package/template/src/components/ui/carousel.jsx +194 -0
- package/template/src/components/ui/checkbox.jsx +22 -0
- package/template/src/components/ui/collapsible.jsx +11 -0
- package/template/src/components/ui/command.jsx +116 -0
- package/template/src/components/ui/dialog.jsx +94 -0
- package/template/src/components/ui/drawer.jsx +92 -0
- package/template/src/components/ui/dropdown-menu.jsx +155 -0
- package/template/src/components/ui/form.jsx +138 -0
- package/template/src/components/ui/hover-card.jsx +25 -0
- package/template/src/components/ui/icons.jsx +81 -0
- package/template/src/components/ui/input.jsx +19 -0
- package/template/src/components/ui/label.jsx +16 -0
- package/template/src/components/ui/menubar.jsx +200 -0
- package/template/src/components/ui/navigation-menu.jsx +104 -0
- package/template/src/components/ui/popover.jsx +25 -0
- package/template/src/components/ui/progress.jsx +20 -0
- package/template/src/components/ui/radio-group.jsx +29 -0
- package/template/src/components/ui/scroll-area.jsx +40 -0
- package/template/src/components/ui/select.jsx +120 -0
- package/template/src/components/ui/separator.jsx +25 -0
- package/template/src/components/ui/sheet.jsx +108 -0
- package/template/src/components/ui/skeleton.jsx +10 -0
- package/template/src/components/ui/slider.jsx +23 -0
- package/template/src/components/ui/sonner.jsx +42 -0
- package/template/src/components/ui/switch.jsx +24 -0
- package/template/src/components/ui/table.jsx +83 -0
- package/template/src/components/ui/tabs.jsx +41 -0
- package/template/src/components/ui/textarea.jsx +18 -0
- package/template/src/components/ui/toast.jsx +82 -0
- package/template/src/components/ui/toaster.jsx +33 -0
- package/template/src/components/ui/toggle.jsx +40 -0
- package/template/src/components/ui/tooltip.jsx +24 -0
- package/template/src/hooks/use-toast.js +155 -0
- package/template/src/index.css +61 -0
- package/template/src/index.js +6 -0
- package/template/src/lib/utils.js +11 -0
- package/template/src/main.jsx +15 -0
- package/template/src/pages/Home.jsx +26 -0
- package/template/tailwind.config.cjs +76 -0
- package/template/vite.config.mts +22 -0
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
"use client"
|
|
2
|
+
|
|
3
|
+
import * as React from "react"
|
|
4
|
+
import * as SliderPrimitive from "@radix-ui/react-slider"
|
|
5
|
+
|
|
6
|
+
import { cn } from "@/lib/utils"
|
|
7
|
+
|
|
8
|
+
const Slider = React.forwardRef(({ className, ...props }, ref) => (
|
|
9
|
+
<SliderPrimitive.Root
|
|
10
|
+
ref={ref}
|
|
11
|
+
className={cn("relative flex w-full touch-none select-none items-center", className)}
|
|
12
|
+
{...props}>
|
|
13
|
+
<SliderPrimitive.Track
|
|
14
|
+
className="relative h-2 w-full grow overflow-hidden rounded-full bg-secondary">
|
|
15
|
+
<SliderPrimitive.Range className="absolute h-full bg-primary" />
|
|
16
|
+
</SliderPrimitive.Track>
|
|
17
|
+
<SliderPrimitive.Thumb
|
|
18
|
+
className="block h-5 w-5 rounded-full border-2 border-primary bg-background ring-offset-background transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:pointer-events-none disabled:opacity-50" />
|
|
19
|
+
</SliderPrimitive.Root>
|
|
20
|
+
))
|
|
21
|
+
Slider.displayName = SliderPrimitive.Root.displayName
|
|
22
|
+
|
|
23
|
+
export { Slider }
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import {
|
|
2
|
+
CircleCheck,
|
|
3
|
+
Info,
|
|
4
|
+
LoaderCircle,
|
|
5
|
+
OctagonX,
|
|
6
|
+
TriangleAlert,
|
|
7
|
+
} from "lucide-react"
|
|
8
|
+
import { useTheme } from "next-themes"
|
|
9
|
+
import { Toaster as Sonner } from "sonner"
|
|
10
|
+
|
|
11
|
+
const Toaster = ({
|
|
12
|
+
...props
|
|
13
|
+
}) => {
|
|
14
|
+
const { theme = "system" } = useTheme()
|
|
15
|
+
|
|
16
|
+
return (
|
|
17
|
+
<Sonner
|
|
18
|
+
theme={theme}
|
|
19
|
+
className="toaster group"
|
|
20
|
+
icons={{
|
|
21
|
+
success: <CircleCheck className="h-4 w-4" />,
|
|
22
|
+
info: <Info className="h-4 w-4" />,
|
|
23
|
+
warning: <TriangleAlert className="h-4 w-4" />,
|
|
24
|
+
error: <OctagonX className="h-4 w-4" />,
|
|
25
|
+
loading: <LoaderCircle className="h-4 w-4 animate-spin" />,
|
|
26
|
+
}}
|
|
27
|
+
toastOptions={{
|
|
28
|
+
classNames: {
|
|
29
|
+
toast:
|
|
30
|
+
"group toast group-[.toaster]:bg-background group-[.toaster]:text-foreground group-[.toaster]:border-border group-[.toaster]:shadow-lg",
|
|
31
|
+
description: "group-[.toast]:text-muted-foreground",
|
|
32
|
+
actionButton:
|
|
33
|
+
"group-[.toast]:bg-primary group-[.toast]:text-primary-foreground",
|
|
34
|
+
cancelButton:
|
|
35
|
+
"group-[.toast]:bg-muted group-[.toast]:text-muted-foreground",
|
|
36
|
+
},
|
|
37
|
+
}}
|
|
38
|
+
{...props} />
|
|
39
|
+
);
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
export { Toaster }
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
"use client"
|
|
2
|
+
|
|
3
|
+
import * as React from "react"
|
|
4
|
+
import * as SwitchPrimitives from "@radix-ui/react-switch"
|
|
5
|
+
|
|
6
|
+
import { cn } from "@/lib/utils"
|
|
7
|
+
|
|
8
|
+
const Switch = React.forwardRef(({ className, ...props }, ref) => (
|
|
9
|
+
<SwitchPrimitives.Root
|
|
10
|
+
className={cn(
|
|
11
|
+
"peer inline-flex h-6 w-11 shrink-0 cursor-pointer items-center rounded-full border-2 border-transparent transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 focus-visible:ring-offset-background disabled:cursor-not-allowed disabled:opacity-50 data-[state=checked]:bg-primary data-[state=unchecked]:bg-input",
|
|
12
|
+
className
|
|
13
|
+
)}
|
|
14
|
+
{...props}
|
|
15
|
+
ref={ref}>
|
|
16
|
+
<SwitchPrimitives.Thumb
|
|
17
|
+
className={cn(
|
|
18
|
+
"pointer-events-none block h-5 w-5 rounded-full bg-background shadow-lg ring-0 transition-transform data-[state=checked]:translate-x-5 data-[state=unchecked]:translate-x-0"
|
|
19
|
+
)} />
|
|
20
|
+
</SwitchPrimitives.Root>
|
|
21
|
+
))
|
|
22
|
+
Switch.displayName = SwitchPrimitives.Root.displayName
|
|
23
|
+
|
|
24
|
+
export { Switch }
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
import * as React from "react"
|
|
2
|
+
|
|
3
|
+
import { cn } from "@/lib/utils"
|
|
4
|
+
|
|
5
|
+
const Table = React.forwardRef(({ className, ...props }, ref) => (
|
|
6
|
+
<div className="relative w-full overflow-auto">
|
|
7
|
+
<table
|
|
8
|
+
ref={ref}
|
|
9
|
+
className={cn("w-full caption-bottom text-sm", className)}
|
|
10
|
+
{...props} />
|
|
11
|
+
</div>
|
|
12
|
+
))
|
|
13
|
+
Table.displayName = "Table"
|
|
14
|
+
|
|
15
|
+
const TableHeader = React.forwardRef(({ className, ...props }, ref) => (
|
|
16
|
+
<thead ref={ref} className={cn("[&_tr]:border-b", className)} {...props} />
|
|
17
|
+
))
|
|
18
|
+
TableHeader.displayName = "TableHeader"
|
|
19
|
+
|
|
20
|
+
const TableBody = React.forwardRef(({ className, ...props }, ref) => (
|
|
21
|
+
<tbody
|
|
22
|
+
ref={ref}
|
|
23
|
+
className={cn("[&_tr:last-child]:border-0", className)}
|
|
24
|
+
{...props} />
|
|
25
|
+
))
|
|
26
|
+
TableBody.displayName = "TableBody"
|
|
27
|
+
|
|
28
|
+
const TableFooter = React.forwardRef(({ className, ...props }, ref) => (
|
|
29
|
+
<tfoot
|
|
30
|
+
ref={ref}
|
|
31
|
+
className={cn("border-t bg-muted/50 font-medium [&>tr]:last:border-b-0", className)}
|
|
32
|
+
{...props} />
|
|
33
|
+
))
|
|
34
|
+
TableFooter.displayName = "TableFooter"
|
|
35
|
+
|
|
36
|
+
const TableRow = React.forwardRef(({ className, ...props }, ref) => (
|
|
37
|
+
<tr
|
|
38
|
+
ref={ref}
|
|
39
|
+
className={cn(
|
|
40
|
+
"border-b transition-colors hover:bg-muted/50 data-[state=selected]:bg-muted",
|
|
41
|
+
className
|
|
42
|
+
)}
|
|
43
|
+
{...props} />
|
|
44
|
+
))
|
|
45
|
+
TableRow.displayName = "TableRow"
|
|
46
|
+
|
|
47
|
+
const TableHead = React.forwardRef(({ className, ...props }, ref) => (
|
|
48
|
+
<th
|
|
49
|
+
ref={ref}
|
|
50
|
+
className={cn(
|
|
51
|
+
"h-12 px-4 text-left align-middle font-medium text-muted-foreground [&:has([role=checkbox])]:pr-0",
|
|
52
|
+
className
|
|
53
|
+
)}
|
|
54
|
+
{...props} />
|
|
55
|
+
))
|
|
56
|
+
TableHead.displayName = "TableHead"
|
|
57
|
+
|
|
58
|
+
const TableCell = React.forwardRef(({ className, ...props }, ref) => (
|
|
59
|
+
<td
|
|
60
|
+
ref={ref}
|
|
61
|
+
className={cn("p-4 align-middle [&:has([role=checkbox])]:pr-0", className)}
|
|
62
|
+
{...props} />
|
|
63
|
+
))
|
|
64
|
+
TableCell.displayName = "TableCell"
|
|
65
|
+
|
|
66
|
+
const TableCaption = React.forwardRef(({ className, ...props }, ref) => (
|
|
67
|
+
<caption
|
|
68
|
+
ref={ref}
|
|
69
|
+
className={cn("mt-4 text-sm text-muted-foreground", className)}
|
|
70
|
+
{...props} />
|
|
71
|
+
))
|
|
72
|
+
TableCaption.displayName = "TableCaption"
|
|
73
|
+
|
|
74
|
+
export {
|
|
75
|
+
Table,
|
|
76
|
+
TableHeader,
|
|
77
|
+
TableBody,
|
|
78
|
+
TableFooter,
|
|
79
|
+
TableHead,
|
|
80
|
+
TableRow,
|
|
81
|
+
TableCell,
|
|
82
|
+
TableCaption,
|
|
83
|
+
}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import * as React from "react"
|
|
2
|
+
import * as TabsPrimitive from "@radix-ui/react-tabs"
|
|
3
|
+
|
|
4
|
+
import { cn } from "@/lib/utils"
|
|
5
|
+
|
|
6
|
+
const Tabs = TabsPrimitive.Root
|
|
7
|
+
|
|
8
|
+
const TabsList = React.forwardRef(({ className, ...props }, ref) => (
|
|
9
|
+
<TabsPrimitive.List
|
|
10
|
+
ref={ref}
|
|
11
|
+
className={cn(
|
|
12
|
+
"inline-flex h-10 items-center justify-center rounded-md bg-muted p-1 text-muted-foreground",
|
|
13
|
+
className
|
|
14
|
+
)}
|
|
15
|
+
{...props} />
|
|
16
|
+
))
|
|
17
|
+
TabsList.displayName = TabsPrimitive.List.displayName
|
|
18
|
+
|
|
19
|
+
const TabsTrigger = React.forwardRef(({ className, ...props }, ref) => (
|
|
20
|
+
<TabsPrimitive.Trigger
|
|
21
|
+
ref={ref}
|
|
22
|
+
className={cn(
|
|
23
|
+
"inline-flex items-center justify-center whitespace-nowrap rounded-sm px-3 py-1.5 text-sm font-medium ring-offset-background transition-all focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:pointer-events-none disabled:opacity-50 data-[state=active]:bg-background data-[state=active]:text-foreground data-[state=active]:shadow-sm",
|
|
24
|
+
className
|
|
25
|
+
)}
|
|
26
|
+
{...props} />
|
|
27
|
+
))
|
|
28
|
+
TabsTrigger.displayName = TabsPrimitive.Trigger.displayName
|
|
29
|
+
|
|
30
|
+
const TabsContent = React.forwardRef(({ className, ...props }, ref) => (
|
|
31
|
+
<TabsPrimitive.Content
|
|
32
|
+
ref={ref}
|
|
33
|
+
className={cn(
|
|
34
|
+
"mt-2 ring-offset-background focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2",
|
|
35
|
+
className
|
|
36
|
+
)}
|
|
37
|
+
{...props} />
|
|
38
|
+
))
|
|
39
|
+
TabsContent.displayName = TabsPrimitive.Content.displayName
|
|
40
|
+
|
|
41
|
+
export { Tabs, TabsList, TabsTrigger, TabsContent }
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import * as React from "react"
|
|
2
|
+
|
|
3
|
+
import { cn } from "@/lib/utils"
|
|
4
|
+
|
|
5
|
+
const Textarea = React.forwardRef(({ className, ...props }, ref) => {
|
|
6
|
+
return (
|
|
7
|
+
<textarea
|
|
8
|
+
className={cn(
|
|
9
|
+
"flex min-h-[80px] w-full rounded-md border border-input bg-background px-3 py-2 text-base ring-offset-background placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50 md:text-sm",
|
|
10
|
+
className
|
|
11
|
+
)}
|
|
12
|
+
ref={ref}
|
|
13
|
+
{...props} />
|
|
14
|
+
);
|
|
15
|
+
})
|
|
16
|
+
Textarea.displayName = "Textarea"
|
|
17
|
+
|
|
18
|
+
export { Textarea }
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
import * as React from "react"
|
|
2
|
+
import * as ToastPrimitives from "@radix-ui/react-toast"
|
|
3
|
+
import { cva } from "class-variance-authority";
|
|
4
|
+
import { X } from "lucide-react"
|
|
5
|
+
|
|
6
|
+
import { cn } from "@/lib/utils"
|
|
7
|
+
|
|
8
|
+
const ToastProvider = ToastPrimitives.Provider
|
|
9
|
+
|
|
10
|
+
const ToastViewport = React.forwardRef(({ className, ...props }, ref) => (
|
|
11
|
+
<ToastPrimitives.Viewport
|
|
12
|
+
ref={ref}
|
|
13
|
+
className={cn(
|
|
14
|
+
"fixed top-0 z-[100] flex max-h-screen w-full flex-col-reverse p-4 sm:bottom-0 sm:right-0 sm:top-auto sm:flex-col md:max-w-[420px]",
|
|
15
|
+
className
|
|
16
|
+
)}
|
|
17
|
+
{...props} />
|
|
18
|
+
))
|
|
19
|
+
ToastViewport.displayName = ToastPrimitives.Viewport.displayName
|
|
20
|
+
|
|
21
|
+
const toastVariants = cva(
|
|
22
|
+
"group pointer-events-auto relative flex w-full items-center justify-between space-x-4 overflow-hidden rounded-md border p-6 pr-8 shadow-lg transition-all data-[swipe=cancel]:translate-x-0 data-[swipe=end]:translate-x-[var(--radix-toast-swipe-end-x)] data-[swipe=move]:translate-x-[var(--radix-toast-swipe-move-x)] data-[swipe=move]:transition-none data-[state=open]:animate-in data-[state=closed]:animate-out data-[swipe=end]:animate-out data-[state=closed]:fade-out-80 data-[state=closed]:slide-out-to-right-full data-[state=open]:slide-in-from-top-full data-[state=open]:sm:slide-in-from-bottom-full",
|
|
23
|
+
{
|
|
24
|
+
variants: {
|
|
25
|
+
variant: {
|
|
26
|
+
default: "border bg-background text-foreground",
|
|
27
|
+
destructive:
|
|
28
|
+
"destructive group border-destructive bg-destructive text-destructive-foreground",
|
|
29
|
+
},
|
|
30
|
+
},
|
|
31
|
+
defaultVariants: {
|
|
32
|
+
variant: "default",
|
|
33
|
+
},
|
|
34
|
+
}
|
|
35
|
+
)
|
|
36
|
+
|
|
37
|
+
const Toast = React.forwardRef(({ className, variant, ...props }, ref) => {
|
|
38
|
+
return (
|
|
39
|
+
<ToastPrimitives.Root
|
|
40
|
+
ref={ref}
|
|
41
|
+
className={cn(toastVariants({ variant }), className)}
|
|
42
|
+
{...props} />
|
|
43
|
+
);
|
|
44
|
+
})
|
|
45
|
+
Toast.displayName = ToastPrimitives.Root.displayName
|
|
46
|
+
|
|
47
|
+
const ToastAction = React.forwardRef(({ className, ...props }, ref) => (
|
|
48
|
+
<ToastPrimitives.Action
|
|
49
|
+
ref={ref}
|
|
50
|
+
className={cn(
|
|
51
|
+
"inline-flex h-8 shrink-0 items-center justify-center rounded-md border bg-transparent px-3 text-sm font-medium ring-offset-background transition-colors hover:bg-secondary focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2 disabled:pointer-events-none disabled:opacity-50 group-[.destructive]:border-muted/40 group-[.destructive]:hover:border-destructive/30 group-[.destructive]:hover:bg-destructive group-[.destructive]:hover:text-destructive-foreground group-[.destructive]:focus:ring-destructive",
|
|
52
|
+
className
|
|
53
|
+
)}
|
|
54
|
+
{...props} />
|
|
55
|
+
))
|
|
56
|
+
ToastAction.displayName = ToastPrimitives.Action.displayName
|
|
57
|
+
|
|
58
|
+
const ToastClose = React.forwardRef(({ className, ...props }, ref) => (
|
|
59
|
+
<ToastPrimitives.Close
|
|
60
|
+
ref={ref}
|
|
61
|
+
className={cn(
|
|
62
|
+
"absolute right-2 top-2 rounded-md p-1 text-foreground/50 opacity-0 transition-opacity hover:text-foreground focus:opacity-100 focus:outline-none focus:ring-2 group-hover:opacity-100 group-[.destructive]:text-red-300 group-[.destructive]:hover:text-red-50 group-[.destructive]:focus:ring-red-400 group-[.destructive]:focus:ring-offset-red-600",
|
|
63
|
+
className
|
|
64
|
+
)}
|
|
65
|
+
toast-close=""
|
|
66
|
+
{...props}>
|
|
67
|
+
<X className="h-4 w-4" />
|
|
68
|
+
</ToastPrimitives.Close>
|
|
69
|
+
))
|
|
70
|
+
ToastClose.displayName = ToastPrimitives.Close.displayName
|
|
71
|
+
|
|
72
|
+
const ToastTitle = React.forwardRef(({ className, ...props }, ref) => (
|
|
73
|
+
<ToastPrimitives.Title ref={ref} className={cn("text-sm font-semibold", className)} {...props} />
|
|
74
|
+
))
|
|
75
|
+
ToastTitle.displayName = ToastPrimitives.Title.displayName
|
|
76
|
+
|
|
77
|
+
const ToastDescription = React.forwardRef(({ className, ...props }, ref) => (
|
|
78
|
+
<ToastPrimitives.Description ref={ref} className={cn("text-sm opacity-90", className)} {...props} />
|
|
79
|
+
))
|
|
80
|
+
ToastDescription.displayName = ToastPrimitives.Description.displayName
|
|
81
|
+
|
|
82
|
+
export { ToastProvider, ToastViewport, Toast, ToastTitle, ToastDescription, ToastClose, ToastAction };
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { useToast } from "@/hooks/use-toast"
|
|
2
|
+
import {
|
|
3
|
+
Toast,
|
|
4
|
+
ToastClose,
|
|
5
|
+
ToastDescription,
|
|
6
|
+
ToastProvider,
|
|
7
|
+
ToastTitle,
|
|
8
|
+
ToastViewport,
|
|
9
|
+
} from "@/components/ui/toast"
|
|
10
|
+
|
|
11
|
+
export function Toaster() {
|
|
12
|
+
const { toasts } = useToast()
|
|
13
|
+
|
|
14
|
+
return (
|
|
15
|
+
<ToastProvider>
|
|
16
|
+
{toasts.map(function ({ id, title, description, action, ...props }) {
|
|
17
|
+
return (
|
|
18
|
+
<Toast key={id} {...props}>
|
|
19
|
+
<div className="grid gap-1">
|
|
20
|
+
{title && <ToastTitle>{title}</ToastTitle>}
|
|
21
|
+
{description && (
|
|
22
|
+
<ToastDescription>{description}</ToastDescription>
|
|
23
|
+
)}
|
|
24
|
+
</div>
|
|
25
|
+
{action}
|
|
26
|
+
<ToastClose />
|
|
27
|
+
</Toast>
|
|
28
|
+
);
|
|
29
|
+
})}
|
|
30
|
+
<ToastViewport />
|
|
31
|
+
</ToastProvider>
|
|
32
|
+
);
|
|
33
|
+
}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
"use client"
|
|
2
|
+
|
|
3
|
+
import * as React from "react"
|
|
4
|
+
import * as TogglePrimitive from "@radix-ui/react-toggle"
|
|
5
|
+
import { cva } from "class-variance-authority";
|
|
6
|
+
|
|
7
|
+
import { cn } from "@/lib/utils"
|
|
8
|
+
|
|
9
|
+
const toggleVariants = cva(
|
|
10
|
+
"inline-flex items-center justify-center rounded-md text-sm font-medium ring-offset-background transition-colors hover:bg-muted hover:text-muted-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:pointer-events-none disabled:opacity-50 data-[state=on]:bg-accent data-[state=on]:text-accent-foreground [&_svg]:pointer-events-none [&_svg]:size-4 [&_svg]:shrink-0 gap-2",
|
|
11
|
+
{
|
|
12
|
+
variants: {
|
|
13
|
+
variant: {
|
|
14
|
+
default: "bg-transparent",
|
|
15
|
+
outline:
|
|
16
|
+
"border border-input bg-transparent hover:bg-accent hover:text-accent-foreground",
|
|
17
|
+
},
|
|
18
|
+
size: {
|
|
19
|
+
default: "h-10 px-3 min-w-10",
|
|
20
|
+
sm: "h-9 px-2.5 min-w-9",
|
|
21
|
+
lg: "h-11 px-5 min-w-11",
|
|
22
|
+
},
|
|
23
|
+
},
|
|
24
|
+
defaultVariants: {
|
|
25
|
+
variant: "default",
|
|
26
|
+
size: "default",
|
|
27
|
+
},
|
|
28
|
+
}
|
|
29
|
+
)
|
|
30
|
+
|
|
31
|
+
const Toggle = React.forwardRef(({ className, variant, size, ...props }, ref) => (
|
|
32
|
+
<TogglePrimitive.Root
|
|
33
|
+
ref={ref}
|
|
34
|
+
className={cn(toggleVariants({ variant, size, className }))}
|
|
35
|
+
{...props} />
|
|
36
|
+
))
|
|
37
|
+
|
|
38
|
+
Toggle.displayName = TogglePrimitive.Root.displayName
|
|
39
|
+
|
|
40
|
+
export { Toggle, toggleVariants }
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import * as React from "react"
|
|
2
|
+
import * as TooltipPrimitive from "@radix-ui/react-tooltip"
|
|
3
|
+
|
|
4
|
+
import { cn } from "@/lib/utils"
|
|
5
|
+
|
|
6
|
+
const TooltipProvider = TooltipPrimitive.Provider
|
|
7
|
+
|
|
8
|
+
const Tooltip = TooltipPrimitive.Root
|
|
9
|
+
|
|
10
|
+
const TooltipTrigger = TooltipPrimitive.Trigger
|
|
11
|
+
|
|
12
|
+
const TooltipContent = React.forwardRef(({ className, sideOffset = 4, ...props }, ref) => (
|
|
13
|
+
<TooltipPrimitive.Content
|
|
14
|
+
ref={ref}
|
|
15
|
+
sideOffset={sideOffset}
|
|
16
|
+
className={cn(
|
|
17
|
+
"z-50 overflow-hidden rounded-md border bg-popover px-3 py-1.5 text-sm text-popover-foreground shadow-md 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 origin-[--radix-tooltip-content-transform-origin]",
|
|
18
|
+
className
|
|
19
|
+
)}
|
|
20
|
+
{...props} />
|
|
21
|
+
))
|
|
22
|
+
TooltipContent.displayName = TooltipPrimitive.Content.displayName
|
|
23
|
+
|
|
24
|
+
export { Tooltip, TooltipTrigger, TooltipContent, TooltipProvider }
|
|
@@ -0,0 +1,155 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
// Inspired by react-hot-toast library
|
|
3
|
+
import * as React from "react"
|
|
4
|
+
|
|
5
|
+
const TOAST_LIMIT = 1
|
|
6
|
+
const TOAST_REMOVE_DELAY = 1000000
|
|
7
|
+
|
|
8
|
+
const actionTypes = {
|
|
9
|
+
ADD_TOAST: "ADD_TOAST",
|
|
10
|
+
UPDATE_TOAST: "UPDATE_TOAST",
|
|
11
|
+
DISMISS_TOAST: "DISMISS_TOAST",
|
|
12
|
+
REMOVE_TOAST: "REMOVE_TOAST"
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
let count = 0
|
|
16
|
+
|
|
17
|
+
function genId() {
|
|
18
|
+
count = (count + 1) % Number.MAX_SAFE_INTEGER
|
|
19
|
+
return count.toString();
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
const toastTimeouts = new Map()
|
|
23
|
+
|
|
24
|
+
const addToRemoveQueue = (toastId) => {
|
|
25
|
+
if (toastTimeouts.has(toastId)) {
|
|
26
|
+
return
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
const timeout = setTimeout(() => {
|
|
30
|
+
toastTimeouts.delete(toastId)
|
|
31
|
+
dispatch({
|
|
32
|
+
type: "REMOVE_TOAST",
|
|
33
|
+
toastId: toastId,
|
|
34
|
+
})
|
|
35
|
+
}, TOAST_REMOVE_DELAY)
|
|
36
|
+
|
|
37
|
+
toastTimeouts.set(toastId, timeout)
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
export const reducer = (state, action) => {
|
|
41
|
+
switch (action.type) {
|
|
42
|
+
case "ADD_TOAST":
|
|
43
|
+
return {
|
|
44
|
+
...state,
|
|
45
|
+
toasts: [action.toast, ...state.toasts].slice(0, TOAST_LIMIT),
|
|
46
|
+
};
|
|
47
|
+
|
|
48
|
+
case "UPDATE_TOAST":
|
|
49
|
+
return {
|
|
50
|
+
...state,
|
|
51
|
+
toasts: state.toasts.map((t) =>
|
|
52
|
+
t.id === action.toast.id ? { ...t, ...action.toast } : t),
|
|
53
|
+
};
|
|
54
|
+
|
|
55
|
+
case "DISMISS_TOAST": {
|
|
56
|
+
const { toastId } = action
|
|
57
|
+
|
|
58
|
+
// ! Side effects ! - This could be extracted into a dismissToast() action,
|
|
59
|
+
// but I'll keep it here for simplicity
|
|
60
|
+
if (toastId) {
|
|
61
|
+
addToRemoveQueue(toastId)
|
|
62
|
+
} else {
|
|
63
|
+
state.toasts.forEach((toast) => {
|
|
64
|
+
addToRemoveQueue(toast.id)
|
|
65
|
+
})
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
return {
|
|
69
|
+
...state,
|
|
70
|
+
toasts: state.toasts.map((t) =>
|
|
71
|
+
t.id === toastId || toastId === undefined
|
|
72
|
+
? {
|
|
73
|
+
...t,
|
|
74
|
+
open: false,
|
|
75
|
+
}
|
|
76
|
+
: t),
|
|
77
|
+
};
|
|
78
|
+
}
|
|
79
|
+
case "REMOVE_TOAST":
|
|
80
|
+
if (action.toastId === undefined) {
|
|
81
|
+
return {
|
|
82
|
+
...state,
|
|
83
|
+
toasts: [],
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
return {
|
|
87
|
+
...state,
|
|
88
|
+
toasts: state.toasts.filter((t) => t.id !== action.toastId),
|
|
89
|
+
};
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
const listeners = []
|
|
94
|
+
|
|
95
|
+
let memoryState = { toasts: [] }
|
|
96
|
+
|
|
97
|
+
function dispatch(action) {
|
|
98
|
+
memoryState = reducer(memoryState, action)
|
|
99
|
+
listeners.forEach((listener) => {
|
|
100
|
+
listener(memoryState)
|
|
101
|
+
})
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
function toast({
|
|
105
|
+
...props
|
|
106
|
+
}) {
|
|
107
|
+
const id = genId()
|
|
108
|
+
|
|
109
|
+
const update = (props) =>
|
|
110
|
+
dispatch({
|
|
111
|
+
type: "UPDATE_TOAST",
|
|
112
|
+
toast: { ...props, id },
|
|
113
|
+
})
|
|
114
|
+
const dismiss = () => dispatch({ type: "DISMISS_TOAST", toastId: id })
|
|
115
|
+
|
|
116
|
+
dispatch({
|
|
117
|
+
type: "ADD_TOAST",
|
|
118
|
+
toast: {
|
|
119
|
+
...props,
|
|
120
|
+
id,
|
|
121
|
+
open: true,
|
|
122
|
+
onOpenChange: (open) => {
|
|
123
|
+
if (!open) dismiss()
|
|
124
|
+
},
|
|
125
|
+
},
|
|
126
|
+
})
|
|
127
|
+
|
|
128
|
+
return {
|
|
129
|
+
id: id,
|
|
130
|
+
dismiss,
|
|
131
|
+
update,
|
|
132
|
+
}
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
function useToast() {
|
|
136
|
+
const [state, setState] = React.useState(memoryState)
|
|
137
|
+
|
|
138
|
+
React.useEffect(() => {
|
|
139
|
+
listeners.push(setState)
|
|
140
|
+
return () => {
|
|
141
|
+
const index = listeners.indexOf(setState)
|
|
142
|
+
if (index > -1) {
|
|
143
|
+
listeners.splice(index, 1)
|
|
144
|
+
}
|
|
145
|
+
};
|
|
146
|
+
}, [state])
|
|
147
|
+
|
|
148
|
+
return {
|
|
149
|
+
...state,
|
|
150
|
+
toast,
|
|
151
|
+
dismiss: (toastId) => dispatch({ type: "DISMISS_TOAST", toastId }),
|
|
152
|
+
};
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
export { useToast, toast }
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
@tailwind base;
|
|
2
|
+
@tailwind components;
|
|
3
|
+
@tailwind utilities;
|
|
4
|
+
|
|
5
|
+
@layer base {
|
|
6
|
+
:root {
|
|
7
|
+
--background: 0 0% 100%;
|
|
8
|
+
--foreground: 222.2 84% 4.9%;
|
|
9
|
+
--card: 0 0% 100%;
|
|
10
|
+
--card-foreground: 222.2 84% 4.9%;
|
|
11
|
+
--popover: 0 0% 100%;
|
|
12
|
+
--popover-foreground: 222.2 84% 4.9%;
|
|
13
|
+
--primary: 222.2 47.4% 11.2%;
|
|
14
|
+
--primary-foreground: 210 40% 98%;
|
|
15
|
+
--secondary: 210 40% 96.1%;
|
|
16
|
+
--secondary-foreground: 222.2 47.4% 11.2%;
|
|
17
|
+
--muted: 210 40% 96.1%;
|
|
18
|
+
--muted-foreground: 215.4 16.3% 46.9%;
|
|
19
|
+
--accent: 210 40% 96.1%;
|
|
20
|
+
--accent-foreground: 222.2 47.4% 11.2%;
|
|
21
|
+
--destructive: 0 84.2% 60.2%;
|
|
22
|
+
--destructive-foreground: 210 40% 98%;
|
|
23
|
+
--border: 214.3 31.8% 91.4%;
|
|
24
|
+
--input: 214.3 31.8% 91.4%;
|
|
25
|
+
--ring: 222.2 84% 4.9%;
|
|
26
|
+
--radius: 0.5rem;
|
|
27
|
+
}
|
|
28
|
+
.dark {
|
|
29
|
+
--background: 222.2 84% 4.9%;
|
|
30
|
+
--foreground: 210 40% 98%;
|
|
31
|
+
--card: 222.2 84% 4.9%;
|
|
32
|
+
--card-foreground: 210 40% 98%;
|
|
33
|
+
--popover: 222.2 84% 4.9%;
|
|
34
|
+
--popover-foreground: 210 40% 98%;
|
|
35
|
+
--primary: 210 40% 98%;
|
|
36
|
+
--primary-foreground: 222.2 47.4% 11.2%;
|
|
37
|
+
--secondary: 217.2 32.6% 17.5%;
|
|
38
|
+
--secondary-foreground: 210 40% 98%;
|
|
39
|
+
--muted: 217.2 32.6% 17.5%;
|
|
40
|
+
--muted-foreground: 215 20.2% 65.1%;
|
|
41
|
+
--accent: 217.2 32.6% 17.5%;
|
|
42
|
+
--accent-foreground: 210 40% 98%;
|
|
43
|
+
--destructive: 0 62.8% 30.6%;
|
|
44
|
+
--destructive-foreground: 210 40% 98%;
|
|
45
|
+
--border: 217.2 32.6% 17.5%;
|
|
46
|
+
--input: 217.2 32.6% 17.5%;
|
|
47
|
+
--ring: 212.7 26.8% 83.9%;
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
@layer base {
|
|
52
|
+
* {
|
|
53
|
+
@apply border-border;
|
|
54
|
+
}
|
|
55
|
+
body {
|
|
56
|
+
@apply bg-background text-foreground;
|
|
57
|
+
}
|
|
58
|
+
h1, h2, h3, h4 {
|
|
59
|
+
@apply font-semibold;
|
|
60
|
+
}
|
|
61
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { clsx } from "clsx";
|
|
2
|
+
import { twMerge } from "tailwind-merge";
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Merges Tailwind CSS classes with clsx + tailwind-merge.
|
|
6
|
+
* @param {...import('clsx').ClassValue} inputs
|
|
7
|
+
* @returns {string}
|
|
8
|
+
*/
|
|
9
|
+
export function cn(...inputs) {
|
|
10
|
+
return twMerge(clsx(inputs));
|
|
11
|
+
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import ReactDOM from "react-dom/client";
|
|
3
|
+
import { BrowserRouter } from "react-router-dom";
|
|
4
|
+
import App from "./App.jsx";
|
|
5
|
+
import "./index.css";
|
|
6
|
+
import { Toaster } from "@/components/ui/sonner";
|
|
7
|
+
|
|
8
|
+
ReactDOM.createRoot(document.getElementById("root")).render(
|
|
9
|
+
<React.StrictMode>
|
|
10
|
+
<BrowserRouter>
|
|
11
|
+
<App />
|
|
12
|
+
<Toaster />
|
|
13
|
+
</BrowserRouter>
|
|
14
|
+
</React.StrictMode>
|
|
15
|
+
);
|