@brightlocal/ui-components 2.27.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 +6 -1
- package/component-meta.json +480 -126
- 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-screen.d.ts → progress-state.d.ts} +30 -18
- package/dist/blocks/progress-state.d.ts.map +1 -0
- package/dist/blocks/{progress-screen.js → progress-state.js} +100 -71
- package/dist/blocks/sidebar.cjs +1 -1
- package/dist/blocks/sidebar.d.ts.map +1 -1
- package/dist/blocks/sidebar.js +160 -161
- package/dist/breadcrumb.cjs +1 -1
- package/dist/breadcrumb.js +1 -1
- package/dist/button.cjs +1 -1
- package/dist/button.js +11 -11
- 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.map +1 -1
- package/dist/chip.js +5 -3
- package/dist/combobox.cjs +2 -2
- package/dist/combobox.d.ts.map +1 -1
- package/dist/combobox.js +81 -79
- 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 +44 -10
- package/dist/data-table.d.ts.map +1 -1
- package/dist/data-table.js +13 -11
- 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 +27 -1
- package/dist/global-layout.d.ts.map +1 -1
- package/dist/global-layout.js +18 -16
- 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 +8 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +512 -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/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/list.cjs +1 -1
- package/dist/list.d.ts.map +1 -1
- package/dist/list.js +62 -58
- 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 +2 -26
- package/dist/progress.d.ts.map +1 -1
- package/dist/progress.js +79 -118
- 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.js +2 -2
- 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.js +26 -26
- package/dist/stepper.cjs +1 -1
- package/dist/stepper.js +40 -40
- package/dist/table.cjs +1 -1
- package/dist/table.d.ts.map +1 -1
- package/dist/table.js +31 -28
- 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 +35 -7
- package/src/blocks/empty-state.tsx +424 -0
- package/src/blocks/input-list.tsx +66 -36
- package/src/blocks/{progress-screen.tsx → progress-state.tsx} +154 -93
- package/src/blocks/sidebar.tsx +25 -26
- 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 +1 -1
- package/src/components/button.tsx +3 -3
- 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 +5 -3
- package/src/components/combobox.tsx +12 -10
- package/src/components/command.tsx +9 -10
- package/src/components/context-menu.tsx +6 -9
- package/src/components/data-table.tsx +72 -17
- 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 +36 -3
- 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/list.tsx +13 -9
- 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 +35 -113
- package/src/components/select.tsx +5 -4
- package/src/components/separator.tsx +1 -1
- package/src/components/sheet.tsx +2 -2
- package/src/components/skeleton.tsx +78 -7
- package/src/components/sonner.tsx +2 -2
- package/src/components/stepper.tsx +3 -3
- package/src/components/table.tsx +6 -3
- 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 +10 -1
- 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
- package/dist/blocks/progress-screen.cjs +0 -1
- package/dist/blocks/progress-screen.d.ts.map +0 -1
|
@@ -5,7 +5,29 @@ import { cn } from "@brightlocal/ui-components/lib/utils";
|
|
|
5
5
|
/**
|
|
6
6
|
* Props for the Skeleton component
|
|
7
7
|
*/
|
|
8
|
+
/**
|
|
9
|
+
* Entry delay for the skeleton's appearance. `false` (default) shows it
|
|
10
|
+
* immediately; "short" holds it back 300ms (the flash zone's upper edge —
|
|
11
|
+
* waits that resolve first never show it); "long" holds it 1000ms for
|
|
12
|
+
* below-the-fold or secondary surfaces; a number sets a measured per-surface
|
|
13
|
+
* value in milliseconds. The delayed skeleton still reserves its geometry —
|
|
14
|
+
* it is invisible, not unmounted.
|
|
15
|
+
*/
|
|
16
|
+
type SkeletonDelay = "short" | "long" | number | false;
|
|
17
|
+
|
|
18
|
+
const SKELETON_DELAY_MS: Record<"short" | "long", number> = {
|
|
19
|
+
short: 300,
|
|
20
|
+
long: 1000,
|
|
21
|
+
};
|
|
22
|
+
|
|
8
23
|
interface SkeletonProps extends React.ComponentProps<"div"> {
|
|
24
|
+
/**
|
|
25
|
+
* Delay before the skeleton becomes visible: `"short"` (300ms),
|
|
26
|
+
* `"long"` (1000ms), or a number of milliseconds. It keeps reserving its
|
|
27
|
+
* space while invisible.
|
|
28
|
+
* @default false
|
|
29
|
+
*/
|
|
30
|
+
delay?: SkeletonDelay;
|
|
9
31
|
/**
|
|
10
32
|
* Data hook for automated testing (optional for Skeleton as it's purely presentational)
|
|
11
33
|
*/
|
|
@@ -20,33 +42,82 @@ interface SkeletonProps extends React.ComponentProps<"div"> {
|
|
|
20
42
|
trackingLabel?: string;
|
|
21
43
|
/**
|
|
22
44
|
* Accessible label announced to screen readers during loading.
|
|
23
|
-
*
|
|
45
|
+
*
|
|
46
|
+
* Unset (the default) the skeleton is silent: `aria-hidden`, with no
|
|
47
|
+
* screen-reader text. A loading layout is many skeletons — a table page is
|
|
48
|
+
* a dozen rows of four — and one announcement per shape is the whole wait
|
|
49
|
+
* read out dozens of times. The region being loaded carries `aria-busy` and
|
|
50
|
+
* makes the single announcement instead.
|
|
51
|
+
*
|
|
52
|
+
* Pass it only for a skeleton that stands alone, where there is no owning
|
|
53
|
+
* region to do the announcing.
|
|
24
54
|
*/
|
|
25
55
|
loadingLabel?: string;
|
|
26
56
|
}
|
|
27
57
|
|
|
28
58
|
/**
|
|
29
59
|
* Skeleton component for loading placeholder states.
|
|
30
|
-
* Displays a
|
|
60
|
+
* Displays a travelling shimmer wave — one soft color wave (skeleton base to
|
|
61
|
+
* a lighter peak) moving left to right through every skeleton shape in the
|
|
62
|
+
* view, so composed layouts light up in position order with no per-shape
|
|
63
|
+
* setup. The skeleton appears instantly at full strength — deliberately no
|
|
64
|
+
* fade-in — and the wave animates color only, never the shape's opacity.
|
|
31
65
|
* Use to represent text, images, avatars, or any other content while data is being fetched.
|
|
66
|
+
*
|
|
67
|
+
* Appears instantly at full strength — deliberately no fade-in: a skeleton
|
|
68
|
+
* is the page assembling, not a transition worth softening. Flicker on fast
|
|
69
|
+
* responses is prevented by not showing the skeleton at all (the `delay`
|
|
70
|
+
* prop, or `useDelayedPending`), never by easing it in. The exit is equally
|
|
71
|
+
* instant: unmounting is immediate, and fading a skeleton out over readable
|
|
72
|
+
* content is banned (a minimum display time by another name).
|
|
32
73
|
*/
|
|
33
74
|
const Skeleton = React.forwardRef<HTMLDivElement, SkeletonProps>(
|
|
34
75
|
(
|
|
35
|
-
{
|
|
76
|
+
{
|
|
77
|
+
className,
|
|
78
|
+
dataHook,
|
|
79
|
+
delay = false,
|
|
80
|
+
style,
|
|
81
|
+
trackingEl,
|
|
82
|
+
trackingLabel,
|
|
83
|
+
loadingLabel,
|
|
84
|
+
...props
|
|
85
|
+
},
|
|
36
86
|
ref
|
|
37
87
|
) => {
|
|
88
|
+
const delayMs =
|
|
89
|
+
delay === false
|
|
90
|
+
? 0
|
|
91
|
+
: typeof delay === "number"
|
|
92
|
+
? delay
|
|
93
|
+
: SKELETON_DELAY_MS[delay];
|
|
94
|
+
/* Announce only when the caller asked for it by name. Silence is the
|
|
95
|
+
default because a skeleton is scaffolding, not information. */
|
|
96
|
+
const announces = loadingLabel !== undefined;
|
|
38
97
|
return (
|
|
39
98
|
<div
|
|
40
99
|
ref={ref}
|
|
41
|
-
aria-busy="true"
|
|
42
|
-
|
|
100
|
+
aria-busy={announces ? "true" : undefined}
|
|
101
|
+
aria-hidden={announces ? undefined : "true"}
|
|
102
|
+
className={cn(
|
|
103
|
+
"bg-skeleton animate-status-shimmer relative rounded-md",
|
|
104
|
+
className
|
|
105
|
+
)}
|
|
43
106
|
data-hook={dataHook}
|
|
44
107
|
data-slot="skeleton"
|
|
45
108
|
data-tracking-el={trackingEl}
|
|
46
109
|
data-tracking-label={trackingLabel}
|
|
110
|
+
style={
|
|
111
|
+
delayMs
|
|
112
|
+
? ({
|
|
113
|
+
"--skeleton-delay": `${delayMs}ms`,
|
|
114
|
+
...style,
|
|
115
|
+
} as React.CSSProperties)
|
|
116
|
+
: style
|
|
117
|
+
}
|
|
47
118
|
{...props}
|
|
48
119
|
>
|
|
49
|
-
<span className="sr-only">{loadingLabel
|
|
120
|
+
{announces ? <span className="sr-only">{loadingLabel}</span> : null}
|
|
50
121
|
</div>
|
|
51
122
|
);
|
|
52
123
|
}
|
|
@@ -55,4 +126,4 @@ Skeleton.displayName = "Skeleton";
|
|
|
55
126
|
|
|
56
127
|
export { Skeleton };
|
|
57
128
|
|
|
58
|
-
export type { SkeletonProps };
|
|
129
|
+
export type { SkeletonDelay, SkeletonProps };
|
|
@@ -97,7 +97,7 @@ const CONTAINER_VARIANTS = cva(
|
|
|
97
97
|
}
|
|
98
98
|
);
|
|
99
99
|
|
|
100
|
-
const TITLE_VARIANTS = cva("text-
|
|
100
|
+
const TITLE_VARIANTS = cva("text-heading-compact", {
|
|
101
101
|
variants: {
|
|
102
102
|
colorSchema: {
|
|
103
103
|
default: "text-foreground",
|
|
@@ -109,7 +109,7 @@ const TITLE_VARIANTS = cva("text-sm leading-normal font-medium", {
|
|
|
109
109
|
},
|
|
110
110
|
});
|
|
111
111
|
|
|
112
|
-
const DESCRIPTION_VARIANTS = cva("text-sm
|
|
112
|
+
const DESCRIPTION_VARIANTS = cva("text-body-sm", {
|
|
113
113
|
variants: {
|
|
114
114
|
colorSchema: {
|
|
115
115
|
default: "text-muted-foreground",
|
|
@@ -446,7 +446,7 @@ StepperTrigger.displayName = "StepperTrigger";
|
|
|
446
446
|
|
|
447
447
|
const stepperIndicatorStyles = cva(
|
|
448
448
|
[
|
|
449
|
-
"relative flex size-8 shrink-0 items-center justify-center rounded-full text-
|
|
449
|
+
"relative flex size-8 shrink-0 items-center justify-center rounded-full text-label-sm",
|
|
450
450
|
"transition-colors duration-fast ease-out",
|
|
451
451
|
// Hover overlay (only visible when wrapped by an interactive trigger).
|
|
452
452
|
"after:pointer-events-none after:absolute after:inset-0 after:rounded-full after:bg-white/10 after:opacity-0 after:transition-opacity after:duration-fast after:ease-out",
|
|
@@ -668,7 +668,7 @@ const StepperTitle = React.forwardRef<
|
|
|
668
668
|
<span
|
|
669
669
|
ref={ref}
|
|
670
670
|
className={cn(
|
|
671
|
-
"text-foreground text-
|
|
671
|
+
"text-foreground text-heading-compact",
|
|
672
672
|
"group-data-[state=inactive]/step:text-muted-foreground",
|
|
673
673
|
"group-data-[disabled=true]/step:text-muted-foreground",
|
|
674
674
|
className
|
|
@@ -688,7 +688,7 @@ const StepperDescription = React.forwardRef<
|
|
|
688
688
|
>(({ className, ...props }, ref) => (
|
|
689
689
|
<span
|
|
690
690
|
ref={ref}
|
|
691
|
-
className={cn("text-muted-foreground text-xs
|
|
691
|
+
className={cn("text-muted-foreground text-body-xs", className)}
|
|
692
692
|
data-slot="stepper-description"
|
|
693
693
|
{...props}
|
|
694
694
|
/>
|
package/src/components/table.tsx
CHANGED
|
@@ -10,7 +10,7 @@ import { cn } from "@brightlocal/ui-components/lib/utils";
|
|
|
10
10
|
* -----------------------------------------------------------------------------------------------*/
|
|
11
11
|
|
|
12
12
|
const tableCellVariants = cva(
|
|
13
|
-
"align-middle bg-transparent text-
|
|
13
|
+
"align-middle bg-transparent text-body-sm text-foreground break-words",
|
|
14
14
|
{
|
|
15
15
|
variants: {
|
|
16
16
|
size: {
|
|
@@ -34,7 +34,7 @@ const tableCellVariants = cva(
|
|
|
34
34
|
const tableHeadVariants = cva(
|
|
35
35
|
// bg-muted only for column headers inside <thead> — a <TableHead
|
|
36
36
|
// scope="row"> in the body must not paint over its row's state tint.
|
|
37
|
-
"[thead_&]:bg-muted h-12 p-2 align-middle text-muted-foreground text-
|
|
37
|
+
"[thead_&]:bg-muted h-12 p-2 align-middle text-muted-foreground text-label font-semibold break-words outline-none focus-visible:shadow-default transition-[background-color,box-shadow] duration-fast ease-out",
|
|
38
38
|
{
|
|
39
39
|
variants: {
|
|
40
40
|
align: {
|
|
@@ -126,7 +126,10 @@ const Table = React.forwardRef<HTMLTableElement, TableProps>(
|
|
|
126
126
|
<table
|
|
127
127
|
ref={ref}
|
|
128
128
|
className={cn(
|
|
129
|
-
|
|
129
|
+
// tabular-nums inherits into every cell (and into DataTable, which
|
|
130
|
+
// renders this root), so numeric columns align by default; a
|
|
131
|
+
// prose-heavy column can opt out with proportional-nums.
|
|
132
|
+
"text-body-sm w-full caption-bottom tabular-nums",
|
|
130
133
|
layout === "fixed" && "table-fixed",
|
|
131
134
|
className
|
|
132
135
|
)}
|
package/src/components/tabs.tsx
CHANGED
|
@@ -199,7 +199,7 @@ function TabsTriggerInner<T extends string = string>(
|
|
|
199
199
|
// Layout
|
|
200
200
|
"inline-flex items-center justify-center gap-2 px-2 py-1",
|
|
201
201
|
// Typography
|
|
202
|
-
"text-
|
|
202
|
+
"text-label whitespace-nowrap",
|
|
203
203
|
// Border radius
|
|
204
204
|
"rounded-md",
|
|
205
205
|
// Border
|
|
@@ -139,6 +139,11 @@ function rafDelay(ms: number, signal: { cancelled: boolean }): Promise<void> {
|
|
|
139
139
|
* <TypographyP dataHook="w2">Processing</TypographyP>
|
|
140
140
|
* </TextRevealMotion>
|
|
141
141
|
* ```
|
|
142
|
+
*
|
|
143
|
+
* @deprecated Removal planned once product usage is gone (DS-907). Cycling
|
|
144
|
+
* phrases on a timer violates the Loading pattern's Honesty principle — the
|
|
145
|
+
* phrases are not stages the backend reported. Use a section skeleton, or a
|
|
146
|
+
* named-stages running screen driven by real stage data (Patterns / Loading).
|
|
142
147
|
*/
|
|
143
148
|
export interface TextRevealMotionProps extends Omit<
|
|
144
149
|
React.ComponentPropsWithoutRef<"div">,
|
|
@@ -205,6 +210,11 @@ export interface TextRevealMotionProps extends Omit<
|
|
|
205
210
|
* The ball rolls across each child, revealing it via clip-path, holds,
|
|
206
211
|
* then rolls back and cycles to the next child. Supports any Typography
|
|
207
212
|
* component as children.
|
|
213
|
+
*
|
|
214
|
+
* @deprecated Removal planned once product usage is gone (DS-907). Cycling
|
|
215
|
+
* phrases on a timer violates the Loading pattern's Honesty principle — the
|
|
216
|
+
* phrases are not stages the backend reported. Use a section skeleton, or a
|
|
217
|
+
* named-stages running screen driven by real stage data (Patterns / Loading).
|
|
208
218
|
*/
|
|
209
219
|
const TextRevealMotion = React.forwardRef<
|
|
210
220
|
HTMLDivElement,
|
|
@@ -10,7 +10,7 @@ const textareaVariants = cva([
|
|
|
10
10
|
"border border-input bg-background rounded-md",
|
|
11
11
|
"outline-none transition-[border-color,background-color,box-shadow] duration-fast ease-out",
|
|
12
12
|
// Typography
|
|
13
|
-
"text-
|
|
13
|
+
"text-body",
|
|
14
14
|
"text-foreground",
|
|
15
15
|
// Spacing
|
|
16
16
|
"px-3 py-2",
|
|
@@ -7,7 +7,7 @@ import { cva, type VariantProps } from "class-variance-authority";
|
|
|
7
7
|
import { cn } from "@brightlocal/ui-components/lib/utils";
|
|
8
8
|
|
|
9
9
|
const toggleVariants = cva(
|
|
10
|
-
"inline-flex items-center justify-center gap-2 rounded-md text-
|
|
10
|
+
"inline-flex items-center justify-center gap-2 rounded-md text-label hover:bg-muted hover:text-muted-foreground disabled:pointer-events-none disabled:opacity-50 data-[state=on]:bg-accent data-[state=on]:text-accent-foreground [&_svg]:pointer-events-none [&_svg]:shrink-0 focus-visible:border-ring focus-visible:shadow-default outline-none transition-[color,box-shadow] duration-fast ease-out whitespace-nowrap",
|
|
11
11
|
{
|
|
12
12
|
variants: {
|
|
13
13
|
variant: {
|
|
@@ -153,7 +153,7 @@ const TooltipContent = React.forwardRef<
|
|
|
153
153
|
<TooltipPrimitive.Content
|
|
154
154
|
ref={ref}
|
|
155
155
|
className={cn(
|
|
156
|
-
"bg-secondary text-secondary-foreground z-50 w-max max-w-sm rounded-md px-3 py-1.5
|
|
156
|
+
"bg-secondary text-secondary-foreground text-body-xs z-50 w-max max-w-sm rounded-md px-3 py-1.5",
|
|
157
157
|
FLOATING_CONTENT_ANIMATION,
|
|
158
158
|
"**:data-[slot=tooltip-arrow]:-translate-y-px",
|
|
159
159
|
className
|
|
@@ -0,0 +1,229 @@
|
|
|
1
|
+
import * as React from "react";
|
|
2
|
+
import { Slot } from "@radix-ui/react-slot";
|
|
3
|
+
import { cva } from "class-variance-authority";
|
|
4
|
+
|
|
5
|
+
import { cn } from "@brightlocal/ui-components/lib/utils";
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* Heading levels — the rendered HTML tag (h1–h6).
|
|
9
|
+
* The level encodes the document outline position only; it is fully
|
|
10
|
+
* independent of the visual style, which is chosen via `variant`.
|
|
11
|
+
*/
|
|
12
|
+
type TypographyHeadingLevel = 1 | 2 | 3 | 4 | 5 | 6;
|
|
13
|
+
|
|
14
|
+
/**
|
|
15
|
+
* Visual styles from the semantic type scale (DS-714). Weights below are the
|
|
16
|
+
* Figma spec values; each utility renders one step lighter in CSS — the
|
|
17
|
+
* Figma→Web parity offset (DS-305).
|
|
18
|
+
* Every heading is Figma 600 (renders 500) — Figma 700 (the `text-emphasis`
|
|
19
|
+
* utility) is inline emphasis only, never a heading.
|
|
20
|
+
* - `display` — Poppins 600 · 36/40. Brand moments only; never a default.
|
|
21
|
+
* Callout is the one component that uses it.
|
|
22
|
+
* - `page` — Poppins 600 · 24/32. The page title; exactly one per screen.
|
|
23
|
+
* - `section` — Inter 600 · 20/28. Card, dialog and sheet titles.
|
|
24
|
+
* - `subsection` — Inter 600 · 16/24. Sections inside a card, panel headers.
|
|
25
|
+
* - `compact` — Inter 600 · 14/20. Titles inside dense surfaces — alert and
|
|
26
|
+
* toast titles, step titles; the smallest heading. Table column headers are
|
|
27
|
+
* not headings — style the `th` as label-size text at 600 instead.
|
|
28
|
+
*/
|
|
29
|
+
type TypographyHeadingVariant =
|
|
30
|
+
| "display"
|
|
31
|
+
| "page"
|
|
32
|
+
| "section"
|
|
33
|
+
| "subsection"
|
|
34
|
+
| "compact";
|
|
35
|
+
|
|
36
|
+
/**
|
|
37
|
+
* Text alignment options.
|
|
38
|
+
*/
|
|
39
|
+
type TypographyHeadingAlign = "left" | "center" | "right";
|
|
40
|
+
|
|
41
|
+
/**
|
|
42
|
+
* Color role from the scale.
|
|
43
|
+
* - `default` — regular foreground.
|
|
44
|
+
* - `muted` — de-emphasis by color only; same size and weight.
|
|
45
|
+
* Headings have no destructive role — error/critical text is TypographyText
|
|
46
|
+
* `color="destructive"`, never a heading.
|
|
47
|
+
*/
|
|
48
|
+
type TypographyHeadingColor = "default" | "muted";
|
|
49
|
+
|
|
50
|
+
const typographyHeadingVariants = cva("", {
|
|
51
|
+
variants: {
|
|
52
|
+
variant: {
|
|
53
|
+
display: "text-display",
|
|
54
|
+
page: "text-heading-page",
|
|
55
|
+
section: "text-heading-section",
|
|
56
|
+
subsection: "text-heading-subsection",
|
|
57
|
+
compact: "text-heading-compact",
|
|
58
|
+
},
|
|
59
|
+
color: {
|
|
60
|
+
default: "text-foreground",
|
|
61
|
+
muted: "text-muted-foreground",
|
|
62
|
+
},
|
|
63
|
+
align: {
|
|
64
|
+
left: "text-left",
|
|
65
|
+
center: "text-center",
|
|
66
|
+
right: "text-right",
|
|
67
|
+
},
|
|
68
|
+
// Tri-state on purpose: `undefined` (the default) emits no class so the
|
|
69
|
+
// heading inherits its context — proportional everywhere except inside a
|
|
70
|
+
// Table root, which sets `tabular-nums` (DS-926). Explicit `false` must
|
|
71
|
+
// therefore emit `proportional-nums`, or opting out inside a Table would
|
|
72
|
+
// be a silent no-op.
|
|
73
|
+
tabular: {
|
|
74
|
+
true: "tabular-nums",
|
|
75
|
+
false: "proportional-nums",
|
|
76
|
+
},
|
|
77
|
+
},
|
|
78
|
+
defaultVariants: {
|
|
79
|
+
color: "default",
|
|
80
|
+
},
|
|
81
|
+
});
|
|
82
|
+
|
|
83
|
+
/**
|
|
84
|
+
* Default visual style for each heading level, used when `variant` is
|
|
85
|
+
* omitted. `display` is never a default — it must be requested explicitly.
|
|
86
|
+
*/
|
|
87
|
+
const defaultVariantForLevel: Record<
|
|
88
|
+
TypographyHeadingLevel,
|
|
89
|
+
TypographyHeadingVariant
|
|
90
|
+
> = {
|
|
91
|
+
1: "page",
|
|
92
|
+
2: "section",
|
|
93
|
+
3: "subsection",
|
|
94
|
+
4: "subsection",
|
|
95
|
+
5: "subsection",
|
|
96
|
+
6: "subsection",
|
|
97
|
+
};
|
|
98
|
+
|
|
99
|
+
/**
|
|
100
|
+
* Props for the TypographyHeading component.
|
|
101
|
+
* Extends native heading props with design system tracking attributes.
|
|
102
|
+
*/
|
|
103
|
+
interface TypographyHeadingProps extends React.ComponentProps<"h1"> {
|
|
104
|
+
/**
|
|
105
|
+
* Document outline level — renders the corresponding h1–h6 tag.
|
|
106
|
+
* Pick it as if CSS didn't exist (one h1 per page, no skipped levels);
|
|
107
|
+
* the visual size is controlled separately via `variant`.
|
|
108
|
+
*/
|
|
109
|
+
level: TypographyHeadingLevel;
|
|
110
|
+
/**
|
|
111
|
+
* Visual style from the semantic type scale, independent of `level`.
|
|
112
|
+
* When omitted, derived from the level: 1 → "page", 2 → "section",
|
|
113
|
+
* 3–6 → "subsection". "display" is always explicit.
|
|
114
|
+
*/
|
|
115
|
+
variant?: TypographyHeadingVariant;
|
|
116
|
+
/**
|
|
117
|
+
* Color role: `muted` de-emphasises with color only (text-muted-foreground) —
|
|
118
|
+
* the scale never de-emphasises via lighter weight or smaller size. There is
|
|
119
|
+
* no destructive heading — error/critical text uses TypographyText
|
|
120
|
+
* `color="destructive"`.
|
|
121
|
+
* @default "default"
|
|
122
|
+
*/
|
|
123
|
+
color?: TypographyHeadingColor;
|
|
124
|
+
/**
|
|
125
|
+
* Text alignment. When omitted, no alignment class is applied and
|
|
126
|
+
* text keeps the default (left) or inherited alignment.
|
|
127
|
+
* @example "center"
|
|
128
|
+
*/
|
|
129
|
+
align?: TypographyHeadingAlign;
|
|
130
|
+
/**
|
|
131
|
+
* Tabular figures (fixed-width numerals) so live values don't jitter —
|
|
132
|
+
* for headings that contain a changing number. Inside Table/DataTable cells
|
|
133
|
+
* figures are already tabular (inherited from the Table root, DS-926);
|
|
134
|
+
* an explicit `false` restores proportional figures there. When omitted,
|
|
135
|
+
* figures follow the surrounding context. Numbers only: never enable
|
|
136
|
+
* it on regular text/prose — it only affects digits, and digits inside
|
|
137
|
+
* prose should stay proportional.
|
|
138
|
+
* No effect on `display`/`page`: Poppins ships no tabular figures, so the
|
|
139
|
+
* request is a harmless no-op there — and a large standalone number is a
|
|
140
|
+
* TypographyText `metric` (plus `tabular` if it must align), not a heading.
|
|
141
|
+
*/
|
|
142
|
+
tabular?: boolean;
|
|
143
|
+
/**
|
|
144
|
+
* Render as a different element using Radix Slot pattern.
|
|
145
|
+
* When true, merges props onto the child element.
|
|
146
|
+
* @default false
|
|
147
|
+
*/
|
|
148
|
+
asChild?: boolean;
|
|
149
|
+
/**
|
|
150
|
+
* Data hook for automated testing (REQUIRED).
|
|
151
|
+
* Used to identify component in tests and E2E automation.
|
|
152
|
+
* @example "page-title", "card-heading"
|
|
153
|
+
*/
|
|
154
|
+
dataHook: string;
|
|
155
|
+
/**
|
|
156
|
+
* Tracking element identifier for analytics.
|
|
157
|
+
* @default "typography-heading-{variant}"
|
|
158
|
+
*/
|
|
159
|
+
trackingEl?: string;
|
|
160
|
+
/**
|
|
161
|
+
* Tracking label for analytics context.
|
|
162
|
+
*/
|
|
163
|
+
trackingLabel?: string;
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
/**
|
|
167
|
+
* Semantic heading with decoupled axes: `level` sets the HTML tag (document
|
|
168
|
+
* outline), `variant` sets the visual style (semantic type scale, DS-714).
|
|
169
|
+
* This makes "an h3 that looks like a section title" a first-class, correct
|
|
170
|
+
* combination — markup encodes meaning, the variant encodes appearance.
|
|
171
|
+
*
|
|
172
|
+
* @example
|
|
173
|
+
* <TypographyHeading level={2} variant="section" dataHook="card-title">
|
|
174
|
+
* Ranking performance
|
|
175
|
+
* </TypographyHeading>
|
|
176
|
+
*/
|
|
177
|
+
const TypographyHeading = React.forwardRef<
|
|
178
|
+
HTMLHeadingElement,
|
|
179
|
+
TypographyHeadingProps
|
|
180
|
+
>(
|
|
181
|
+
(
|
|
182
|
+
{
|
|
183
|
+
className,
|
|
184
|
+
level,
|
|
185
|
+
variant,
|
|
186
|
+
color = "default",
|
|
187
|
+
align,
|
|
188
|
+
tabular,
|
|
189
|
+
asChild = false,
|
|
190
|
+
dataHook,
|
|
191
|
+
trackingEl,
|
|
192
|
+
trackingLabel,
|
|
193
|
+
...props
|
|
194
|
+
},
|
|
195
|
+
ref
|
|
196
|
+
) => {
|
|
197
|
+
const resolvedVariant = variant ?? defaultVariantForLevel[level];
|
|
198
|
+
const Comp = asChild ? Slot : (`h${level}` as const);
|
|
199
|
+
return (
|
|
200
|
+
<Comp
|
|
201
|
+
ref={ref}
|
|
202
|
+
className={cn(
|
|
203
|
+
typographyHeadingVariants({
|
|
204
|
+
variant: resolvedVariant,
|
|
205
|
+
color,
|
|
206
|
+
align,
|
|
207
|
+
tabular,
|
|
208
|
+
}),
|
|
209
|
+
className
|
|
210
|
+
)}
|
|
211
|
+
data-hook={dataHook}
|
|
212
|
+
data-slot="typography-heading"
|
|
213
|
+
data-tracking-el={trackingEl || `typography-heading-${resolvedVariant}`}
|
|
214
|
+
data-tracking-label={trackingLabel}
|
|
215
|
+
{...props}
|
|
216
|
+
/>
|
|
217
|
+
);
|
|
218
|
+
}
|
|
219
|
+
);
|
|
220
|
+
TypographyHeading.displayName = "TypographyHeading";
|
|
221
|
+
|
|
222
|
+
export { TypographyHeading };
|
|
223
|
+
export type {
|
|
224
|
+
TypographyHeadingProps,
|
|
225
|
+
TypographyHeadingLevel,
|
|
226
|
+
TypographyHeadingVariant,
|
|
227
|
+
TypographyHeadingAlign,
|
|
228
|
+
TypographyHeadingColor,
|
|
229
|
+
};
|