@gunjo/ui 0.0.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 (88) hide show
  1. package/README.md +129 -0
  2. package/design/atoms-metadata.json +82 -0
  3. package/design/molecules-metadata.json +130 -0
  4. package/design/organisms-metadata.json +38 -0
  5. package/design/templates-metadata.json +38 -0
  6. package/package.json +158 -0
  7. package/src/components/atoms/Alert.tsx +63 -0
  8. package/src/components/atoms/Avatar.tsx +57 -0
  9. package/src/components/atoms/Badge.tsx +30 -0
  10. package/src/components/atoms/Button.tsx +29 -0
  11. package/src/components/atoms/ButtonVariants.ts +37 -0
  12. package/src/components/atoms/Checkbox.tsx +52 -0
  13. package/src/components/atoms/Img.tsx +102 -0
  14. package/src/components/atoms/Input.tsx +37 -0
  15. package/src/components/atoms/Kbd.tsx +22 -0
  16. package/src/components/atoms/Label.tsx +22 -0
  17. package/src/components/atoms/Progress.tsx +38 -0
  18. package/src/components/atoms/RadioGroup.tsx +86 -0
  19. package/src/components/atoms/Select.tsx +28 -0
  20. package/src/components/atoms/Separator.tsx +33 -0
  21. package/src/components/atoms/Skeleton.tsx +36 -0
  22. package/src/components/atoms/Slider.tsx +26 -0
  23. package/src/components/atoms/Spinner.tsx +34 -0
  24. package/src/components/atoms/Switch.tsx +47 -0
  25. package/src/components/atoms/Textarea.tsx +34 -0
  26. package/src/components/atoms/ToggleGroup.tsx +60 -0
  27. package/src/components/atoms/ToolPill.tsx +77 -0
  28. package/src/components/atoms/generated/default-variant-keys.ts +36 -0
  29. package/src/components/atoms/generated/variant-keys.ts +61 -0
  30. package/src/components/generated/component-manifest.ts +741 -0
  31. package/src/components/generated/component-style-hints.ts +1262 -0
  32. package/src/components/molecules/AIChatInput.tsx +140 -0
  33. package/src/components/molecules/AIChatMessage.tsx +109 -0
  34. package/src/components/molecules/Accordion.tsx +99 -0
  35. package/src/components/molecules/Breadcrumb.tsx +115 -0
  36. package/src/components/molecules/Calendar.tsx +60 -0
  37. package/src/components/molecules/Card.tsx +78 -0
  38. package/src/components/molecules/Carousel.tsx +261 -0
  39. package/src/components/molecules/Command.tsx +152 -0
  40. package/src/components/molecules/ContextMenu.tsx +200 -0
  41. package/src/components/molecules/Dialog.tsx +122 -0
  42. package/src/components/molecules/DropdownMenu.tsx +200 -0
  43. package/src/components/molecules/FilterButton.tsx +133 -0
  44. package/src/components/molecules/Form.tsx +90 -0
  45. package/src/components/molecules/HoverCard.tsx +29 -0
  46. package/src/components/molecules/List.tsx +120 -0
  47. package/src/components/molecules/Menubar.tsx +231 -0
  48. package/src/components/molecules/Modal.tsx +66 -0
  49. package/src/components/molecules/NotificationCenter.tsx +118 -0
  50. package/src/components/molecules/Pagination.tsx +118 -0
  51. package/src/components/molecules/Popover.tsx +31 -0
  52. package/src/components/molecules/ProgressWidget.tsx +40 -0
  53. package/src/components/molecules/Resizable.tsx +47 -0
  54. package/src/components/molecules/ScrollArea.tsx +48 -0
  55. package/src/components/molecules/Sheet.tsx +140 -0
  56. package/src/components/molecules/SidebarItem.tsx +134 -0
  57. package/src/components/molecules/SortButton.tsx +56 -0
  58. package/src/components/molecules/StatusBar.tsx +41 -0
  59. package/src/components/molecules/Stepper.tsx +108 -0
  60. package/src/components/molecules/Table.tsx +117 -0
  61. package/src/components/molecules/Tabs.tsx +64 -0
  62. package/src/components/molecules/Toast.tsx +57 -0
  63. package/src/components/molecules/Tooltip.tsx +30 -0
  64. package/src/components/molecules/generated/default-variant-keys.ts +22 -0
  65. package/src/components/molecules/generated/variant-keys.ts +33 -0
  66. package/src/components/organisms/AppRail.tsx +28 -0
  67. package/src/components/organisms/CommandPalette.tsx +58 -0
  68. package/src/components/organisms/FileUploader.tsx +151 -0
  69. package/src/components/organisms/FloatingPanel.tsx +46 -0
  70. package/src/components/organisms/InspectorPanel.tsx +65 -0
  71. package/src/components/organisms/RightRail.tsx +29 -0
  72. package/src/components/organisms/ShareModal.tsx +182 -0
  73. package/src/components/organisms/SpatialCanvas.tsx +36 -0
  74. package/src/components/organisms/ToastProvider.tsx +49 -0
  75. package/src/components/templates/AuthTemplate.tsx +58 -0
  76. package/src/components/templates/BannalyzeTemplate.tsx +55 -0
  77. package/src/components/templates/ChatTemplate.tsx +55 -0
  78. package/src/components/templates/DashboardTemplate.tsx +34 -0
  79. package/src/components/templates/EditorTemplate.tsx +46 -0
  80. package/src/components/templates/KanbanTemplate.tsx +38 -0
  81. package/src/components/templates/LandingTemplate.tsx +53 -0
  82. package/src/components/templates/MediaLibraryTemplate.tsx +55 -0
  83. package/src/components/templates/SettingsTemplate.tsx +48 -0
  84. package/src/globals.css +108 -0
  85. package/src/index.ts +89 -0
  86. package/src/lib/utils.ts +6 -0
  87. package/tailwind-preset.js +11 -0
  88. package/tailwind-theme-extend.cjs +86 -0
@@ -0,0 +1,120 @@
1
+ import * as React from "react"
2
+ import { cn } from "../../lib/utils"
3
+ import { Check, Circle, Dot } from "lucide-react"
4
+ import { listVariantKeys, type ListVariantKey } from "./generated/variant-keys"
5
+ import { listDefaultVariantKey } from "./generated/default-variant-keys"
6
+
7
+ type ListMarkerKey = ListVariantKey | "number" | "none"
8
+
9
+ const listVariantKeySet = new Set<ListVariantKey>(listVariantKeys)
10
+
11
+ const markerIcons: Record<ListVariantKey, React.ReactNode> = {
12
+ check: <Check className="h-4 w-4 flex-shrink-0 text-primary" />,
13
+ circle: <Circle className="h-3 w-3 flex-shrink-0 text-muted-foreground" fill="currentColor" />,
14
+ dot: <Dot className="h-4 w-4 flex-shrink-0 text-muted-foreground" />,
15
+ }
16
+
17
+ const listLayoutClasses: Record<ListVariantKey, string> = {
18
+ dot: "flex flex-col items-center w-fit gap-2",
19
+ check: "flex flex-col items-center w-fit gap-2",
20
+ circle: "flex flex-col items-center w-fit gap-2",
21
+ }
22
+
23
+ function isListVariantKey(value: ListMarkerKey | undefined): value is ListVariantKey {
24
+ return !!value && listVariantKeySet.has(value as ListVariantKey)
25
+ }
26
+
27
+ export interface ListProps extends React.HTMLAttributes<HTMLUListElement | HTMLOListElement> {
28
+ variant?: "unordered" | "ordered" | "none"
29
+ marker?: ListMarkerKey
30
+ spacing?: "default" | "tight" | "loose"
31
+ }
32
+
33
+ const List = React.forwardRef<HTMLElement, ListProps>(
34
+ ({ className, variant = "unordered", marker, spacing = "default", children, ...props }, ref) => {
35
+ const Comp = variant === "ordered" ? "ol" : "ul"
36
+
37
+ // Determine default marker based on variant if not specified
38
+ const effectiveMarker =
39
+ marker ||
40
+ (variant === "ordered"
41
+ ? "number"
42
+ : variant === "unordered"
43
+ ? listDefaultVariantKey
44
+ : "none");
45
+
46
+ return (
47
+ <Comp
48
+ ref={ref as any}
49
+ className={cn(
50
+ "text-muted-foreground",
51
+ isListVariantKey(effectiveMarker) && listLayoutClasses[effectiveMarker],
52
+ spacing === "default" && "space-y-2",
53
+ spacing === "tight" && "space-y-1",
54
+ spacing === "loose" && "space-y-4",
55
+ className
56
+ )}
57
+ {...props}
58
+ >
59
+ {React.Children.map(children, (child) => {
60
+ if (React.isValidElement(child) && child.type === ListItem) {
61
+ const item = child as React.ReactElement<ListItemProps>;
62
+ return React.cloneElement(item, {
63
+ marker: item.props.marker || effectiveMarker,
64
+ })
65
+ }
66
+ return child
67
+ })}
68
+ </Comp>
69
+ )
70
+ }
71
+ )
72
+ List.displayName = "List"
73
+
74
+ export interface ListItemProps extends React.LiHTMLAttributes<HTMLLIElement> {
75
+ marker?: ListMarkerKey
76
+ icon?: React.ReactNode
77
+ }
78
+
79
+ const ListItem = React.forwardRef<HTMLLIElement, ListItemProps>(
80
+ ({ className, children, marker, icon, ...props }, ref) => {
81
+
82
+ let markerEl = null;
83
+ if (icon) {
84
+ markerEl = <span className="flex-shrink-0 text-muted-foreground">{icon}</span>
85
+ } else if (isListVariantKey(marker)) {
86
+ markerEl = markerIcons[marker]
87
+ } else {
88
+ switch (marker) {
89
+ case "number":
90
+ // For ordered lists, we typically rely on list-style-type,
91
+ // but for custom styling we might want a span.
92
+ // Let's use standard list-decimal class for 'number' if no icon
93
+ break;
94
+ default:
95
+ break;
96
+ }
97
+ }
98
+
99
+ const isStandardOrdered = marker === "number" && !icon;
100
+
101
+ return (
102
+ <li
103
+ ref={ref}
104
+ className={cn(
105
+ "flex items-center gap-2",
106
+ isStandardOrdered && "list-decimal list-inside ml-4 list-item", // Restore standard list behavior
107
+ !isStandardOrdered && "list-none",
108
+ className
109
+ )}
110
+ {...props}
111
+ >
112
+ {!isStandardOrdered && markerEl}
113
+ <span className="flex-1 text-sm text-muted-foreground">{children}</span>
114
+ </li>
115
+ )
116
+ }
117
+ )
118
+ ListItem.displayName = "ListItem"
119
+
120
+ export { List, ListItem }
@@ -0,0 +1,231 @@
1
+ "use client"
2
+
3
+ import * as React from "react"
4
+ import * as MenubarPrimitive from "@radix-ui/react-menubar"
5
+ import { Check, ChevronRight, Circle } from "lucide-react"
6
+
7
+ import { cn } from "../../lib/utils"
8
+
9
+ const Menubar = React.forwardRef<
10
+ React.ElementRef<typeof MenubarPrimitive.Root>,
11
+ React.ComponentPropsWithoutRef<typeof MenubarPrimitive.Root>
12
+ >(({ className, ...props }, ref) => (
13
+ <MenubarPrimitive.Root
14
+ ref={ref}
15
+ className={cn(
16
+ "flex flex-col flex-row h-10 items-center gap-1 space-x-1 rounded-md border bg-background p-1",
17
+ className
18
+ )}
19
+ {...props}
20
+ />
21
+ ))
22
+ Menubar.displayName = MenubarPrimitive.Root.displayName
23
+
24
+ const MenubarMenu = MenubarPrimitive.Menu
25
+
26
+ const MenubarTrigger = React.forwardRef<
27
+ React.ElementRef<typeof MenubarPrimitive.Trigger>,
28
+ React.ComponentPropsWithoutRef<typeof MenubarPrimitive.Trigger>
29
+ >(({ className, ...props }, ref) => (
30
+ <MenubarPrimitive.Trigger
31
+ ref={ref}
32
+ className={cn(
33
+ "flex cursor-default select-none items-center rounded-sm px-3 py-1.5 text-sm font-medium outline-none focus:bg-accent focus:text-accent-foreground data-[state=open]:bg-accent data-[state=open]:text-accent-foreground",
34
+ className
35
+ )}
36
+ {...props}
37
+ />
38
+ ))
39
+ MenubarTrigger.displayName = MenubarPrimitive.Trigger.displayName
40
+
41
+ const MenubarSubTrigger = React.forwardRef<
42
+ React.ElementRef<typeof MenubarPrimitive.SubTrigger>,
43
+ React.ComponentPropsWithoutRef<typeof MenubarPrimitive.SubTrigger> & {
44
+ inset?: boolean
45
+ }
46
+ >(({ className, inset, children, ...props }, ref) => (
47
+ <MenubarPrimitive.SubTrigger
48
+ ref={ref}
49
+ className={cn(
50
+ "flex cursor-default select-none items-center rounded-sm px-2 py-1.5 text-sm outline-none focus:bg-accent focus:text-accent-foreground data-[state=open]:bg-accent data-[state=open]:text-accent-foreground",
51
+ inset && "pl-8",
52
+ className
53
+ )}
54
+ {...props}
55
+ >
56
+ {children}
57
+ <ChevronRight className="ml-auto h-4 w-4" />
58
+ </MenubarPrimitive.SubTrigger>
59
+ ))
60
+ MenubarSubTrigger.displayName = MenubarPrimitive.SubTrigger.displayName
61
+
62
+ const MenubarSubContent = React.forwardRef<
63
+ React.ElementRef<typeof MenubarPrimitive.SubContent>,
64
+ React.ComponentPropsWithoutRef<typeof MenubarPrimitive.SubContent>
65
+ >(({ className, ...props }, ref) => (
66
+ <MenubarPrimitive.SubContent
67
+ ref={ref}
68
+ className={cn(
69
+ "z-50 min-w-[8rem] overflow-hidden rounded-md border bg-popover p-1 text-popover-foreground 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 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",
70
+ className
71
+ )}
72
+ {...props}
73
+ />
74
+ ))
75
+ MenubarSubContent.displayName = MenubarPrimitive.SubContent.displayName
76
+
77
+ const MenubarContent = React.forwardRef<
78
+ React.ElementRef<typeof MenubarPrimitive.Content>,
79
+ React.ComponentPropsWithoutRef<typeof MenubarPrimitive.Content>
80
+ >(({ className, align = "start", alignOffset = -4, sideOffset = 8, ...props }, ref) => (
81
+ <MenubarPrimitive.Portal>
82
+ <MenubarPrimitive.Content
83
+ ref={ref}
84
+ align={align}
85
+ alignOffset={alignOffset}
86
+ sideOffset={sideOffset}
87
+ className={cn(
88
+ "z-50 min-w-[12rem] overflow-hidden rounded-md border bg-popover p-1 text-popover-foreground shadow-md data-[state=open]:animate-in data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-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",
89
+ className
90
+ )}
91
+ {...props}
92
+ />
93
+ </MenubarPrimitive.Portal>
94
+ ))
95
+ MenubarContent.displayName = MenubarPrimitive.Content.displayName
96
+
97
+ const MenubarItem = React.forwardRef<
98
+ React.ElementRef<typeof MenubarPrimitive.Item>,
99
+ React.ComponentPropsWithoutRef<typeof MenubarPrimitive.Item> & {
100
+ inset?: boolean
101
+ }
102
+ >(({ className, inset, ...props }, ref) => (
103
+ <MenubarPrimitive.Item
104
+ ref={ref}
105
+ className={cn(
106
+ "relative flex cursor-default select-none items-center rounded-sm px-2 py-1.5 text-sm outline-none focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50",
107
+ inset && "pl-8",
108
+ className
109
+ )}
110
+ {...props}
111
+ />
112
+ ))
113
+ MenubarItem.displayName = MenubarPrimitive.Item.displayName
114
+
115
+ const MenubarCheckboxItem = React.forwardRef<
116
+ React.ElementRef<typeof MenubarPrimitive.CheckboxItem>,
117
+ React.ComponentPropsWithoutRef<typeof MenubarPrimitive.CheckboxItem>
118
+ >(({ className, children, checked, ...props }, ref) => (
119
+ <MenubarPrimitive.CheckboxItem
120
+ ref={ref}
121
+ className={cn(
122
+ "relative flex cursor-default select-none items-center rounded-sm py-1.5 pl-8 pr-2 text-sm outline-none focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50",
123
+ className
124
+ )}
125
+ checked={checked}
126
+ {...props}
127
+ >
128
+ <span className="absolute left-2 flex h-3.5 w-3.5 items-center justify-center">
129
+ <MenubarPrimitive.ItemIndicator>
130
+ <Check className="h-4 w-4" />
131
+ </MenubarPrimitive.ItemIndicator>
132
+ </span>
133
+ {children}
134
+ </MenubarPrimitive.CheckboxItem>
135
+ ))
136
+ MenubarCheckboxItem.displayName = MenubarPrimitive.CheckboxItem.displayName
137
+
138
+ const MenubarRadioItem = React.forwardRef<
139
+ React.ElementRef<typeof MenubarPrimitive.RadioItem>,
140
+ React.ComponentPropsWithoutRef<typeof MenubarPrimitive.RadioItem>
141
+ >(({ className, children, ...props }, ref) => (
142
+ <MenubarPrimitive.RadioItem
143
+ ref={ref}
144
+ className={cn(
145
+ "relative flex cursor-default select-none items-center rounded-sm py-1.5 pl-8 pr-2 text-sm outline-none focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50",
146
+ className
147
+ )}
148
+ {...props}
149
+ >
150
+ <span className="absolute left-2 flex h-3.5 w-3.5 items-center justify-center">
151
+ <MenubarPrimitive.ItemIndicator>
152
+ <Circle className="h-2 w-2 fill-current" />
153
+ </MenubarPrimitive.ItemIndicator>
154
+ </span>
155
+ {children}
156
+ </MenubarPrimitive.RadioItem>
157
+ ))
158
+ MenubarRadioItem.displayName = MenubarPrimitive.RadioItem.displayName
159
+
160
+ const MenubarLabel = React.forwardRef<
161
+ React.ElementRef<typeof MenubarPrimitive.Label>,
162
+ React.ComponentPropsWithoutRef<typeof MenubarPrimitive.Label> & {
163
+ inset?: boolean
164
+ }
165
+ >(({ className, inset, ...props }, ref) => (
166
+ <MenubarPrimitive.Label
167
+ ref={ref}
168
+ className={cn(
169
+ "px-2 py-1.5 text-sm font-semibold",
170
+ inset && "pl-8",
171
+ className
172
+ )}
173
+ {...props}
174
+ />
175
+ ))
176
+ MenubarLabel.displayName = MenubarPrimitive.Label.displayName
177
+
178
+ const MenubarSeparator = React.forwardRef<
179
+ React.ElementRef<typeof MenubarPrimitive.Separator>,
180
+ React.ComponentPropsWithoutRef<typeof MenubarPrimitive.Separator>
181
+ >(({ className, ...props }, ref) => (
182
+ <MenubarPrimitive.Separator
183
+ ref={ref}
184
+ className={cn("-mx-1 my-1 h-px bg-muted", className)}
185
+ {...props}
186
+ />
187
+ ))
188
+ MenubarSeparator.displayName = MenubarPrimitive.Separator.displayName
189
+
190
+ const MenubarShortcut = ({
191
+ className,
192
+ ...props
193
+ }: React.HTMLAttributes<HTMLSpanElement>) => {
194
+ return (
195
+ <span
196
+ className={cn(
197
+ "ml-auto text-xs tracking-widest text-muted-foreground",
198
+ className
199
+ )}
200
+ {...props}
201
+ />
202
+ )
203
+ }
204
+ MenubarShortcut.displayName = "MenubarShortcut"
205
+
206
+ export {
207
+ Menubar,
208
+ MenubarMenu,
209
+ MenubarTrigger,
210
+ MenubarContent,
211
+ MenubarItem,
212
+ MenubarSeparator,
213
+ MenubarLabel,
214
+ MenubarCheckboxItem,
215
+ MenubarRadioGroup,
216
+ MenubarRadioItem,
217
+ MenubarPortal,
218
+ MenubarSubContent,
219
+ MenubarSubTrigger,
220
+ MenubarGroup,
221
+ MenubarSub,
222
+ MenubarShortcut,
223
+ }
224
+
225
+ const MenubarGroup = MenubarPrimitive.Group
226
+
227
+ const MenubarPortal = MenubarPrimitive.Portal
228
+
229
+ const MenubarSub = MenubarPrimitive.Sub
230
+
231
+ const MenubarRadioGroup = MenubarPrimitive.RadioGroup
@@ -0,0 +1,66 @@
1
+ "use client"
2
+ import React, { useEffect, useRef } from 'react';
3
+ import { X } from 'lucide-react';
4
+ import { cn } from '../../lib/utils';
5
+
6
+ export interface ModalProps {
7
+ isOpen: boolean;
8
+ onClose: () => void;
9
+ title: string;
10
+ children: React.ReactNode;
11
+ footer?: React.ReactNode;
12
+ }
13
+
14
+ export function Modal({ isOpen, onClose, title, children, footer }: ModalProps) {
15
+ const modalRef = useRef<HTMLDivElement>(null);
16
+
17
+ useEffect(() => {
18
+ const handleEscape = (e: KeyboardEvent) => {
19
+ if (e.key === 'Escape') onClose();
20
+ };
21
+
22
+ if (isOpen) {
23
+ document.addEventListener('keydown', handleEscape);
24
+ document.body.style.overflow = 'hidden';
25
+ }
26
+
27
+ return () => {
28
+ document.removeEventListener('keydown', handleEscape);
29
+ document.body.style.overflow = 'unset';
30
+ };
31
+ }, [isOpen, onClose]);
32
+
33
+ if (!isOpen) return null;
34
+
35
+ const content = (
36
+ <div data-prevent-deselect="true" className="fixed inset-0 z-[9999] flex items-center justify-center bg-overlay/60 backdrop-blur-sm animate-in fade-in duration-200" onClick={(e) => e.stopPropagation()}>
37
+ <div
38
+ ref={modalRef}
39
+ onClick={(e) => e.stopPropagation()}
40
+ className="flex flex-col w-[448px] bg-card border border-border rounded-lg shadow-xl w-full max-w-md mx-4 overflow-hidden animate-in zoom-in-95 duration-200"
41
+ >
42
+ <div className="flex items-center justify-between px-4 py-3 border-b border-border">
43
+ <h3 className="font-semibold text-foreground">{title}</h3>
44
+ <button onClick={onClose} className="text-muted-foreground hover:text-foreground transition-colors">
45
+ <X size={18} />
46
+ </button>
47
+ </div>
48
+ <div className="p-4">
49
+ {children}
50
+ </div>
51
+ {footer && (
52
+ <div className="px-4 py-3 bg-muted/50 border-t border-border flex justify-end gap-2">
53
+ {footer}
54
+ </div>
55
+ )}
56
+ </div>
57
+ </div>
58
+ );
59
+
60
+ // Use Portal if available
61
+ if (typeof document !== 'undefined') {
62
+ const { createPortal } = require('react-dom');
63
+ return createPortal(content, document.body);
64
+ }
65
+ return content;
66
+ }
@@ -0,0 +1,118 @@
1
+ "use client"
2
+
3
+ import * as React from "react"
4
+ import { Bell, Check } from "lucide-react"
5
+ import { Button } from "../atoms/Button"
6
+ import { Popover, PopoverContent, PopoverTrigger } from "./Popover"
7
+ import { ScrollArea } from "./ScrollArea"
8
+ import { cn } from "../../lib/utils"
9
+
10
+ export interface Notification {
11
+ id: string
12
+ title: string
13
+ description: string
14
+ timestamp: string
15
+ read: boolean
16
+ }
17
+
18
+ export interface NotificationCenterProps {
19
+ notifications: Notification[]
20
+ onMarkAsRead?: (id: string) => void
21
+ onLinkClick?: (id: string) => void
22
+ onClearAll?: () => void
23
+ }
24
+
25
+ const NotificationCenter = ({
26
+ notifications,
27
+ onMarkAsRead,
28
+ onLinkClick,
29
+ onClearAll,
30
+ }: NotificationCenterProps) => {
31
+ const unreadCount = notifications.filter((n) => !n.read).length
32
+ const [isOpen, setIsOpen] = React.useState(false)
33
+
34
+ return (
35
+ <Popover open={isOpen} onOpenChange={setIsOpen}>
36
+ <PopoverTrigger asChild>
37
+ <Button variant="ghost" size="icon" className="relative text-muted-foreground hover:text-foreground">
38
+ <Bell className="h-5 w-5" />
39
+ {unreadCount > 0 && (
40
+ <span className="absolute top-2 right-2 h-2 w-2 rounded-full bg-destructive ring-2 ring-background" />
41
+ )}
42
+ <span className="sr-only">Toggle notifications</span>
43
+ </Button>
44
+ </PopoverTrigger>
45
+ <PopoverContent align="end" className="w-[320px] w-80 p-0" sideOffset={8}>
46
+ <div className="flex items-center justify-between border-b px-4 py-3 bg-muted/50 backdrop-blur">
47
+ <h4 className="font-semibold text-sm">Notifications</h4>
48
+ {unreadCount > 0 && onClearAll && (
49
+ <Button
50
+ variant="ghost"
51
+ size="sm"
52
+ className="h-auto px-2 text-xs text-muted-foreground hover:text-foreground"
53
+ onClick={onClearAll}
54
+ >
55
+ Clear all
56
+ </Button>
57
+ )}
58
+ </div>
59
+ <ScrollArea className="h-[300px]">
60
+ {notifications.length === 0 ? (
61
+ <div className="flex h-full flex-col items-center justify-center p-4 text-center text-muted-foreground">
62
+ <Bell className="h-8 w-8 mb-2 opacity-20" />
63
+ <p className="text-sm">No notifications</p>
64
+ </div>
65
+ ) : (
66
+ <div className="grid">
67
+ {notifications.map((notification) => (
68
+ <div
69
+ key={notification.id}
70
+ className={cn(
71
+ "flex flex-col gap-1 border-b p-4 text-sm transition-colors hover:bg-muted/50",
72
+ !notification.read && "bg-primary/10"
73
+ )}
74
+ onClick={() => onLinkClick?.(notification.id)}
75
+ >
76
+ <div className="flex items-start justify-between gap-2">
77
+ <p className="font-medium leading-none text-foreground">
78
+ {notification.title}
79
+ </p>
80
+ {!notification.read && onMarkAsRead && (
81
+ <Button
82
+ variant="ghost"
83
+ size="icon"
84
+ className="h-6 w-6 -mr-2 -mt-1 text-muted-foreground hover:text-primary"
85
+ onClick={(e) => {
86
+ e.stopPropagation();
87
+ onMarkAsRead(notification.id);
88
+ }}
89
+ title="Mark as read"
90
+ >
91
+ <span className="sr-only">Mark as read</span>
92
+ <div className="h-1.5 w-1.5 rounded-full bg-primary" />
93
+ </Button>
94
+ )}
95
+ </div>
96
+ <p className="text-muted-foreground line-clamp-2">
97
+ {notification.description}
98
+ </p>
99
+ <p className="mt-1 text-xs text-muted-foreground">
100
+ {notification.timestamp}
101
+ </p>
102
+ </div>
103
+ ))}
104
+ </div>
105
+ )}
106
+ </ScrollArea>
107
+ <div className="border-t p-2">
108
+ <Button variant="ghost" className="h-8 w-full text-xs text-muted-foreground hover:text-foreground">
109
+ View all notification history
110
+ </Button>
111
+ </div>
112
+ </PopoverContent>
113
+ </Popover>
114
+ )
115
+ }
116
+ NotificationCenter.displayName = "NotificationCenter"
117
+
118
+ export { NotificationCenter }
@@ -0,0 +1,118 @@
1
+ import * as React from "react"
2
+ import { ChevronLeft, ChevronRight, MoreHorizontal } from "lucide-react"
3
+ import { cn } from "../../lib/utils"
4
+ import { ButtonProps } from "../atoms/Button"
5
+ import { buttonVariants } from "../atoms/ButtonVariants"
6
+
7
+
8
+ const Pagination = ({ className, ...props }: React.ComponentProps<"nav">) => (
9
+ <nav
10
+ role="navigation"
11
+ aria-label="pagination"
12
+ className={cn("mx-auto flex flex-col w-full justify-center", className)}
13
+ {...props}
14
+ />
15
+ )
16
+ Pagination.displayName = "Pagination"
17
+
18
+ const PaginationContent = React.forwardRef<
19
+ HTMLUListElement,
20
+ React.ComponentProps<"ul">
21
+ >(({ className, ...props }, ref) => (
22
+ <ul
23
+ ref={ref}
24
+ className={cn("flex items-center gap-1", className)}
25
+ {...props}
26
+ />
27
+ ))
28
+ PaginationContent.displayName = "PaginationContent"
29
+
30
+ const PaginationItem = React.forwardRef<
31
+ HTMLLIElement,
32
+ React.ComponentProps<"li">
33
+ >(({ className, ...props }, ref) => (
34
+ <li ref={ref} className={cn("", className)} {...props} />
35
+ ))
36
+ PaginationItem.displayName = "PaginationItem"
37
+
38
+ type PaginationLinkProps = {
39
+ isActive?: boolean
40
+ } & Pick<ButtonProps, "size"> &
41
+ React.ComponentProps<"a">
42
+
43
+ const PaginationLink = ({
44
+ className,
45
+ isActive,
46
+ size = "icon",
47
+ ...props
48
+ }: PaginationLinkProps) => (
49
+ <a
50
+ aria-current={isActive ? "page" : undefined}
51
+ className={cn(
52
+ buttonVariants({
53
+ variant: isActive ? "outline" : "ghost",
54
+ size,
55
+ }),
56
+ className
57
+ )}
58
+ {...props}
59
+ />
60
+ )
61
+ PaginationLink.displayName = "PaginationLink"
62
+
63
+ const PaginationPrevious = ({
64
+ className,
65
+ ...props
66
+ }: React.ComponentProps<typeof PaginationLink>) => (
67
+ <PaginationLink
68
+ aria-label="Go to previous page"
69
+ size="default"
70
+ className={cn("gap-1 pl-2.5", className)}
71
+ {...props}
72
+ >
73
+ <ChevronLeft className="h-4 w-4" />
74
+ <span>Previous</span>
75
+ </PaginationLink>
76
+ )
77
+ PaginationPrevious.displayName = "PaginationPrevious"
78
+
79
+ const PaginationNext = ({
80
+ className,
81
+ ...props
82
+ }: React.ComponentProps<typeof PaginationLink>) => (
83
+ <PaginationLink
84
+ aria-label="Go to next page"
85
+ size="default"
86
+ className={cn("gap-1 pr-2.5", className)}
87
+ {...props}
88
+ >
89
+ <span>Next</span>
90
+ <ChevronRight className="h-4 w-4" />
91
+ </PaginationLink>
92
+ )
93
+ PaginationNext.displayName = "PaginationNext"
94
+
95
+ const PaginationEllipsis = ({
96
+ className,
97
+ ...props
98
+ }: React.ComponentProps<"span">) => (
99
+ <span
100
+ aria-hidden
101
+ className={cn("flex h-9 w-9 items-center justify-center", className)}
102
+ {...props}
103
+ >
104
+ <MoreHorizontal className="h-4 w-4" />
105
+ <span className="sr-only">More pages</span>
106
+ </span>
107
+ )
108
+ PaginationEllipsis.displayName = "PaginationEllipsis"
109
+
110
+ export {
111
+ Pagination,
112
+ PaginationContent,
113
+ PaginationEllipsis,
114
+ PaginationItem,
115
+ PaginationLink,
116
+ PaginationNext,
117
+ PaginationPrevious,
118
+ }
@@ -0,0 +1,31 @@
1
+ "use client"
2
+
3
+ import * as React from "react"
4
+ import * as PopoverPrimitive from "@radix-ui/react-popover"
5
+
6
+ import { cn } from "../../lib/utils"
7
+
8
+ const Popover = PopoverPrimitive.Root
9
+
10
+ const PopoverTrigger = PopoverPrimitive.Trigger
11
+
12
+ const PopoverContent = React.forwardRef<
13
+ React.ElementRef<typeof PopoverPrimitive.Content>,
14
+ React.ComponentPropsWithoutRef<typeof PopoverPrimitive.Content>
15
+ >(({ className, align = "center", sideOffset = 4, ...props }, ref) => (
16
+ <PopoverPrimitive.Portal>
17
+ <PopoverPrimitive.Content
18
+ ref={ref}
19
+ align={align}
20
+ sideOffset={sideOffset}
21
+ className={cn(
22
+ "z-50 flex flex-col w-72 w-[288px] rounded-md rounded-lg border bg-popover p-4 text-popover-foreground shadow-md outline-none 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 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",
23
+ className
24
+ )}
25
+ {...props}
26
+ />
27
+ </PopoverPrimitive.Portal>
28
+ ))
29
+ PopoverContent.displayName = PopoverPrimitive.Content.displayName
30
+
31
+ export { Popover, PopoverTrigger, PopoverContent }