@hanzo/ui 4.0.3 → 4.0.5

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.
@@ -44,9 +44,6 @@ const CtaBlockComponent: React.FC<BlockComponentProps & {
44
44
  }
45
45
 
46
46
  const mobile2Columns = containsToken(specifiers, 'mobile-2-columns')
47
- // normally 'default' buttons have a min width only at > lg.
48
- // generally if more than one we don't want this and override it,
49
- // but this specifier asks to observe the default behavior.
50
47
  const fillEvenly = !containsToken(specifiers, 'desktop-dont-fill')
51
48
  const mobileCenterFirstIfOdd = containsToken(specifiers, 'mobile-center-first-if-odd')
52
49
  const mobileOddFullWidth = containsToken(specifiers, 'mobile-odd-full-width')
@@ -58,6 +55,11 @@ const CtaBlockComponent: React.FC<BlockComponentProps & {
58
55
  layoutclx = 'grid grid-cols-2 gap-2 self-stretch '
59
56
  resetMinWidth = true
60
57
  }
58
+ /*
59
+ else {
60
+ layoutclx = 'flex flex-col items-stretch gap-2 self-stretch md:flex-row sm:justify-center'
61
+ }
62
+ */
61
63
  if (fillEvenly) {
62
64
  layoutclx = (layoutclx ?? 'grid grid-cols-2 gap-2 self-stretch')
63
65
  resetMinWidth = true
@@ -3,13 +3,19 @@ import type Block from './block'
3
3
 
4
4
  interface CTABlock extends Block {
5
5
  blockType: 'cta'
6
- // fill: fills the parent width with the elements
7
- // left / right: (>= md) left or right justify the elements (default is center)
8
- // mobile-2-columns: mobile defaults to rendering each element full width,
9
- // on it's own line. This renders them in two columns instead.
10
- // mobile-center-first-if-odd: if (mobile-2-columns) and length is odd,
11
- // default is to center last
12
- // mobile-odd-full-width: fills the full two columns w the centered element
6
+
7
+ /**
8
+ * fill: fills the parent width with the elements
9
+ left / right: (>= md) left or right justify the elements (default is center)
10
+ mobile-2-columns: mobile defaults to rendering each element full width,
11
+ on it's own line. This renders them in two columns instead.
12
+ mobile-center-first-if-odd: if (mobile-2-columns) and length is odd,
13
+ default is to center last
14
+ mobile-odd-full-width: fills the full two columns w the centered element
15
+ desktop-dont-fill: normally 'default' buttons have a min width only at > lg.
16
+ generally if more than one we don't want this and override it,
17
+ but this specifier asks to observe the default behavior.
18
+ */
13
19
  specifiers?: string
14
20
  elements: (LinkDef | ButtonDef)[]
15
21
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@hanzo/ui",
3
- "version": "4.0.3",
3
+ "version": "4.0.5",
4
4
  "description": "Library that contains shared UI primitives, support for a common design system, and other boilerplate support.",
5
5
  "publishConfig": {
6
6
  "registry": "https://registry.npmjs.org/",
@@ -49,6 +49,7 @@
49
49
  "@radix-ui/react-aspect-ratio": "^1.0.3",
50
50
  "@radix-ui/react-avatar": "^1.0.3",
51
51
  "@radix-ui/react-checkbox": "^1.0.4",
52
+ "@radix-ui/react-context-menu": "^2.2.2",
52
53
  "@radix-ui/react-dialog": "^1.0.5",
53
54
  "@radix-ui/react-icons": "^1.3.0",
54
55
  "@radix-ui/react-label": "^2.0.2",
@@ -0,0 +1,200 @@
1
+ "use client"
2
+
3
+ import * as React from "react"
4
+ import * as ContextMenuPrimitive from "@radix-ui/react-context-menu"
5
+ import { Check, ChevronRight, Circle } from "lucide-react"
6
+
7
+ import { cn } from "../util"
8
+
9
+ const ContextMenu = ContextMenuPrimitive.Root
10
+ const ContextMenuTrigger = ContextMenuPrimitive.Trigger
11
+ const ContextMenuGroup = ContextMenuPrimitive.Group
12
+ const ContextMenuPortal = ContextMenuPrimitive.Portal
13
+ const ContextMenuSub = ContextMenuPrimitive.Sub
14
+ const ContextMenuRadioGroup = ContextMenuPrimitive.RadioGroup
15
+
16
+ const ContextMenuSubTrigger = React.forwardRef<
17
+ React.ElementRef<typeof ContextMenuPrimitive.SubTrigger>,
18
+ React.ComponentPropsWithoutRef<typeof ContextMenuPrimitive.SubTrigger> & {
19
+ inset?: boolean
20
+ }
21
+ >(({ className, inset, children, ...props }, ref) => (
22
+ <ContextMenuPrimitive.SubTrigger
23
+ ref={ref}
24
+ className={cn(
25
+ 'flex cursor-default select-none items-center rounded-sm px-2 py-1.5 text-sm outline-none ' +
26
+ 'focus:bg-level-1 focus:text-accent data-[state=open]:bg-level-1 data-[state=open]:text-accent',
27
+ inset && "pl-8",
28
+ className
29
+ )}
30
+ {...props}
31
+ >
32
+ {children}
33
+ <ChevronRight className="ml-auto h-4 w-4" />
34
+ </ContextMenuPrimitive.SubTrigger>
35
+ ))
36
+ ContextMenuSubTrigger.displayName = ContextMenuPrimitive.SubTrigger.displayName
37
+
38
+ const ContextMenuSubContent = React.forwardRef<
39
+ React.ElementRef<typeof ContextMenuPrimitive.SubContent>,
40
+ React.ComponentPropsWithoutRef<typeof ContextMenuPrimitive.SubContent>
41
+ >(({ className, ...props }, ref) => (
42
+ <ContextMenuPrimitive.SubContent
43
+ ref={ref}
44
+ className={cn(
45
+ 'z-popup min-w-[8rem] overflow-hidden rounded-md border bg-background p-1 text-foreground shadow-md ' +
46
+ 'data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 ' +
47
+ 'data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 ' +
48
+ 'data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 ' +
49
+ 'data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2',
50
+ className
51
+ )}
52
+ {...props}
53
+ />
54
+ ))
55
+ ContextMenuSubContent.displayName = ContextMenuPrimitive.SubContent.displayName
56
+
57
+ const ContextMenuContent = React.forwardRef<
58
+ React.ElementRef<typeof ContextMenuPrimitive.Content>,
59
+ React.ComponentPropsWithoutRef<typeof ContextMenuPrimitive.Content>
60
+ >(({ className, ...props }, ref) => (
61
+ <ContextMenuPrimitive.Portal>
62
+ <ContextMenuPrimitive.Content
63
+ ref={ref}
64
+ className={cn(
65
+ "z-popup min-w-[8rem] overflow-hidden rounded-md border bg-background p-1 text-foreground shadow-md animate-in fade-in-80 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",
66
+ className
67
+ )}
68
+ {...props}
69
+ />
70
+ </ContextMenuPrimitive.Portal>
71
+ ))
72
+ ContextMenuContent.displayName = ContextMenuPrimitive.Content.displayName
73
+
74
+ const ContextMenuItem = React.forwardRef<
75
+ React.ElementRef<typeof ContextMenuPrimitive.Item>,
76
+ React.ComponentPropsWithoutRef<typeof ContextMenuPrimitive.Item> & {
77
+ inset?: boolean
78
+ }
79
+ >(({ className, inset, ...props }, ref) => (
80
+ <ContextMenuPrimitive.Item
81
+ ref={ref}
82
+ className={cn(
83
+ "relative flex cursor-default select-none items-center rounded-sm px-2 py-1.5 text-sm outline-none focus:bg-level-1 focus:text-accent data-[disabled]:pointer-events-none data-[disabled]:opacity-50",
84
+ inset && "pl-8",
85
+ className
86
+ )}
87
+ {...props}
88
+ />
89
+ ))
90
+ ContextMenuItem.displayName = ContextMenuPrimitive.Item.displayName
91
+
92
+ const ContextMenuCheckboxItem = React.forwardRef<
93
+ React.ElementRef<typeof ContextMenuPrimitive.CheckboxItem>,
94
+ React.ComponentPropsWithoutRef<typeof ContextMenuPrimitive.CheckboxItem>
95
+ >(({ className, children, checked, ...props }, ref) => (
96
+ <ContextMenuPrimitive.CheckboxItem
97
+ ref={ref}
98
+ className={cn(
99
+ "relative flex cursor-default select-none items-center rounded-sm py-1.5 pl-8 pr-2 text-sm outline-none focus:bg-level-1 focus:text-accent data-[disabled]:pointer-events-none data-[disabled]:opacity-50",
100
+ className
101
+ )}
102
+ checked={checked}
103
+ {...props}
104
+ >
105
+ <span className="absolute left-2 flex h-3.5 w-3.5 items-center justify-center">
106
+ <ContextMenuPrimitive.ItemIndicator>
107
+ <Check className="h-4 w-4" />
108
+ </ContextMenuPrimitive.ItemIndicator>
109
+ </span>
110
+ {children}
111
+ </ContextMenuPrimitive.CheckboxItem>
112
+ ))
113
+ ContextMenuCheckboxItem.displayName =
114
+ ContextMenuPrimitive.CheckboxItem.displayName
115
+
116
+ const ContextMenuRadioItem = React.forwardRef<
117
+ React.ElementRef<typeof ContextMenuPrimitive.RadioItem>,
118
+ React.ComponentPropsWithoutRef<typeof ContextMenuPrimitive.RadioItem>
119
+ >(({ className, children, ...props }, ref) => (
120
+ <ContextMenuPrimitive.RadioItem
121
+ ref={ref}
122
+ className={cn(
123
+ "relative flex cursor-default select-none items-center rounded-sm py-1.5 pl-8 pr-2 text-sm outline-none focus:bg-level-1 focus:text-accent data-[disabled]:pointer-events-none data-[disabled]:opacity-50",
124
+ className
125
+ )}
126
+ {...props}
127
+ >
128
+ <span className="absolute left-2 flex h-3.5 w-3.5 items-center justify-center">
129
+ <ContextMenuPrimitive.ItemIndicator>
130
+ <Circle className="h-2 w-2 fill-current" />
131
+ </ContextMenuPrimitive.ItemIndicator>
132
+ </span>
133
+ {children}
134
+ </ContextMenuPrimitive.RadioItem>
135
+ ))
136
+ ContextMenuRadioItem.displayName = ContextMenuPrimitive.RadioItem.displayName
137
+
138
+ const ContextMenuLabel = React.forwardRef<
139
+ React.ElementRef<typeof ContextMenuPrimitive.Label>,
140
+ React.ComponentPropsWithoutRef<typeof ContextMenuPrimitive.Label> & {
141
+ inset?: boolean
142
+ }
143
+ >(({ className, inset, ...props }, ref) => (
144
+ <ContextMenuPrimitive.Label
145
+ ref={ref}
146
+ className={cn(
147
+ "px-2 py-1.5 text-sm font-semibold text-foreground",
148
+ inset && "pl-8",
149
+ className
150
+ )}
151
+ {...props}
152
+ />
153
+ ))
154
+ ContextMenuLabel.displayName = ContextMenuPrimitive.Label.displayName
155
+
156
+ const ContextMenuSeparator = React.forwardRef<
157
+ React.ElementRef<typeof ContextMenuPrimitive.Separator>,
158
+ React.ComponentPropsWithoutRef<typeof ContextMenuPrimitive.Separator>
159
+ >(({ className, ...props }, ref) => (
160
+ <ContextMenuPrimitive.Separator
161
+ ref={ref}
162
+ className={cn("-mx-1 my-1 h-px bg-border", className)}
163
+ {...props}
164
+ />
165
+ ))
166
+ ContextMenuSeparator.displayName = ContextMenuPrimitive.Separator.displayName
167
+
168
+ const ContextMenuShortcut = ({
169
+ className,
170
+ ...props
171
+ }: React.HTMLAttributes<HTMLSpanElement>) => {
172
+ return (
173
+ <span
174
+ className={cn(
175
+ "ml-auto text-xs tracking-widest text-muted",
176
+ className
177
+ )}
178
+ {...props}
179
+ />
180
+ )
181
+ }
182
+ ContextMenuShortcut.displayName = "ContextMenuShortcut"
183
+
184
+ export {
185
+ ContextMenu,
186
+ ContextMenuTrigger,
187
+ ContextMenuContent,
188
+ ContextMenuItem,
189
+ ContextMenuCheckboxItem,
190
+ ContextMenuRadioItem,
191
+ ContextMenuLabel,
192
+ ContextMenuSeparator,
193
+ ContextMenuShortcut,
194
+ ContextMenuGroup,
195
+ ContextMenuPortal,
196
+ ContextMenuSub,
197
+ ContextMenuSubContent,
198
+ ContextMenuSubTrigger,
199
+ ContextMenuRadioGroup,
200
+ }
@@ -58,6 +58,26 @@ export {
58
58
  CommandSeparator,
59
59
  } from './command'
60
60
 
61
+
62
+ export {
63
+ ContextMenu,
64
+ ContextMenuTrigger,
65
+ ContextMenuContent,
66
+ ContextMenuItem,
67
+ ContextMenuCheckboxItem,
68
+ ContextMenuRadioItem,
69
+ ContextMenuLabel,
70
+ ContextMenuSeparator,
71
+ ContextMenuShortcut,
72
+ ContextMenuGroup,
73
+ ContextMenuPortal,
74
+ ContextMenuSub,
75
+ ContextMenuSubContent,
76
+ ContextMenuSubTrigger,
77
+ ContextMenuRadioGroup,
78
+ } from './context-menu'
79
+
80
+
61
81
  export {
62
82
  type DrawerProps,
63
83
  Drawer,
@@ -7,12 +7,6 @@
7
7
  box-sizing: inherit;
8
8
  }
9
9
 
10
- *,
11
- ::before,
12
- ::after {
13
- @apply border-muted-3
14
- }
15
-
16
10
  /*
17
11
  using this approach:
18
12
  https://stackoverflow.com/a/76066443/11645689
@@ -103,7 +103,7 @@ export default {
103
103
  },
104
104
  borderColor: ({ theme }) => ({
105
105
  ...theme('colors'),
106
- DEFAULT: theme('colors.gray.200', 'currentColor'),
106
+ DEFAULT: theme('colors.muted.3'),
107
107
  }),
108
108
  borderOpacity: ({ theme }) => theme('opacity'),
109
109
  borderRadius: {