@brightlocal/ui-components 2.25.0 → 2.27.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/README.md +4 -2
- package/component-meta.json +3809 -182
- package/dist/alert.cjs +1 -1
- package/dist/alert.d.ts +23 -9
- package/dist/alert.d.ts.map +1 -1
- package/dist/alert.js +95 -87
- package/dist/blocks/progress-screen.cjs +1 -0
- package/dist/blocks/progress-screen.d.ts +109 -0
- package/dist/blocks/progress-screen.d.ts.map +1 -0
- package/dist/blocks/progress-screen.js +339 -0
- package/dist/blocks/sidebar.cjs +1 -1
- package/dist/blocks/sidebar.d.ts.map +1 -1
- package/dist/blocks/sidebar.js +155 -153
- package/dist/brand-illustration-motif.d.ts +1 -1
- package/dist/breadcrumb.cjs +1 -1
- package/dist/breadcrumb.d.ts.map +1 -1
- package/dist/breadcrumb.js +44 -40
- package/dist/button.cjs +1 -1
- package/dist/button.d.ts.map +1 -1
- package/dist/button.js +28 -28
- package/dist/chip.cjs +1 -1
- package/dist/chip.d.ts +1 -1
- package/dist/chip.d.ts.map +1 -1
- package/dist/chip.js +42 -41
- package/dist/combobox.cjs +3 -3
- package/dist/combobox.d.ts +4 -2
- package/dist/combobox.d.ts.map +1 -1
- package/dist/combobox.js +161 -161
- package/dist/data-table.cjs +1 -1
- package/dist/data-table.d.ts +155 -4
- package/dist/data-table.d.ts.map +1 -1
- package/dist/data-table.js +462 -309
- package/dist/global-layout.cjs +1 -1
- package/dist/global-layout.d.ts +31 -5
- package/dist/global-layout.d.ts.map +1 -1
- package/dist/global-layout.js +276 -194
- package/dist/index.cjs +1 -1
- package/dist/index.d.ts +3 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +462 -451
- package/dist/lib/motion.cjs +1 -1
- package/dist/lib/motion.js +10 -8
- package/dist/link.cjs +1 -1
- package/dist/link.d.ts +5 -2
- package/dist/link.d.ts.map +1 -1
- package/dist/link.js +97 -91
- package/dist/list.cjs +1 -1
- package/dist/list.js +65 -63
- package/dist/progress.cjs +1 -1
- package/dist/progress.d.ts +61 -3
- package/dist/progress.d.ts.map +1 -1
- package/dist/progress.js +142 -65
- package/dist/route-progress.cjs +1 -0
- package/dist/route-progress.d.ts +103 -0
- package/dist/route-progress.d.ts.map +1 -0
- package/dist/route-progress.js +106 -0
- package/dist/sheet.cjs +1 -1
- package/dist/sheet.d.ts +35 -2
- package/dist/sheet.d.ts.map +1 -1
- package/dist/sheet.js +102 -65
- package/dist/sonner.cjs +1 -1
- package/dist/sonner.d.ts.map +1 -1
- package/dist/sonner.js +11 -15
- package/dist/spinner.cjs +1 -0
- package/dist/spinner.d.ts +57 -0
- package/dist/spinner.d.ts.map +1 -0
- package/dist/spinner.js +35 -0
- package/dist/stepper.cjs +1 -1
- package/dist/stepper.d.ts.map +1 -1
- package/dist/stepper.js +26 -25
- package/dist/table.cjs +1 -1
- package/dist/table.d.ts +1 -1
- package/dist/table.d.ts.map +1 -1
- package/dist/table.js +6 -2
- package/package.json +15 -6
- package/src/blocks/progress-screen.tsx +481 -0
- package/src/blocks/sidebar.tsx +22 -15
- package/src/components/alert.tsx +68 -33
- package/src/components/breadcrumb.tsx +9 -4
- package/src/components/button.tsx +2 -5
- package/src/components/chip.tsx +4 -3
- package/src/components/combobox.tsx +15 -8
- package/src/components/data-table.tsx +358 -16
- package/src/components/global-layout.tsx +228 -62
- package/src/components/link.tsx +88 -63
- package/src/components/list.tsx +5 -5
- package/src/components/progress.tsx +217 -30
- package/src/components/route-progress.tsx +354 -0
- package/src/components/sheet.tsx +87 -5
- package/src/components/sonner.tsx +3 -12
- package/src/components/spinner.tsx +94 -0
- package/src/components/stepper.tsx +3 -4
- package/src/components/table.tsx +6 -2
- package/src/index.ts +3 -0
- package/dist/browser-entry.d.ts +0 -19
- package/dist/browser-entry.d.ts.map +0 -1
- package/src/browser-entry.ts +0 -99
- package/src/browser-tokens.css +0 -1
|
@@ -2,6 +2,7 @@ import * as React from "react";
|
|
|
2
2
|
|
|
3
3
|
import { ArrowLeft } from "@brightlocal/icons";
|
|
4
4
|
import { cn } from "@brightlocal/ui-components/lib/utils";
|
|
5
|
+
import { Breadcrumb } from "./breadcrumb";
|
|
5
6
|
import { Header } from "./header";
|
|
6
7
|
import { Link } from "./link";
|
|
7
8
|
import { ScrollArea } from "./scroll-area";
|
|
@@ -21,8 +22,11 @@ interface GlobalLayoutProps extends React.ComponentProps<"div"> {
|
|
|
21
22
|
*/
|
|
22
23
|
trackingLabel?: string;
|
|
23
24
|
/**
|
|
24
|
-
* Maximum width of the global container.
|
|
25
|
-
*
|
|
25
|
+
* Maximum width of the global container. Unconstrained by default so the
|
|
26
|
+
* sidebar pins to the viewport edge and content centres in the remaining
|
|
27
|
+
* space; pass a `breakpoint` token from `@brightlocal/tokens/breakpoints`
|
|
28
|
+
* to cap the whole shell.
|
|
29
|
+
* @default "none"
|
|
26
30
|
*/
|
|
27
31
|
maxWidth?: string | number;
|
|
28
32
|
}
|
|
@@ -31,7 +35,7 @@ const GlobalLayout = React.forwardRef<HTMLDivElement, GlobalLayoutProps>(
|
|
|
31
35
|
(
|
|
32
36
|
{
|
|
33
37
|
className,
|
|
34
|
-
maxWidth = "
|
|
38
|
+
maxWidth = "none",
|
|
35
39
|
dataHook,
|
|
36
40
|
trackingEl,
|
|
37
41
|
trackingLabel,
|
|
@@ -45,8 +49,11 @@ const GlobalLayout = React.forwardRef<HTMLDivElement, GlobalLayoutProps>(
|
|
|
45
49
|
|
|
46
50
|
return (
|
|
47
51
|
<ScrollArea
|
|
52
|
+
// The viewport's default 4px padding would inset the full-bleed
|
|
53
|
+
// sidebar from the viewport edge and make its 100dvh height
|
|
54
|
+
// overflow, so the page-level scroll region drops it.
|
|
48
55
|
className={cn(
|
|
49
|
-
"h-dvh w-full [&>[data-radix-scroll-area-viewport]>div]:block! [&>[data-radix-scroll-area-viewport]>div]:min-w-0!",
|
|
56
|
+
"h-dvh w-full [&>[data-radix-scroll-area-viewport]]:p-0! [&>[data-radix-scroll-area-viewport]>div]:block! [&>[data-radix-scroll-area-viewport]>div]:min-w-0!",
|
|
50
57
|
className
|
|
51
58
|
)}
|
|
52
59
|
dataHook={`${dataHook}-scroll`}
|
|
@@ -54,7 +61,7 @@ const GlobalLayout = React.forwardRef<HTMLDivElement, GlobalLayoutProps>(
|
|
|
54
61
|
>
|
|
55
62
|
<div
|
|
56
63
|
ref={ref}
|
|
57
|
-
className="
|
|
64
|
+
className="flex min-h-dvh w-full flex-col"
|
|
58
65
|
data-hook={dataHook}
|
|
59
66
|
data-slot="global-layout"
|
|
60
67
|
data-tracking-el={trackingEl}
|
|
@@ -76,7 +83,9 @@ const GlobalLayout = React.forwardRef<HTMLDivElement, GlobalLayoutProps>(
|
|
|
76
83
|
|
|
77
84
|
GlobalLayout.displayName = "GlobalLayout";
|
|
78
85
|
|
|
79
|
-
|
|
86
|
+
// Sidebar rail width per DS-860 — matches the Figma binding to `width/w-72`
|
|
87
|
+
// so nav labels fit without truncation on small desktop screens.
|
|
88
|
+
const SIDEBAR_WIDTH = "288px";
|
|
80
89
|
|
|
81
90
|
interface GlobalLayoutSidebarProps extends React.ComponentProps<"aside"> {
|
|
82
91
|
/**
|
|
@@ -84,7 +93,7 @@ interface GlobalLayoutSidebarProps extends React.ComponentProps<"aside"> {
|
|
|
84
93
|
*/
|
|
85
94
|
dataHook?: string;
|
|
86
95
|
/**
|
|
87
|
-
* Width of the sidebar (default:
|
|
96
|
+
* Width of the sidebar (default: 288px)
|
|
88
97
|
*/
|
|
89
98
|
width?: string | number;
|
|
90
99
|
}
|
|
@@ -107,8 +116,8 @@ const GlobalLayoutSidebar = React.forwardRef<
|
|
|
107
116
|
{...props}
|
|
108
117
|
style={{
|
|
109
118
|
width: widthStyle,
|
|
110
|
-
top:
|
|
111
|
-
height: "
|
|
119
|
+
top: 0,
|
|
120
|
+
height: "100dvh",
|
|
112
121
|
...props.style,
|
|
113
122
|
}}
|
|
114
123
|
>
|
|
@@ -151,8 +160,14 @@ const GlobalLayoutContent = React.forwardRef<
|
|
|
151
160
|
return (
|
|
152
161
|
<div
|
|
153
162
|
ref={ref}
|
|
163
|
+
// Top padding is desktop-only: below lg the mobile header bar sits
|
|
164
|
+
// flush at the top edge and carries its own padding. No horizontal
|
|
165
|
+
// padding here — each region (header, actions, body) pads itself,
|
|
166
|
+
// so a full-width border or sticky treatment under the header stays
|
|
167
|
+
// possible (Figma: Page Header Region / Content Region are separate
|
|
168
|
+
// full-width regions).
|
|
154
169
|
className={cn(
|
|
155
|
-
"
|
|
170
|
+
"pb-section-sm lg:pt-section-sm flex min-w-0 flex-1 flex-col gap-6",
|
|
156
171
|
className
|
|
157
172
|
)}
|
|
158
173
|
data-hook={dataHook}
|
|
@@ -170,6 +185,14 @@ const GlobalLayoutContent = React.forwardRef<
|
|
|
170
185
|
|
|
171
186
|
GlobalLayoutContent.displayName = "GlobalLayoutContent";
|
|
172
187
|
|
|
188
|
+
// Horizontal padding for the full-width regions inside GlobalLayoutContent
|
|
189
|
+
// (header, actions, body): fixed 16px mobile / 24px tablet per the DS-860
|
|
190
|
+
// Figma breakpoint modes; from lg the responsive section-padding token takes
|
|
191
|
+
// over. Applied per region — not on GlobalLayoutContent — so region-level
|
|
192
|
+
// treatments (a border under the header, a future sticky header) can span
|
|
193
|
+
// the full width.
|
|
194
|
+
const CONTENT_REGION_PX = "px-4 md:px-6 lg:px-section-xs";
|
|
195
|
+
|
|
173
196
|
interface GlobalLayoutBackLinkProps extends React.AnchorHTMLAttributes<HTMLAnchorElement> {
|
|
174
197
|
/**
|
|
175
198
|
* Data hook for automated testing
|
|
@@ -228,19 +251,27 @@ interface GlobalLayoutSubtitleProps extends React.ComponentProps<"p"> {
|
|
|
228
251
|
* @default "content-header-subtitle"
|
|
229
252
|
*/
|
|
230
253
|
dataHook?: string;
|
|
254
|
+
/**
|
|
255
|
+
* Render the subtitle as its own child element (Radix Slot) while keeping
|
|
256
|
+
* the muted description typography — use it for rich description rows
|
|
257
|
+
* (icons, rating, a status Badge) that need their own flex layout.
|
|
258
|
+
*/
|
|
259
|
+
asChild?: boolean;
|
|
231
260
|
}
|
|
232
261
|
|
|
233
262
|
/**
|
|
234
263
|
* Muted description text for the page header. Place it as a direct child of
|
|
235
264
|
* `GlobalLayoutContentHeader` — the header positions it below the title row.
|
|
265
|
+
* For rich descriptions, pass `asChild` with your own flex row as the child.
|
|
236
266
|
*/
|
|
237
267
|
const GlobalLayoutSubtitle = React.forwardRef<
|
|
238
268
|
HTMLParagraphElement,
|
|
239
269
|
GlobalLayoutSubtitleProps
|
|
240
|
-
>(({ dataHook, ...props }, ref) => {
|
|
270
|
+
>(({ dataHook, asChild, ...props }, ref) => {
|
|
241
271
|
return (
|
|
242
272
|
<TypographyMuted
|
|
243
273
|
ref={ref}
|
|
274
|
+
asChild={asChild}
|
|
244
275
|
data-slot="content-header-subtitle"
|
|
245
276
|
dataHook={dataHook ?? "content-header-subtitle"}
|
|
246
277
|
{...props}
|
|
@@ -250,6 +281,44 @@ const GlobalLayoutSubtitle = React.forwardRef<
|
|
|
250
281
|
|
|
251
282
|
GlobalLayoutSubtitle.displayName = "GlobalLayoutSubtitle";
|
|
252
283
|
|
|
284
|
+
interface GlobalLayoutImageProps extends React.ComponentProps<"div"> {
|
|
285
|
+
/**
|
|
286
|
+
* Data hook for automated testing
|
|
287
|
+
* @default "content-header-image"
|
|
288
|
+
*/
|
|
289
|
+
dataHook?: string;
|
|
290
|
+
}
|
|
291
|
+
|
|
292
|
+
/**
|
|
293
|
+
* Thumbnail frame for the page header (the Figma Page Header "Show Image"
|
|
294
|
+
* slot). Place it as a direct child of `GlobalLayoutContentHeader` — the
|
|
295
|
+
* header positions it before the breadcrumb + title column. Pass your own
|
|
296
|
+
* `img` (or `Avatar`) as the child; it is cropped to a rounded 3:2 frame,
|
|
297
|
+
* 48px tall by default (size via `className`, e.g. `h-21` for the 84px
|
|
298
|
+
* variant).
|
|
299
|
+
*/
|
|
300
|
+
const GlobalLayoutImage = React.forwardRef<
|
|
301
|
+
HTMLDivElement,
|
|
302
|
+
GlobalLayoutImageProps
|
|
303
|
+
>(({ className, dataHook, children, ...props }, ref) => {
|
|
304
|
+
return (
|
|
305
|
+
<div
|
|
306
|
+
ref={ref}
|
|
307
|
+
className={cn(
|
|
308
|
+
"aspect-[3/2] h-12 shrink-0 overflow-hidden rounded-md [&_img]:size-full [&_img]:object-cover",
|
|
309
|
+
className
|
|
310
|
+
)}
|
|
311
|
+
data-hook={dataHook ?? "content-header-image"}
|
|
312
|
+
data-slot="content-header-image"
|
|
313
|
+
{...props}
|
|
314
|
+
>
|
|
315
|
+
{children}
|
|
316
|
+
</div>
|
|
317
|
+
);
|
|
318
|
+
});
|
|
319
|
+
|
|
320
|
+
GlobalLayoutImage.displayName = "GlobalLayoutImage";
|
|
321
|
+
|
|
253
322
|
interface GlobalLayoutContentHeaderProps extends React.ComponentProps<"header"> {
|
|
254
323
|
/**
|
|
255
324
|
* Data hook for automated testing (required)
|
|
@@ -273,37 +342,86 @@ const GlobalLayoutContentHeader = React.forwardRef<
|
|
|
273
342
|
{ className, dataHook, trackingEl, trackingLabel, children, ...props },
|
|
274
343
|
ref
|
|
275
344
|
) => {
|
|
276
|
-
// Slot the back link and subtitle out of the flat children
|
|
277
|
-
// header can lay them out per the design: back link before a
|
|
278
|
-
// title row + subtitle.
|
|
279
|
-
// fragments or other elements).
|
|
345
|
+
// Slot the back link, breadcrumb, and subtitle out of the flat children
|
|
346
|
+
// so the header can lay them out per the design: back link before a
|
|
347
|
+
// column of breadcrumb + title row + subtitle. All must be direct
|
|
348
|
+
// children (not wrapped in fragments or other elements).
|
|
280
349
|
const backLinks: React.ReactNode[] = [];
|
|
350
|
+
const images: React.ReactNode[] = [];
|
|
351
|
+
const breadcrumbs: React.ReactNode[] = [];
|
|
281
352
|
const subtitles: React.ReactNode[] = [];
|
|
353
|
+
const actions: React.ReactNode[] = [];
|
|
282
354
|
const titleChildren: React.ReactNode[] = [];
|
|
283
355
|
|
|
284
356
|
React.Children.forEach(children, (child) => {
|
|
285
357
|
if (React.isValidElement(child) && child.type === GlobalLayoutBackLink) {
|
|
286
358
|
backLinks.push(child);
|
|
359
|
+
} else if (
|
|
360
|
+
React.isValidElement(child) &&
|
|
361
|
+
child.type === GlobalLayoutImage
|
|
362
|
+
) {
|
|
363
|
+
images.push(child);
|
|
364
|
+
} else if (React.isValidElement(child) && child.type === Breadcrumb) {
|
|
365
|
+
breadcrumbs.push(child);
|
|
287
366
|
} else if (
|
|
288
367
|
React.isValidElement(child) &&
|
|
289
368
|
child.type === GlobalLayoutSubtitle
|
|
290
369
|
) {
|
|
291
370
|
subtitles.push(child);
|
|
371
|
+
} else if (
|
|
372
|
+
React.isValidElement(child) &&
|
|
373
|
+
child.type === GlobalLayoutContentActions
|
|
374
|
+
) {
|
|
375
|
+
actions.push(child);
|
|
292
376
|
} else {
|
|
293
377
|
titleChildren.push(child);
|
|
294
378
|
}
|
|
295
379
|
});
|
|
296
380
|
|
|
297
|
-
// Without a back link
|
|
298
|
-
// structure — children are laid out
|
|
299
|
-
|
|
381
|
+
// Without a back link, image, breadcrumb, subtitle, or actions the
|
|
382
|
+
// header keeps its original flat structure — children are laid out
|
|
383
|
+
// directly by the header row.
|
|
384
|
+
if (
|
|
385
|
+
backLinks.length === 0 &&
|
|
386
|
+
images.length === 0 &&
|
|
387
|
+
breadcrumbs.length === 0 &&
|
|
388
|
+
subtitles.length === 0 &&
|
|
389
|
+
actions.length === 0
|
|
390
|
+
) {
|
|
300
391
|
return (
|
|
392
|
+
<div
|
|
393
|
+
className={cn("w-full", CONTENT_REGION_PX)}
|
|
394
|
+
data-slot="content-header-region"
|
|
395
|
+
>
|
|
396
|
+
<Header
|
|
397
|
+
ref={ref}
|
|
398
|
+
className={cn(
|
|
399
|
+
"mx-auto w-full flex-wrap justify-between gap-4 max-md:flex-col max-md:items-start",
|
|
400
|
+
className
|
|
401
|
+
)}
|
|
402
|
+
data-slot="content-header"
|
|
403
|
+
dataHook={dataHook}
|
|
404
|
+
style={{ maxWidth: "var(--ds-breakpoint-lg)" }}
|
|
405
|
+
trackingEl={trackingEl}
|
|
406
|
+
trackingLabel={trackingLabel}
|
|
407
|
+
{...props}
|
|
408
|
+
>
|
|
409
|
+
{children}
|
|
410
|
+
</Header>
|
|
411
|
+
</div>
|
|
412
|
+
);
|
|
413
|
+
}
|
|
414
|
+
|
|
415
|
+
return (
|
|
416
|
+
<div
|
|
417
|
+
className={cn("w-full", CONTENT_REGION_PX)}
|
|
418
|
+
data-slot="content-header-region"
|
|
419
|
+
>
|
|
301
420
|
<Header
|
|
302
421
|
ref={ref}
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
)}
|
|
422
|
+
// gap-4 matches the Figma Header Row spacing between the back
|
|
423
|
+
// link / image and the text column.
|
|
424
|
+
className={cn("mx-auto w-full items-start gap-4", className)}
|
|
307
425
|
data-slot="content-header"
|
|
308
426
|
dataHook={dataHook}
|
|
309
427
|
style={{ maxWidth: "var(--ds-breakpoint-lg)" }}
|
|
@@ -311,42 +429,58 @@ const GlobalLayoutContentHeader = React.forwardRef<
|
|
|
311
429
|
trackingLabel={trackingLabel}
|
|
312
430
|
{...props}
|
|
313
431
|
>
|
|
314
|
-
{
|
|
315
|
-
|
|
316
|
-
);
|
|
317
|
-
}
|
|
318
|
-
|
|
319
|
-
return (
|
|
320
|
-
<Header
|
|
321
|
-
ref={ref}
|
|
322
|
-
className={cn("mx-auto w-full items-start", className)}
|
|
323
|
-
data-slot="content-header"
|
|
324
|
-
dataHook={dataHook}
|
|
325
|
-
style={{ maxWidth: "var(--ds-breakpoint-lg)" }}
|
|
326
|
-
trackingEl={trackingEl}
|
|
327
|
-
trackingLabel={trackingLabel}
|
|
328
|
-
{...props}
|
|
329
|
-
>
|
|
330
|
-
{backLinks}
|
|
331
|
-
<div
|
|
332
|
-
className="flex min-w-0 flex-1 flex-col gap-2"
|
|
333
|
-
data-slot="content-header-body"
|
|
334
|
-
>
|
|
432
|
+
{backLinks}
|
|
433
|
+
{images}
|
|
335
434
|
<div
|
|
336
|
-
className="flex w-
|
|
337
|
-
data-slot="content-header-
|
|
435
|
+
className="flex min-w-0 flex-1 flex-col gap-2"
|
|
436
|
+
data-slot="content-header-body"
|
|
338
437
|
>
|
|
339
|
-
{
|
|
438
|
+
{breadcrumbs}
|
|
439
|
+
{actions.length > 0 ? (
|
|
440
|
+
// With a slotted GlobalLayoutContentActions the header follows
|
|
441
|
+
// the Figma Page Header structure: a text block (title +
|
|
442
|
+
// description) with the actions beside it — and below it on
|
|
443
|
+
// mobile, so the action lands under the description.
|
|
444
|
+
<div
|
|
445
|
+
className="flex w-full flex-wrap items-start justify-between gap-4 max-md:flex-col"
|
|
446
|
+
data-slot="content-header-title"
|
|
447
|
+
>
|
|
448
|
+
<div
|
|
449
|
+
className="flex min-w-0 flex-1 flex-col gap-2"
|
|
450
|
+
data-slot="content-header-text"
|
|
451
|
+
>
|
|
452
|
+
{titleChildren}
|
|
453
|
+
{subtitles}
|
|
454
|
+
</div>
|
|
455
|
+
<GlobalLayoutHeaderSlotContext.Provider value={true}>
|
|
456
|
+
{actions}
|
|
457
|
+
</GlobalLayoutHeaderSlotContext.Provider>
|
|
458
|
+
</div>
|
|
459
|
+
) : (
|
|
460
|
+
<>
|
|
461
|
+
<div
|
|
462
|
+
className="flex w-full flex-wrap items-center justify-between gap-4 max-md:flex-col max-md:items-start"
|
|
463
|
+
data-slot="content-header-title"
|
|
464
|
+
>
|
|
465
|
+
{titleChildren}
|
|
466
|
+
</div>
|
|
467
|
+
{subtitles}
|
|
468
|
+
</>
|
|
469
|
+
)}
|
|
340
470
|
</div>
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
</Header>
|
|
471
|
+
</Header>
|
|
472
|
+
</div>
|
|
344
473
|
);
|
|
345
474
|
}
|
|
346
475
|
);
|
|
347
476
|
|
|
348
477
|
GlobalLayoutContentHeader.displayName = "GlobalLayoutContentHeader";
|
|
349
478
|
|
|
479
|
+
// True while rendering inside GlobalLayoutContentHeader's actions slot —
|
|
480
|
+
// GlobalLayoutContentActions switches from its standalone desktop-row
|
|
481
|
+
// styling to an inline title-row group.
|
|
482
|
+
const GlobalLayoutHeaderSlotContext = React.createContext(false);
|
|
483
|
+
|
|
350
484
|
interface GlobalLayoutContentActionsProps extends React.ComponentProps<"div"> {
|
|
351
485
|
/**
|
|
352
486
|
* Data hook for automated testing (required)
|
|
@@ -370,23 +504,41 @@ const GlobalLayoutContentActions = React.forwardRef<
|
|
|
370
504
|
{ className, dataHook, trackingEl, trackingLabel, children, ...props },
|
|
371
505
|
ref
|
|
372
506
|
) => {
|
|
373
|
-
|
|
507
|
+
// Slotted inside GlobalLayoutContentHeader the actions render inline in
|
|
508
|
+
// the title row on every breakpoint; standalone they keep the legacy
|
|
509
|
+
// desktop-only full-width row, wrapped in a padded full-width region.
|
|
510
|
+
const inHeader = React.useContext(GlobalLayoutHeaderSlotContext);
|
|
511
|
+
|
|
512
|
+
const actionsRow = (
|
|
374
513
|
<div
|
|
375
514
|
ref={ref}
|
|
376
515
|
className={cn(
|
|
377
|
-
|
|
516
|
+
inHeader
|
|
517
|
+
? "flex shrink-0 items-center gap-2"
|
|
518
|
+
: "mx-auto hidden w-full items-center justify-end gap-2 lg:flex",
|
|
378
519
|
className
|
|
379
520
|
)}
|
|
380
521
|
data-hook={dataHook}
|
|
381
522
|
data-slot="content-actions"
|
|
382
523
|
data-tracking-el={trackingEl}
|
|
383
524
|
data-tracking-label={trackingLabel}
|
|
384
|
-
style={{ maxWidth: "var(--ds-breakpoint-lg)" }}
|
|
525
|
+
style={inHeader ? undefined : { maxWidth: "var(--ds-breakpoint-lg)" }}
|
|
385
526
|
{...props}
|
|
386
527
|
>
|
|
387
528
|
{children}
|
|
388
529
|
</div>
|
|
389
530
|
);
|
|
531
|
+
|
|
532
|
+
if (inHeader) return actionsRow;
|
|
533
|
+
|
|
534
|
+
return (
|
|
535
|
+
<div
|
|
536
|
+
className={cn("w-full", CONTENT_REGION_PX)}
|
|
537
|
+
data-slot="content-actions-region"
|
|
538
|
+
>
|
|
539
|
+
{actionsRow}
|
|
540
|
+
</div>
|
|
541
|
+
);
|
|
390
542
|
}
|
|
391
543
|
);
|
|
392
544
|
|
|
@@ -417,16 +569,21 @@ const GlobalLayoutContentBody = React.forwardRef<
|
|
|
417
569
|
) => {
|
|
418
570
|
return (
|
|
419
571
|
<div
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
data-hook={dataHook}
|
|
423
|
-
data-slot="content-body"
|
|
424
|
-
data-tracking-el={trackingEl}
|
|
425
|
-
data-tracking-label={trackingLabel}
|
|
426
|
-
style={{ maxWidth: "var(--content-max-width)" }}
|
|
427
|
-
{...props}
|
|
572
|
+
className={cn("flex w-full flex-1 flex-col", CONTENT_REGION_PX)}
|
|
573
|
+
data-slot="content-body-region"
|
|
428
574
|
>
|
|
429
|
-
|
|
575
|
+
<div
|
|
576
|
+
ref={ref}
|
|
577
|
+
className={cn("mx-auto flex w-full flex-1 flex-col gap-6", className)}
|
|
578
|
+
data-hook={dataHook}
|
|
579
|
+
data-slot="content-body"
|
|
580
|
+
data-tracking-el={trackingEl}
|
|
581
|
+
data-tracking-label={trackingLabel}
|
|
582
|
+
style={{ maxWidth: "var(--content-max-width)" }}
|
|
583
|
+
{...props}
|
|
584
|
+
>
|
|
585
|
+
{children}
|
|
586
|
+
</div>
|
|
430
587
|
</div>
|
|
431
588
|
);
|
|
432
589
|
}
|
|
@@ -474,8 +631,15 @@ const GlobalLayoutMobileHeader = React.forwardRef<
|
|
|
474
631
|
<div
|
|
475
632
|
ref={ref}
|
|
476
633
|
aria-label={ariaLabel ?? "Mobile navigation"}
|
|
634
|
+
// Carries the same region padding as the header/body regions so the
|
|
635
|
+
// trigger and logo align with the page header below (the bar only
|
|
636
|
+
// renders below lg). Vertical rhythm per the Figma Bar: 24px above
|
|
637
|
+
// the trigger, 8px below.
|
|
477
638
|
className={cn(
|
|
478
|
-
|
|
639
|
+
// The 2px negative margin pulls a slotted SidebarTrigger's box
|
|
640
|
+
// left by its icon inset so the burger glyph — not the invisible
|
|
641
|
+
// button box — sits on the content edge.
|
|
642
|
+
"flex w-full items-center justify-start gap-2 px-4 pt-6 pb-2 md:px-6 lg:hidden [&_[data-slot=sidebar-trigger]]:-ml-0.5",
|
|
479
643
|
className
|
|
480
644
|
)}
|
|
481
645
|
data-hook={dataHook}
|
|
@@ -501,6 +665,7 @@ export {
|
|
|
501
665
|
GlobalLayoutContentHeader,
|
|
502
666
|
GlobalLayoutBackLink,
|
|
503
667
|
GlobalLayoutSubtitle,
|
|
668
|
+
GlobalLayoutImage,
|
|
504
669
|
GlobalLayoutContentBody,
|
|
505
670
|
GlobalLayoutMobileHeader,
|
|
506
671
|
};
|
|
@@ -513,6 +678,7 @@ export type {
|
|
|
513
678
|
GlobalLayoutContentHeaderProps,
|
|
514
679
|
GlobalLayoutBackLinkProps,
|
|
515
680
|
GlobalLayoutSubtitleProps,
|
|
681
|
+
GlobalLayoutImageProps,
|
|
516
682
|
GlobalLayoutContentBodyProps,
|
|
517
683
|
GlobalLayoutMobileHeaderProps,
|
|
518
684
|
};
|
package/src/components/link.tsx
CHANGED
|
@@ -3,38 +3,55 @@ import { ExternalLink } from "@brightlocal/icons";
|
|
|
3
3
|
import { Slot, Slottable } from "@radix-ui/react-slot";
|
|
4
4
|
import { cva, type VariantProps } from "class-variance-authority";
|
|
5
5
|
|
|
6
|
+
import {
|
|
7
|
+
ButtonVariants,
|
|
8
|
+
type ButtonVariant,
|
|
9
|
+
} from "@brightlocal/ui-components/button";
|
|
6
10
|
import { cn } from "@brightlocal/ui-components/lib/utils";
|
|
7
11
|
|
|
8
|
-
//
|
|
9
|
-
//
|
|
10
|
-
//
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
"
|
|
16
|
-
"
|
|
17
|
-
"
|
|
18
|
-
"
|
|
19
|
-
"
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
12
|
+
// Button state classes that must NOT apply to links. Unlike `:disabled`
|
|
13
|
+
// (inert on anchors), these selectors DO match anchors and would introduce
|
|
14
|
+
// styling hooks Link never had: `aria-disabled` dimming (a link would look
|
|
15
|
+
// disabled while staying clickable), `aria-invalid` destructive rings, and
|
|
16
|
+
// the persistent open-trigger highlight when a ghost/icon link is used as a
|
|
17
|
+
// Radix overlay trigger via asChild.
|
|
18
|
+
const buttonOnlyStateClasses = new Set([
|
|
19
|
+
"aria-disabled:opacity-50",
|
|
20
|
+
"aria-invalid:ring-destructive/20",
|
|
21
|
+
"dark:aria-invalid:ring-destructive/40",
|
|
22
|
+
"aria-invalid:border-destructive",
|
|
23
|
+
"data-[state=open]:bg-accent",
|
|
24
|
+
]);
|
|
25
|
+
|
|
26
|
+
// Button-styled variants delegate to the Button component's own CVA so the
|
|
27
|
+
// treatments stay visually identical across both components and never drift.
|
|
28
|
+
// Anchors carry a browser-default underline that buttons never have, hence
|
|
29
|
+
// the `no-underline`.
|
|
30
|
+
const buttonStyledLink = (variant: ButtonVariant) =>
|
|
31
|
+
cn(
|
|
32
|
+
ButtonVariants({ variant, size: "default" })
|
|
33
|
+
.split(/\s+/)
|
|
34
|
+
.filter((cls) => cls && !buttonOnlyStateClasses.has(cls))
|
|
35
|
+
.join(" "),
|
|
36
|
+
"no-underline"
|
|
37
|
+
);
|
|
29
38
|
|
|
30
39
|
const linkVariants = cva(
|
|
31
|
-
//
|
|
32
|
-
|
|
40
|
+
// No shared base: the button-styled variants carry the Button base classes,
|
|
41
|
+
// and a base here would be silently overridden by them in tailwind-merge
|
|
42
|
+
// (last wins). Each variant is self-contained.
|
|
43
|
+
"",
|
|
33
44
|
{
|
|
34
45
|
variants: {
|
|
35
46
|
variant: {
|
|
36
47
|
// Inline text link (default) — the original Link styling.
|
|
48
|
+
// `gap-2` (spacing/2) matches the Button icon–text gap.
|
|
37
49
|
inline: [
|
|
50
|
+
"inline-flex",
|
|
51
|
+
"items-center",
|
|
52
|
+
"gap-2",
|
|
53
|
+
"cursor-pointer",
|
|
54
|
+
"outline-none",
|
|
38
55
|
"rounded-sm",
|
|
39
56
|
// Color tokens (light mode: #2563EB, dark mode: #3B82F6)
|
|
40
57
|
"text-link",
|
|
@@ -53,47 +70,52 @@ const linkVariants = cva(
|
|
|
53
70
|
// Focus state
|
|
54
71
|
"focus-visible:shadow-default",
|
|
55
72
|
],
|
|
56
|
-
//
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
//
|
|
64
|
-
//
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
"
|
|
68
|
-
"
|
|
69
|
-
"
|
|
70
|
-
"
|
|
71
|
-
"text-
|
|
72
|
-
|
|
73
|
-
"
|
|
74
|
-
"
|
|
75
|
-
"
|
|
76
|
-
"
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
"
|
|
83
|
-
"
|
|
84
|
-
"
|
|
73
|
+
// Inline link that reads as part of the surrounding sentence: no
|
|
74
|
+
// link colour of its own — `color: inherit` picks up whatever the
|
|
75
|
+
// parent text sets (muted body copy, alert foregrounds, ...).
|
|
76
|
+
// Because colour no longer distinguishes the link from the text
|
|
77
|
+
// around it, the underline is the only affordance and is therefore
|
|
78
|
+
// persistent (WCAG 1.4.1) — hover feedback comes from the underline
|
|
79
|
+
// strengthening, not from a colour change. Deliberately no `visited:`
|
|
80
|
+
// styling: a purple visited colour would break the "part of the
|
|
81
|
+
// sentence" goal. Plain `inline` display (not `inline-flex`) so the
|
|
82
|
+
// link wraps naturally across lines inside a paragraph.
|
|
83
|
+
inherit: [
|
|
84
|
+
"inline",
|
|
85
|
+
"cursor-pointer",
|
|
86
|
+
"outline-none",
|
|
87
|
+
"rounded-sm",
|
|
88
|
+
"text-inherit",
|
|
89
|
+
// Persistent underline; softened until hovered
|
|
90
|
+
"underline",
|
|
91
|
+
"underline-offset-4",
|
|
92
|
+
"decoration-current/60",
|
|
93
|
+
"hover:decoration-current",
|
|
94
|
+
// External icon sits in the text flow with the label
|
|
95
|
+
"[&_svg]:ml-1",
|
|
96
|
+
"[&_svg]:inline",
|
|
97
|
+
"[&_svg]:align-text-bottom",
|
|
98
|
+
// Transitions
|
|
99
|
+
"transition-[text-decoration-color]",
|
|
100
|
+
"duration-fast",
|
|
101
|
+
"ease-out",
|
|
102
|
+
// Focus state
|
|
103
|
+
"focus-visible:shadow-default",
|
|
85
104
|
],
|
|
105
|
+
// Button-styled, brand CTA (matches Button `primary`).
|
|
106
|
+
primary: buttonStyledLink("primary"),
|
|
107
|
+
// Button-styled, filled (maps to Button `secondary`).
|
|
108
|
+
filled: buttonStyledLink("secondary"),
|
|
109
|
+
// Button-styled, bordered (matches Button `outline`). Button's outline
|
|
110
|
+
// declares no text color (buttons default sensibly; anchors inherit
|
|
111
|
+
// ambient/link colors), so links must pin `text-foreground` explicitly.
|
|
112
|
+
outline: cn(buttonStyledLink("outline"), "text-foreground"),
|
|
113
|
+
// Button-styled, transparent (matches Button `ghost`).
|
|
114
|
+
ghost: buttonStyledLink("ghost"),
|
|
86
115
|
// Icon-only, circular. Mirrors `ghost` in a fixed 36px square
|
|
87
|
-
// footprint
|
|
88
|
-
// Requires an `aria-label` since there is no text content.
|
|
89
|
-
icon:
|
|
90
|
-
...buttonStyledBase,
|
|
91
|
-
"w-9",
|
|
92
|
-
"px-0",
|
|
93
|
-
"bg-transparent",
|
|
94
|
-
"text-foreground",
|
|
95
|
-
"hover:bg-accent",
|
|
96
|
-
],
|
|
116
|
+
// footprint — the same `size-9 p-0` Button applies to icon-only
|
|
117
|
+
// buttons. Requires an `aria-label` since there is no text content.
|
|
118
|
+
icon: cn(buttonStyledLink("ghost"), "size-9 p-0"),
|
|
97
119
|
},
|
|
98
120
|
},
|
|
99
121
|
defaultVariants: {
|
|
@@ -113,7 +135,10 @@ export interface LinkProps extends React.AnchorHTMLAttributes<HTMLAnchorElement>
|
|
|
113
135
|
*/
|
|
114
136
|
dataHook: string;
|
|
115
137
|
/**
|
|
116
|
-
* Visual style variant. `inline` renders a standard text link; `
|
|
138
|
+
* Visual style variant. `inline` renders a standard text link; `inherit`
|
|
139
|
+
* renders an always-underlined link that takes the surrounding text colour
|
|
140
|
+
* (for links inside body copy, alerts and muted text); `primary` renders
|
|
141
|
+
* the brand CTA treatment (matches `Button variant="primary"`); `filled`,
|
|
117
142
|
* `outline` and `ghost` render button-styled treatments for inline actions
|
|
118
143
|
* and high-priority navigation; `icon` renders a circular icon-only link
|
|
119
144
|
* (provide an `aria-label` since there is no text content).
|