@slipstream-ui/core 0.11.4 → 0.11.6

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 (246) hide show
  1. package/dist/index.d.mts +100 -3
  2. package/dist/index.d.ts +100 -3
  3. package/dist/index.js +589 -441
  4. package/dist/index.js.map +1 -1
  5. package/dist/index.mjs +484 -337
  6. package/dist/index.mjs.map +1 -1
  7. package/dist/manifests/accordion.manifest.json +1 -1
  8. package/dist/manifests/alert.manifest.json +1 -1
  9. package/dist/manifests/announcement-bar.manifest.json +1 -1
  10. package/dist/manifests/app-shell.manifest.json +1 -1
  11. package/dist/manifests/applied-filters.manifest.json +1 -1
  12. package/dist/manifests/article-card.manifest.json +1 -1
  13. package/dist/manifests/auth-layout.manifest.json +1 -1
  14. package/dist/manifests/autocomplete.manifest.json +1 -1
  15. package/dist/manifests/avatar.manifest.json +1 -1
  16. package/dist/manifests/badge.manifest.json +1 -1
  17. package/dist/manifests/block.manifest.json +1 -1
  18. package/dist/manifests/bottom-nav.manifest.json +1 -1
  19. package/dist/manifests/breadcrumb.manifest.json +1 -1
  20. package/dist/manifests/button-group.manifest.json +1 -1
  21. package/dist/manifests/button.manifest.json +1 -1
  22. package/dist/manifests/calendar.manifest.json +1 -1
  23. package/dist/manifests/card.manifest.json +1 -1
  24. package/dist/manifests/checkbox.manifest.json +1 -1
  25. package/dist/manifests/comparison-table.manifest.json +1 -1
  26. package/dist/manifests/confirm-dialog.manifest.json +1 -1
  27. package/dist/manifests/contact-strip.manifest.json +1 -1
  28. package/dist/manifests/container.manifest.json +1 -1
  29. package/dist/manifests/cover-image.manifest.json +151 -0
  30. package/dist/manifests/cta-section.manifest.json +1 -1
  31. package/dist/manifests/data-table.manifest.json +1 -1
  32. package/dist/manifests/date-picker-popover.manifest.json +1 -1
  33. package/dist/manifests/date-picker.manifest.json +1 -1
  34. package/dist/manifests/date-range-picker.manifest.json +1 -1
  35. package/dist/manifests/deal-card.manifest.json +1 -1
  36. package/dist/manifests/dialog.manifest.json +1 -1
  37. package/dist/manifests/document-card.manifest.json +1 -1
  38. package/dist/manifests/drawer.manifest.json +1 -1
  39. package/dist/manifests/empty-state.manifest.json +45 -1
  40. package/dist/manifests/entity-card.manifest.json +1 -1
  41. package/dist/manifests/feature-grid.manifest.json +1 -1
  42. package/dist/manifests/feature-row.manifest.json +1 -1
  43. package/dist/manifests/fieldset.manifest.json +1 -1
  44. package/dist/manifests/file-upload.manifest.json +1 -1
  45. package/dist/manifests/filter-bar.manifest.json +1 -1
  46. package/dist/manifests/filter-chips.manifest.json +1 -1
  47. package/dist/manifests/filter-panel.manifest.json +1 -1
  48. package/dist/manifests/flex.manifest.json +1 -1
  49. package/dist/manifests/form-field.manifest.json +1 -1
  50. package/dist/manifests/form-layout.manifest.json +1 -1
  51. package/dist/manifests/form.manifest.json +1 -1
  52. package/dist/manifests/grid.manifest.json +1 -1
  53. package/dist/manifests/heading.manifest.json +1 -1
  54. package/dist/manifests/hero.manifest.json +1 -1
  55. package/dist/manifests/image.manifest.json +7 -1
  56. package/dist/manifests/input-group.manifest.json +1 -1
  57. package/dist/manifests/input.manifest.json +1 -1
  58. package/dist/manifests/label.manifest.json +1 -1
  59. package/dist/manifests/link-tabs.manifest.json +1 -1
  60. package/dist/manifests/link.manifest.json +1 -1
  61. package/dist/manifests/list.manifest.json +1 -1
  62. package/dist/manifests/load-more.manifest.json +1 -1
  63. package/dist/manifests/logo-cloud.manifest.json +1 -1
  64. package/dist/manifests/menu.manifest.json +1 -1
  65. package/dist/manifests/metric-card.manifest.json +1 -1
  66. package/dist/manifests/multi-select.manifest.json +1 -1
  67. package/dist/manifests/newsletter.manifest.json +1 -1
  68. package/dist/manifests/page-header.manifest.json +1 -1
  69. package/dist/manifests/pagination.manifest.json +1 -1
  70. package/dist/manifests/password-input.manifest.json +1 -1
  71. package/dist/manifests/popover.manifest.json +1 -1
  72. package/dist/manifests/process-steps.manifest.json +1 -1
  73. package/dist/manifests/progress.manifest.json +1 -1
  74. package/dist/manifests/prose.manifest.json +1 -1
  75. package/dist/manifests/radio.manifest.json +1 -1
  76. package/dist/manifests/range-slider.manifest.json +1 -1
  77. package/dist/manifests/search.manifest.json +1 -1
  78. package/dist/manifests/section-heading.manifest.json +1 -1
  79. package/dist/manifests/section.manifest.json +1 -1
  80. package/dist/manifests/segmented-control.manifest.json +29 -2
  81. package/dist/manifests/select-menu.manifest.json +1 -1
  82. package/dist/manifests/select.manifest.json +1 -1
  83. package/dist/manifests/separator.manifest.json +1 -1
  84. package/dist/manifests/site-footer.manifest.json +1 -1
  85. package/dist/manifests/site-header.manifest.json +1 -1
  86. package/dist/manifests/skeleton.manifest.json +1 -1
  87. package/dist/manifests/spinner.manifest.json +1 -1
  88. package/dist/manifests/stat-band.manifest.json +23 -1
  89. package/dist/manifests/stepper.manifest.json +1 -1
  90. package/dist/manifests/switch.manifest.json +1 -1
  91. package/dist/manifests/table-card.manifest.json +1 -1
  92. package/dist/manifests/table-of-contents.manifest.json +1 -1
  93. package/dist/manifests/table.manifest.json +1 -1
  94. package/dist/manifests/tabs.manifest.json +1 -1
  95. package/dist/manifests/testimonial.manifest.json +1 -1
  96. package/dist/manifests/text.manifest.json +1 -1
  97. package/dist/manifests/textarea.manifest.json +1 -1
  98. package/dist/manifests/theme-toggle.manifest.json +1 -1
  99. package/dist/manifests/time-picker.manifest.json +1 -1
  100. package/dist/manifests/timeline.manifest.json +1 -1
  101. package/dist/manifests/toast.manifest.json +1 -1
  102. package/dist/manifests/tombstone-card.manifest.json +1 -1
  103. package/dist/manifests/tooltip.manifest.json +1 -1
  104. package/dist/src/components/cover-image/CoverImage.d.ts +34 -0
  105. package/dist/src/components/cover-image/CoverImage.js +94 -0
  106. package/dist/src/components/cover-image/CoverImage.js.map +1 -0
  107. package/dist/src/components/cover-image/CoverImage.mjs +70 -0
  108. package/dist/src/components/cover-image/CoverImage.mjs.map +1 -0
  109. package/dist/src/components/cover-image/index.d.ts +1 -0
  110. package/dist/src/components/cover-image/index.js +29 -0
  111. package/dist/src/components/cover-image/index.js.map +1 -0
  112. package/dist/src/components/cover-image/index.mjs +5 -0
  113. package/dist/src/components/cover-image/index.mjs.map +1 -0
  114. package/dist/src/components/empty-state/EmptyState.d.ts +24 -0
  115. package/dist/src/components/empty-state/EmptyState.js +16 -6
  116. package/dist/src/components/empty-state/EmptyState.js.map +1 -1
  117. package/dist/src/components/empty-state/EmptyState.mjs +16 -6
  118. package/dist/src/components/empty-state/EmptyState.mjs.map +1 -1
  119. package/dist/src/components/image/Image.d.ts +3 -1
  120. package/dist/src/components/image/Image.js +2 -0
  121. package/dist/src/components/image/Image.js.map +1 -1
  122. package/dist/src/components/image/Image.mjs +2 -0
  123. package/dist/src/components/image/Image.mjs.map +1 -1
  124. package/dist/src/components/segmented-control/SegmentedControl.d.ts +21 -0
  125. package/dist/src/components/segmented-control/SegmentedControl.js +47 -16
  126. package/dist/src/components/segmented-control/SegmentedControl.js.map +1 -1
  127. package/dist/src/components/segmented-control/SegmentedControl.mjs +48 -17
  128. package/dist/src/components/segmented-control/SegmentedControl.mjs.map +1 -1
  129. package/dist/src/components/stat-band/StatBand.d.ts +16 -0
  130. package/dist/src/components/stat-band/StatBand.js +46 -9
  131. package/dist/src/components/stat-band/StatBand.js.map +1 -1
  132. package/dist/src/components/stat-band/StatBand.mjs +46 -9
  133. package/dist/src/components/stat-band/StatBand.mjs.map +1 -1
  134. package/dist/src/index.d.ts +1 -0
  135. package/dist/styles-full.css +1 -1
  136. package/dist/styles.css +1 -1
  137. package/package.json +2 -2
  138. package/src/components/cover-image/CoverImage.test.tsx +88 -0
  139. package/src/components/cover-image/CoverImage.tsx +109 -0
  140. package/src/components/cover-image/index.ts +1 -0
  141. package/src/components/empty-state/EmptyState.test.tsx +33 -0
  142. package/src/components/empty-state/EmptyState.tsx +34 -6
  143. package/src/components/image/Image.tsx +4 -0
  144. package/src/components/segmented-control/SegmentedControl.test.tsx +64 -0
  145. package/src/components/segmented-control/SegmentedControl.tsx +69 -15
  146. package/src/components/stat-band/StatBand.test.tsx +26 -0
  147. package/src/components/stat-band/StatBand.tsx +52 -7
  148. package/src/index.ts +1 -0
  149. package/src/manifests/accordion.manifest.json +1 -1
  150. package/src/manifests/alert.manifest.json +1 -1
  151. package/src/manifests/announcement-bar.manifest.json +1 -1
  152. package/src/manifests/app-shell.manifest.json +1 -1
  153. package/src/manifests/applied-filters.manifest.json +1 -1
  154. package/src/manifests/article-card.manifest.json +1 -1
  155. package/src/manifests/auth-layout.manifest.json +1 -1
  156. package/src/manifests/autocomplete.manifest.json +1 -1
  157. package/src/manifests/avatar.manifest.json +1 -1
  158. package/src/manifests/badge.manifest.json +1 -1
  159. package/src/manifests/block.manifest.json +1 -1
  160. package/src/manifests/bottom-nav.manifest.json +1 -1
  161. package/src/manifests/breadcrumb.manifest.json +1 -1
  162. package/src/manifests/button-group.manifest.json +1 -1
  163. package/src/manifests/button.manifest.json +1 -1
  164. package/src/manifests/calendar.manifest.json +1 -1
  165. package/src/manifests/card.manifest.json +1 -1
  166. package/src/manifests/checkbox.manifest.json +1 -1
  167. package/src/manifests/comparison-table.manifest.json +1 -1
  168. package/src/manifests/confirm-dialog.manifest.json +1 -1
  169. package/src/manifests/contact-strip.manifest.json +1 -1
  170. package/src/manifests/container.manifest.json +1 -1
  171. package/src/manifests/cover-image.manifest.json +151 -0
  172. package/src/manifests/cta-section.manifest.json +1 -1
  173. package/src/manifests/data-table.manifest.json +1 -1
  174. package/src/manifests/date-picker-popover.manifest.json +1 -1
  175. package/src/manifests/date-picker.manifest.json +1 -1
  176. package/src/manifests/date-range-picker.manifest.json +1 -1
  177. package/src/manifests/deal-card.manifest.json +1 -1
  178. package/src/manifests/dialog.manifest.json +1 -1
  179. package/src/manifests/document-card.manifest.json +1 -1
  180. package/src/manifests/drawer.manifest.json +1 -1
  181. package/src/manifests/empty-state.manifest.json +45 -1
  182. package/src/manifests/entity-card.manifest.json +1 -1
  183. package/src/manifests/feature-grid.manifest.json +1 -1
  184. package/src/manifests/feature-row.manifest.json +1 -1
  185. package/src/manifests/fieldset.manifest.json +1 -1
  186. package/src/manifests/file-upload.manifest.json +1 -1
  187. package/src/manifests/filter-bar.manifest.json +1 -1
  188. package/src/manifests/filter-chips.manifest.json +1 -1
  189. package/src/manifests/filter-panel.manifest.json +1 -1
  190. package/src/manifests/flex.manifest.json +1 -1
  191. package/src/manifests/form-field.manifest.json +1 -1
  192. package/src/manifests/form-layout.manifest.json +1 -1
  193. package/src/manifests/form.manifest.json +1 -1
  194. package/src/manifests/grid.manifest.json +1 -1
  195. package/src/manifests/heading.manifest.json +1 -1
  196. package/src/manifests/hero.manifest.json +1 -1
  197. package/src/manifests/image.manifest.json +7 -1
  198. package/src/manifests/input-group.manifest.json +1 -1
  199. package/src/manifests/input.manifest.json +1 -1
  200. package/src/manifests/label.manifest.json +1 -1
  201. package/src/manifests/link-tabs.manifest.json +1 -1
  202. package/src/manifests/link.manifest.json +1 -1
  203. package/src/manifests/list.manifest.json +1 -1
  204. package/src/manifests/load-more.manifest.json +1 -1
  205. package/src/manifests/logo-cloud.manifest.json +1 -1
  206. package/src/manifests/menu.manifest.json +1 -1
  207. package/src/manifests/metric-card.manifest.json +1 -1
  208. package/src/manifests/multi-select.manifest.json +1 -1
  209. package/src/manifests/newsletter.manifest.json +1 -1
  210. package/src/manifests/page-header.manifest.json +1 -1
  211. package/src/manifests/pagination.manifest.json +1 -1
  212. package/src/manifests/password-input.manifest.json +1 -1
  213. package/src/manifests/popover.manifest.json +1 -1
  214. package/src/manifests/process-steps.manifest.json +1 -1
  215. package/src/manifests/progress.manifest.json +1 -1
  216. package/src/manifests/prose.manifest.json +1 -1
  217. package/src/manifests/radio.manifest.json +1 -1
  218. package/src/manifests/range-slider.manifest.json +1 -1
  219. package/src/manifests/search.manifest.json +1 -1
  220. package/src/manifests/section-heading.manifest.json +1 -1
  221. package/src/manifests/section.manifest.json +1 -1
  222. package/src/manifests/segmented-control.manifest.json +29 -2
  223. package/src/manifests/select-menu.manifest.json +1 -1
  224. package/src/manifests/select.manifest.json +1 -1
  225. package/src/manifests/separator.manifest.json +1 -1
  226. package/src/manifests/site-footer.manifest.json +1 -1
  227. package/src/manifests/site-header.manifest.json +1 -1
  228. package/src/manifests/skeleton.manifest.json +1 -1
  229. package/src/manifests/spinner.manifest.json +1 -1
  230. package/src/manifests/stat-band.manifest.json +23 -1
  231. package/src/manifests/stepper.manifest.json +1 -1
  232. package/src/manifests/switch.manifest.json +1 -1
  233. package/src/manifests/table-card.manifest.json +1 -1
  234. package/src/manifests/table-of-contents.manifest.json +1 -1
  235. package/src/manifests/table.manifest.json +1 -1
  236. package/src/manifests/tabs.manifest.json +1 -1
  237. package/src/manifests/testimonial.manifest.json +1 -1
  238. package/src/manifests/text.manifest.json +1 -1
  239. package/src/manifests/textarea.manifest.json +1 -1
  240. package/src/manifests/theme-toggle.manifest.json +1 -1
  241. package/src/manifests/time-picker.manifest.json +1 -1
  242. package/src/manifests/timeline.manifest.json +1 -1
  243. package/src/manifests/toast.manifest.json +1 -1
  244. package/src/manifests/tombstone-card.manifest.json +1 -1
  245. package/src/manifests/tooltip.manifest.json +1 -1
  246. package/src/styles.css +5 -0
@@ -0,0 +1,88 @@
1
+ import { fireEvent, render, screen } from '@testing-library/react';
2
+ import { renderToString } from 'react-dom/server';
3
+ import { axe } from 'jest-axe';
4
+ import { describe, expect, it } from 'vitest';
5
+ import { CoverImage } from './CoverImage';
6
+
7
+ describe('CoverImage', () => {
8
+ it('renders the image inside an aspect-ratio box', () => {
9
+ render(<CoverImage src="/cover.jpg" alt="Fall Classic" />);
10
+ const img = screen.getByRole('img', { name: 'Fall Classic' });
11
+ expect(img).toHaveAttribute('src', '/cover.jpg');
12
+ expect(img.parentElement).toHaveClass('aspect-video', 'overflow-hidden');
13
+ expect(img).toHaveClass('object-cover');
14
+ });
15
+
16
+ it('supports aspect presets and custom ratios', () => {
17
+ const { container, rerender } = render(
18
+ <CoverImage src="/a.jpg" alt="A" aspect="square" />
19
+ );
20
+ expect(container.firstElementChild).toHaveClass('aspect-square');
21
+ rerender(<CoverImage src="/a.jpg" alt="A" aspect="16/10" />);
22
+ expect((container.firstElementChild as HTMLElement).style.aspectRatio).toBe('16 / 10');
23
+ });
24
+
25
+ it('renders the seeded gradient fallback when src is absent', () => {
26
+ const { container } = render(<CoverImage alt="No art" seed="entity-42" />);
27
+ expect(screen.queryByRole('img')).not.toBeInTheDocument();
28
+ const fallback = container.querySelector('[style*="linear-gradient"]');
29
+ expect(fallback).not.toBeNull();
30
+ });
31
+
32
+ it('picks a stable gradient per seed', () => {
33
+ const a = render(<CoverImage alt="A" seed="same" />).container.querySelector('[style*="linear-gradient"]') as HTMLElement;
34
+ const b = render(<CoverImage alt="B" seed="same" />).container.querySelector('[style*="linear-gradient"]') as HTMLElement;
35
+ const c = render(<CoverImage alt="C" seed="other" />).container.querySelector('[style*="linear-gradient"]') as HTMLElement;
36
+ expect(a.style.backgroundImage).toBe(b.style.backgroundImage);
37
+ expect(a.style.backgroundImage).toContain('linear-gradient');
38
+ // different seeds may collide by chance; assert determinism only for same seed
39
+ expect(c.style.backgroundImage).toContain('linear-gradient');
40
+ });
41
+
42
+ it('degrades a broken image to the fallback gradient', () => {
43
+ render(<CoverImage src="/broken.jpg" alt="Event" seed="x" />);
44
+ fireEvent.error(screen.getByRole('img', { name: 'Event' }));
45
+ expect(screen.queryByRole('img')).not.toBeInTheDocument();
46
+ });
47
+
48
+ it('honors priority and sizes on the image', () => {
49
+ render(<CoverImage src="/hero.jpg" alt="Hero" priority sizes="100vw" />);
50
+ const img = screen.getByRole('img', { name: 'Hero' });
51
+ expect(img).toHaveAttribute('loading', 'eager');
52
+ expect(img).toHaveAttribute('fetchpriority', 'high');
53
+ expect(img).toHaveAttribute('sizes', '100vw');
54
+ });
55
+
56
+ it('renders a custom fallback and mark', () => {
57
+ render(
58
+ <CoverImage
59
+ alt="Event"
60
+ mark={<svg data-testid="mark" />}
61
+ fallback={<div data-testid="custom">Custom</div>}
62
+ />
63
+ );
64
+ expect(screen.getByTestId('custom')).toBeInTheDocument();
65
+ expect(screen.queryByTestId('mark')).not.toBeInTheDocument();
66
+ });
67
+
68
+ it('renders the mark on the default gradient', () => {
69
+ render(<CoverImage alt="Event" mark={<svg data-testid="mark" />} />);
70
+ expect(screen.getByTestId('mark')).toBeInTheDocument();
71
+ });
72
+
73
+ it('keeps the aspect box in server-rendered markup', () => {
74
+ const html = renderToString(<CoverImage src="/c.jpg" alt="Cover" />);
75
+ expect(html).toContain('aspect-video');
76
+ expect(html).toContain('alt="Cover"');
77
+ });
78
+
79
+ it('has no accessibility violations', async () => {
80
+ const { container } = render(
81
+ <>
82
+ <CoverImage src="/c.jpg" alt="With image" />
83
+ <CoverImage alt="Placeholder" seed="s" />
84
+ </>
85
+ );
86
+ expect(await axe(container)).toHaveNoViolations();
87
+ });
88
+ });
@@ -0,0 +1,109 @@
1
+ import * as React from 'react';
2
+ import { cn } from '../../utils/cn';
3
+ import { Image } from '../image/Image';
4
+
5
+ export type CoverImageProps = {
6
+ /** Cover URL. When absent or broken, the seeded fallback renders instead. */
7
+ src?: string | null;
8
+ /** Required: describes the image for assistive tech. */
9
+ alt: string;
10
+ /**
11
+ * Aspect ratio: 'video' (16:9), 'square' (1:1), 'wide' (2:1), or any CSS
12
+ * aspect-ratio value such as '16/9' or '4/3'.
13
+ */
14
+ aspect?: 'video' | 'square' | 'wide' | string;
15
+ /** Stable key selecting the fallback gradient (e.g. entity slug). */
16
+ seed?: string;
17
+ /** Load eagerly and fetch at high priority for the LCP image. */
18
+ priority?: boolean;
19
+ /** Responsive `sizes` hint forwarded to the image. */
20
+ sizes?: string;
21
+ /** Custom fallback content; defaults to the seed-derived gradient. */
22
+ fallback?: React.ReactNode;
23
+ /** Optional mark centered on the default gradient (icon, monogram). */
24
+ mark?: React.ReactNode;
25
+ className?: string;
26
+ };
27
+
28
+ const aspectClasses = {
29
+ video: 'aspect-video',
30
+ square: 'aspect-square',
31
+ wide: 'aspect-[2/1]',
32
+ } as const;
33
+
34
+ // Token-derived gradients: every entry uses theme variables so covers stay on
35
+ // the active palette in light and dark mode and pass the token audit.
36
+ const gradients = [
37
+ 'linear-gradient(135deg, hsl(var(--primary) / 0.18), hsl(var(--info) / 0.10))',
38
+ 'linear-gradient(135deg, hsl(var(--info) / 0.16), hsl(var(--primary) / 0.08))',
39
+ 'linear-gradient(135deg, hsl(var(--warning) / 0.14), hsl(var(--primary) / 0.10))',
40
+ 'linear-gradient(135deg, hsl(var(--success) / 0.14), hsl(var(--info) / 0.08))',
41
+ ] as const;
42
+
43
+ function hashSeed(seed: string): number {
44
+ let hash = 0;
45
+ for (let i = 0; i < seed.length; i += 1) {
46
+ hash = (hash * 31 + seed.charCodeAt(i)) >>> 0;
47
+ }
48
+ return hash;
49
+ }
50
+
51
+ function seededGradient(seed: string): React.CSSProperties {
52
+ return { backgroundImage: gradients[hashSeed(seed) % gradients.length] };
53
+ }
54
+
55
+ /**
56
+ * Media cover with a deterministic placeholder: a fixed-aspect box that shows
57
+ * the image when present and a seed-derived token gradient (plus optional
58
+ * mark) when the entity has no art. Broken images degrade to the same
59
+ * gradient through Image's fallback chain, so imageless grids still look
60
+ * intentional.
61
+ */
62
+ export function CoverImage({
63
+ src,
64
+ alt,
65
+ aspect = 'video',
66
+ seed,
67
+ priority = false,
68
+ sizes,
69
+ fallback,
70
+ mark,
71
+ className,
72
+ }: CoverImageProps) {
73
+ const preset = aspectClasses[aspect as keyof typeof aspectClasses];
74
+ const aspectStyle =
75
+ preset === undefined && typeof aspect === 'string' ? { aspectRatio: aspect } : undefined;
76
+
77
+ const fallbackNode =
78
+ fallback ?? (
79
+ <div
80
+ className="flex h-full w-full items-center justify-center"
81
+ style={seededGradient(seed ?? alt)}
82
+ aria-hidden="true"
83
+ >
84
+ {mark && <span className="text-muted-foreground [&_svg]:size-8">{mark}</span>}
85
+ </div>
86
+ );
87
+
88
+ return (
89
+ <div
90
+ className={cn('relative overflow-hidden rounded-lg bg-muted', preset, className)}
91
+ style={aspectStyle}
92
+ >
93
+ {src ? (
94
+ <Image
95
+ src={src}
96
+ alt={alt}
97
+ priority={priority}
98
+ sizes={sizes}
99
+ fallback={fallbackNode}
100
+ className="h-full w-full object-cover"
101
+ />
102
+ ) : (
103
+ fallbackNode
104
+ )}
105
+ </div>
106
+ );
107
+ }
108
+
109
+ CoverImage.displayName = 'CoverImage';
@@ -0,0 +1 @@
1
+ export { CoverImage, type CoverImageProps } from './CoverImage';
@@ -64,4 +64,37 @@ describe('action object form', () => {
64
64
  render(<EmptyState title="No results" action={<button type="button">Custom</button>} />);
65
65
  expect(screen.getByRole('button', { name: 'Custom' })).toBeInTheDocument();
66
66
  });
67
+
68
+ it('routes action hrefs through linkComponent and linkHrefProp', () => {
69
+ const RouterLink = ({ to, children, ...rest }: { to: string; children: React.ReactNode }) => (
70
+ <a href={to} data-to={to} {...rest}>{children}</a>
71
+ );
72
+ render(
73
+ <EmptyState
74
+ title="No results"
75
+ linkComponent={RouterLink}
76
+ linkHrefProp="to"
77
+ action={{ label: 'Create one', href: '/new' }}
78
+ />
79
+ );
80
+ expect(screen.getByRole('link', { name: 'Create one' })).toHaveAttribute('data-to', '/new');
81
+ });
82
+ });
83
+
84
+ describe('align and tone', () => {
85
+ it('renders a left-aligned tinted panel', () => {
86
+ const { container } = render(
87
+ <EmptyState align="start" tone="panel" title="No matches" description="Try widening the filters." />
88
+ );
89
+ const root = container.firstChild as HTMLElement;
90
+ expect(root).toHaveClass('items-start', 'text-left', 'bg-muted', 'border-border');
91
+ expect(root).not.toHaveClass('border-dashed');
92
+ });
93
+
94
+ it('keeps the centered dashed default', () => {
95
+ const { container } = render(<EmptyState title="Empty" />);
96
+ const root = container.firstChild as HTMLElement;
97
+ expect(root).toHaveClass('items-center', 'text-center', 'border-dashed');
98
+ expect(root).not.toHaveClass('bg-muted');
99
+ });
67
100
  });
@@ -26,6 +26,18 @@ export type EmptyStateProps = React.HTMLAttributes<HTMLDivElement> & {
26
26
  titleAs?: 'p' | 'h2' | 'h3' | 'h4';
27
27
  /** Compact padding for use inside panels and table bodies. */
28
28
  size?: 'sm' | 'md';
29
+ /** Horizontal alignment of content and actions. Default 'center'. */
30
+ align?: 'center' | 'start';
31
+ /**
32
+ * Surface treatment. 'panel' renders a tinted, solid-bordered surface for
33
+ * content pages (typically paired with align="start"); 'plain' keeps the
34
+ * default dashed outline. Default 'plain'.
35
+ */
36
+ tone?: 'plain' | 'panel';
37
+ /** Custom link element for action hrefs (Next Link, react-router Link). */
38
+ linkComponent?: React.ElementType;
39
+ /** Prop used to pass the destination to `linkComponent`. */
40
+ linkHrefProp?: 'href' | 'to';
29
41
  };
30
42
 
31
43
  function isActionObject(value: unknown): value is EmptyStateAction {
@@ -38,13 +50,19 @@ function isActionObject(value: unknown): value is EmptyStateAction {
38
50
  }
39
51
 
40
52
  /** Normalizes the node and object forms into a single element. */
41
- function renderAction(action: React.ReactNode | EmptyStateAction | undefined): React.ReactNode {
53
+ function renderAction(
54
+ action: React.ReactNode | EmptyStateAction | undefined,
55
+ linkComponent?: React.ElementType,
56
+ linkHrefProp: 'href' | 'to' = 'href'
57
+ ): React.ReactNode {
42
58
  if (!isActionObject(action)) return action;
43
59
  const { label, onClick, href, variant } = action;
44
60
  if (href) {
61
+ const LinkEl = linkComponent ?? 'a';
62
+ const destination = linkHrefProp === 'to' ? { to: href } : { href };
45
63
  return (
46
64
  <Button variant={variant} asChild>
47
- <a href={href}>{label}</a>
65
+ <LinkEl {...destination}>{label}</LinkEl>
48
66
  </Button>
49
67
  );
50
68
  }
@@ -70,18 +88,28 @@ export const EmptyState = React.forwardRef<HTMLDivElement, EmptyStateProps>(func
70
88
  secondaryAction,
71
89
  titleAs: Title = 'p',
72
90
  size = 'md',
91
+ align = 'center',
92
+ tone = 'plain',
93
+ linkComponent,
94
+ linkHrefProp = 'href',
73
95
  className,
74
96
  children,
75
97
  ...props
76
98
  },
77
99
  ref
78
100
  ) {
79
- const primaryAction = renderAction(action) ?? actions;
101
+ const primaryAction = renderAction(action, linkComponent, linkHrefProp) ?? actions;
102
+ const start = align === 'start';
80
103
  return (
81
104
  <div
82
105
  ref={ref}
83
106
  className={cn(
84
- 'flex flex-col items-center justify-center rounded-lg border border-dashed border-border text-center',
107
+ 'flex flex-col rounded-lg text-center',
108
+ start ? 'items-start text-left' : 'items-center text-center',
109
+ 'justify-center',
110
+ tone === 'panel'
111
+ ? 'border border-border bg-muted'
112
+ : 'border border-dashed border-border',
85
113
  size === 'md' ? 'gap-3 px-6 py-12' : 'gap-2 px-4 py-6',
86
114
  className
87
115
  )}
@@ -89,10 +117,10 @@ export const EmptyState = React.forwardRef<HTMLDivElement, EmptyStateProps>(func
89
117
  >
90
118
  {icon && <div className="text-muted-foreground [&_svg]:size-8">{icon}</div>}
91
119
  <Title className={cn('font-semibold', size === 'md' ? 'text-base' : 'text-sm')}>{title}</Title>
92
- {description && <p className="max-w-sm text-sm text-muted-foreground">{description}</p>}
120
+ {description && <p className={cn('max-w-sm text-sm text-muted-foreground', start && 'max-w-md')}>{description}</p>}
93
121
  {children}
94
122
  {(primaryAction || secondaryAction) && (
95
- <div className="mt-1 flex flex-wrap items-center justify-center gap-2">
123
+ <div className={cn('mt-1 flex flex-wrap items-center gap-2', start ? 'justify-start' : 'justify-center')}>
96
124
  {primaryAction}
97
125
  {secondaryAction}
98
126
  </div>
@@ -22,6 +22,8 @@ export type ImageProps = {
22
22
  className?: string;
23
23
  /** Classes for the image when a consumer wants to keep them separate. */
24
24
  imgClassName?: string;
25
+ /** Responsive `sizes` hint for the browser's source selection. */
26
+ sizes?: string;
25
27
  style?: React.CSSProperties;
26
28
  };
27
29
 
@@ -43,6 +45,7 @@ export function Image({
43
45
  height = 630,
44
46
  className,
45
47
  imgClassName,
48
+ sizes,
46
49
  style,
47
50
  }: ImageProps) {
48
51
  const [stage, setStage] = React.useState<0 | 1 | 2>(0);
@@ -68,6 +71,7 @@ export function Image({
68
71
  loading={priority ? 'eager' : 'lazy'}
69
72
  fetchPriority={priority ? 'high' : 'auto'}
70
73
  decoding="async"
74
+ sizes={sizes}
71
75
  className={cn(className, imgClassName)}
72
76
  style={style}
73
77
  onError={onError}
@@ -59,4 +59,68 @@ describe('SegmentedControl', () => {
59
59
  const { container } = render(<ControlledExample />);
60
60
  expect(await axe(container)).toHaveNoViolations();
61
61
  });
62
+
63
+ it('renders options with href as links and marks the active segment', () => {
64
+ render(
65
+ <SegmentedControl
66
+ aria-label="View"
67
+ value="grid"
68
+ options={[
69
+ { value: 'list', label: 'List', href: '/items?view=list' },
70
+ { value: 'grid', label: 'Grid', href: '/items?view=grid' },
71
+ ]}
72
+ />
73
+ );
74
+ expect(screen.getByRole('link', { name: 'List' })).toHaveAttribute('href', '/items?view=list');
75
+ expect(screen.queryByRole('link', { name: 'Grid' })).not.toBeInTheDocument();
76
+ expect(screen.getByText('Grid').closest('[aria-current]')).toHaveAttribute('aria-current', 'page');
77
+ });
78
+
79
+ it('honors linkComponent and linkHrefProp', () => {
80
+ const RouterLink = ({ to, children, ...rest }: { to: string; children: React.ReactNode }) => (
81
+ <a href={to} data-to={to} {...rest}>{children}</a>
82
+ );
83
+ render(
84
+ <SegmentedControl
85
+ aria-label="View"
86
+ value="list"
87
+ linkComponent={RouterLink}
88
+ linkHrefProp="to"
89
+ options={[
90
+ { value: 'list', label: 'List', href: '/items?view=list' },
91
+ { value: 'grid', label: 'Grid', href: '/items?view=grid' },
92
+ ]}
93
+ />
94
+ );
95
+ expect(screen.getByRole('link', { name: 'Grid' })).toHaveAttribute('data-to', '/items?view=grid');
96
+ });
97
+
98
+ it('renders a disabled link option as a non-interactive marker', () => {
99
+ render(
100
+ <SegmentedControl
101
+ aria-label="View"
102
+ value="list"
103
+ options={[
104
+ { value: 'list', label: 'List', href: '/items?view=list' },
105
+ { value: 'grid', label: 'Grid', href: '/items?view=grid', disabled: true },
106
+ ]}
107
+ />
108
+ );
109
+ expect(screen.queryByRole('link', { name: 'Grid' })).not.toBeInTheDocument();
110
+ expect(screen.getByText('Grid').closest('[aria-disabled]')).toHaveAttribute('aria-disabled', 'true');
111
+ });
112
+
113
+ it('has no accessibility violations in link mode', async () => {
114
+ const { container } = render(
115
+ <SegmentedControl
116
+ aria-label="View"
117
+ value="grid"
118
+ options={[
119
+ { value: 'list', label: 'List', href: '/items?view=list' },
120
+ { value: 'grid', label: 'Grid', href: '/items?view=grid' },
121
+ ]}
122
+ />
123
+ );
124
+ expect(await axe(container)).toHaveNoViolations();
125
+ });
62
126
  });
@@ -9,6 +9,13 @@ export type SegmentedOption = {
9
9
  /** Optional leading icon. */
10
10
  icon?: React.ReactNode;
11
11
  disabled?: boolean;
12
+ /**
13
+ * Destination URL. When set the segment renders as a link instead of a
14
+ * button - use this for view switches that must survive refresh and work
15
+ * without JavaScript. The active segment renders as a non-link
16
+ * `aria-current="page"` marker.
17
+ */
18
+ href?: string;
12
19
  };
13
20
 
14
21
  export type SegmentedControlProps = Omit<React.HTMLAttributes<HTMLDivElement>, 'onChange'> & {
@@ -26,6 +33,10 @@ export type SegmentedControlProps = Omit<React.HTMLAttributes<HTMLDivElement>, '
26
33
  size?: 'sm' | 'md' | 'lg';
27
34
  /** Stretch segments to fill the container width. */
28
35
  fullWidth?: boolean;
36
+ /** Custom link element for routers (Next Link, react-router Link). */
37
+ linkComponent?: React.ElementType;
38
+ /** Prop used to pass the destination to `linkComponent`. */
39
+ linkHrefProp?: 'href' | 'to';
29
40
  };
30
41
 
31
42
  const sizeClasses = {
@@ -39,6 +50,12 @@ const sizeClasses = {
39
50
  * semantics and arrow-key navigation; multiple-select uses pressed buttons.
40
51
  * Use it for filters such as All / Investors / Advisors, not for tab panels
41
52
  * (use Tabs when each segment owns a tabpanel).
53
+ *
54
+ * Give an option an `href` to render it as a real link - the pattern for
55
+ * view switches that must survive refresh, work without JavaScript, and stay
56
+ * cacheable. The active segment then renders as a non-link
57
+ * `aria-current="page"` marker and link segments use normal tab navigation
58
+ * instead of roving tabindex. Link mode is intended for single-select.
42
59
  */
43
60
  export const SegmentedControl = React.forwardRef<HTMLDivElement, SegmentedControlProps>(
44
61
  function SegmentedControl(
@@ -50,6 +67,8 @@ export const SegmentedControl = React.forwardRef<HTMLDivElement, SegmentedContro
50
67
  multiple = false,
51
68
  size = 'md',
52
69
  fullWidth = false,
70
+ linkComponent,
71
+ linkHrefProp = 'href',
53
72
  className,
54
73
  'aria-label': ariaLabel = 'Segmented control',
55
74
  ...props
@@ -75,6 +94,10 @@ export const SegmentedControl = React.forwardRef<HTMLDivElement, SegmentedContro
75
94
  ? current
76
95
  : '';
77
96
 
97
+ const linkMode = options.some((option) => option.href !== undefined);
98
+ const LinkEl = linkComponent ?? 'a';
99
+ const destination = (href: string) => (linkHrefProp === 'to' ? { to: href } : { href });
100
+
78
101
  const refs = React.useRef<Array<HTMLButtonElement | null>>([]);
79
102
 
80
103
  const commit = (next: string | string[]) => {
@@ -137,7 +160,7 @@ export const SegmentedControl = React.forwardRef<HTMLDivElement, SegmentedContro
137
160
  return (
138
161
  <div
139
162
  ref={ref}
140
- role={multiple ? 'group' : 'radiogroup'}
163
+ role={multiple || linkMode ? 'group' : 'radiogroup'}
141
164
  aria-label={ariaLabel}
142
165
  className={cn(
143
166
  'inline-flex items-center gap-1 rounded-lg border border-border bg-muted p-1',
@@ -152,6 +175,46 @@ export const SegmentedControl = React.forwardRef<HTMLDivElement, SegmentedContro
152
175
  : selected === option.value;
153
176
  const firstEnabled = options.findIndex((entry) => !entry.disabled);
154
177
  const focusable = multiple || active || (!selected && index === firstEnabled);
178
+ const segmentClass = cn(
179
+ 'inline-flex items-center justify-center gap-2 rounded-md font-medium transition-colors',
180
+ 'focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 focus-visible:ring-offset-background',
181
+ 'disabled:pointer-events-none disabled:opacity-50',
182
+ sizeClasses[size],
183
+ fullWidth && 'flex-1',
184
+ active
185
+ ? 'bg-background text-foreground shadow-sm'
186
+ : 'text-muted-foreground hover:text-foreground'
187
+ );
188
+ const segmentContent = (
189
+ <>
190
+ {option.icon && <span className="shrink-0 [&_svg]:size-4">{option.icon}</span>}
191
+ <span className="truncate">{option.label}</span>
192
+ </>
193
+ );
194
+
195
+ if (option.href !== undefined) {
196
+ if (option.disabled || active) {
197
+ return (
198
+ <span
199
+ key={option.value}
200
+ aria-current={active ? 'page' : undefined}
201
+ aria-disabled={option.disabled || undefined}
202
+ className={cn(segmentClass, option.disabled && 'opacity-50')}
203
+ >
204
+ {segmentContent}
205
+ </span>
206
+ );
207
+ }
208
+ return (
209
+ <LinkEl
210
+ key={option.value}
211
+ {...destination(option.href)}
212
+ className={segmentClass}
213
+ >
214
+ {segmentContent}
215
+ </LinkEl>
216
+ );
217
+ }
155
218
 
156
219
  return (
157
220
  <button
@@ -160,26 +223,17 @@ export const SegmentedControl = React.forwardRef<HTMLDivElement, SegmentedContro
160
223
  refs.current[index] = node;
161
224
  }}
162
225
  type="button"
163
- role={multiple ? undefined : 'radio'}
164
- aria-checked={multiple ? undefined : active}
226
+ role={multiple || linkMode ? undefined : 'radio'}
227
+ aria-checked={multiple || linkMode ? undefined : active}
165
228
  aria-pressed={multiple ? active : undefined}
229
+ aria-current={linkMode && active ? 'page' : undefined}
166
230
  disabled={option.disabled}
167
231
  tabIndex={focusable ? 0 : -1}
168
232
  onClick={() => select(option)}
169
233
  onKeyDown={onKeyDown}
170
- className={cn(
171
- 'inline-flex items-center justify-center gap-2 rounded-md font-medium transition-colors',
172
- 'focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 focus-visible:ring-offset-background',
173
- 'disabled:pointer-events-none disabled:opacity-50',
174
- sizeClasses[size],
175
- fullWidth && 'flex-1',
176
- active
177
- ? 'bg-background text-foreground shadow-sm'
178
- : 'text-muted-foreground hover:text-foreground'
179
- )}
234
+ className={segmentClass}
180
235
  >
181
- {option.icon && <span className="shrink-0 [&_svg]:size-4">{option.icon}</span>}
182
- <span className="truncate">{option.label}</span>
236
+ {segmentContent}
183
237
  </button>
184
238
  );
185
239
  })}
@@ -35,8 +35,34 @@ describe('StatBand', () => {
35
35
  expect(screen.getByText('One').parentElement).toHaveClass('items-start', 'text-left');
36
36
  });
37
37
 
38
+ it('renders a bordered panel variant with dense cells', () => {
39
+ const { container } = render(
40
+ <StatBand
41
+ variant="panel"
42
+ align="left"
43
+ valueClassName="font-mono"
44
+ items={[
45
+ { value: '3', label: 'Deadlines', hint: 'closing soon' },
46
+ { value: '12', label: 'Events' },
47
+ ]}
48
+ />
49
+ );
50
+ const dl = container.firstElementChild as HTMLElement;
51
+ expect(dl).toHaveClass('border', 'border-border', 'rounded-lg', 'divide-y', 'sm:divide-x');
52
+ expect(screen.getByText('3')).toHaveClass('font-mono', 'text-xl');
53
+ const label = screen.getByText('Deadlines');
54
+ expect(label).toHaveClass('uppercase');
55
+ });
56
+
38
57
  it('has no accessibility violations', async () => {
39
58
  const { container } = render(<StatBand items={[{ value: '10+', label: 'Years' }]} />);
40
59
  expect(await axe(container)).toHaveNoViolations();
41
60
  });
61
+
62
+ it('has no accessibility violations in panel variant', async () => {
63
+ const { container } = render(
64
+ <StatBand variant="panel" items={[{ value: '10+', label: 'Years', hint: 'and counting' }]} />
65
+ );
66
+ expect(await axe(container)).toHaveNoViolations();
67
+ });
42
68
  });