shapes-ui 0.2.0 → 0.3.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/CHANGELOG.md CHANGED
@@ -1,5 +1,11 @@
1
1
  # shapes-ui
2
2
 
3
+ ## 0.3.0
4
+
5
+ ### Minor Changes
6
+
7
+ - 230f6ad: Added Dialog component
8
+
3
9
  ## 0.2.0
4
10
 
5
11
  ### Minor Changes
@@ -0,0 +1,11 @@
1
+ ---
2
+ title: Dialog
3
+ slug: dialog
4
+ description: Modal overlay for confirmations and forms.
5
+ ---
6
+
7
+ <RenderPreview name="dialog-demo" />
8
+
9
+ ## Installation
10
+
11
+ <InstallationBlock name="dialog" />
@@ -276,6 +276,17 @@ export const examples: ExampleRegistry = {
276
276
  },
277
277
  ],
278
278
  },
279
+ dialog: {
280
+ title: "Dialog",
281
+ code: lazy(() => import("../src/components/ui/dialog").then(m => ({ default: m.Dialog || m.default }))),
282
+ examples: [
283
+ {
284
+ name: "dialog-demo",
285
+ title: "Demo",
286
+ code: lazy(() => import("./dialog-demo")),
287
+ },
288
+ ],
289
+ },
279
290
  field: {
280
291
  title: "Field",
281
292
  code: lazy(() => import("../src/components/ui/field").then(m => ({ default: m.Field || m.default }))),
@@ -0,0 +1,44 @@
1
+ import { Button } from "@/components/ui/button"
2
+ import {
3
+ Dialog,
4
+ DialogClose,
5
+ DialogPopup,
6
+ DialogDescription,
7
+ DialogFooter,
8
+ DialogHeader,
9
+ DialogTitle,
10
+ DialogTrigger,
11
+ } from "@/components/ui/dialog"
12
+ import { Input } from "@/components/ui/input"
13
+
14
+
15
+ export default function DialogCloseButton() {
16
+ return (
17
+ <Dialog>
18
+ <DialogTrigger render={<Button variant="outline">Share</Button>} />
19
+ <DialogPopup className="sm:max-w-md">
20
+ <DialogHeader>
21
+ <DialogTitle>Share link</DialogTitle>
22
+ <DialogDescription>
23
+ Anyone who has this link will be able to view this.
24
+ </DialogDescription>
25
+ </DialogHeader>
26
+ <div className="flex items-center gap-2">
27
+ <div className="grid flex-1 gap-2">
28
+ <label htmlFor="link" className="sr-only">
29
+ Link
30
+ </label>
31
+ <Input
32
+ id="link"
33
+ defaultValue="https://shapes-ui.com/docs/installation"
34
+ readOnly
35
+ />
36
+ </div>
37
+ </div>
38
+ <DialogFooter className="sm:justify-start">
39
+ <DialogClose render={<Button type="button">Close</Button>} />
40
+ </DialogFooter>
41
+ </DialogPopup>
42
+ </Dialog>
43
+ )
44
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "shapes-ui",
3
- "version": "0.2.0",
3
+ "version": "0.3.0",
4
4
  "repository": {
5
5
  "type": "git",
6
6
  "url": "https://github.com/abbbdab/shapes-ui.git"
@@ -0,0 +1,18 @@
1
+ {
2
+ "name": "dialog",
3
+ "type": "registry:ui",
4
+ "dependencies": [
5
+ "@base-ui/react",
6
+ "lucide-react"
7
+ ],
8
+ "registryDependencies": [
9
+ "button"
10
+ ],
11
+ "files": [
12
+ {
13
+ "path": "dialog.tsx",
14
+ "content": "\"use client\"\n\nimport * as React from \"react\"\nimport { Dialog as DialogPrimitive } from \"@base-ui/react/dialog\"\n\nimport { cn } from \"@/lib/utils\"\nimport { Button } from \"@/components/ui/button\"\nimport { XIcon } from \"lucide-react\"\n\nfunction Dialog({ ...props }: DialogPrimitive.Root.Props) {\n return <DialogPrimitive.Root data-slot=\"dialog\" {...props} />\n}\n\nfunction DialogTrigger({ ...props }: DialogPrimitive.Trigger.Props) {\n return <DialogPrimitive.Trigger data-slot=\"dialog-trigger\" {...props} />\n}\n\nfunction DialogPortal({ ...props }: DialogPrimitive.Portal.Props) {\n return <DialogPrimitive.Portal data-slot=\"dialog-portal\" {...props} />\n}\n\nfunction DialogClose({ ...props }: DialogPrimitive.Close.Props) {\n return <DialogPrimitive.Close data-slot=\"dialog-close\" {...props} />\n}\n\nfunction DialogBackdrop({\n className,\n ...props\n}: DialogPrimitive.Backdrop.Props) {\n return (\n <DialogPrimitive.Backdrop\n data-slot=\"dialog-backdrop\"\n className={cn(\"data-open:animate-in data-closed:animate-out data-closed:fade-out-0 data-open:fade-in-0 bg-black/10 duration-100 supports-backdrop-filter:backdrop-blur-xs fixed inset-0 isolate z-50\", className)}\n {...props}\n />\n )\n}\n\nfunction DialogPopup({\n className,\n children,\n showCloseButton = true,\n ...props\n}: DialogPrimitive.Popup.Props & {\n showCloseButton?: boolean\n}) {\n return (\n <DialogPortal>\n <DialogBackdrop />\n <DialogPrimitive.Popup\n data-slot=\"dialog-popup\"\n className={cn(\n \"bg-background data-open:animate-in data-closed:animate-out data-closed:fade-out-0 data-open:fade-in-0 data-closed:zoom-out-95 data-open:zoom-in-95 ring-foreground/10 grid max-w-[calc(100%-2rem)] gap-4 rounded-xl p-4 text-sm ring-1 duration-100 sm:max-w-sm fixed top-1/2 left-1/2 z-50 w-full -translate-x-1/2 -translate-y-1/2 outline-none\",\n className\n )}\n {...props}\n >\n {children}\n {showCloseButton && (\n <DialogPrimitive.Close data-slot=\"dialog-close\" render={<Button variant=\"ghost\" className=\"absolute top-2 right-2\" size=\"icon-sm\"><XIcon\n /><span className=\"sr-only\">Close</span></Button>} />\n )}\n </DialogPrimitive.Popup>\n </DialogPortal>\n )\n}\n\nfunction DialogHeader({ className, ...props }: React.ComponentProps<\"div\">) {\n return (\n <div\n data-slot=\"dialog-header\"\n className={cn(\"gap-2 flex flex-col\", className)}\n {...props}\n />\n )\n}\n\nfunction DialogFooter({\n className,\n showCloseButton = false,\n children,\n ...props\n}: React.ComponentProps<\"div\"> & {\n showCloseButton?: boolean\n}) {\n return (\n <div\n data-slot=\"dialog-footer\"\n className={cn(\n \"-mx-4 -mb-4 rounded-b-xl border-t p-4 flex flex-col-reverse gap-2 sm:flex-row sm:justify-end\",\n className\n )}\n {...props}\n >\n {children}\n {showCloseButton && (\n <DialogPrimitive.Close render={<Button variant=\"outline\">Close</Button>} />\n )}\n </div>\n )\n}\n\nfunction DialogTitle({ className, ...props }: DialogPrimitive.Title.Props) {\n return (\n <DialogPrimitive.Title\n data-slot=\"dialog-title\"\n className={cn(\"text-base leading-none font-medium\", className)}\n {...props}\n />\n )\n}\n\nfunction DialogDescription({\n className,\n ...props\n}: DialogPrimitive.Description.Props) {\n return (\n <DialogPrimitive.Description\n data-slot=\"dialog-description\"\n className={cn(\"text-muted-foreground *:[a]:hover:text-foreground text-sm *:[a]:underline *:[a]:underline-offset-3\", className)}\n {...props}\n />\n )\n}\n\nexport {\n Dialog,\n DialogClose,\n DialogPopup,\n DialogDescription,\n DialogFooter,\n DialogHeader,\n DialogBackdrop,\n DialogPortal,\n DialogTitle,\n DialogTrigger,\n}\n",
15
+ "type": "registry:ui"
16
+ }
17
+ ]
18
+ }
@@ -8,6 +8,7 @@
8
8
  "card",
9
9
  "checkbox",
10
10
  "collapsible",
11
+ "dialog",
11
12
  "field",
12
13
  "fieldset",
13
14
  "input-group",
@@ -0,0 +1,137 @@
1
+ "use client"
2
+
3
+ import * as React from "react"
4
+ import { Dialog as DialogPrimitive } from "@base-ui/react/dialog"
5
+
6
+ import { cn } from "@/lib/utils"
7
+ import { Button } from "@/components/ui/button"
8
+ import { XIcon } from "lucide-react"
9
+
10
+ function Dialog({ ...props }: DialogPrimitive.Root.Props) {
11
+ return <DialogPrimitive.Root data-slot="dialog" {...props} />
12
+ }
13
+
14
+ function DialogTrigger({ ...props }: DialogPrimitive.Trigger.Props) {
15
+ return <DialogPrimitive.Trigger data-slot="dialog-trigger" {...props} />
16
+ }
17
+
18
+ function DialogPortal({ ...props }: DialogPrimitive.Portal.Props) {
19
+ return <DialogPrimitive.Portal data-slot="dialog-portal" {...props} />
20
+ }
21
+
22
+ function DialogClose({ ...props }: DialogPrimitive.Close.Props) {
23
+ return <DialogPrimitive.Close data-slot="dialog-close" {...props} />
24
+ }
25
+
26
+ function DialogBackdrop({
27
+ className,
28
+ ...props
29
+ }: DialogPrimitive.Backdrop.Props) {
30
+ return (
31
+ <DialogPrimitive.Backdrop
32
+ data-slot="dialog-backdrop"
33
+ className={cn("data-open:animate-in data-closed:animate-out data-closed:fade-out-0 data-open:fade-in-0 bg-black/10 duration-100 supports-backdrop-filter:backdrop-blur-xs fixed inset-0 isolate z-50", className)}
34
+ {...props}
35
+ />
36
+ )
37
+ }
38
+
39
+ function DialogPopup({
40
+ className,
41
+ children,
42
+ showCloseButton = true,
43
+ ...props
44
+ }: DialogPrimitive.Popup.Props & {
45
+ showCloseButton?: boolean
46
+ }) {
47
+ return (
48
+ <DialogPortal>
49
+ <DialogBackdrop />
50
+ <DialogPrimitive.Popup
51
+ data-slot="dialog-popup"
52
+ className={cn(
53
+ "bg-background data-open:animate-in data-closed:animate-out data-closed:fade-out-0 data-open:fade-in-0 data-closed:zoom-out-95 data-open:zoom-in-95 ring-foreground/10 grid max-w-[calc(100%-2rem)] gap-4 rounded-xl p-4 text-sm ring-1 duration-100 sm:max-w-sm fixed top-1/2 left-1/2 z-50 w-full -translate-x-1/2 -translate-y-1/2 outline-none",
54
+ className
55
+ )}
56
+ {...props}
57
+ >
58
+ {children}
59
+ {showCloseButton && (
60
+ <DialogPrimitive.Close data-slot="dialog-close" render={<Button variant="ghost" className="absolute top-2 right-2" size="icon-sm"><XIcon
61
+ /><span className="sr-only">Close</span></Button>} />
62
+ )}
63
+ </DialogPrimitive.Popup>
64
+ </DialogPortal>
65
+ )
66
+ }
67
+
68
+ function DialogHeader({ className, ...props }: React.ComponentProps<"div">) {
69
+ return (
70
+ <div
71
+ data-slot="dialog-header"
72
+ className={cn("gap-2 flex flex-col", className)}
73
+ {...props}
74
+ />
75
+ )
76
+ }
77
+
78
+ function DialogFooter({
79
+ className,
80
+ showCloseButton = false,
81
+ children,
82
+ ...props
83
+ }: React.ComponentProps<"div"> & {
84
+ showCloseButton?: boolean
85
+ }) {
86
+ return (
87
+ <div
88
+ data-slot="dialog-footer"
89
+ className={cn(
90
+ "-mx-4 -mb-4 rounded-b-xl border-t p-4 flex flex-col-reverse gap-2 sm:flex-row sm:justify-end",
91
+ className
92
+ )}
93
+ {...props}
94
+ >
95
+ {children}
96
+ {showCloseButton && (
97
+ <DialogPrimitive.Close render={<Button variant="outline">Close</Button>} />
98
+ )}
99
+ </div>
100
+ )
101
+ }
102
+
103
+ function DialogTitle({ className, ...props }: DialogPrimitive.Title.Props) {
104
+ return (
105
+ <DialogPrimitive.Title
106
+ data-slot="dialog-title"
107
+ className={cn("text-base leading-none font-medium", className)}
108
+ {...props}
109
+ />
110
+ )
111
+ }
112
+
113
+ function DialogDescription({
114
+ className,
115
+ ...props
116
+ }: DialogPrimitive.Description.Props) {
117
+ return (
118
+ <DialogPrimitive.Description
119
+ data-slot="dialog-description"
120
+ className={cn("text-muted-foreground *:[a]:hover:text-foreground text-sm *:[a]:underline *:[a]:underline-offset-3", className)}
121
+ {...props}
122
+ />
123
+ )
124
+ }
125
+
126
+ export {
127
+ Dialog,
128
+ DialogClose,
129
+ DialogPopup,
130
+ DialogDescription,
131
+ DialogFooter,
132
+ DialogHeader,
133
+ DialogBackdrop,
134
+ DialogPortal,
135
+ DialogTitle,
136
+ DialogTrigger,
137
+ }