@brightlocal/ui-components 2.26.0 → 3.0.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 +9 -2
- package/component-meta.json +4010 -255
- package/deprecations.json +189 -2
- package/dist/accordion.cjs +1 -1
- package/dist/accordion.js +2 -2
- package/dist/alert-dialog.cjs +1 -1
- package/dist/alert-dialog.js +18 -18
- package/dist/alert.cjs +1 -1
- package/dist/alert.d.ts +11 -1
- package/dist/alert.d.ts.map +1 -1
- package/dist/alert.js +31 -28
- package/dist/avatar.cjs +1 -1
- package/dist/avatar.js +4 -4
- package/dist/badge.cjs +1 -1
- package/dist/badge.d.ts.map +1 -1
- package/dist/badge.js +15 -11
- package/dist/blocks/empty-state.cjs +1 -0
- package/dist/blocks/empty-state.d.ts +172 -0
- package/dist/blocks/empty-state.d.ts.map +1 -0
- package/dist/blocks/empty-state.js +155 -0
- package/dist/blocks/input-list.cjs +2 -2
- package/dist/blocks/input-list.d.ts.map +1 -1
- package/dist/blocks/input-list.js +124 -108
- package/dist/blocks/progress-state.cjs +1 -0
- package/dist/blocks/progress-state.d.ts +121 -0
- package/dist/blocks/progress-state.d.ts.map +1 -0
- package/dist/blocks/progress-state.js +368 -0
- package/dist/blocks/sidebar.cjs +1 -1
- package/dist/blocks/sidebar.d.ts.map +1 -1
- package/dist/blocks/sidebar.js +297 -296
- 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 +23 -23
- package/dist/calendar.cjs +1 -1
- package/dist/calendar.d.ts.map +1 -1
- package/dist/calendar.js +37 -38
- package/dist/callout.cjs +1 -1
- package/dist/callout.d.ts +24 -2
- package/dist/callout.d.ts.map +1 -1
- package/dist/callout.js +57 -55
- package/dist/card.cjs +1 -1
- package/dist/card.d.ts +23 -2
- package/dist/card.d.ts.map +1 -1
- package/dist/card.js +94 -91
- package/dist/chart-empty.cjs +1 -0
- package/dist/chart-empty.d.ts +59 -0
- package/dist/chart-empty.d.ts.map +1 -0
- package/dist/chart-empty.js +29 -0
- package/dist/chart.cjs +6 -6
- package/dist/chart.d.ts +6 -1
- package/dist/chart.d.ts.map +1 -1
- package/dist/chart.js +183 -183
- 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 +47 -44
- 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 +143 -141
- package/dist/command.cjs +1 -1
- package/dist/command.d.ts.map +1 -1
- package/dist/command.js +74 -77
- package/dist/context-menu.cjs +1 -1
- package/dist/context-menu.d.ts.map +1 -1
- package/dist/context-menu.js +26 -29
- package/dist/data-table.cjs +1 -1
- package/dist/data-table.d.ts +182 -13
- package/dist/data-table.d.ts.map +1 -1
- package/dist/data-table.js +462 -314
- package/dist/description.cjs +1 -1
- package/dist/description.js +5 -5
- package/dist/dialog.cjs +1 -1
- package/dist/dialog.js +20 -20
- package/dist/drawer.cjs +1 -1
- package/dist/drawer.d.ts.map +1 -1
- package/dist/drawer.js +8 -11
- package/dist/dropdown-menu.cjs +1 -1
- package/dist/dropdown-menu.d.ts.map +1 -1
- package/dist/dropdown-menu.js +17 -20
- package/dist/field.cjs +1 -1
- package/dist/field.d.ts.map +1 -1
- package/dist/field.js +29 -25
- package/dist/global-layout.cjs +1 -1
- package/dist/global-layout.d.ts +58 -6
- package/dist/global-layout.d.ts.map +1 -1
- package/dist/global-layout.js +278 -194
- package/dist/grid.cjs +1 -0
- package/dist/grid.d.ts +56 -0
- package/dist/grid.d.ts.map +1 -0
- package/dist/grid.js +32 -0
- package/dist/header.d.ts +13 -0
- package/dist/header.d.ts.map +1 -1
- package/dist/hooks/use-delayed-pending.cjs +1 -0
- package/dist/hooks/use-delayed-pending.d.ts +34 -0
- package/dist/hooks/use-delayed-pending.d.ts.map +1 -0
- package/dist/hooks/use-delayed-pending.js +17 -0
- package/dist/hover-card.cjs +1 -1
- package/dist/hover-card.js +13 -13
- package/dist/index.cjs +1 -1
- package/dist/index.d.ts +10 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +523 -494
- package/dist/input-chip.cjs +1 -1
- package/dist/input-chip.js +25 -25
- package/dist/input-group.cjs +1 -1
- package/dist/input-group.js +9 -9
- package/dist/input-otp.cjs +1 -1
- package/dist/input-otp.js +9 -9
- package/dist/input-password.cjs +1 -1
- package/dist/input-password.js +51 -51
- package/dist/input.cjs +1 -1
- package/dist/input.js +9 -9
- package/dist/label.cjs +1 -1
- package/dist/label.d.ts.map +1 -1
- package/dist/label.js +25 -28
- package/dist/lib/block-illustration.cjs +1 -0
- package/dist/lib/block-illustration.d.ts +28 -0
- package/dist/lib/block-illustration.d.ts.map +1 -0
- package/dist/lib/block-illustration.js +21 -0
- package/dist/lib/empty-canvas.cjs +1 -0
- package/dist/lib/empty-canvas.d.ts +27 -0
- package/dist/lib/empty-canvas.d.ts.map +1 -0
- package/dist/lib/empty-canvas.js +62 -0
- package/dist/lib/motion.cjs +1 -1
- package/dist/lib/motion.js +10 -8
- package/dist/lib/optical-center.cjs +1 -0
- package/dist/lib/optical-center.d.ts +12 -0
- package/dist/lib/optical-center.d.ts.map +1 -0
- package/dist/lib/optical-center.js +11 -0
- package/dist/lib/utils.cjs +1 -1
- package/dist/lib/utils.d.ts.map +1 -1
- package/dist/lib/utils.js +28 -5
- package/dist/link.cjs +1 -1
- package/dist/link.d.ts +8 -6
- package/dist/link.d.ts.map +1 -1
- package/dist/link.js +52 -20
- package/dist/list.cjs +1 -1
- package/dist/list.d.ts.map +1 -1
- package/dist/list.js +87 -81
- package/dist/map.cjs +1 -1
- package/dist/map.d.ts +60 -2
- package/dist/map.d.ts.map +1 -1
- package/dist/map.js +187 -164
- package/dist/media-empty.cjs +1 -0
- package/dist/media-empty.d.ts +72 -0
- package/dist/media-empty.d.ts.map +1 -0
- package/dist/media-empty.js +45 -0
- package/dist/menubar.cjs +1 -1
- package/dist/menubar.d.ts.map +1 -1
- package/dist/menubar.js +17 -20
- package/dist/navigation-menu.cjs +1 -1
- package/dist/navigation-menu.js +7 -7
- package/dist/pagination.cjs +1 -1
- package/dist/pagination.d.ts +127 -1
- package/dist/pagination.d.ts.map +1 -1
- package/dist/pagination.js +189 -98
- package/dist/progress.cjs +1 -1
- package/dist/progress.d.ts +37 -3
- package/dist/progress.d.ts.map +1 -1
- package/dist/progress.js +102 -64
- 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/select.cjs +2 -2
- package/dist/select.d.ts.map +1 -1
- package/dist/select.js +19 -18
- package/dist/separator.cjs +1 -1
- package/dist/separator.js +8 -8
- 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 +103 -66
- package/dist/skeleton.cjs +1 -1
- package/dist/skeleton.d.ts +38 -3
- package/dist/skeleton.d.ts.map +1 -1
- package/dist/skeleton.js +43 -20
- package/dist/sonner.cjs +1 -1
- package/dist/sonner.d.ts.map +1 -1
- package/dist/sonner.js +32 -36
- 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 +23 -22
- 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 +36 -29
- package/dist/tabs.cjs +1 -1
- package/dist/tabs.js +1 -1
- package/dist/text-reveal-motion.d.ts +10 -0
- package/dist/text-reveal-motion.d.ts.map +1 -1
- package/dist/textarea.cjs +1 -1
- package/dist/textarea.js +11 -11
- package/dist/toggle.cjs +1 -1
- package/dist/toggle.js +8 -8
- package/dist/tooltip.cjs +1 -1
- package/dist/tooltip.js +8 -8
- package/dist/typography-heading.cjs +1 -0
- package/dist/typography-heading.d.ts +116 -0
- package/dist/typography-heading.d.ts.map +1 -0
- package/dist/typography-heading.js +84 -0
- package/dist/typography-text.cjs +1 -0
- package/dist/typography-text.d.ts +113 -0
- package/dist/typography-text.d.ts.map +1 -0
- package/dist/typography-text.js +81 -0
- package/dist/typography.d.ts +13 -0
- package/dist/typography.d.ts.map +1 -1
- package/package.json +42 -2
- package/src/blocks/empty-state.tsx +424 -0
- package/src/blocks/input-list.tsx +66 -36
- package/src/blocks/progress-state.tsx +542 -0
- package/src/blocks/sidebar.tsx +46 -40
- package/src/components/accordion.tsx +2 -2
- package/src/components/alert-dialog.tsx +2 -2
- package/src/components/alert.tsx +27 -13
- package/src/components/avatar.tsx +1 -1
- package/src/components/badge.tsx +8 -4
- package/src/components/breadcrumb.tsx +9 -4
- package/src/components/button.tsx +5 -8
- package/src/components/calendar.tsx +5 -6
- package/src/components/callout.tsx +48 -15
- package/src/components/card.tsx +52 -17
- package/src/components/chart-empty.tsx +116 -0
- package/src/components/chart.tsx +43 -17
- package/src/components/chip.tsx +9 -6
- package/src/components/combobox.tsx +21 -12
- package/src/components/command.tsx +9 -10
- package/src/components/context-menu.tsx +6 -9
- package/src/components/data-table.tsx +405 -31
- package/src/components/description.tsx +1 -1
- package/src/components/dialog.tsx +2 -2
- package/src/components/drawer.tsx +2 -5
- package/src/components/dropdown-menu.tsx +8 -11
- package/src/components/field.tsx +8 -4
- package/src/components/global-layout.tsx +264 -65
- package/src/components/grid.tsx +130 -0
- package/src/components/header.tsx +13 -0
- package/src/components/hover-card.tsx +1 -1
- package/src/components/input-chip.tsx +1 -1
- package/src/components/input-group.tsx +1 -1
- package/src/components/input-otp.tsx +1 -1
- package/src/components/input-password.tsx +1 -1
- package/src/components/input.tsx +1 -1
- package/src/components/label.tsx +10 -13
- package/src/components/link.tsx +39 -5
- package/src/components/list.tsx +18 -14
- package/src/components/map.tsx +101 -5
- package/src/components/media-empty.tsx +156 -0
- package/src/components/menubar.tsx +7 -10
- package/src/components/navigation-menu.tsx +1 -1
- package/src/components/pagination.tsx +279 -1
- package/src/components/progress.tsx +120 -11
- package/src/components/route-progress.tsx +354 -0
- package/src/components/select.tsx +5 -4
- package/src/components/separator.tsx +1 -1
- package/src/components/sheet.tsx +89 -7
- package/src/components/skeleton.tsx +78 -7
- package/src/components/sonner.tsx +5 -14
- package/src/components/spinner.tsx +94 -0
- package/src/components/stepper.tsx +6 -7
- package/src/components/table.tsx +11 -4
- package/src/components/tabs.tsx +1 -1
- package/src/components/text-reveal-motion.tsx +10 -0
- package/src/components/textarea.tsx +1 -1
- package/src/components/toggle.tsx +1 -1
- package/src/components/tooltip.tsx +1 -1
- package/src/components/typography-heading.tsx +229 -0
- package/src/components/typography-text.tsx +225 -0
- package/src/components/typography.tsx +13 -0
- package/src/hooks/use-delayed-pending.ts +60 -0
- package/src/index.ts +12 -0
- package/src/lib/block-illustration.tsx +88 -0
- package/src/lib/empty-canvas.tsx +128 -0
- package/src/lib/optical-center.tsx +45 -0
- package/src/lib/utils.ts +26 -0
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
import * as React from "react";
|
|
2
|
+
|
|
3
|
+
/* -------------------------------------------------------------------------------------------------
|
|
4
|
+
* BlockIllustration (internal)
|
|
5
|
+
*
|
|
6
|
+
* The illustration slot shared by the blocks that draw one — ProgressState,
|
|
7
|
+
* and EmptyState at page scope. Both had the same problem and the same fix, so
|
|
8
|
+
* it lives once.
|
|
9
|
+
*
|
|
10
|
+
* The block owns the size, not the caller. Left to the consumer it was a number
|
|
11
|
+
* to get wrong on every call site, and forgetting it was as bad as mistyping
|
|
12
|
+
* it: the illustrations default to 250, so an unsized one arrives nearly twice
|
|
13
|
+
* the intended height and buries the title under it.
|
|
14
|
+
*
|
|
15
|
+
* The size is applied twice on purpose. As the element's own `size` prop,
|
|
16
|
+
* because clamping it only in the stylesheet means the artwork paints at 250
|
|
17
|
+
* and snaps down the moment the CSS lands — one visible jump on every mount.
|
|
18
|
+
* And as the wrapper's inline width/height, which is the whole mechanism for
|
|
19
|
+
* children that cannot take the prop.
|
|
20
|
+
*
|
|
21
|
+
* The box is square but the artwork is NOT stretched into it. The child keeps
|
|
22
|
+
* its own width — capped by the box — and takes its height from that, which is
|
|
23
|
+
* why `h-auto` is set and `w-auto` deliberately is not: an `<img>`'s `width`
|
|
24
|
+
* attribute is only a presentational hint, so a `w-auto` class beats it and
|
|
25
|
+
* collapses the element to nothing until the source has loaded. Most of the
|
|
26
|
+
* library's illustrations are square SVGs with a `size` prop, but a couple are
|
|
27
|
+
* `<img>`s with their own width and height (`GlobeyFixingFault` is 164×137),
|
|
28
|
+
* and forcing `size-full` on one of those squashed it. The child is capped by
|
|
29
|
+
* the box and keeps its own ratio instead, centred in whatever room is left, so
|
|
30
|
+
* the column's rhythm stays predictable whichever kind of artwork arrives.
|
|
31
|
+
* -----------------------------------------------------------------------------------------------*/
|
|
32
|
+
|
|
33
|
+
/**
|
|
34
|
+
* The size the design specifies for a page-scope illustration, shared by every
|
|
35
|
+
* block that draws one — `ProgressState` and `EmptyState` at page scope — so the
|
|
36
|
+
* artwork never resizes as one of those screens becomes the other.
|
|
37
|
+
*
|
|
38
|
+
* The artwork is the title's companion, not the subject of the screen: much
|
|
39
|
+
* larger and it outweighs the 24px heading under it, and the eye lands on the
|
|
40
|
+
* drawing instead of the words that say what to do next.
|
|
41
|
+
*/
|
|
42
|
+
const BLOCK_ILLUSTRATION_SIZE = 130;
|
|
43
|
+
|
|
44
|
+
/**
|
|
45
|
+
* Props for the internal BlockIllustration wrapper.
|
|
46
|
+
*/
|
|
47
|
+
interface BlockIllustrationProps {
|
|
48
|
+
/** The illustration element, exactly as the consumer passed it. */
|
|
49
|
+
children: React.ReactNode;
|
|
50
|
+
/** Rendered width and height in pixels. */
|
|
51
|
+
size: number;
|
|
52
|
+
/** The owning block's slot name, e.g. `"empty-screen-illustration"`. */
|
|
53
|
+
slot: string;
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
/**
|
|
57
|
+
* Renders a consumer-supplied illustration at the block's own size.
|
|
58
|
+
*/
|
|
59
|
+
function BlockIllustration({ children, size, slot }: BlockIllustrationProps) {
|
|
60
|
+
/* Override whatever the caller set — including nothing, which is the
|
|
61
|
+
illustration's own 250. Merging leaves their other props (aria-hidden,
|
|
62
|
+
className) intact.
|
|
63
|
+
|
|
64
|
+
Only a plain function component gets the prop, and that is deliberately
|
|
65
|
+
narrow: those are the 109 SVG illustrations that declare `size`. A
|
|
66
|
+
`forwardRef` illustration (the two `<img>` ones) has an object type and so
|
|
67
|
+
falls through, which is what we want — `size` is not in its API and would
|
|
68
|
+
land on the `<img>` as an invalid attribute. A host element or a fragment
|
|
69
|
+
falls through for the same reason. Those are handled by the box below. */
|
|
70
|
+
const sized =
|
|
71
|
+
React.isValidElement(children) && typeof children.type === "function"
|
|
72
|
+
? React.cloneElement(children as React.ReactElement<{ size?: number }>, {
|
|
73
|
+
size,
|
|
74
|
+
})
|
|
75
|
+
: children;
|
|
76
|
+
|
|
77
|
+
return (
|
|
78
|
+
<div
|
|
79
|
+
className="flex shrink-0 items-center justify-center [&>*]:h-auto [&>*]:max-h-full [&>*]:max-w-full"
|
|
80
|
+
data-slot={slot}
|
|
81
|
+
style={{ width: size, height: size }}
|
|
82
|
+
>
|
|
83
|
+
{sized}
|
|
84
|
+
</div>
|
|
85
|
+
);
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
export { BlockIllustration, BLOCK_ILLUSTRATION_SIZE };
|
|
@@ -0,0 +1,128 @@
|
|
|
1
|
+
import * as React from "react";
|
|
2
|
+
|
|
3
|
+
import { cn } from "@brightlocal/ui-components/lib/utils";
|
|
4
|
+
import { TypographyText } from "../components/typography-text";
|
|
5
|
+
|
|
6
|
+
/* -------------------------------------------------------------------------------------------------
|
|
7
|
+
* EmptyCanvas (internal)
|
|
8
|
+
*
|
|
9
|
+
* The shared body of the canvas-empty family — `ChartEmpty`, `MapEmpty` and
|
|
10
|
+
* `MediaEmpty`. A muted surface filling the box the consumer reserved, one bare
|
|
11
|
+
* glyph, one quiet line. No title, no CTA, and no circle chip, because a circle
|
|
12
|
+
* on a flat surface reads as a button.
|
|
13
|
+
*
|
|
14
|
+
* It is deliberately NOT `EmptyState` with most of its parts switched off. A
|
|
15
|
+
* canvas shares only the muted vocabulary with the standard block, not its
|
|
16
|
+
* anatomy — and `EmptyState` is a block that composes typography and actions,
|
|
17
|
+
* while these three are primitives. Borrowing the block here would point a
|
|
18
|
+
* primitive at a block and invert the layering.
|
|
19
|
+
*
|
|
20
|
+
* Internal, so it lives in `lib/` rather than `components/`: the package's
|
|
21
|
+
* `"./*"` export maps every file in `components/` to a public entry point, and
|
|
22
|
+
* this is not one.
|
|
23
|
+
* -----------------------------------------------------------------------------------------------*/
|
|
24
|
+
|
|
25
|
+
/**
|
|
26
|
+
* The glyph is one size, everywhere: 32.
|
|
27
|
+
*
|
|
28
|
+
* It does not scale with the box, and there is no size step either. A canvas
|
|
29
|
+
* empty is one treatment, so it reads the same on a metric card's plot, a map
|
|
30
|
+
* well and a photo slot — and every box these land in is a real content box,
|
|
31
|
+
* where 32 is right. A step existed briefly for a 1200px mockup-filler frame
|
|
32
|
+
* that no longer exists; three variants of one treatment were noise.
|
|
33
|
+
*/
|
|
34
|
+
const CANVAS_ICON_SIZE = 32;
|
|
35
|
+
|
|
36
|
+
/**
|
|
37
|
+
* Props for the internal EmptyCanvas body.
|
|
38
|
+
*/
|
|
39
|
+
interface EmptyCanvasProps extends Omit<
|
|
40
|
+
React.ComponentPropsWithoutRef<"div">,
|
|
41
|
+
"children" | "title"
|
|
42
|
+
> {
|
|
43
|
+
/** Required data-hook; the parts derive `-icon` and `-message` from it. */
|
|
44
|
+
dataHook: string;
|
|
45
|
+
/**
|
|
46
|
+
* The decorative glyph. This component owns its size — whatever the element
|
|
47
|
+
* carries is overridden — so no call site has a number to get wrong.
|
|
48
|
+
*/
|
|
49
|
+
icon: React.ReactNode;
|
|
50
|
+
/** The one line under the glyph. */
|
|
51
|
+
message: string;
|
|
52
|
+
/** The calling component's slot name, e.g. `"chart-empty"`. */
|
|
53
|
+
slot: string;
|
|
54
|
+
/** Tracking element identifier for analytics. */
|
|
55
|
+
trackingEl?: string;
|
|
56
|
+
/** Tracking label for analytics context. */
|
|
57
|
+
trackingLabel?: string;
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
/**
|
|
61
|
+
* Renders the muted canvas surface with its glyph and line.
|
|
62
|
+
*/
|
|
63
|
+
const EmptyCanvas = React.forwardRef<HTMLDivElement, EmptyCanvasProps>(
|
|
64
|
+
(
|
|
65
|
+
{
|
|
66
|
+
className,
|
|
67
|
+
dataHook,
|
|
68
|
+
icon,
|
|
69
|
+
message,
|
|
70
|
+
slot,
|
|
71
|
+
trackingEl,
|
|
72
|
+
trackingLabel,
|
|
73
|
+
...props
|
|
74
|
+
},
|
|
75
|
+
ref
|
|
76
|
+
) => {
|
|
77
|
+
/* Override whatever size the element carries, including none. Only
|
|
78
|
+
component elements get the prop — DS icons (forwardRef) and any icon
|
|
79
|
+
component take `size` — while a host element (`<svg>`, `<img>`) or a
|
|
80
|
+
fragment would receive it as an invalid attribute, so those fall
|
|
81
|
+
through; the span's CSS below sizes a raw svg instead. */
|
|
82
|
+
const sized =
|
|
83
|
+
React.isValidElement(icon) &&
|
|
84
|
+
typeof icon.type !== "string" &&
|
|
85
|
+
icon.type !== React.Fragment
|
|
86
|
+
? React.cloneElement(icon as React.ReactElement<{ size?: number }>, {
|
|
87
|
+
size: CANVAS_ICON_SIZE,
|
|
88
|
+
})
|
|
89
|
+
: icon;
|
|
90
|
+
|
|
91
|
+
return (
|
|
92
|
+
<div
|
|
93
|
+
ref={ref}
|
|
94
|
+
className={cn(
|
|
95
|
+
"bg-muted flex flex-col items-center justify-center gap-2 text-center",
|
|
96
|
+
className
|
|
97
|
+
)}
|
|
98
|
+
data-hook={dataHook}
|
|
99
|
+
data-slot={slot}
|
|
100
|
+
data-tracking-el={trackingEl ?? slot}
|
|
101
|
+
data-tracking-label={trackingLabel}
|
|
102
|
+
{...props}
|
|
103
|
+
>
|
|
104
|
+
<span
|
|
105
|
+
aria-hidden="true"
|
|
106
|
+
className="text-muted-foreground flex items-center justify-center [&_svg:not([class*='size-'])]:size-8"
|
|
107
|
+
data-hook={`${dataHook}-icon`}
|
|
108
|
+
data-slot={`${slot}-icon`}
|
|
109
|
+
>
|
|
110
|
+
{sized}
|
|
111
|
+
</span>
|
|
112
|
+
<TypographyText
|
|
113
|
+
align="center"
|
|
114
|
+
color="muted"
|
|
115
|
+
data-slot={`${slot}-message`}
|
|
116
|
+
dataHook={`${dataHook}-message`}
|
|
117
|
+
variant="body-sm"
|
|
118
|
+
>
|
|
119
|
+
{message}
|
|
120
|
+
</TypographyText>
|
|
121
|
+
</div>
|
|
122
|
+
);
|
|
123
|
+
}
|
|
124
|
+
);
|
|
125
|
+
|
|
126
|
+
EmptyCanvas.displayName = "EmptyCanvas";
|
|
127
|
+
|
|
128
|
+
export { EmptyCanvas };
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import * as React from "react";
|
|
2
|
+
|
|
3
|
+
/* -------------------------------------------------------------------------------------------------
|
|
4
|
+
* OpticalCenter (internal)
|
|
5
|
+
*
|
|
6
|
+
* The one agreement every single-message screen shares: where "centred in the
|
|
7
|
+
* page body" actually is. Rendered as a fragment of two flexible spacers, so
|
|
8
|
+
* the OWNER of the element supplies the box (`flex flex-1 flex-col`) and this
|
|
9
|
+
* helper supplies only the ratio.
|
|
10
|
+
*
|
|
11
|
+
* Centred on the viewport, not on the container — hence 38/62 rather than
|
|
12
|
+
* 50/50. A block fills the page BODY, but the reader centres the whole window,
|
|
13
|
+
* and the page header above the body biases that by about half its height:
|
|
14
|
+
* centred in the body, the block's centre lands 22–45px below the window's
|
|
15
|
+
* across every realistic viewport (720–1080). Sitting 38% down cancels most of
|
|
16
|
+
* it — the offset falls to single digits at the 800–900px heights most people
|
|
17
|
+
* are on. Both spacers are flexible, so in a container with no room to spare
|
|
18
|
+
* they collapse together and the content simply centres rather than
|
|
19
|
+
* overflowing.
|
|
20
|
+
*
|
|
21
|
+
* Internal on purpose: everyone — consumers and the DS's own blocks alike —
|
|
22
|
+
* reaches this through `Grid variant="centered"`. The number must never be
|
|
23
|
+
* re-typed at a call site — that is the whole reason this file exists.
|
|
24
|
+
* -----------------------------------------------------------------------------------------------*/
|
|
25
|
+
|
|
26
|
+
interface OpticalCenterProps {
|
|
27
|
+
/** The content to hold at the optical centre. */
|
|
28
|
+
children: React.ReactNode;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
/**
|
|
32
|
+
* Two flexible spacers in a 38/62 ratio around the children. The parent must
|
|
33
|
+
* be a `flex flex-1 flex-col` box for the ratio to have room to work.
|
|
34
|
+
*/
|
|
35
|
+
function OpticalCenter({ children }: OpticalCenterProps) {
|
|
36
|
+
return (
|
|
37
|
+
<>
|
|
38
|
+
<div aria-hidden="true" className="flex-1" />
|
|
39
|
+
{children}
|
|
40
|
+
<div aria-hidden="true" className="flex-[1.6]" />
|
|
41
|
+
</>
|
|
42
|
+
);
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
export { OpticalCenter };
|
package/src/lib/utils.ts
CHANGED
|
@@ -4,11 +4,37 @@ import { extendTailwindMerge } from "tailwind-merge";
|
|
|
4
4
|
// The motion scale adds named duration/ease utilities (tailwind-preset.css)
|
|
5
5
|
// that stock twMerge does not recognize — without registering them, a
|
|
6
6
|
// consumer's `duration-300` would not replace a baked-in `duration-fast`.
|
|
7
|
+
// The semantic type scale (DS-714) must register as font-size classes:
|
|
8
|
+
// unknown `text-*` values are otherwise treated as text colours, so
|
|
9
|
+
// `cn("text-body", "text-foreground")` would drop the scale utility.
|
|
7
10
|
const twMerge = extendTailwindMerge({
|
|
8
11
|
extend: {
|
|
9
12
|
classGroups: {
|
|
10
13
|
duration: [{ duration: ["fast", "base", "slow"] }],
|
|
11
14
|
ease: [{ ease: ["emphasized", "overshoot"] }],
|
|
15
|
+
// text-emphasis sets font-weight only, so it belongs to the font-weight
|
|
16
|
+
// group (conflicts with font-bold etc.), NOT font-size — and unregistered
|
|
17
|
+
// it would be treated as a text colour and clobber color utilities.
|
|
18
|
+
"font-weight": [{ text: ["emphasis"] }],
|
|
19
|
+
"font-size": [
|
|
20
|
+
{
|
|
21
|
+
text: [
|
|
22
|
+
"display",
|
|
23
|
+
"heading-page",
|
|
24
|
+
"heading-section",
|
|
25
|
+
"heading-subsection",
|
|
26
|
+
"heading-compact",
|
|
27
|
+
"body",
|
|
28
|
+
"body-sm",
|
|
29
|
+
"body-xs",
|
|
30
|
+
"label",
|
|
31
|
+
"label-sm",
|
|
32
|
+
"metric",
|
|
33
|
+
"code",
|
|
34
|
+
"code-inline",
|
|
35
|
+
],
|
|
36
|
+
},
|
|
37
|
+
],
|
|
12
38
|
},
|
|
13
39
|
},
|
|
14
40
|
});
|