@boyernick/standard-ui-react 0.1.1-canary.9 → 0.2.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/package.json +5 -3
- package/src/accordion.tsx +5 -2
- package/src/alert-dialog.tsx +1 -1
- package/src/attachment.tsx +5 -2
- package/src/autocomplete.tsx +4 -3
- package/src/block-editor.tsx +1747 -0
- package/src/brand.tsx +2 -2
- package/src/breadcrumb.tsx +14 -7
- package/src/button.tsx +22 -11
- package/src/calendar.tsx +6 -3
- package/src/carousel.tsx +220 -53
- package/src/checkbox.tsx +3 -2
- package/src/code-block.tsx +66 -5
- package/src/collapsible.tsx +4 -2
- package/src/combobox.tsx +4 -3
- package/src/command.tsx +27 -12
- package/src/dialog.tsx +33 -10
- package/src/empty.tsx +4 -4
- package/src/field.tsx +4 -3
- package/src/filter-group.tsx +143 -0
- package/src/icons.tsx +28 -1
- package/src/illustrations.tsx +219 -141
- package/src/index.ts +238 -18
- package/src/input.tsx +8 -5
- package/src/kbd.tsx +10 -4
- package/src/lib/focus.ts +41 -0
- package/src/lib/popup.ts +1 -1
- package/src/lifeline/company-icon.tsx +71 -0
- package/src/lifeline/index.ts +42 -0
- package/src/lifeline/lifeline-data.ts +97 -0
- package/src/lifeline/lifeline-desktop.tsx +204 -0
- package/src/lifeline/lifeline-event.tsx +108 -0
- package/src/lifeline/lifeline-fireworks.tsx +302 -0
- package/src/lifeline/lifeline-hover-image.tsx +269 -0
- package/src/lifeline/lifeline-icons.tsx +39 -0
- package/src/lifeline/lifeline-intro-timing.ts +105 -0
- package/src/lifeline/lifeline-labels.tsx +24 -0
- package/src/lifeline/lifeline-layout.ts +1 -0
- package/src/lifeline/lifeline-legend.tsx +31 -0
- package/src/lifeline/lifeline-lightbox.tsx +309 -0
- package/src/lifeline/lifeline-marker.tsx +183 -0
- package/src/lifeline/lifeline-people.tsx +99 -0
- package/src/lifeline/lifeline-photos.tsx +366 -0
- package/src/lifeline/lifeline-shell.tsx +135 -0
- package/src/lifeline/lifeline-utils.ts +83 -0
- package/src/lifeline/lifeline-vertical.tsx +482 -0
- package/src/lifeline/lifeline.tsx +69 -0
- package/src/lifeline/types.ts +112 -0
- package/src/lifeline/use-lifeline-intro.ts +130 -0
- package/src/lifeline/use-lifeline-scroll.ts +1011 -0
- package/src/lifeline/use-lifeline-vertical-scroll.ts +271 -0
- package/src/menubar.tsx +9 -2
- package/src/minimap.tsx +296 -0
- package/src/modal.tsx +608 -0
- package/src/navigation-menu.tsx +338 -67
- package/src/number-field.tsx +336 -61
- package/src/otp-field.tsx +4 -3
- package/src/pagination.tsx +262 -42
- package/src/password-protection.tsx +345 -0
- package/src/popover.tsx +1 -1
- package/src/progress.tsx +5 -0
- package/src/questionnaire.tsx +284 -0
- package/src/radio.tsx +4 -2
- package/src/scroll-area.tsx +4 -1
- package/src/select.tsx +5 -2
- package/src/sidebar.tsx +113 -28
- package/src/slider.tsx +66 -6
- package/src/sounds.tsx +6 -10
- package/src/spinner.tsx +105 -32
- package/src/switch.tsx +4 -1
- package/src/table.tsx +82 -15
- package/src/tabs.tsx +189 -38
- package/src/text-animate.tsx +71 -28
- package/src/textarea.tsx +6 -1
- package/src/timeline.tsx +378 -0
- package/src/toast.tsx +214 -35
- package/src/toggle.tsx +4 -2
- package/src/toolbar.tsx +12 -7
- package/src/tooltip.tsx +43 -3
- package/src/video-player.tsx +396 -127
- package/src/image-modal.tsx +0 -110
- package/src/markdown-editor.tsx +0 -302
package/src/toast.tsx
CHANGED
|
@@ -1,15 +1,34 @@
|
|
|
1
1
|
"use client"
|
|
2
2
|
|
|
3
3
|
import { Toast as BaseToast } from "@base-ui/react/toast"
|
|
4
|
-
import type
|
|
5
|
-
import {
|
|
4
|
+
import { cva, type VariantProps } from "class-variance-authority"
|
|
5
|
+
import {
|
|
6
|
+
createContext,
|
|
7
|
+
useContext,
|
|
8
|
+
type ComponentProps,
|
|
9
|
+
} from "react"
|
|
10
|
+
import {
|
|
11
|
+
IconCircleCheck,
|
|
12
|
+
IconCircleInfo,
|
|
13
|
+
IconCrossSmall,
|
|
14
|
+
IconExclamationCircle,
|
|
15
|
+
IconExclamationTriangle,
|
|
16
|
+
} from "./icons"
|
|
17
|
+
import { Spinner } from "./spinner"
|
|
6
18
|
import { cn } from "./lib/cn"
|
|
19
|
+
import { focusRing, focusRingBorder } from "./lib/focus"
|
|
7
20
|
import { motion } from "./lib/motion"
|
|
8
21
|
|
|
22
|
+
export type ToastPlacement = "top-center" | "bottom-right"
|
|
23
|
+
|
|
24
|
+
const ToastPlacementContext = createContext<ToastPlacement>("top-center")
|
|
25
|
+
|
|
9
26
|
export type ToastProviderProps = ComponentProps<typeof BaseToast.Provider>
|
|
10
27
|
export type ToastPortalProps = ComponentProps<typeof BaseToast.Portal>
|
|
11
|
-
export type ToastViewportProps = ComponentProps<typeof BaseToast.Viewport>
|
|
12
|
-
|
|
28
|
+
export type ToastViewportProps = ComponentProps<typeof BaseToast.Viewport> &
|
|
29
|
+
VariantProps<typeof toastViewportVariants>
|
|
30
|
+
export type ToastRootProps = ComponentProps<typeof BaseToast.Root> &
|
|
31
|
+
VariantProps<typeof toastRootVariants>
|
|
13
32
|
export type ToastContentProps = ComponentProps<typeof BaseToast.Content>
|
|
14
33
|
export type ToastTitleProps = ComponentProps<typeof BaseToast.Title>
|
|
15
34
|
export type ToastDescriptionProps = ComponentProps<typeof BaseToast.Description>
|
|
@@ -18,6 +37,10 @@ export type ToastCloseProps = ComponentProps<typeof BaseToast.Close>
|
|
|
18
37
|
export type ToastPositionerProps = ComponentProps<typeof BaseToast.Positioner>
|
|
19
38
|
export type ToastArrowProps = ComponentProps<typeof BaseToast.Arrow>
|
|
20
39
|
|
|
40
|
+
/** The types that carry a glyph. Anything else renders no icon. */
|
|
41
|
+
export type ToastType = "success" | "error" | "warning" | "info" | "loading"
|
|
42
|
+
export type ToastIconProps = ComponentProps<"span"> & { type?: string }
|
|
43
|
+
|
|
21
44
|
export const ToastProvider = (props: ToastProviderProps) => (
|
|
22
45
|
<BaseToast.Provider {...props} />
|
|
23
46
|
)
|
|
@@ -26,37 +49,182 @@ export const ToastPortal = (props: ToastPortalProps) => (
|
|
|
26
49
|
<BaseToast.Portal {...props} />
|
|
27
50
|
)
|
|
28
51
|
|
|
29
|
-
export const
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
52
|
+
export const toastViewportVariants = cva(
|
|
53
|
+
// No flex column: the toasts inside are absolutely positioned so they pile
|
|
54
|
+
// up as a stack. In flow they would march down past the edge.
|
|
55
|
+
"fixed z-[100] w-[min(100vw-2rem,28rem)] outline-none",
|
|
56
|
+
{
|
|
57
|
+
variants: {
|
|
58
|
+
placement: {
|
|
59
|
+
"top-center": "top-8 left-1/2 -translate-x-1/2",
|
|
60
|
+
"bottom-right": "right-4 bottom-4 sm:right-8 sm:bottom-8",
|
|
61
|
+
},
|
|
62
|
+
},
|
|
63
|
+
defaultVariants: { placement: "top-center" },
|
|
64
|
+
},
|
|
37
65
|
)
|
|
38
66
|
|
|
39
|
-
export const
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
67
|
+
export const ToastViewport = ({
|
|
68
|
+
className,
|
|
69
|
+
placement = "top-center",
|
|
70
|
+
children,
|
|
71
|
+
...props
|
|
72
|
+
}: ToastViewportProps) => (
|
|
73
|
+
<ToastPlacementContext.Provider value={placement ?? "top-center"}>
|
|
74
|
+
<BaseToast.Viewport
|
|
75
|
+
data-placement={placement}
|
|
76
|
+
className={cn(toastViewportVariants({ placement }), className)}
|
|
77
|
+
{...props}
|
|
78
|
+
>
|
|
79
|
+
{children}
|
|
80
|
+
</BaseToast.Viewport>
|
|
81
|
+
</ToastPlacementContext.Provider>
|
|
82
|
+
)
|
|
83
|
+
|
|
84
|
+
/** Shared chrome. Placement owns where the stack anchors and how cards move. */
|
|
85
|
+
const toastRootVariants = cva(
|
|
86
|
+
cn(
|
|
87
|
+
"absolute right-0 left-0 z-[calc(1000-var(--toast-index))] box-border w-full",
|
|
88
|
+
"[--gap:0.625rem] [--peek:0.875rem]",
|
|
89
|
+
"[--scale:calc(max(0,1-(var(--toast-index)*0.05)))]",
|
|
90
|
+
"[--height:var(--toast-frontmost-height,var(--toast-height))]",
|
|
91
|
+
// A row, not an overlay: the action and the close sit inline at the right,
|
|
92
|
+
// so the close cannot be absolutely positioned over reserved padding.
|
|
93
|
+
"flex items-start gap-2 rounded-xl border py-2.5 pr-2 pl-4 shadow-lg outline-none select-none",
|
|
94
|
+
"h-[var(--height)] data-expanded:h-[var(--toast-height)]",
|
|
95
|
+
// Bridges the gap between cards so crossing it does not collapse the fan.
|
|
96
|
+
"after:absolute after:top-full after:left-0 after:h-[calc(var(--gap)+1px)] after:w-full after:content-['']",
|
|
97
|
+
"transition-[transform,opacity,height] duration-[var(--duration-md)] ease-enter motion-reduce:transition-none",
|
|
98
|
+
"data-ending-style:opacity-0 data-limited:opacity-0",
|
|
99
|
+
),
|
|
100
|
+
{
|
|
101
|
+
variants: {
|
|
102
|
+
variant: {
|
|
103
|
+
// The page's own surface. The border stays transparent so the edge is
|
|
104
|
+
// `shadow-lg`'s hairline, the same one every dropdown carries.
|
|
105
|
+
default: "border-transparent bg-surface text-fg-primary",
|
|
106
|
+
// Flipped against the page. Here the hairline is invisible — a black
|
|
107
|
+
// line on a near-black card — so the edge is drawn with the inverted
|
|
108
|
+
// foreground, which flips with the theme alongside the surface.
|
|
109
|
+
inverted: "border-fg-inverted/10 bg-surface-inverted text-fg-inverted",
|
|
110
|
+
},
|
|
111
|
+
placement: {
|
|
112
|
+
/** Pinned to the top of the viewport; behind cards peek below. */
|
|
113
|
+
"top-center": cn(
|
|
114
|
+
"top-0 origin-top",
|
|
115
|
+
"[--offset-y:calc(var(--toast-offset-y)+calc(var(--toast-index)*var(--gap))+var(--toast-swipe-movement-y,0px))]",
|
|
116
|
+
"[transform:translateX(var(--toast-swipe-movement-x,0px))_translateY(calc(var(--toast-swipe-movement-y,0px)+(var(--toast-index)*var(--peek))))_scale(var(--scale))]",
|
|
117
|
+
"data-expanded:[transform:translateX(var(--toast-swipe-movement-x,0px))_translateY(var(--offset-y))]",
|
|
118
|
+
"data-starting-style:[transform:translateY(-150%)]",
|
|
119
|
+
"[&[data-ending-style]:not([data-limited]):not([data-swipe-direction])]:[transform:translateY(-150%)]",
|
|
120
|
+
),
|
|
121
|
+
/** Pinned to the bottom-right; behind cards peek above. */
|
|
122
|
+
"bottom-right": cn(
|
|
123
|
+
"bottom-0 origin-bottom",
|
|
124
|
+
"[--shrink:calc(1-var(--scale))]",
|
|
125
|
+
"[--offset-y:calc(var(--toast-offset-y)*-1+calc(var(--toast-index)*var(--gap)*-1)+var(--toast-swipe-movement-y,0px))]",
|
|
126
|
+
"[transform:translateX(var(--toast-swipe-movement-x,0px))_translateY(calc(var(--toast-swipe-movement-y,0px)-(var(--toast-index)*var(--peek))-(var(--shrink)*var(--height))))_scale(var(--scale))]",
|
|
127
|
+
"data-expanded:[transform:translateX(var(--toast-swipe-movement-x,0px))_translateY(var(--offset-y))]",
|
|
128
|
+
"data-starting-style:[transform:translateY(150%)]",
|
|
129
|
+
"[&[data-ending-style]:not([data-limited]):not([data-swipe-direction])]:[transform:translateY(150%)]",
|
|
130
|
+
),
|
|
131
|
+
},
|
|
132
|
+
},
|
|
133
|
+
defaultVariants: { variant: "default", placement: "top-center" },
|
|
134
|
+
},
|
|
54
135
|
)
|
|
55
136
|
|
|
137
|
+
/** The variant is published as `data-variant` rather than passed down: the
|
|
138
|
+
* title, description, action, close and icon all have to follow the surface,
|
|
139
|
+
* and a data attribute lets each one carry its own pair of rules instead of
|
|
140
|
+
* every caller threading a prop through five components.
|
|
141
|
+
*
|
|
142
|
+
* Placement defaults from the nearest `ToastViewport` so the stack and the
|
|
143
|
+
* corner stay in sync without repeating the prop on every root. */
|
|
144
|
+
export const ToastRoot = ({
|
|
145
|
+
className,
|
|
146
|
+
variant = "default",
|
|
147
|
+
placement: placementProp,
|
|
148
|
+
...props
|
|
149
|
+
}: ToastRootProps) => {
|
|
150
|
+
const placementFromViewport = useContext(ToastPlacementContext)
|
|
151
|
+
const placement = placementProp ?? placementFromViewport
|
|
152
|
+
|
|
153
|
+
return (
|
|
154
|
+
<BaseToast.Root
|
|
155
|
+
data-variant={variant}
|
|
156
|
+
data-placement={placement}
|
|
157
|
+
className={cn(
|
|
158
|
+
"group/toast",
|
|
159
|
+
toastRootVariants({ variant, placement }),
|
|
160
|
+
className,
|
|
161
|
+
)}
|
|
162
|
+
{...props}
|
|
163
|
+
/>
|
|
164
|
+
)
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
export { toastRootVariants }
|
|
168
|
+
|
|
169
|
+
const toastGlyphs = {
|
|
170
|
+
success: {
|
|
171
|
+
Icon: IconCircleCheck,
|
|
172
|
+
tone: `text-status-success group-data-[variant=inverted]/toast:text-status-success-inverted`,
|
|
173
|
+
},
|
|
174
|
+
error: {
|
|
175
|
+
Icon: IconExclamationCircle,
|
|
176
|
+
tone: `text-status-critical group-data-[variant=inverted]/toast:text-status-critical-inverted`,
|
|
177
|
+
},
|
|
178
|
+
warning: {
|
|
179
|
+
Icon: IconExclamationTriangle,
|
|
180
|
+
tone: `text-status-warning group-data-[variant=inverted]/toast:text-status-warning-inverted`,
|
|
181
|
+
},
|
|
182
|
+
info: {
|
|
183
|
+
Icon: IconCircleInfo,
|
|
184
|
+
tone: `text-status-info group-data-[variant=inverted]/toast:text-status-info-inverted`,
|
|
185
|
+
},
|
|
186
|
+
} as const
|
|
187
|
+
|
|
188
|
+
/** The glyph tracks the title, not the block. The row is `items-start` so the
|
|
189
|
+
* glyph and the content column measure from the same top edge, and `mt-0.5`
|
|
190
|
+
* is the half-leading above a 14px title in a 20px line — which centres the
|
|
191
|
+
* 16px glyph on the title whether or not a description follows it.
|
|
192
|
+
*
|
|
193
|
+
* The margin is on both axes, not just the top. Every item beside the content
|
|
194
|
+
* column is collapsed to a 20px outer box — the height of the title's line —
|
|
195
|
+
* so it centres on that line while contributing nothing extra to the row. A
|
|
196
|
+
* top-only offset lines the item up but leaves its full height in the box, and
|
|
197
|
+
* the tallest control then stretches the toast downward and everything reads
|
|
198
|
+
* high. Hit areas are untouched: the boxes overflow, they do not shrink. */
|
|
199
|
+
const ICON_ALIGN = "my-0.5 flex shrink-0"
|
|
200
|
+
|
|
201
|
+
/** The glyph for a toast's type. Each tone carries both surfaces: the plain
|
|
202
|
+
* status tokens are tuned for the page, and the `-inverted` pair for a card
|
|
203
|
+
* that flips against it. Pass `toast.type` from the render loop — Base UI
|
|
204
|
+
* gives no way to read the toast from inside the root. */
|
|
205
|
+
export const ToastIcon = ({ type, className, ...props }: ToastIconProps) => {
|
|
206
|
+
if (type === "loading") {
|
|
207
|
+
return (
|
|
208
|
+
<span className={cn(ICON_ALIGN, className)} {...props}>
|
|
209
|
+
<Spinner size="sm" />
|
|
210
|
+
</span>
|
|
211
|
+
)
|
|
212
|
+
}
|
|
213
|
+
|
|
214
|
+
const glyph = toastGlyphs[type as keyof typeof toastGlyphs]
|
|
215
|
+
if (!glyph) return null
|
|
216
|
+
|
|
217
|
+
return (
|
|
218
|
+
<span className={cn(ICON_ALIGN, glyph.tone, className)} {...props}>
|
|
219
|
+
<glyph.Icon size={16} className="size-4" aria-hidden />
|
|
220
|
+
</span>
|
|
221
|
+
)
|
|
222
|
+
}
|
|
223
|
+
|
|
56
224
|
export const ToastContent = ({ className, ...props }: ToastContentProps) => (
|
|
57
225
|
<BaseToast.Content
|
|
58
226
|
className={cn(
|
|
59
|
-
"flex flex-col gap-
|
|
227
|
+
"flex min-w-0 flex-1 flex-col gap-0.5 overflow-hidden transition-opacity duration-[var(--duration-sm)]",
|
|
60
228
|
"data-behind:pointer-events-none data-behind:opacity-0 data-expanded:data-behind:opacity-100",
|
|
61
229
|
className,
|
|
62
230
|
)}
|
|
@@ -66,7 +234,10 @@ export const ToastContent = ({ className, ...props }: ToastContentProps) => (
|
|
|
66
234
|
|
|
67
235
|
export const ToastTitle = ({ className, ...props }: ToastTitleProps) => (
|
|
68
236
|
<BaseToast.Title
|
|
69
|
-
className={cn(
|
|
237
|
+
className={cn(
|
|
238
|
+
"text-sm-strong text-fg-primary group-data-[variant=inverted]/toast:text-fg-inverted",
|
|
239
|
+
className,
|
|
240
|
+
)}
|
|
70
241
|
{...props}
|
|
71
242
|
/>
|
|
72
243
|
)
|
|
@@ -76,7 +247,10 @@ export const ToastDescription = ({
|
|
|
76
247
|
...props
|
|
77
248
|
}: ToastDescriptionProps) => (
|
|
78
249
|
<BaseToast.Description
|
|
79
|
-
className={cn(
|
|
250
|
+
className={cn(
|
|
251
|
+
"text-sm text-fg-secondary group-data-[variant=inverted]/toast:text-fg-inverted-secondary",
|
|
252
|
+
className,
|
|
253
|
+
)}
|
|
80
254
|
{...props}
|
|
81
255
|
/>
|
|
82
256
|
)
|
|
@@ -84,9 +258,11 @@ export const ToastDescription = ({
|
|
|
84
258
|
export const ToastAction = ({ className, ...props }: ToastActionProps) => (
|
|
85
259
|
<BaseToast.Action
|
|
86
260
|
className={cn(
|
|
87
|
-
"
|
|
261
|
+
"text-xs -my-1 inline-flex h-7 shrink-0 cursor-pointer items-center justify-center rounded-md border border-border-secondary px-2.5 text-fg-primary",
|
|
88
262
|
motion.colors,
|
|
89
|
-
|
|
263
|
+
focusRing,
|
|
264
|
+
"hover:bg-background-tertiary",
|
|
265
|
+
"group-data-[variant=inverted]/toast:border-fg-inverted/15 group-data-[variant=inverted]/toast:text-fg-inverted group-data-[variant=inverted]/toast:hover:bg-fg-inverted/10 group-data-[variant=inverted]/toast:focus-visible:border-fg-inverted/50 group-data-[variant=inverted]/toast:focus-visible:ring-fg-inverted/50",
|
|
90
266
|
className,
|
|
91
267
|
)}
|
|
92
268
|
{...props}
|
|
@@ -100,15 +276,18 @@ export const ToastClose = ({
|
|
|
100
276
|
}: ToastCloseProps) => (
|
|
101
277
|
<BaseToast.Close
|
|
102
278
|
className={cn(
|
|
103
|
-
"
|
|
279
|
+
"-my-0.5 inline-flex size-6 shrink-0 cursor-pointer items-center justify-center rounded-md text-fg-tertiary",
|
|
280
|
+
focusRingBorder,
|
|
104
281
|
motion.colors,
|
|
105
|
-
|
|
282
|
+
focusRing,
|
|
283
|
+
"hover:bg-background-tertiary hover:text-fg-primary",
|
|
284
|
+
"group-data-[variant=inverted]/toast:text-fg-inverted/50 group-data-[variant=inverted]/toast:hover:bg-fg-inverted/10 group-data-[variant=inverted]/toast:hover:text-fg-inverted group-data-[variant=inverted]/toast:focus-visible:border-fg-inverted/50 group-data-[variant=inverted]/toast:focus-visible:ring-fg-inverted/50",
|
|
106
285
|
className,
|
|
107
286
|
)}
|
|
108
287
|
{...props}
|
|
109
288
|
>
|
|
110
289
|
{children ?? (
|
|
111
|
-
<IconCrossSmall size={
|
|
290
|
+
<IconCrossSmall size={18} className="size-4.5" aria-hidden />
|
|
112
291
|
)}
|
|
113
292
|
</BaseToast.Close>
|
|
114
293
|
)
|
package/src/toggle.tsx
CHANGED
|
@@ -4,6 +4,7 @@ import { Toggle as BaseToggle } from "@base-ui/react/toggle"
|
|
|
4
4
|
import { ToggleGroup as BaseToggleGroup } from "@base-ui/react/toggle-group"
|
|
5
5
|
import type { ComponentProps } from "react"
|
|
6
6
|
import { cn } from "./lib/cn"
|
|
7
|
+
import { focusRing } from "./lib/focus"
|
|
7
8
|
import { motion } from "./lib/motion"
|
|
8
9
|
|
|
9
10
|
export type ToggleProps = ComponentProps<typeof BaseToggle>
|
|
@@ -12,9 +13,10 @@ export type ToggleGroupProps = ComponentProps<typeof BaseToggleGroup>
|
|
|
12
13
|
export const Toggle = ({ className, ...props }: ToggleProps) => (
|
|
13
14
|
<BaseToggle
|
|
14
15
|
className={cn(
|
|
15
|
-
"inline-flex h-8 cursor-pointer items-center justify-center gap-1.5 rounded-md border border-transparent px-2.5 text-sm text-fg-secondary
|
|
16
|
+
"inline-flex h-8 cursor-pointer items-center justify-center gap-1.5 rounded-md border border-transparent px-2.5 text-sm text-fg-secondary",
|
|
16
17
|
motion.colors,
|
|
17
|
-
|
|
18
|
+
focusRing,
|
|
19
|
+
"hover:bg-background-tertiary data-disabled:cursor-not-allowed data-disabled:opacity-50 data-pressed:bg-background-tertiary data-pressed:text-fg-primary",
|
|
18
20
|
className,
|
|
19
21
|
)}
|
|
20
22
|
{...props}
|
package/src/toolbar.tsx
CHANGED
|
@@ -3,6 +3,7 @@
|
|
|
3
3
|
import { Toolbar as BaseToolbar } from "@base-ui/react/toolbar"
|
|
4
4
|
import type { ComponentProps } from "react"
|
|
5
5
|
import { cn } from "./lib/cn"
|
|
6
|
+
import { focusRing, focusRingBorder } from "./lib/focus"
|
|
6
7
|
import { motion } from "./lib/motion"
|
|
7
8
|
|
|
8
9
|
export type ToolbarProps = ComponentProps<typeof BaseToolbar.Root>
|
|
@@ -15,7 +16,7 @@ export type ToolbarSeparatorProps = ComponentProps<typeof BaseToolbar.Separator>
|
|
|
15
16
|
export const Toolbar = ({ className, ...props }: ToolbarProps) => (
|
|
16
17
|
<BaseToolbar.Root
|
|
17
18
|
className={cn(
|
|
18
|
-
"inline-flex items-center gap-0.5 rounded-lg
|
|
19
|
+
"inline-flex items-center gap-0.5 rounded-lg py-0.5 pr-1.5 pl-0.5 shadow-lg",
|
|
19
20
|
className,
|
|
20
21
|
)}
|
|
21
22
|
{...props}
|
|
@@ -32,9 +33,11 @@ export const ToolbarGroup = ({ className, ...props }: ToolbarGroupProps) => (
|
|
|
32
33
|
export const ToolbarButton = ({ className, ...props }: ToolbarButtonProps) => (
|
|
33
34
|
<BaseToolbar.Button
|
|
34
35
|
className={cn(
|
|
35
|
-
"inline-flex h-8 cursor-pointer items-center justify-center gap-1.5 rounded-md px-2.5 text-sm text-fg-secondary
|
|
36
|
+
"inline-flex h-8 cursor-pointer items-center justify-center gap-1.5 rounded-md px-2.5 text-sm text-fg-secondary",
|
|
37
|
+
focusRingBorder,
|
|
36
38
|
motion.colors,
|
|
37
|
-
|
|
39
|
+
focusRing,
|
|
40
|
+
"hover:bg-background-tertiary hover:text-fg-primary data-disabled:cursor-not-allowed data-disabled:opacity-50 data-pressed:bg-background-tertiary data-pressed:text-fg-primary",
|
|
38
41
|
className,
|
|
39
42
|
)}
|
|
40
43
|
{...props}
|
|
@@ -44,9 +47,11 @@ export const ToolbarButton = ({ className, ...props }: ToolbarButtonProps) => (
|
|
|
44
47
|
export const ToolbarLink = ({ className, ...props }: ToolbarLinkProps) => (
|
|
45
48
|
<BaseToolbar.Link
|
|
46
49
|
className={cn(
|
|
47
|
-
"inline-flex h-8 cursor-pointer items-center justify-center gap-1.5 rounded-md px-2.5 text-sm text-fg-secondary
|
|
50
|
+
"inline-flex h-8 cursor-pointer items-center justify-center gap-1.5 rounded-md px-2.5 text-sm text-fg-secondary",
|
|
51
|
+
focusRingBorder,
|
|
48
52
|
motion.colors,
|
|
49
|
-
|
|
53
|
+
focusRing,
|
|
54
|
+
"hover:bg-background-tertiary hover:text-fg-primary",
|
|
50
55
|
className,
|
|
51
56
|
)}
|
|
52
57
|
{...props}
|
|
@@ -56,8 +61,8 @@ export const ToolbarLink = ({ className, ...props }: ToolbarLinkProps) => (
|
|
|
56
61
|
export const ToolbarInput = ({ className, ...props }: ToolbarInputProps) => (
|
|
57
62
|
<BaseToolbar.Input
|
|
58
63
|
className={cn(
|
|
59
|
-
"h-8 min-w-28 cursor-text rounded-md border border-border-secondary bg-surface px-2.5 text-sm text-fg-primary
|
|
60
|
-
|
|
64
|
+
"h-8 min-w-28 cursor-text rounded-md border border-border-secondary bg-surface px-2.5 text-sm text-fg-primary placeholder:text-fg-quaternary",
|
|
65
|
+
focusRing,
|
|
61
66
|
className,
|
|
62
67
|
)}
|
|
63
68
|
{...props}
|
package/src/tooltip.tsx
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
"use client"
|
|
2
2
|
|
|
3
3
|
import { Tooltip as BaseTooltip } from "@base-ui/react/tooltip"
|
|
4
|
+
import { cva, type VariantProps } from "class-variance-authority"
|
|
4
5
|
import type { ComponentProps } from "react"
|
|
5
6
|
import { cn } from "./lib/cn"
|
|
6
7
|
import { motion } from "./lib/motion"
|
|
@@ -12,7 +13,8 @@ export type TooltipPortalProps = ComponentProps<typeof BaseTooltip.Portal>
|
|
|
12
13
|
export type TooltipPositionerProps = ComponentProps<
|
|
13
14
|
typeof BaseTooltip.Positioner
|
|
14
15
|
>
|
|
15
|
-
export type TooltipPopupProps = ComponentProps<typeof BaseTooltip.Popup>
|
|
16
|
+
export type TooltipPopupProps = ComponentProps<typeof BaseTooltip.Popup> &
|
|
17
|
+
VariantProps<typeof tooltipPopupVariants>
|
|
16
18
|
|
|
17
19
|
export const TooltipProvider = (props: TooltipProviderProps) => (
|
|
18
20
|
<BaseTooltip.Provider {...props} />
|
|
@@ -43,13 +45,51 @@ export const TooltipPositioner = ({
|
|
|
43
45
|
/>
|
|
44
46
|
)
|
|
45
47
|
|
|
46
|
-
|
|
48
|
+
// Neither variant carries a border — `shadow-md` already composes
|
|
49
|
+
// `--elevation-hairline`, so one would stack a second edge. That hairline is
|
|
50
|
+
// what gives the default popup its edge against a same-coloured page.
|
|
51
|
+
const tooltipPopupVariants = cva(
|
|
52
|
+
cn(
|
|
53
|
+
"z-50 max-w-xs rounded-md px-2.5 py-1 text-xs shadow-md outline-none",
|
|
54
|
+
// A trailing keycap already carries its own inset, so the full 10px beside
|
|
55
|
+
// it reads as a gap rather than padding — but sitting flush on the vertical
|
|
56
|
+
// inset crowds the corner, so it gets a touch more than that.
|
|
57
|
+
//
|
|
58
|
+
// Laying the row out as flex is what centres it. On a text line the keycap
|
|
59
|
+
// is an inline-flex aligned `middle`, which sets its centre against the
|
|
60
|
+
// baseline plus half an x-height rather than the line's centre — at 16px it
|
|
61
|
+
// hung 1.18px low, leaving 6.36px above and 4px below. Scoped to `has-[kbd]`
|
|
62
|
+
// because making every popup a flex container would turn a multi-child
|
|
63
|
+
// tooltip from stacked blocks into a row.
|
|
64
|
+
"has-[kbd]:flex has-[kbd]:items-center has-[kbd]:pr-1.5",
|
|
65
|
+
),
|
|
66
|
+
{
|
|
67
|
+
variants: {
|
|
68
|
+
variant: {
|
|
69
|
+
// Sits on the page's own surface: white in light mode, dark in dark.
|
|
70
|
+
default: "bg-surface text-fg-primary",
|
|
71
|
+
// Flipped against the page — dark in light mode, light in dark — for
|
|
72
|
+
// a hint that should read as separate from what it floats over.
|
|
73
|
+
inverted: "bg-surface-inverted text-fg-inverted",
|
|
74
|
+
},
|
|
75
|
+
},
|
|
76
|
+
defaultVariants: { variant: "default" },
|
|
77
|
+
},
|
|
78
|
+
)
|
|
79
|
+
|
|
80
|
+
export const TooltipPopup = ({
|
|
81
|
+
className,
|
|
82
|
+
variant,
|
|
83
|
+
...props
|
|
84
|
+
}: TooltipPopupProps) => (
|
|
47
85
|
<BaseTooltip.Popup
|
|
48
86
|
className={cn(
|
|
49
|
-
|
|
87
|
+
tooltipPopupVariants({ variant }),
|
|
50
88
|
motion.popupAnchor,
|
|
51
89
|
className,
|
|
52
90
|
)}
|
|
53
91
|
{...props}
|
|
54
92
|
/>
|
|
55
93
|
)
|
|
94
|
+
|
|
95
|
+
export { tooltipPopupVariants }
|