@brightlocal/ui-components 3.4.0 → 3.5.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.
Files changed (196) hide show
  1. package/AI_USAGE.md +22 -3
  2. package/README.md +177 -109
  3. package/component-meta.json +1061 -102
  4. package/dist/alert-dialog.cjs +1 -1
  5. package/dist/alert-dialog.d.ts +13 -2
  6. package/dist/alert-dialog.d.ts.map +1 -1
  7. package/dist/alert-dialog.js +4 -3
  8. package/dist/banner.cjs +1 -1
  9. package/dist/banner.d.ts +47 -11
  10. package/dist/banner.d.ts.map +1 -1
  11. package/dist/banner.js +156 -79
  12. package/dist/blocks/empty-state.cjs +1 -1
  13. package/dist/blocks/empty-state.d.ts +40 -5
  14. package/dist/blocks/empty-state.d.ts.map +1 -1
  15. package/dist/blocks/empty-state.js +59 -52
  16. package/dist/blocks/input-list.d.ts +1 -0
  17. package/dist/blocks/input-list.d.ts.map +1 -1
  18. package/dist/blocks/sidebar.cjs +1 -1
  19. package/dist/blocks/sidebar.d.ts +12 -6
  20. package/dist/blocks/sidebar.d.ts.map +1 -1
  21. package/dist/blocks/sidebar.js +64 -63
  22. package/dist/button.cjs +1 -1
  23. package/dist/button.d.ts.map +1 -1
  24. package/dist/button.js +47 -43
  25. package/dist/card.cjs +1 -1
  26. package/dist/card.d.ts +12 -0
  27. package/dist/card.d.ts.map +1 -1
  28. package/dist/card.js +115 -97
  29. package/dist/chart.cjs +6 -6
  30. package/dist/chart.d.ts +6 -10
  31. package/dist/chart.d.ts.map +1 -1
  32. package/dist/chart.js +281 -296
  33. package/dist/combobox.cjs +3 -3
  34. package/dist/combobox.d.ts.map +1 -1
  35. package/dist/combobox.js +430 -343
  36. package/dist/command.cjs +1 -1
  37. package/dist/command.d.ts +23 -2
  38. package/dist/command.d.ts.map +1 -1
  39. package/dist/command.js +212 -207
  40. package/dist/count-indicator.cjs +1 -0
  41. package/dist/count-indicator.d.ts +85 -0
  42. package/dist/count-indicator.d.ts.map +1 -0
  43. package/dist/count-indicator.js +72 -0
  44. package/dist/data-table.cjs +1 -1
  45. package/dist/data-table.d.ts +101 -11
  46. package/dist/data-table.d.ts.map +1 -1
  47. package/dist/data-table.js +593 -523
  48. package/dist/dialog.cjs +1 -1
  49. package/dist/dialog.d.ts +26 -3
  50. package/dist/dialog.d.ts.map +1 -1
  51. package/dist/dialog.js +62 -47
  52. package/dist/drawer.cjs +1 -1
  53. package/dist/drawer.d.ts +8 -4
  54. package/dist/drawer.d.ts.map +1 -1
  55. package/dist/drawer.js +37 -38
  56. package/dist/file-upload.cjs +1 -0
  57. package/dist/file-upload.d.ts +546 -0
  58. package/dist/file-upload.d.ts.map +1 -0
  59. package/dist/file-upload.js +1103 -0
  60. package/dist/global-layout.cjs +1 -1
  61. package/dist/global-layout.d.ts +7 -2
  62. package/dist/global-layout.d.ts.map +1 -1
  63. package/dist/global-layout.js +52 -52
  64. package/dist/hooks/use-file-dropzone.cjs +1 -0
  65. package/dist/hooks/use-file-dropzone.d.ts +75 -0
  66. package/dist/hooks/use-file-dropzone.d.ts.map +1 -0
  67. package/dist/hooks/use-file-dropzone.js +133 -0
  68. package/dist/hover-card.cjs +1 -1
  69. package/dist/hover-card.d.ts +29 -16
  70. package/dist/hover-card.d.ts.map +1 -1
  71. package/dist/hover-card.js +153 -36
  72. package/dist/index.cjs +1 -1
  73. package/dist/index.d.ts +3 -0
  74. package/dist/index.d.ts.map +1 -1
  75. package/dist/index.js +676 -640
  76. package/dist/input-chip.cjs +1 -1
  77. package/dist/input-chip.d.ts +30 -1
  78. package/dist/input-chip.d.ts.map +1 -1
  79. package/dist/input-chip.js +131 -115
  80. package/dist/input-group.cjs +1 -1
  81. package/dist/input-group.d.ts +37 -2
  82. package/dist/input-group.d.ts.map +1 -1
  83. package/dist/input-group.js +131 -114
  84. package/dist/input-password.cjs +1 -1
  85. package/dist/input-password.js +6 -6
  86. package/dist/lib/empty-canvas.cjs +1 -1
  87. package/dist/lib/empty-canvas.d.ts +27 -1
  88. package/dist/lib/empty-canvas.d.ts.map +1 -1
  89. package/dist/lib/empty-canvas.js +27 -23
  90. package/dist/lib/empty-chip.cjs +1 -1
  91. package/dist/lib/empty-chip.d.ts +19 -2
  92. package/dist/lib/empty-chip.d.ts.map +1 -1
  93. package/dist/lib/empty-chip.js +14 -9
  94. package/dist/lib/field-aria.cjs +1 -1
  95. package/dist/lib/field-aria.d.ts +4 -4
  96. package/dist/lib/field-aria.d.ts.map +1 -1
  97. package/dist/lib/field-aria.js +7 -5
  98. package/dist/lib/media-viewer-content.cjs +1 -1
  99. package/dist/lib/media-viewer-content.js +1 -1
  100. package/dist/lib/table-internal.cjs +1 -1
  101. package/dist/lib/table-internal.d.ts +19 -0
  102. package/dist/lib/table-internal.d.ts.map +1 -1
  103. package/dist/lib/table-internal.js +22 -7
  104. package/dist/list.cjs +1 -1
  105. package/dist/list.d.ts +13 -0
  106. package/dist/list.d.ts.map +1 -1
  107. package/dist/list.js +103 -82
  108. package/dist/logo-mark.cjs +1 -1
  109. package/dist/logo-mark.d.ts +18 -2
  110. package/dist/logo-mark.d.ts.map +1 -1
  111. package/dist/logo-mark.js +159 -79
  112. package/dist/media-empty.cjs +1 -1
  113. package/dist/media-empty.d.ts +50 -7
  114. package/dist/media-empty.d.ts.map +1 -1
  115. package/dist/media-empty.js +14 -13
  116. package/dist/media-viewer.cjs +1 -1
  117. package/dist/media-viewer.js +6 -6
  118. package/dist/multi-select-filter.cjs +1 -1
  119. package/dist/multi-select-filter.d.ts.map +1 -1
  120. package/dist/multi-select-filter.js +92 -101
  121. package/dist/pagination.cjs +1 -1
  122. package/dist/pagination.d.ts +11 -0
  123. package/dist/pagination.d.ts.map +1 -1
  124. package/dist/pagination.js +17 -17
  125. package/dist/relative-date.d.ts +6 -0
  126. package/dist/relative-date.d.ts.map +1 -1
  127. package/dist/resizable.d.ts +1 -1
  128. package/dist/result-count.cjs +1 -1
  129. package/dist/result-count.d.ts +13 -16
  130. package/dist/result-count.d.ts.map +1 -1
  131. package/dist/result-count.js +24 -33
  132. package/dist/sheet.cjs +1 -1
  133. package/dist/sheet.d.ts +22 -3
  134. package/dist/sheet.d.ts.map +1 -1
  135. package/dist/sheet.js +152 -125
  136. package/dist/single-select-filter.cjs +1 -1
  137. package/dist/single-select-filter.d.ts.map +1 -1
  138. package/dist/single-select-filter.js +67 -76
  139. package/dist/table.cjs +1 -1
  140. package/dist/table.d.ts.map +1 -1
  141. package/dist/table.js +77 -76
  142. package/dist/tabs.cjs +1 -1
  143. package/dist/tabs.d.ts +39 -3
  144. package/dist/tabs.d.ts.map +1 -1
  145. package/dist/tabs.js +127 -76
  146. package/dist/textarea.cjs +1 -1
  147. package/dist/textarea.d.ts +34 -0
  148. package/dist/textarea.d.ts.map +1 -1
  149. package/dist/textarea.js +115 -19
  150. package/dist/tooltip.cjs +1 -1
  151. package/dist/tooltip.d.ts.map +1 -1
  152. package/dist/tooltip.js +137 -131
  153. package/dist/typography-text.cjs +1 -1
  154. package/dist/typography-text.d.ts +6 -2
  155. package/dist/typography-text.d.ts.map +1 -1
  156. package/dist/typography-text.js +14 -13
  157. package/package.json +3 -4
  158. package/src/blocks/empty-state.tsx +108 -48
  159. package/src/blocks/input-list.tsx +1 -0
  160. package/src/blocks/sidebar.tsx +39 -16
  161. package/src/components/alert-dialog.tsx +18 -2
  162. package/src/components/banner.tsx +247 -68
  163. package/src/components/button.tsx +27 -10
  164. package/src/components/card.tsx +89 -7
  165. package/src/components/chart.tsx +47 -67
  166. package/src/components/combobox.tsx +221 -12
  167. package/src/components/command.tsx +83 -37
  168. package/src/components/count-indicator.tsx +188 -0
  169. package/src/components/data-table.tsx +506 -159
  170. package/src/components/dialog.tsx +74 -5
  171. package/src/components/drawer.tsx +52 -32
  172. package/src/components/file-upload.tsx +2574 -0
  173. package/src/components/global-layout.tsx +18 -5
  174. package/src/components/hover-card.tsx +395 -65
  175. package/src/components/input-chip.tsx +67 -2
  176. package/src/components/input-group.tsx +89 -6
  177. package/src/components/list.tsx +40 -3
  178. package/src/components/logo-mark.tsx +109 -25
  179. package/src/components/media-empty.tsx +62 -7
  180. package/src/components/multi-select-filter.tsx +9 -16
  181. package/src/components/pagination.tsx +15 -2
  182. package/src/components/relative-date.tsx +6 -0
  183. package/src/components/result-count.tsx +27 -54
  184. package/src/components/sheet.tsx +86 -8
  185. package/src/components/single-select-filter.tsx +9 -16
  186. package/src/components/table.tsx +16 -1
  187. package/src/components/tabs.tsx +223 -41
  188. package/src/components/textarea.tsx +271 -4
  189. package/src/components/tooltip.tsx +29 -2
  190. package/src/components/typography-text.tsx +7 -2
  191. package/src/hooks/use-file-dropzone.ts +325 -0
  192. package/src/index.ts +3 -0
  193. package/src/lib/empty-canvas.tsx +47 -20
  194. package/src/lib/empty-chip.tsx +38 -3
  195. package/src/lib/field-aria.tsx +11 -6
  196. package/src/lib/table-internal.ts +38 -0
@@ -11,35 +11,72 @@ type BannerVariant = "sky" | "violet";
11
11
  /** Document outline level for the banner title */
12
12
  type BannerTitleLevel = 1 | 2 | 3 | 4 | 5 | 6;
13
13
 
14
- // Compact on purpose: a banner is a note, not a hero. Below `md` the parts
15
- // stack (illustration, content, actions); from `md` they sit in one row with
16
- // the actions vertically centred on the right.
17
- const bannerVariants = cva(
18
- "relative flex w-full flex-col gap-3 rounded-xl p-4 md:flex-row md:items-center md:gap-5 md:pl-5",
19
- {
20
- variants: {
21
- variant: {
22
- sky: "bg-highlight-sky text-highlight-sky-foreground",
23
- violet: "bg-highlight-violet text-highlight-violet-foreground",
24
- },
25
- dismissible: {
26
- // Keep the content clear of the absolutely positioned close button.
27
- true: "pr-12 md:pr-14",
28
- false: "",
29
- },
14
+ /** Scale of the banner — a compact strip or a hero */
15
+ type BannerSize = "sm" | "lg";
16
+
17
+ /** How an `sm` banner arranges its parts — `lg` has one fixed composition */
18
+ type BannerFlow = "horizontal" | "vertical";
19
+
20
+ // sm horizontal — the strip. Below `md` the parts stack (illustration,
21
+ // content, actions); from `md` the illustration moves to the left, centred
22
+ // against the text, and the actions stay under the text — never off to the
23
+ // right, where they float beside multi-line copy. Auto-placement does the
24
+ // work: the illustration spans both rows of the first column, so the content
25
+ // and the actions fill the second; without an illustration it is one column.
26
+ // sm vertical — the strip for narrow containers: everything stacked and
27
+ // centred at every width.
28
+ // lg — the hero. Below `md` everything stacks centred. From `md` a grid puts
29
+ // the content and the actions in the left column, the illustration in the
30
+ // right column centred against them (the 1fr rows absorb the difference),
31
+ // and the details full width underneath. Row gaps are margins on the parts so
32
+ // an absent part leaves no gap behind.
33
+ const bannerVariants = cva("relative w-full", {
34
+ variants: {
35
+ variant: {
36
+ sky: "bg-highlight-sky text-highlight-sky-foreground",
37
+ violet: "bg-highlight-violet text-highlight-violet-foreground",
30
38
  },
31
- defaultVariants: {
32
- variant: "sky",
33
- dismissible: false,
39
+ layout: {
40
+ horizontal:
41
+ "flex flex-col gap-3 rounded-xl p-4 md:grid md:grid-cols-1 md:gap-x-5 md:pl-5 md:has-[>[data-slot=banner-illustration]]:grid-cols-[auto_minmax(0,1fr)]",
42
+ vertical: "flex flex-col items-center gap-4 rounded-xl p-5 text-center",
43
+ hero: "grid grid-cols-1 justify-items-center gap-6 rounded-3xl p-6 text-center md:grid-cols-[minmax(0,1fr)_16rem] md:grid-rows-[1fr_auto_auto_1fr_auto] md:justify-items-stretch md:gap-x-12 md:gap-y-0 md:p-10 md:text-left",
34
44
  },
35
- }
36
- );
45
+ dismissible: {
46
+ true: "",
47
+ false: "",
48
+ },
49
+ },
50
+ compoundVariants: [
51
+ // Keep the content clear of the absolutely positioned close button. The
52
+ // vertical strip pads the top instead of the side so the content stays
53
+ // centred — unless an illustration already sits under the button.
54
+ { layout: "horizontal", dismissible: true, className: "pr-12 md:pr-14" },
55
+ {
56
+ layout: "vertical",
57
+ dismissible: true,
58
+ className: "pt-12 has-[>[data-slot=banner-illustration]]:pt-5",
59
+ },
60
+ ],
61
+ defaultVariants: {
62
+ variant: "sky",
63
+ layout: "horizontal",
64
+ dismissible: false,
65
+ },
66
+ });
67
+
68
+ type BannerLayout = "horizontal" | "vertical" | "hero";
37
69
 
38
70
  const descriptionColorMap: Record<BannerVariant, string> = {
39
71
  sky: "text-highlight-sky-muted-foreground",
40
72
  violet: "text-highlight-violet-muted-foreground",
41
73
  };
42
74
 
75
+ const dividerColorMap: Record<BannerVariant, string> = {
76
+ sky: "border-highlight-sky-foreground/15",
77
+ violet: "border-highlight-violet-foreground/15",
78
+ };
79
+
43
80
  const dismissColorMap: Record<BannerVariant, string> = {
44
81
  sky: "text-highlight-sky-foreground hover:bg-highlight-sky-foreground/10",
45
82
  violet:
@@ -50,12 +87,17 @@ const dismissColorMap: Record<BannerVariant, string> = {
50
87
  // accessible name stay the component's job whatever the composition.
51
88
  interface BannerContextValue {
52
89
  variant: BannerVariant;
90
+ layout: BannerLayout;
91
+ /** True for parts rendered inside BannerDetails — they take the compact scale */
92
+ inDetails: boolean;
53
93
  titleId: string;
54
94
  registerTitle: () => () => void;
55
95
  }
56
96
 
57
97
  const BannerContext = React.createContext<BannerContextValue>({
58
98
  variant: "sky",
99
+ layout: "horizontal",
100
+ inDetails: false,
59
101
  titleId: "",
60
102
  registerTitle: () => () => {},
61
103
  });
@@ -70,6 +112,20 @@ interface BannerProps extends React.ComponentPropsWithoutRef<"section"> {
70
112
  * @default "sky"
71
113
  */
72
114
  variant?: BannerVariant;
115
+ /**
116
+ * Scale. `sm` is the compact strip — a nudge next to the page's content.
117
+ * `lg` is the hero — it carries the page (a feature introduction or a plan
118
+ * gate): display title, large illustration on the right, the actions under
119
+ * the text and an optional `BannerDetails` underneath.
120
+ * @default "sm"
121
+ */
122
+ size?: BannerSize;
123
+ /**
124
+ * How an `sm` banner arranges its parts. `vertical` stacks and centres them
125
+ * — for narrow containers like a sidebar or a card column. Ignored at `lg`.
126
+ * @default "horizontal"
127
+ */
128
+ flow?: BannerFlow;
73
129
  /**
74
130
  * Called when the close button is pressed. The close button renders only
75
131
  * when this is set; the consumer decides where the dismissal is remembered.
@@ -90,15 +146,18 @@ interface BannerProps extends React.ComponentPropsWithoutRef<"section"> {
90
146
  * Branded, dismissible banner that invites the user to do something optional
91
147
  * — an invitation, not a fault. Use an Alert when something happened.
92
148
  *
93
- * Compose it from `BannerIllustration`, `BannerContent` (with `BannerTitle`
94
- * and `BannerDescription`) and `BannerActions`. The root owns the surface,
95
- * the layout and the close button.
149
+ * Compose it from `BannerIllustration`, `BannerContent` (with an optional
150
+ * `BannerEyebrow`, `BannerTitle` and `BannerDescription`), `BannerActions`
151
+ * and — at `lg` — `BannerDetails`. The root owns the surface, the layout and
152
+ * the close button.
96
153
  */
97
154
  const Banner = React.forwardRef<HTMLElement, BannerProps>(
98
155
  (
99
156
  {
100
157
  className,
101
158
  variant = "sky",
159
+ size = "sm",
160
+ flow = "horizontal",
102
161
  onDismiss,
103
162
  dismissLabel,
104
163
  dataHook,
@@ -116,9 +175,10 @@ const Banner = React.forwardRef<HTMLElement, BannerProps>(
116
175
  setTitleCount((count) => count + 1);
117
176
  return () => setTitleCount((count) => count - 1);
118
177
  }, []);
178
+ const layout: BannerLayout = size === "lg" ? "hero" : flow;
119
179
  const context = React.useMemo(
120
- () => ({ variant, titleId, registerTitle }),
121
- [variant, titleId, registerTitle]
180
+ () => ({ variant, layout, inDetails: false, titleId, registerTitle }),
181
+ [variant, layout, titleId, registerTitle]
122
182
  );
123
183
  const dismissible = onDismiss != null;
124
184
 
@@ -127,8 +187,13 @@ const Banner = React.forwardRef<HTMLElement, BannerProps>(
127
187
  <section
128
188
  ref={ref}
129
189
  aria-labelledby={titleCount > 0 ? titleId : undefined}
130
- className={cn(bannerVariants({ variant, dismissible }), className)}
190
+ className={cn(
191
+ bannerVariants({ variant, layout, dismissible }),
192
+ className
193
+ )}
194
+ data-flow={size === "lg" ? undefined : flow}
131
195
  data-hook={dataHook}
196
+ data-size={size}
132
197
  data-slot="banner"
133
198
  data-tracking-el={trackingEl || `banner-${variant}`}
134
199
  data-tracking-label={trackingLabel}
@@ -160,45 +225,97 @@ interface BannerPartProps extends React.HTMLAttributes<HTMLDivElement> {
160
225
  dataHook?: string;
161
226
  }
162
227
 
228
+ const illustrationLayoutMap: Record<BannerLayout, string> = {
229
+ horizontal: "size-14 md:row-span-2 md:size-16 md:self-center",
230
+ vertical: "size-14 md:size-16",
231
+ hero: "size-40 md:col-start-2 md:row-start-1 md:row-end-5 md:size-48 md:self-center md:justify-self-center",
232
+ };
233
+
163
234
  /**
164
235
  * Decorative illustration from `@brightlocal/illustrations`, sized by the
165
- * banner (56px, 64px from `md`). Hidden from assistive technologies. Leave
166
- * the illustration's `variant` unset so it follows light/dark mode.
236
+ * banner (56px, 64px from `md`; 160px, 192px from `md` at `lg`). Hidden from
237
+ * assistive technologies. Leave the illustration's `variant` unset so it
238
+ * follows light/dark mode.
167
239
  */
168
240
  const BannerIllustration = React.forwardRef<HTMLDivElement, BannerPartProps>(
169
- ({ className, dataHook, ...props }, ref) => (
170
- <div
171
- ref={ref}
172
- aria-hidden="true"
173
- className={cn(
174
- "flex size-14 shrink-0 md:size-16 [&>svg]:size-full",
175
- className
176
- )}
177
- data-hook={dataHook}
178
- data-slot="banner-illustration"
179
- {...props}
180
- />
181
- )
241
+ ({ className, dataHook, ...props }, ref) => {
242
+ const { layout } = React.useContext(BannerContext);
243
+
244
+ return (
245
+ <div
246
+ ref={ref}
247
+ aria-hidden="true"
248
+ className={cn(
249
+ "flex shrink-0 [&>svg]:size-full",
250
+ illustrationLayoutMap[layout],
251
+ className
252
+ )}
253
+ data-hook={dataHook}
254
+ data-slot="banner-illustration"
255
+ {...props}
256
+ />
257
+ );
258
+ }
182
259
  );
183
260
  BannerIllustration.displayName = "BannerIllustration";
184
261
 
262
+ const contentLayoutMap: Record<BannerLayout, string> = {
263
+ horizontal: "gap-1",
264
+ vertical: "items-center gap-1",
265
+ hero: "items-center gap-3 md:col-start-1 md:row-start-2 md:items-start",
266
+ };
267
+
185
268
  /**
186
- * The text column — takes the remaining width. Holds `BannerTitle` and
187
- * `BannerDescription`, plus anything else the composition needs.
269
+ * The text column — takes the remaining width. Holds `BannerEyebrow`,
270
+ * `BannerTitle` and `BannerDescription`, plus anything else the composition
271
+ * needs.
188
272
  */
189
273
  const BannerContent = React.forwardRef<HTMLDivElement, BannerPartProps>(
190
- ({ className, dataHook, ...props }, ref) => (
191
- <div
192
- ref={ref}
193
- className={cn("flex min-w-0 flex-1 flex-col gap-1", className)}
194
- data-hook={dataHook}
195
- data-slot="banner-content"
196
- {...props}
197
- />
198
- )
274
+ ({ className, dataHook, ...props }, ref) => {
275
+ const { layout } = React.useContext(BannerContext);
276
+
277
+ return (
278
+ <div
279
+ ref={ref}
280
+ className={cn(
281
+ "flex min-w-0 flex-col",
282
+ contentLayoutMap[layout],
283
+ className
284
+ )}
285
+ data-hook={dataHook}
286
+ data-slot="banner-content"
287
+ {...props}
288
+ />
289
+ );
290
+ }
199
291
  );
200
292
  BannerContent.displayName = "BannerContent";
201
293
 
294
+ /**
295
+ * Short line above the title that frames it — the plan it belongs to, the
296
+ * feature's name. Optional; in the surface's muted text role.
297
+ */
298
+ const BannerEyebrow = React.forwardRef<HTMLDivElement, BannerPartProps>(
299
+ ({ className, dataHook, ...props }, ref) => {
300
+ const { variant } = React.useContext(BannerContext);
301
+
302
+ return (
303
+ <div
304
+ ref={ref}
305
+ className={cn(
306
+ "text-body-sm font-semibold break-words",
307
+ descriptionColorMap[variant],
308
+ className
309
+ )}
310
+ data-hook={dataHook}
311
+ data-slot="banner-eyebrow"
312
+ {...props}
313
+ />
314
+ );
315
+ }
316
+ );
317
+ BannerEyebrow.displayName = "BannerEyebrow";
318
+
202
319
  /** Props for BannerTitle */
203
320
  interface BannerTitleProps extends Omit<BannerPartProps, "id"> {
204
321
  /**
@@ -213,14 +330,18 @@ interface BannerTitleProps extends Omit<BannerPartProps, "id"> {
213
330
  /** Heading — what the user is being invited to do. Names the banner region. */
214
331
  const BannerTitle = React.forwardRef<HTMLHeadingElement, BannerTitleProps>(
215
332
  ({ className, level, dataHook, ...props }, ref) => {
216
- const { titleId, registerTitle } = React.useContext(BannerContext);
333
+ const { layout, titleId, registerTitle } = React.useContext(BannerContext);
217
334
  React.useLayoutEffect(() => registerTitle(), [registerTitle]);
218
335
  const Title = level ? (`h${level}` as const) : "div";
219
336
 
220
337
  return (
221
338
  <Title
222
339
  ref={ref}
223
- className={cn("text-heading-subsection break-words", className)}
340
+ className={cn(
341
+ layout === "hero" ? "text-display" : "text-heading-subsection",
342
+ "break-words",
343
+ className
344
+ )}
224
345
  data-hook={dataHook}
225
346
  data-slot="banner-title"
226
347
  id={titleId}
@@ -234,13 +355,16 @@ BannerTitle.displayName = "BannerTitle";
234
355
  /** One or two lines of supporting copy, in the surface's muted text role */
235
356
  const BannerDescription = React.forwardRef<HTMLDivElement, BannerPartProps>(
236
357
  ({ className, dataHook, ...props }, ref) => {
237
- const { variant } = React.useContext(BannerContext);
358
+ const { variant, layout, inDetails } = React.useContext(BannerContext);
238
359
 
239
360
  return (
240
361
  <div
241
362
  ref={ref}
242
363
  className={cn(
243
- "text-body-sm break-words",
364
+ // The hero's lead paragraph is body-sized; copy inside the details
365
+ // (a benefit, a list item) stays compact.
366
+ layout === "hero" && !inDetails ? "text-body" : "text-body-sm",
367
+ "break-words",
244
368
  descriptionColorMap[variant],
245
369
  className
246
370
  )}
@@ -253,30 +377,83 @@ const BannerDescription = React.forwardRef<HTMLDivElement, BannerPartProps>(
253
377
  );
254
378
  BannerDescription.displayName = "BannerDescription";
255
379
 
380
+ const actionsLayoutMap: Record<BannerLayout, string> = {
381
+ horizontal: "",
382
+ vertical: "justify-center",
383
+ // Full-width on phones, under the text from `md`.
384
+ hero: "w-full justify-center max-md:[&>*]:flex-1 md:col-start-1 md:row-start-3 md:mt-5 md:w-auto md:justify-start",
385
+ };
386
+
256
387
  /**
257
- * The action(s) — usually one outline `sm` Button. Sits on the right from
258
- * `md`, under the text on phones.
388
+ * The action(s), always under the text — one outline Button (`sm` in the
389
+ * strip, default size at `lg`), optionally followed by a ghost Button for a
390
+ * secondary action such as "Learn more". Centred in the vertical strip,
391
+ * full width on phones at `lg`.
259
392
  */
260
393
  const BannerActions = React.forwardRef<HTMLDivElement, BannerPartProps>(
261
- ({ className, dataHook, ...props }, ref) => (
262
- <div
263
- ref={ref}
264
- className={cn("flex shrink-0 flex-wrap items-center gap-2", className)}
265
- data-hook={dataHook}
266
- data-slot="banner-actions"
267
- {...props}
268
- />
269
- )
394
+ ({ className, dataHook, ...props }, ref) => {
395
+ const { layout } = React.useContext(BannerContext);
396
+
397
+ return (
398
+ <div
399
+ ref={ref}
400
+ className={cn(
401
+ "flex shrink-0 flex-wrap items-center gap-2",
402
+ actionsLayoutMap[layout],
403
+ className
404
+ )}
405
+ data-hook={dataHook}
406
+ data-slot="banner-actions"
407
+ {...props}
408
+ />
409
+ );
410
+ }
270
411
  );
271
412
  BannerActions.displayName = "BannerActions";
272
413
 
414
+ /**
415
+ * Supporting content under a divider, full width — a grid of benefits, a
416
+ * checklist. `lg` only: the strip has no room for it. `BannerEyebrow` and
417
+ * `BannerDescription` inside it take the compact scale and the surface's
418
+ * muted role, so the content needs no colour or type classes of its own.
419
+ */
420
+ const BannerDetails = React.forwardRef<HTMLDivElement, BannerPartProps>(
421
+ ({ className, dataHook, ...props }, ref) => {
422
+ const parent = React.useContext(BannerContext);
423
+ const { variant } = parent;
424
+ const context = React.useMemo(
425
+ () => ({ ...parent, inDetails: true }),
426
+ [parent]
427
+ );
428
+
429
+ return (
430
+ <BannerContext.Provider value={context}>
431
+ <div
432
+ ref={ref}
433
+ className={cn(
434
+ "w-full border-t pt-8 text-left md:col-span-2 md:row-start-5 md:mt-10",
435
+ dividerColorMap[variant],
436
+ className
437
+ )}
438
+ data-hook={dataHook}
439
+ data-slot="banner-details"
440
+ {...props}
441
+ />
442
+ </BannerContext.Provider>
443
+ );
444
+ }
445
+ );
446
+ BannerDetails.displayName = "BannerDetails";
447
+
273
448
  export {
274
449
  Banner,
275
450
  BannerIllustration,
276
451
  BannerContent,
452
+ BannerEyebrow,
277
453
  BannerTitle,
278
454
  BannerDescription,
279
455
  BannerActions,
456
+ BannerDetails,
280
457
  bannerVariants,
281
458
  };
282
459
  export type {
@@ -284,5 +461,7 @@ export type {
284
461
  BannerPartProps,
285
462
  BannerTitleProps,
286
463
  BannerVariant,
464
+ BannerSize,
465
+ BannerFlow,
287
466
  BannerTitleLevel,
288
467
  };
@@ -135,6 +135,24 @@ const ButtonVariants = cva(
135
135
  }
136
136
  );
137
137
 
138
+ const ICON_ONLY_SIZE: Record<
139
+ NonNullable<ButtonVariantProps["size"]>,
140
+ string
141
+ > = {
142
+ sm: "size-8 p-0",
143
+ default: "size-9 p-0",
144
+ lg: "size-10 p-0",
145
+ };
146
+
147
+ const SPINNER_SIZE: Record<
148
+ NonNullable<ButtonVariantProps["size"]>,
149
+ "sm" | "md" | "lg"
150
+ > = {
151
+ sm: "md",
152
+ default: "md",
153
+ lg: "lg",
154
+ };
155
+
138
156
  /**
139
157
  * Props for the Button component
140
158
  */
@@ -224,7 +242,7 @@ const Button = React.forwardRef<HTMLButtonElement, ButtonProps>(
224
242
  state: visualState,
225
243
  fullWidth,
226
244
  }),
227
- isSingleIconOnly && "size-9 p-0",
245
+ isSingleIconOnly && ICON_ONLY_SIZE[size],
228
246
  className
229
247
  )}
230
248
  data-hook={dataHook}
@@ -252,7 +270,7 @@ const Button = React.forwardRef<HTMLButtonElement, ButtonProps>(
252
270
  state: visualState,
253
271
  fullWidth,
254
272
  }),
255
- isSingleIconOnly && "size-9 p-0",
273
+ isSingleIconOnly && ICON_ONLY_SIZE[size],
256
274
  className
257
275
  )}
258
276
  data-hook={dataHook}
@@ -263,15 +281,14 @@ const Button = React.forwardRef<HTMLButtonElement, ButtonProps>(
263
281
  type={props.type ?? "button"}
264
282
  {...props}
265
283
  >
266
- {showLoadingSpinner && (
267
- <div
268
- className="pointer-events-none flex items-center justify-center"
269
- data-slot="button-loading-icon"
270
- >
271
- <Spinner size="md" />
272
- </div>
284
+ {showLoadingSpinner && isSingleIconOnly ? (
285
+ <Spinner size={SPINNER_SIZE[size]} />
286
+ ) : (
287
+ <>
288
+ {showLoadingSpinner && <Spinner size={SPINNER_SIZE[size]} />}
289
+ {children}
290
+ </>
273
291
  )}
274
- {children}
275
292
  </Comp>
276
293
  );
277
294
  }
@@ -1,7 +1,7 @@
1
1
  "use client";
2
2
 
3
3
  import * as React from "react";
4
- import { Slot } from "@radix-ui/react-slot";
4
+ import { Slot, Slottable } from "@radix-ui/react-slot";
5
5
  import { cva } from "class-variance-authority";
6
6
 
7
7
  import { cn } from "@brightlocal/ui-components/lib/utils";
@@ -236,7 +236,8 @@ const cardHeaderVariants = cva(
236
236
  align: {
237
237
  left: "items-start",
238
238
  center: "justify-items-center text-center",
239
- right: "items-start text-right",
239
+ // A title with an icon is a flex row; keep it on the right edge too.
240
+ right: "items-start text-right [&>[data-slot=card-title]]:justify-end",
240
241
  },
241
242
  },
242
243
  defaultVariants: {
@@ -407,6 +408,18 @@ type CardTitleProps = CardSubComponentProps & {
407
408
  * @default false
408
409
  */
409
410
  asChild?: boolean;
411
+ /**
412
+ * Optional icon rendered before the title text — a DS icon or a 20px
413
+ * platform logo (`LogoMark`). Placed with an 8px gap like `SheetTitle`,
414
+ * and centred on the title's first line so a wrapping title keeps the
415
+ * icon beside its opening words. A bare DS icon is sized to 20px; a
416
+ * `LogoMark` keeps its own size (`size="sm" variant="transparent"` or
417
+ * `size="xs"` for 20px). Decorative: hidden from assistive tech, so the
418
+ * title text must carry the meaning. Works with every `size`, `level`
419
+ * and `asChild`.
420
+ * @example <CardTitle size="small" icon={<LogoMark name="google" size="xs" dataHook="gbp-logo" />}>Google Business Profile</CardTitle>
421
+ */
422
+ icon?: React.ReactNode;
410
423
  };
411
424
 
412
425
  /**
@@ -416,25 +429,94 @@ type CardTitleProps = CardSubComponentProps & {
416
429
  // arbitrary element, so heading refs must type-check too.
417
430
  const CardTitle = React.forwardRef<HTMLElement, CardTitleProps>(
418
431
  (
419
- { className, size = "default", level, asChild = false, dataHook, ...props },
432
+ {
433
+ className,
434
+ size = "default",
435
+ level,
436
+ asChild = false,
437
+ icon,
438
+ children,
439
+ dataHook,
440
+ ...props
441
+ },
420
442
  ref
421
443
  ) => {
422
444
  const sharedProps = {
423
- className: cn(cardTitleVariants({ size }), className),
445
+ className: cn(
446
+ cardTitleVariants({ size }),
447
+ // Same 8px gap as SheetTitle, aligned to the first line: the icon
448
+ // box is one line tall (h-lh) and centres the icon in it, so a title
449
+ // that wraps keeps the icon beside its opening words.
450
+ icon && "flex items-start gap-2",
451
+ className
452
+ ),
424
453
  "data-hook": dataHook,
425
454
  "data-slot": "card-title",
426
455
  ...props,
427
456
  };
457
+ const iconNode = icon ? (
458
+ <span
459
+ aria-hidden="true"
460
+ className="flex h-lh shrink-0 items-center [&>svg]:size-5"
461
+ data-slot="card-title-icon"
462
+ >
463
+ {icon}
464
+ </span>
465
+ ) : null;
466
+ // The text gets its own box so inline markup in the title keeps flowing
467
+ // as one run instead of splitting into separate flex items.
468
+ const wrapText = (text: React.ReactNode) => (
469
+ <span className="min-w-0" data-slot="card-title-text">
470
+ {text}
471
+ </span>
472
+ );
428
473
  if (asChild) {
429
- return <Slot ref={ref} {...sharedProps} />;
474
+ if (
475
+ !icon ||
476
+ !React.isValidElement<{ children?: React.ReactNode }>(children)
477
+ ) {
478
+ return (
479
+ <Slot ref={ref} {...sharedProps}>
480
+ {children}
481
+ </Slot>
482
+ );
483
+ }
484
+ // asChild + icon: the icon goes before the slotted element's own
485
+ // contents, which are wrapped like the non-asChild text.
486
+ return (
487
+ <Slot ref={ref} {...sharedProps}>
488
+ {iconNode}
489
+ <Slottable>
490
+ {React.cloneElement(
491
+ children,
492
+ undefined,
493
+ wrapText(children.props.children)
494
+ )}
495
+ </Slottable>
496
+ </Slot>
497
+ );
430
498
  }
499
+ const content = icon ? (
500
+ <>
501
+ {iconNode}
502
+ {wrapText(children)}
503
+ </>
504
+ ) : (
505
+ children
506
+ );
431
507
  if (level) {
432
508
  const Heading = `h${level}` as const;
433
509
  return (
434
- <Heading ref={ref as React.Ref<HTMLHeadingElement>} {...sharedProps} />
510
+ <Heading ref={ref as React.Ref<HTMLHeadingElement>} {...sharedProps}>
511
+ {content}
512
+ </Heading>
435
513
  );
436
514
  }
437
- return <div ref={ref as React.Ref<HTMLDivElement>} {...sharedProps} />;
515
+ return (
516
+ <div ref={ref as React.Ref<HTMLDivElement>} {...sharedProps}>
517
+ {content}
518
+ </div>
519
+ );
438
520
  }
439
521
  );
440
522
  CardTitle.displayName = "CardTitle";