@slipstream-ui/core 0.11.8 → 0.11.10

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 (272) hide show
  1. package/dist/index.d.mts +176 -9
  2. package/dist/index.d.ts +176 -9
  3. package/dist/index.js +1297 -905
  4. package/dist/index.js.map +1 -1
  5. package/dist/index.mjs +1294 -905
  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 +4 -2
  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 +1 -1
  30. package/dist/manifests/cta-section.manifest.json +1 -1
  31. package/dist/manifests/data-table.manifest.json +22 -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 +1 -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 +1 -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-toolbar.manifest.json +120 -0
  62. package/dist/manifests/list.manifest.json +1 -1
  63. package/dist/manifests/load-more.manifest.json +1 -1
  64. package/dist/manifests/logo-cloud.manifest.json +1 -1
  65. package/dist/manifests/media-card.manifest.json +161 -0
  66. package/dist/manifests/menu.manifest.json +1 -1
  67. package/dist/manifests/metric-card.manifest.json +1 -1
  68. package/dist/manifests/month-schedule.manifest.json +217 -0
  69. package/dist/manifests/multi-select.manifest.json +1 -1
  70. package/dist/manifests/newsletter.manifest.json +1 -1
  71. package/dist/manifests/page-header.manifest.json +1 -1
  72. package/dist/manifests/pagination.manifest.json +1 -1
  73. package/dist/manifests/password-input.manifest.json +1 -1
  74. package/dist/manifests/popover.manifest.json +1 -1
  75. package/dist/manifests/process-steps.manifest.json +1 -1
  76. package/dist/manifests/progress.manifest.json +1 -1
  77. package/dist/manifests/prose.manifest.json +1 -1
  78. package/dist/manifests/radio.manifest.json +1 -1
  79. package/dist/manifests/range-slider.manifest.json +1 -1
  80. package/dist/manifests/search.manifest.json +1 -1
  81. package/dist/manifests/section-heading.manifest.json +1 -1
  82. package/dist/manifests/section.manifest.json +1 -1
  83. package/dist/manifests/segmented-control.manifest.json +4 -4
  84. package/dist/manifests/select-menu.manifest.json +1 -1
  85. package/dist/manifests/select.manifest.json +1 -1
  86. package/dist/manifests/separator.manifest.json +1 -1
  87. package/dist/manifests/site-footer.manifest.json +1 -1
  88. package/dist/manifests/site-header.manifest.json +1 -1
  89. package/dist/manifests/skeleton.manifest.json +1 -1
  90. package/dist/manifests/spinner.manifest.json +1 -1
  91. package/dist/manifests/stat-band.manifest.json +1 -1
  92. package/dist/manifests/stepper.manifest.json +1 -1
  93. package/dist/manifests/switch.manifest.json +1 -1
  94. package/dist/manifests/table-card.manifest.json +1 -1
  95. package/dist/manifests/table-of-contents.manifest.json +1 -1
  96. package/dist/manifests/table.manifest.json +1 -1
  97. package/dist/manifests/tabs.manifest.json +1 -1
  98. package/dist/manifests/testimonial.manifest.json +1 -1
  99. package/dist/manifests/text.manifest.json +1 -1
  100. package/dist/manifests/textarea.manifest.json +1 -1
  101. package/dist/manifests/theme-toggle.manifest.json +1 -1
  102. package/dist/manifests/time-picker.manifest.json +1 -1
  103. package/dist/manifests/timeline.manifest.json +1 -1
  104. package/dist/manifests/toast.manifest.json +1 -1
  105. package/dist/manifests/tombstone-card.manifest.json +1 -1
  106. package/dist/manifests/tooltip.manifest.json +1 -1
  107. package/dist/src/components/button/Button.d.ts +2 -2
  108. package/dist/src/components/button/Button.js +1 -0
  109. package/dist/src/components/button/Button.js.map +1 -1
  110. package/dist/src/components/button/Button.mjs +1 -0
  111. package/dist/src/components/button/Button.mjs.map +1 -1
  112. package/dist/src/components/data-table/DataTable.d.ts +12 -1
  113. package/dist/src/components/data-table/DataTable.js +189 -112
  114. package/dist/src/components/data-table/DataTable.js.map +1 -1
  115. package/dist/src/components/data-table/DataTable.mjs +189 -112
  116. package/dist/src/components/data-table/DataTable.mjs.map +1 -1
  117. package/dist/src/components/list-toolbar/ListToolbar.d.ts +25 -0
  118. package/dist/src/components/list-toolbar/ListToolbar.js +68 -0
  119. package/dist/src/components/list-toolbar/ListToolbar.js.map +1 -0
  120. package/dist/src/components/list-toolbar/ListToolbar.mjs +44 -0
  121. package/dist/src/components/list-toolbar/ListToolbar.mjs.map +1 -0
  122. package/dist/src/components/list-toolbar/index.d.ts +1 -0
  123. package/dist/src/components/list-toolbar/index.js +23 -0
  124. package/dist/src/components/list-toolbar/index.js.map +1 -0
  125. package/dist/src/components/list-toolbar/index.mjs +2 -0
  126. package/dist/src/components/list-toolbar/index.mjs.map +1 -0
  127. package/dist/src/components/media-card/MediaCard.d.ts +61 -0
  128. package/dist/src/components/media-card/MediaCard.js +88 -0
  129. package/dist/src/components/media-card/MediaCard.js.map +1 -0
  130. package/dist/src/components/media-card/MediaCard.mjs +54 -0
  131. package/dist/src/components/media-card/MediaCard.mjs.map +1 -0
  132. package/dist/src/components/media-card/index.d.ts +1 -0
  133. package/dist/src/components/media-card/index.js +23 -0
  134. package/dist/src/components/media-card/index.js.map +1 -0
  135. package/dist/src/components/media-card/index.mjs +2 -0
  136. package/dist/src/components/media-card/index.mjs.map +1 -0
  137. package/dist/src/components/month-schedule/MonthSchedule.d.ts +56 -0
  138. package/dist/src/components/month-schedule/MonthSchedule.js +245 -0
  139. package/dist/src/components/month-schedule/MonthSchedule.js.map +1 -0
  140. package/dist/src/components/month-schedule/MonthSchedule.mjs +219 -0
  141. package/dist/src/components/month-schedule/MonthSchedule.mjs.map +1 -0
  142. package/dist/src/components/month-schedule/index.d.ts +1 -0
  143. package/dist/src/components/month-schedule/index.js +23 -0
  144. package/dist/src/components/month-schedule/index.js.map +1 -0
  145. package/dist/src/components/month-schedule/index.mjs +2 -0
  146. package/dist/src/components/month-schedule/index.mjs.map +1 -0
  147. package/dist/src/components/segmented-control/SegmentedControl.d.ts +20 -4
  148. package/dist/src/components/segmented-control/SegmentedControl.js +17 -3
  149. package/dist/src/components/segmented-control/SegmentedControl.js.map +1 -1
  150. package/dist/src/components/segmented-control/SegmentedControl.mjs +17 -3
  151. package/dist/src/components/segmented-control/SegmentedControl.mjs.map +1 -1
  152. package/dist/src/index.d.ts +3 -0
  153. package/dist/styles-full.css +1 -1
  154. package/dist/styles.css +1 -1
  155. package/package.json +3 -3
  156. package/src/components/button/Button.ssr.test.tsx +1 -1
  157. package/src/components/button/Button.test.tsx +6 -0
  158. package/src/components/button/Button.tsx +1 -0
  159. package/src/components/data-table/DataTable.test.tsx +99 -0
  160. package/src/components/data-table/DataTable.tsx +115 -1
  161. package/src/components/list-toolbar/ListToolbar.test.tsx +50 -0
  162. package/src/components/list-toolbar/ListToolbar.tsx +64 -0
  163. package/src/components/list-toolbar/index.ts +1 -0
  164. package/src/components/media-card/MediaCard.test.tsx +97 -0
  165. package/src/components/media-card/MediaCard.tsx +116 -0
  166. package/src/components/media-card/index.ts +1 -0
  167. package/src/components/month-schedule/MonthSchedule.test.tsx +137 -0
  168. package/src/components/month-schedule/MonthSchedule.tsx +332 -0
  169. package/src/components/month-schedule/index.ts +1 -0
  170. package/src/components/segmented-control/SegmentedControl.test.tsx +51 -0
  171. package/src/components/segmented-control/SegmentedControl.tsx +36 -4
  172. package/src/index.ts +3 -0
  173. package/src/manifests/accordion.manifest.json +1 -1
  174. package/src/manifests/alert.manifest.json +1 -1
  175. package/src/manifests/announcement-bar.manifest.json +1 -1
  176. package/src/manifests/app-shell.manifest.json +1 -1
  177. package/src/manifests/applied-filters.manifest.json +1 -1
  178. package/src/manifests/article-card.manifest.json +1 -1
  179. package/src/manifests/auth-layout.manifest.json +1 -1
  180. package/src/manifests/autocomplete.manifest.json +1 -1
  181. package/src/manifests/avatar.manifest.json +1 -1
  182. package/src/manifests/badge.manifest.json +1 -1
  183. package/src/manifests/block.manifest.json +1 -1
  184. package/src/manifests/bottom-nav.manifest.json +1 -1
  185. package/src/manifests/breadcrumb.manifest.json +1 -1
  186. package/src/manifests/button-group.manifest.json +1 -1
  187. package/src/manifests/button.manifest.json +4 -2
  188. package/src/manifests/calendar.manifest.json +1 -1
  189. package/src/manifests/card.manifest.json +1 -1
  190. package/src/manifests/checkbox.manifest.json +1 -1
  191. package/src/manifests/comparison-table.manifest.json +1 -1
  192. package/src/manifests/confirm-dialog.manifest.json +1 -1
  193. package/src/manifests/contact-strip.manifest.json +1 -1
  194. package/src/manifests/container.manifest.json +1 -1
  195. package/src/manifests/cover-image.manifest.json +1 -1
  196. package/src/manifests/cta-section.manifest.json +1 -1
  197. package/src/manifests/data-table.manifest.json +22 -1
  198. package/src/manifests/date-picker-popover.manifest.json +1 -1
  199. package/src/manifests/date-picker.manifest.json +1 -1
  200. package/src/manifests/date-range-picker.manifest.json +1 -1
  201. package/src/manifests/deal-card.manifest.json +1 -1
  202. package/src/manifests/dialog.manifest.json +1 -1
  203. package/src/manifests/document-card.manifest.json +1 -1
  204. package/src/manifests/drawer.manifest.json +1 -1
  205. package/src/manifests/empty-state.manifest.json +1 -1
  206. package/src/manifests/entity-card.manifest.json +1 -1
  207. package/src/manifests/feature-grid.manifest.json +1 -1
  208. package/src/manifests/feature-row.manifest.json +1 -1
  209. package/src/manifests/fieldset.manifest.json +1 -1
  210. package/src/manifests/file-upload.manifest.json +1 -1
  211. package/src/manifests/filter-bar.manifest.json +1 -1
  212. package/src/manifests/filter-chips.manifest.json +1 -1
  213. package/src/manifests/filter-panel.manifest.json +1 -1
  214. package/src/manifests/flex.manifest.json +1 -1
  215. package/src/manifests/form-field.manifest.json +1 -1
  216. package/src/manifests/form-layout.manifest.json +1 -1
  217. package/src/manifests/form.manifest.json +1 -1
  218. package/src/manifests/grid.manifest.json +1 -1
  219. package/src/manifests/heading.manifest.json +1 -1
  220. package/src/manifests/hero.manifest.json +1 -1
  221. package/src/manifests/image.manifest.json +1 -1
  222. package/src/manifests/input-group.manifest.json +1 -1
  223. package/src/manifests/input.manifest.json +1 -1
  224. package/src/manifests/label.manifest.json +1 -1
  225. package/src/manifests/link-tabs.manifest.json +1 -1
  226. package/src/manifests/link.manifest.json +1 -1
  227. package/src/manifests/list-toolbar.manifest.json +120 -0
  228. package/src/manifests/list.manifest.json +1 -1
  229. package/src/manifests/load-more.manifest.json +1 -1
  230. package/src/manifests/logo-cloud.manifest.json +1 -1
  231. package/src/manifests/media-card.manifest.json +161 -0
  232. package/src/manifests/menu.manifest.json +1 -1
  233. package/src/manifests/metric-card.manifest.json +1 -1
  234. package/src/manifests/month-schedule.manifest.json +217 -0
  235. package/src/manifests/multi-select.manifest.json +1 -1
  236. package/src/manifests/newsletter.manifest.json +1 -1
  237. package/src/manifests/page-header.manifest.json +1 -1
  238. package/src/manifests/pagination.manifest.json +1 -1
  239. package/src/manifests/password-input.manifest.json +1 -1
  240. package/src/manifests/popover.manifest.json +1 -1
  241. package/src/manifests/process-steps.manifest.json +1 -1
  242. package/src/manifests/progress.manifest.json +1 -1
  243. package/src/manifests/prose.manifest.json +1 -1
  244. package/src/manifests/radio.manifest.json +1 -1
  245. package/src/manifests/range-slider.manifest.json +1 -1
  246. package/src/manifests/search.manifest.json +1 -1
  247. package/src/manifests/section-heading.manifest.json +1 -1
  248. package/src/manifests/section.manifest.json +1 -1
  249. package/src/manifests/segmented-control.manifest.json +4 -4
  250. package/src/manifests/select-menu.manifest.json +1 -1
  251. package/src/manifests/select.manifest.json +1 -1
  252. package/src/manifests/separator.manifest.json +1 -1
  253. package/src/manifests/site-footer.manifest.json +1 -1
  254. package/src/manifests/site-header.manifest.json +1 -1
  255. package/src/manifests/skeleton.manifest.json +1 -1
  256. package/src/manifests/spinner.manifest.json +1 -1
  257. package/src/manifests/stat-band.manifest.json +1 -1
  258. package/src/manifests/stepper.manifest.json +1 -1
  259. package/src/manifests/switch.manifest.json +1 -1
  260. package/src/manifests/table-card.manifest.json +1 -1
  261. package/src/manifests/table-of-contents.manifest.json +1 -1
  262. package/src/manifests/table.manifest.json +1 -1
  263. package/src/manifests/tabs.manifest.json +1 -1
  264. package/src/manifests/testimonial.manifest.json +1 -1
  265. package/src/manifests/text.manifest.json +1 -1
  266. package/src/manifests/textarea.manifest.json +1 -1
  267. package/src/manifests/theme-toggle.manifest.json +1 -1
  268. package/src/manifests/time-picker.manifest.json +1 -1
  269. package/src/manifests/timeline.manifest.json +1 -1
  270. package/src/manifests/toast.manifest.json +1 -1
  271. package/src/manifests/tombstone-card.manifest.json +1 -1
  272. package/src/manifests/tooltip.manifest.json +1 -1
@@ -0,0 +1,64 @@
1
+ import * as React from 'react';
2
+ import { cn } from '../../utils/cn';
3
+
4
+ export type ListToolbarProps = React.HTMLAttributes<HTMLDivElement> & {
5
+ /** Number of matching results; renders "{count} {countLabel}". */
6
+ count?: number;
7
+ /** Noun for the result count. Default "results". */
8
+ countLabel?: string;
9
+ /** Page/range position text, e.g. "Page 2 of 5" or "Showing 21–40 of 137". */
10
+ position?: React.ReactNode;
11
+ /** Muted note at the end of the summary line, e.g. "Sorted by date, soonest first". */
12
+ note?: React.ReactNode;
13
+ /** Controls rendered at the far end: SegmentedControl view switch, sort Select. */
14
+ children?: React.ReactNode;
15
+ /** Distribution of the bar. Default 'between' (summary left, controls right). */
16
+ align?: 'between' | 'start' | 'center' | 'end';
17
+ };
18
+
19
+ const alignClasses = {
20
+ between: 'justify-between',
21
+ start: 'justify-start',
22
+ center: 'justify-center',
23
+ end: 'justify-end',
24
+ } as const;
25
+
26
+ /**
27
+ * Slim result bar for filtered lists and directories: result count, optional
28
+ * page position and a "sorted by" note on the left; a view switch (e.g.
29
+ * SegmentedControl in link mode) and sort control on the right. Pair with
30
+ * FilterBar for the input row above and Pagination below.
31
+ */
32
+ export function ListToolbar({
33
+ count,
34
+ countLabel = 'results',
35
+ position,
36
+ note,
37
+ align = 'between',
38
+ className,
39
+ children,
40
+ ...props
41
+ }: ListToolbarProps) {
42
+ const hasSummary = count !== undefined || position !== undefined || note !== undefined;
43
+ return (
44
+ <div
45
+ className={cn('flex flex-wrap items-center gap-x-4 gap-y-2 text-sm', alignClasses[align], className)}
46
+ {...props}
47
+ >
48
+ {hasSummary && (
49
+ <p className="flex flex-wrap items-baseline gap-x-2 text-muted-foreground" aria-live="polite">
50
+ {count !== undefined && (
51
+ <span className="font-medium text-foreground">
52
+ {count} {countLabel}
53
+ </span>
54
+ )}
55
+ {position && <span>{position}</span>}
56
+ {note && <span className="text-xs">{note}</span>}
57
+ </p>
58
+ )}
59
+ {children && <div className="flex flex-wrap items-center gap-2">{children}</div>}
60
+ </div>
61
+ );
62
+ }
63
+
64
+ ListToolbar.displayName = 'ListToolbar';
@@ -0,0 +1 @@
1
+ export * from './ListToolbar';
@@ -0,0 +1,97 @@
1
+ import { render, screen } from '@testing-library/react';
2
+ import { axe } from 'jest-axe';
3
+ import { describe, expect, it } from 'vitest';
4
+ import { MediaCard } from './MediaCard';
5
+
6
+ describe('MediaCard', () => {
7
+ it('renders title, description, meta, chips and footer', () => {
8
+ render(
9
+ <MediaCard
10
+ title="Fall Classic"
11
+ description="Two days of ballroom."
12
+ meta="Mar 14 · Salt Lake City"
13
+ chips={[{ label: 'Open', variant: 'outline-success', dot: true }]}
14
+ footer="Details →"
15
+ />
16
+ );
17
+ expect(screen.getByRole('heading', { name: 'Fall Classic' })).toBeInTheDocument();
18
+ expect(screen.getByText('Two days of ballroom.')).toBeInTheDocument();
19
+ expect(screen.getByText('Mar 14 · Salt Lake City')).toBeInTheDocument();
20
+ expect(screen.getByText('Open')).toBeInTheDocument();
21
+ expect(screen.getByText('Details →')).toBeInTheDocument();
22
+ });
23
+
24
+ it('makes the whole card a single link when href is set', () => {
25
+ const { container } = render(
26
+ <MediaCard href="/events/fall-classic" title="Fall Classic" meta="Mar 14" />
27
+ );
28
+ const link = screen.getByRole('link', { name: /Fall Classic/ });
29
+ expect(link).toHaveAttribute('href', '/events/fall-classic');
30
+ expect(container.querySelectorAll('a')).toHaveLength(1);
31
+ expect(link).toHaveClass('group');
32
+ });
33
+
34
+ it('renders a static article when href is absent', () => {
35
+ render(<MediaCard title="No link" />);
36
+ expect(screen.queryByRole('link')).not.toBeInTheDocument();
37
+ expect(screen.getByRole('article')).toBeInTheDocument();
38
+ });
39
+
40
+ it('renders the cover through CoverImage with the seeded fallback', () => {
41
+ const { container } = render(
42
+ <MediaCard
43
+ title="No art"
44
+ cover={{ alt: 'No art cover', seed: 'no-art', aspect: 'square' }}
45
+ />
46
+ );
47
+ expect(container.querySelector('.aspect-square')).toBeInTheDocument();
48
+ expect(container.querySelector('img')).not.toBeInTheDocument();
49
+ });
50
+
51
+ it('renders the cover image when src is provided', () => {
52
+ render(
53
+ <MediaCard
54
+ title="With art"
55
+ cover={{ src: '/cover.jpg', alt: 'Event cover', aspect: 'video' }}
56
+ />
57
+ );
58
+ expect(screen.getByRole('img', { name: 'Event cover' })).toBeInTheDocument();
59
+ });
60
+
61
+ it('supports row layout with a fixed-width cover', () => {
62
+ const { container } = render(
63
+ <MediaCard layout="row" title="Row" cover={{ alt: 'Row cover' }} />
64
+ );
65
+ expect(container.querySelector('.sm\\:w-44')).toBeInTheDocument();
66
+ });
67
+
68
+ it('routes href through a custom linkComponent and linkHrefProp', () => {
69
+ function RouterLink({ to, children, ...rest }: { to: string; children: React.ReactNode }) {
70
+ return <a href={to} data-router-link={to} {...rest}>{children}</a>;
71
+ }
72
+ render(
73
+ <MediaCard
74
+ href="/events/x"
75
+ title="Routed"
76
+ linkComponent={RouterLink}
77
+ linkHrefProp="to"
78
+ />
79
+ );
80
+ const link = screen.getByRole('link', { name: /Routed/ });
81
+ expect(link).toHaveAttribute('data-router-link', '/events/x');
82
+ });
83
+
84
+ it('has no axe violations', async () => {
85
+ const { container } = render(
86
+ <MediaCard
87
+ href="/events/fall-classic"
88
+ title="Fall Classic"
89
+ description="Two days of ballroom."
90
+ cover={{ alt: 'Fall Classic cover', seed: 'fall-classic' }}
91
+ chips={[{ label: 'Open', variant: 'outline-success', dot: true }]}
92
+ footer="Details →"
93
+ />
94
+ );
95
+ expect(await axe(container)).toHaveNoViolations();
96
+ });
97
+ });
@@ -0,0 +1,116 @@
1
+ import * as React from 'react';
2
+ import { cn } from '../../utils/cn';
3
+ import { Badge, type BadgeProps } from '../badge/Badge';
4
+ import { CoverImage, type CoverImageProps } from '../cover-image/CoverImage';
5
+
6
+ export type MediaCardChip = {
7
+ label: string;
8
+ /** Badge variant; quiet outline tones fit status metadata best. */
9
+ variant?: BadgeProps['variant'];
10
+ /** Leading status dot. */
11
+ dot?: boolean;
12
+ };
13
+
14
+ export type MediaCardProps = Omit<React.HTMLAttributes<HTMLElement>, 'title'> & {
15
+ /** Card title. */
16
+ title: string;
17
+ /** Supporting copy under the title. */
18
+ description?: React.ReactNode;
19
+ /** Destination URL; the whole card becomes one link when set. */
20
+ href?: string;
21
+ /** Cover art rendered through CoverImage (seeded gradient fallback included). */
22
+ cover?: Omit<CoverImageProps, 'className'>;
23
+ /** Metadata line under the description (date, location, deadline). */
24
+ meta?: React.ReactNode;
25
+ /** Status/category chips rendered as Badges. */
26
+ chips?: MediaCardChip[];
27
+ /** Bottom slot for a details affordance or secondary text. Non-interactive when the card is a link. */
28
+ footer?: React.ReactNode;
29
+ /** 'vertical' stacks cover over content; 'row' puts a fixed-width cover beside it. */
30
+ layout?: 'vertical' | 'row';
31
+ /** Custom link element for routers (Next Link, react-router). */
32
+ linkComponent?: React.ElementType;
33
+ /** Prop used to pass the destination to linkComponent ('href' or 'to'). */
34
+ linkHrefProp?: 'href' | 'to';
35
+ };
36
+
37
+ /**
38
+ * Media card for event, article and listing grids: CoverImage on top (or
39
+ * beside in `layout="row"`), title, description, metadata line, status chips
40
+ * and an optional footer. With `href` the entire card is a single link —
41
+ * one target, one hover state, one focus ring — so keep `footer` free of
42
+ * nested interactive elements.
43
+ */
44
+ export const MediaCard = React.forwardRef<HTMLElement, MediaCardProps>(function MediaCard(
45
+ {
46
+ title,
47
+ description,
48
+ href,
49
+ cover,
50
+ meta,
51
+ chips,
52
+ footer,
53
+ layout = 'vertical',
54
+ linkComponent,
55
+ linkHrefProp = 'href',
56
+ className,
57
+ ...props
58
+ },
59
+ ref
60
+ ) {
61
+ const Link = linkComponent ?? 'a';
62
+ const destination = href ? (linkHrefProp === 'to' ? { to: href } : { href }) : undefined;
63
+ const row = layout === 'row';
64
+
65
+ const body = (
66
+ <>
67
+ {cover && (
68
+ <CoverImage
69
+ {...cover}
70
+ className={cn(
71
+ row ? 'w-36 shrink-0 sm:w-44' : 'w-full',
72
+ !row && 'rounded-none border-b border-border'
73
+ )}
74
+ />
75
+ )}
76
+ <div className={cn('flex min-w-0 flex-1 flex-col gap-2', row ? 'p-4' : 'p-5')}>
77
+ {chips && chips.length > 0 && (
78
+ <div className="flex flex-wrap gap-1.5">
79
+ {chips.map((chip) => (
80
+ <Badge key={chip.label} variant={chip.variant ?? 'outline'} size="sm" dot={chip.dot}>
81
+ {chip.label}
82
+ </Badge>
83
+ ))}
84
+ </div>
85
+ )}
86
+ <h3 className="font-semibold tracking-tight transition-colors group-hover:text-primary-ink">{title}</h3>
87
+ {description && (
88
+ <div className="line-clamp-3 text-sm leading-relaxed text-muted-foreground">{description}</div>
89
+ )}
90
+ {meta && <div className="text-xs text-muted-foreground">{meta}</div>}
91
+ {footer && <div className="mt-auto pt-2 text-xs text-muted-foreground">{footer}</div>}
92
+ </div>
93
+ </>
94
+ );
95
+
96
+ const cardClass = cn(
97
+ 'group flex h-full overflow-hidden rounded-xl border border-border bg-card shadow-sm transition-colors hover:border-primary/40',
98
+ 'focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 focus-visible:ring-offset-background',
99
+ row ? 'flex-row' : 'flex-col',
100
+ className
101
+ );
102
+
103
+ return (
104
+ <article ref={ref as never} className="h-full" {...props}>
105
+ {href && destination ? (
106
+ <Link {...destination} className={cardClass}>
107
+ {body}
108
+ </Link>
109
+ ) : (
110
+ <div className={cardClass}>{body}</div>
111
+ )}
112
+ </article>
113
+ );
114
+ });
115
+
116
+ MediaCard.displayName = 'MediaCard';
@@ -0,0 +1 @@
1
+ export * from './MediaCard';
@@ -0,0 +1,137 @@
1
+ import { render, screen } from '@testing-library/react';
2
+ import userEvent from '@testing-library/user-event';
3
+ import { axe } from 'jest-axe';
4
+ import { describe, expect, it, vi } from 'vitest';
5
+ import { MonthSchedule } from './MonthSchedule';
6
+
7
+ type Event = { id: string; date: string; title: string; type?: string; href?: string };
8
+
9
+ const events: Event[] = [
10
+ { id: '1', date: '2026-03-14', title: 'Fall Classic', type: 'competition', href: '/events/fall-classic' },
11
+ { id: '2', date: '2026-03-14', title: 'Open Floor', type: 'social' },
12
+ { id: '3', date: '2026-03-21', title: 'Workshop', type: 'class' },
13
+ { id: '4', date: '2026-04-15', title: 'Next Month', type: 'social' },
14
+ ];
15
+
16
+ const legend = [
17
+ { type: 'competition', label: 'Competition' },
18
+ { type: 'social', label: 'Social' },
19
+ { type: 'class', label: 'Class' },
20
+ ];
21
+
22
+ const base = {
23
+ events,
24
+ getDate: (e: Event) => e.date,
25
+ getLabel: (e: Event) => e.title,
26
+ getType: (e: Event) => e.type,
27
+ getHref: (e: Event) => e.href,
28
+ };
29
+
30
+ describe('MonthSchedule', () => {
31
+ it('renders the month label and events inside their days', () => {
32
+ render(<MonthSchedule {...base} month="2026-03" today="2026-03-01" />);
33
+ expect(screen.getByText('March 2026')).toBeInTheDocument();
34
+ // Event chips appear in the grid; count both grid + agenda copies? agenda is
35
+ // hidden via CSS but still in the DOM, so use getAllByText.
36
+ expect(screen.getAllByText('Fall Classic').length).toBeGreaterThan(0);
37
+ expect(screen.getAllByText('Open Floor').length).toBeGreaterThan(0);
38
+ expect(screen.getAllByText('Workshop').length).toBeGreaterThan(0);
39
+ // April event must not render for March.
40
+ expect(screen.queryByText('Next Month')).not.toBeInTheDocument();
41
+ });
42
+
43
+ it('marks today with aria-current', () => {
44
+ const { container } = render(
45
+ <MonthSchedule {...base} month="2026-03" today="2026-03-14" />
46
+ );
47
+ expect(container.querySelector('[aria-current="date"]')).toBeInTheDocument();
48
+ });
49
+
50
+ it('collapses overflow beyond maxPerDay', () => {
51
+ const many: Event[] = Array.from({ length: 5 }, (_, i) => ({
52
+ id: `m${i}`,
53
+ date: '2026-03-10',
54
+ title: `Event ${i}`,
55
+ }));
56
+ render(
57
+ <MonthSchedule
58
+ events={many}
59
+ getDate={(e) => e.date}
60
+ getLabel={(e) => e.title}
61
+ month="2026-03"
62
+ today="2026-03-01"
63
+ maxPerDay={2}
64
+ />
65
+ );
66
+ expect(screen.getAllByText('+3 more').length).toBeGreaterThan(0);
67
+ });
68
+
69
+ it('renders the legend with type labels', () => {
70
+ render(<MonthSchedule {...base} month="2026-03" today="2026-03-01" legend={legend} />);
71
+ expect(screen.getByText('Competition')).toBeInTheDocument();
72
+ expect(screen.getByText('Social')).toBeInTheDocument();
73
+ expect(screen.getByText('Class')).toBeInTheDocument();
74
+ });
75
+
76
+ it('links events through linkComponent and linkHrefProp', () => {
77
+ function RouterLink({ to, children, ...rest }: { to: string; children: React.ReactNode }) {
78
+ return <a href={to} data-router-link={to} {...rest}>{children}</a>;
79
+ }
80
+ render(
81
+ <MonthSchedule
82
+ {...base}
83
+ month="2026-03"
84
+ today="2026-03-01"
85
+ linkComponent={RouterLink}
86
+ linkHrefProp="to"
87
+ />
88
+ );
89
+ const links = screen.getAllByRole('link', { name: 'Fall Classic' });
90
+ expect(links.length).toBeGreaterThan(0);
91
+ expect(links[0]).toHaveAttribute('data-router-link', '/events/fall-classic');
92
+ });
93
+
94
+ it('pages months and notifies onMonthChange', async () => {
95
+ const user = userEvent.setup();
96
+ const onMonthChange = vi.fn();
97
+ render(
98
+ <MonthSchedule
99
+ {...base}
100
+ month="2026-03"
101
+ today="2026-03-01"
102
+ onMonthChange={onMonthChange}
103
+ />
104
+ );
105
+ await user.click(screen.getByRole('button', { name: 'Next month' }));
106
+ expect(onMonthChange).toHaveBeenCalledWith('2026-04');
107
+ // Controlled: displayed month stays March until the parent updates it.
108
+ expect(screen.getByText('March 2026')).toBeInTheDocument();
109
+ });
110
+
111
+ it('pages uncontrolled via defaultMonth', async () => {
112
+ const user = userEvent.setup();
113
+ render(<MonthSchedule {...base} defaultMonth="2026-03" today="2026-03-01" />);
114
+ await user.click(screen.getByRole('button', { name: 'Next month' }));
115
+ expect(await screen.findByText('April 2026')).toBeInTheDocument();
116
+ });
117
+
118
+ it('shows the agenda empty state when a month has no events', () => {
119
+ render(
120
+ <MonthSchedule
121
+ events={[]}
122
+ getDate={(e: Event) => e.date}
123
+ getLabel={(e: Event) => e.title}
124
+ month="2026-05"
125
+ today="2026-03-01"
126
+ />
127
+ );
128
+ expect(screen.getByText('No events this month.')).toBeInTheDocument();
129
+ });
130
+
131
+ it('has no axe violations', async () => {
132
+ const { container } = render(
133
+ <MonthSchedule {...base} month="2026-03" today="2026-03-01" legend={legend} />
134
+ );
135
+ expect(await axe(container)).toHaveNoViolations();
136
+ });
137
+ });