@slipstream-ui/core 0.11.9 → 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.
- package/dist/index.d.mts +117 -2
- package/dist/index.d.ts +117 -2
- package/dist/index.js +1084 -827
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +1082 -827
- package/dist/index.mjs.map +1 -1
- package/dist/manifests/accordion.manifest.json +1 -1
- package/dist/manifests/alert.manifest.json +1 -1
- package/dist/manifests/announcement-bar.manifest.json +1 -1
- package/dist/manifests/app-shell.manifest.json +1 -1
- package/dist/manifests/applied-filters.manifest.json +1 -1
- package/dist/manifests/article-card.manifest.json +1 -1
- package/dist/manifests/auth-layout.manifest.json +1 -1
- package/dist/manifests/autocomplete.manifest.json +1 -1
- package/dist/manifests/avatar.manifest.json +1 -1
- package/dist/manifests/badge.manifest.json +1 -1
- package/dist/manifests/block.manifest.json +1 -1
- package/dist/manifests/bottom-nav.manifest.json +1 -1
- package/dist/manifests/breadcrumb.manifest.json +1 -1
- package/dist/manifests/button-group.manifest.json +1 -1
- package/dist/manifests/button.manifest.json +1 -1
- package/dist/manifests/calendar.manifest.json +1 -1
- package/dist/manifests/card.manifest.json +1 -1
- package/dist/manifests/checkbox.manifest.json +1 -1
- package/dist/manifests/comparison-table.manifest.json +1 -1
- package/dist/manifests/confirm-dialog.manifest.json +1 -1
- package/dist/manifests/contact-strip.manifest.json +1 -1
- package/dist/manifests/container.manifest.json +1 -1
- package/dist/manifests/cover-image.manifest.json +1 -1
- package/dist/manifests/cta-section.manifest.json +1 -1
- package/dist/manifests/data-table.manifest.json +1 -1
- package/dist/manifests/date-picker-popover.manifest.json +1 -1
- package/dist/manifests/date-picker.manifest.json +1 -1
- package/dist/manifests/date-range-picker.manifest.json +1 -1
- package/dist/manifests/deal-card.manifest.json +1 -1
- package/dist/manifests/dialog.manifest.json +1 -1
- package/dist/manifests/document-card.manifest.json +1 -1
- package/dist/manifests/drawer.manifest.json +1 -1
- package/dist/manifests/empty-state.manifest.json +1 -1
- package/dist/manifests/entity-card.manifest.json +1 -1
- package/dist/manifests/feature-grid.manifest.json +1 -1
- package/dist/manifests/feature-row.manifest.json +1 -1
- package/dist/manifests/fieldset.manifest.json +1 -1
- package/dist/manifests/file-upload.manifest.json +1 -1
- package/dist/manifests/filter-bar.manifest.json +1 -1
- package/dist/manifests/filter-chips.manifest.json +1 -1
- package/dist/manifests/filter-panel.manifest.json +1 -1
- package/dist/manifests/flex.manifest.json +1 -1
- package/dist/manifests/form-field.manifest.json +1 -1
- package/dist/manifests/form-layout.manifest.json +1 -1
- package/dist/manifests/form.manifest.json +1 -1
- package/dist/manifests/grid.manifest.json +1 -1
- package/dist/manifests/heading.manifest.json +1 -1
- package/dist/manifests/hero.manifest.json +1 -1
- package/dist/manifests/image.manifest.json +1 -1
- package/dist/manifests/input-group.manifest.json +1 -1
- package/dist/manifests/input.manifest.json +1 -1
- package/dist/manifests/label.manifest.json +1 -1
- package/dist/manifests/link-tabs.manifest.json +1 -1
- package/dist/manifests/link.manifest.json +1 -1
- package/dist/manifests/list-toolbar.manifest.json +1 -1
- package/dist/manifests/list.manifest.json +1 -1
- package/dist/manifests/load-more.manifest.json +1 -1
- package/dist/manifests/logo-cloud.manifest.json +1 -1
- package/dist/manifests/media-card.manifest.json +161 -0
- package/dist/manifests/menu.manifest.json +1 -1
- package/dist/manifests/metric-card.manifest.json +1 -1
- package/dist/manifests/month-schedule.manifest.json +217 -0
- package/dist/manifests/multi-select.manifest.json +1 -1
- package/dist/manifests/newsletter.manifest.json +1 -1
- package/dist/manifests/page-header.manifest.json +1 -1
- package/dist/manifests/pagination.manifest.json +1 -1
- package/dist/manifests/password-input.manifest.json +1 -1
- package/dist/manifests/popover.manifest.json +1 -1
- package/dist/manifests/process-steps.manifest.json +1 -1
- package/dist/manifests/progress.manifest.json +1 -1
- package/dist/manifests/prose.manifest.json +1 -1
- package/dist/manifests/radio.manifest.json +1 -1
- package/dist/manifests/range-slider.manifest.json +1 -1
- package/dist/manifests/search.manifest.json +1 -1
- package/dist/manifests/section-heading.manifest.json +1 -1
- package/dist/manifests/section.manifest.json +1 -1
- package/dist/manifests/segmented-control.manifest.json +1 -1
- package/dist/manifests/select-menu.manifest.json +1 -1
- package/dist/manifests/select.manifest.json +1 -1
- package/dist/manifests/separator.manifest.json +1 -1
- package/dist/manifests/site-footer.manifest.json +1 -1
- package/dist/manifests/site-header.manifest.json +1 -1
- package/dist/manifests/skeleton.manifest.json +1 -1
- package/dist/manifests/spinner.manifest.json +1 -1
- package/dist/manifests/stat-band.manifest.json +1 -1
- package/dist/manifests/stepper.manifest.json +1 -1
- package/dist/manifests/switch.manifest.json +1 -1
- package/dist/manifests/table-card.manifest.json +1 -1
- package/dist/manifests/table-of-contents.manifest.json +1 -1
- package/dist/manifests/table.manifest.json +1 -1
- package/dist/manifests/tabs.manifest.json +1 -1
- package/dist/manifests/testimonial.manifest.json +1 -1
- package/dist/manifests/text.manifest.json +1 -1
- package/dist/manifests/textarea.manifest.json +1 -1
- package/dist/manifests/theme-toggle.manifest.json +1 -1
- package/dist/manifests/time-picker.manifest.json +1 -1
- package/dist/manifests/timeline.manifest.json +1 -1
- package/dist/manifests/toast.manifest.json +1 -1
- package/dist/manifests/tombstone-card.manifest.json +1 -1
- package/dist/manifests/tooltip.manifest.json +1 -1
- package/dist/src/components/media-card/MediaCard.d.ts +61 -0
- package/dist/src/components/media-card/MediaCard.js +88 -0
- package/dist/src/components/media-card/MediaCard.js.map +1 -0
- package/dist/src/components/media-card/MediaCard.mjs +54 -0
- package/dist/src/components/media-card/MediaCard.mjs.map +1 -0
- package/dist/src/components/media-card/index.d.ts +1 -0
- package/dist/src/components/media-card/index.js +23 -0
- package/dist/src/components/media-card/index.js.map +1 -0
- package/dist/src/components/media-card/index.mjs +2 -0
- package/dist/src/components/media-card/index.mjs.map +1 -0
- package/dist/src/components/month-schedule/MonthSchedule.d.ts +56 -0
- package/dist/src/components/month-schedule/MonthSchedule.js +245 -0
- package/dist/src/components/month-schedule/MonthSchedule.js.map +1 -0
- package/dist/src/components/month-schedule/MonthSchedule.mjs +219 -0
- package/dist/src/components/month-schedule/MonthSchedule.mjs.map +1 -0
- package/dist/src/components/month-schedule/index.d.ts +1 -0
- package/dist/src/components/month-schedule/index.js +23 -0
- package/dist/src/components/month-schedule/index.js.map +1 -0
- package/dist/src/components/month-schedule/index.mjs +2 -0
- package/dist/src/components/month-schedule/index.mjs.map +1 -0
- package/dist/src/index.d.ts +2 -0
- package/dist/styles-full.css +1 -1
- package/dist/styles.css +1 -1
- package/package.json +1 -1
- package/src/components/media-card/MediaCard.test.tsx +97 -0
- package/src/components/media-card/MediaCard.tsx +116 -0
- package/src/components/media-card/index.ts +1 -0
- package/src/components/month-schedule/MonthSchedule.test.tsx +137 -0
- package/src/components/month-schedule/MonthSchedule.tsx +332 -0
- package/src/components/month-schedule/index.ts +1 -0
- package/src/index.ts +2 -0
- package/src/manifests/accordion.manifest.json +1 -1
- package/src/manifests/alert.manifest.json +1 -1
- package/src/manifests/announcement-bar.manifest.json +1 -1
- package/src/manifests/app-shell.manifest.json +1 -1
- package/src/manifests/applied-filters.manifest.json +1 -1
- package/src/manifests/article-card.manifest.json +1 -1
- package/src/manifests/auth-layout.manifest.json +1 -1
- package/src/manifests/autocomplete.manifest.json +1 -1
- package/src/manifests/avatar.manifest.json +1 -1
- package/src/manifests/badge.manifest.json +1 -1
- package/src/manifests/block.manifest.json +1 -1
- package/src/manifests/bottom-nav.manifest.json +1 -1
- package/src/manifests/breadcrumb.manifest.json +1 -1
- package/src/manifests/button-group.manifest.json +1 -1
- package/src/manifests/button.manifest.json +1 -1
- package/src/manifests/calendar.manifest.json +1 -1
- package/src/manifests/card.manifest.json +1 -1
- package/src/manifests/checkbox.manifest.json +1 -1
- package/src/manifests/comparison-table.manifest.json +1 -1
- package/src/manifests/confirm-dialog.manifest.json +1 -1
- package/src/manifests/contact-strip.manifest.json +1 -1
- package/src/manifests/container.manifest.json +1 -1
- package/src/manifests/cover-image.manifest.json +1 -1
- package/src/manifests/cta-section.manifest.json +1 -1
- package/src/manifests/data-table.manifest.json +1 -1
- package/src/manifests/date-picker-popover.manifest.json +1 -1
- package/src/manifests/date-picker.manifest.json +1 -1
- package/src/manifests/date-range-picker.manifest.json +1 -1
- package/src/manifests/deal-card.manifest.json +1 -1
- package/src/manifests/dialog.manifest.json +1 -1
- package/src/manifests/document-card.manifest.json +1 -1
- package/src/manifests/drawer.manifest.json +1 -1
- package/src/manifests/empty-state.manifest.json +1 -1
- package/src/manifests/entity-card.manifest.json +1 -1
- package/src/manifests/feature-grid.manifest.json +1 -1
- package/src/manifests/feature-row.manifest.json +1 -1
- package/src/manifests/fieldset.manifest.json +1 -1
- package/src/manifests/file-upload.manifest.json +1 -1
- package/src/manifests/filter-bar.manifest.json +1 -1
- package/src/manifests/filter-chips.manifest.json +1 -1
- package/src/manifests/filter-panel.manifest.json +1 -1
- package/src/manifests/flex.manifest.json +1 -1
- package/src/manifests/form-field.manifest.json +1 -1
- package/src/manifests/form-layout.manifest.json +1 -1
- package/src/manifests/form.manifest.json +1 -1
- package/src/manifests/grid.manifest.json +1 -1
- package/src/manifests/heading.manifest.json +1 -1
- package/src/manifests/hero.manifest.json +1 -1
- package/src/manifests/image.manifest.json +1 -1
- package/src/manifests/input-group.manifest.json +1 -1
- package/src/manifests/input.manifest.json +1 -1
- package/src/manifests/label.manifest.json +1 -1
- package/src/manifests/link-tabs.manifest.json +1 -1
- package/src/manifests/link.manifest.json +1 -1
- package/src/manifests/list-toolbar.manifest.json +1 -1
- package/src/manifests/list.manifest.json +1 -1
- package/src/manifests/load-more.manifest.json +1 -1
- package/src/manifests/logo-cloud.manifest.json +1 -1
- package/src/manifests/media-card.manifest.json +161 -0
- package/src/manifests/menu.manifest.json +1 -1
- package/src/manifests/metric-card.manifest.json +1 -1
- package/src/manifests/month-schedule.manifest.json +217 -0
- package/src/manifests/multi-select.manifest.json +1 -1
- package/src/manifests/newsletter.manifest.json +1 -1
- package/src/manifests/page-header.manifest.json +1 -1
- package/src/manifests/pagination.manifest.json +1 -1
- package/src/manifests/password-input.manifest.json +1 -1
- package/src/manifests/popover.manifest.json +1 -1
- package/src/manifests/process-steps.manifest.json +1 -1
- package/src/manifests/progress.manifest.json +1 -1
- package/src/manifests/prose.manifest.json +1 -1
- package/src/manifests/radio.manifest.json +1 -1
- package/src/manifests/range-slider.manifest.json +1 -1
- package/src/manifests/search.manifest.json +1 -1
- package/src/manifests/section-heading.manifest.json +1 -1
- package/src/manifests/section.manifest.json +1 -1
- package/src/manifests/segmented-control.manifest.json +1 -1
- package/src/manifests/select-menu.manifest.json +1 -1
- package/src/manifests/select.manifest.json +1 -1
- package/src/manifests/separator.manifest.json +1 -1
- package/src/manifests/site-footer.manifest.json +1 -1
- package/src/manifests/site-header.manifest.json +1 -1
- package/src/manifests/skeleton.manifest.json +1 -1
- package/src/manifests/spinner.manifest.json +1 -1
- package/src/manifests/stat-band.manifest.json +1 -1
- package/src/manifests/stepper.manifest.json +1 -1
- package/src/manifests/switch.manifest.json +1 -1
- package/src/manifests/table-card.manifest.json +1 -1
- package/src/manifests/table-of-contents.manifest.json +1 -1
- package/src/manifests/table.manifest.json +1 -1
- package/src/manifests/tabs.manifest.json +1 -1
- package/src/manifests/testimonial.manifest.json +1 -1
- package/src/manifests/text.manifest.json +1 -1
- package/src/manifests/textarea.manifest.json +1 -1
- package/src/manifests/theme-toggle.manifest.json +1 -1
- package/src/manifests/time-picker.manifest.json +1 -1
- package/src/manifests/timeline.manifest.json +1 -1
- package/src/manifests/toast.manifest.json +1 -1
- package/src/manifests/tombstone-card.manifest.json +1 -1
- package/src/manifests/tooltip.manifest.json +1 -1
|
@@ -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
|
+
});
|
|
@@ -0,0 +1,332 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
|
|
3
|
+
import * as React from 'react';
|
|
4
|
+
import { cn } from '../../utils/cn';
|
|
5
|
+
import {
|
|
6
|
+
addMonths,
|
|
7
|
+
calendarWeeks,
|
|
8
|
+
formatDateLabel,
|
|
9
|
+
monthLabel,
|
|
10
|
+
parseDateKey,
|
|
11
|
+
todayKey,
|
|
12
|
+
weekdayLabels,
|
|
13
|
+
} from '../../utils/date';
|
|
14
|
+
import { Badge } from '../badge/Badge';
|
|
15
|
+
import { Button } from '../button';
|
|
16
|
+
|
|
17
|
+
export type MonthScheduleLegendItem = {
|
|
18
|
+
/** Type key returned by getType. */
|
|
19
|
+
type: string;
|
|
20
|
+
/** Human-readable label shown in the legend. */
|
|
21
|
+
label: string;
|
|
22
|
+
};
|
|
23
|
+
|
|
24
|
+
export type MonthScheduleProps<T> = {
|
|
25
|
+
/** Events to place inside days; each is dated via getDate. */
|
|
26
|
+
events: T[];
|
|
27
|
+
/** ISO date key (YYYY-MM-DD) for an event. */
|
|
28
|
+
getDate: (event: T) => string;
|
|
29
|
+
/** Short label shown on the day chip and in the agenda. */
|
|
30
|
+
getLabel: (event: T) => string;
|
|
31
|
+
/** Optional type key used for chip color and the legend. */
|
|
32
|
+
getType?: (event: T) => string | undefined;
|
|
33
|
+
/** Optional destination per event. */
|
|
34
|
+
getHref?: (event: T) => string | undefined;
|
|
35
|
+
/** Controlled month as YYYY-MM. Falls back to defaultMonth, then today. */
|
|
36
|
+
month?: string;
|
|
37
|
+
/** Uncontrolled initial month (YYYY-MM). */
|
|
38
|
+
defaultMonth?: string;
|
|
39
|
+
/** Called with the new YYYY-MM when paging. */
|
|
40
|
+
onMonthChange?: (month: string) => void;
|
|
41
|
+
/** Override "today" for deterministic server rendering and tests. */
|
|
42
|
+
today?: string;
|
|
43
|
+
/** BCP-47 locale for month, weekday and agenda labels. */
|
|
44
|
+
locale?: string;
|
|
45
|
+
/** 0 starts the week on Sunday, 1 on Monday. */
|
|
46
|
+
weekStartsOn?: 0 | 1;
|
|
47
|
+
/** Maximum event chips per day before collapsing into "+N more". */
|
|
48
|
+
maxPerDay?: number;
|
|
49
|
+
/** Type key → label/color entries rendered as a legend under the grid. */
|
|
50
|
+
legend?: MonthScheduleLegendItem[];
|
|
51
|
+
/**
|
|
52
|
+
* Below this breakpoint an agenda list replaces the day grid:
|
|
53
|
+
* 'sm' swaps under 640px, 'md' under 768px.
|
|
54
|
+
*/
|
|
55
|
+
agendaBreakpoint?: 'sm' | 'md';
|
|
56
|
+
/** Custom link element for event hrefs (Next Link, react-router). */
|
|
57
|
+
linkComponent?: React.ElementType;
|
|
58
|
+
/** Prop used to pass the destination to linkComponent ('href' or 'to'). */
|
|
59
|
+
linkHrefProp?: 'href' | 'to';
|
|
60
|
+
'aria-label'?: string;
|
|
61
|
+
className?: string;
|
|
62
|
+
};
|
|
63
|
+
|
|
64
|
+
// Deterministic tone per type so chips and legend agree without a color map
|
|
65
|
+
// in consumer code. Order chosen for adjacent contrast.
|
|
66
|
+
const TYPE_TONES = [
|
|
67
|
+
'outline-info',
|
|
68
|
+
'outline-success',
|
|
69
|
+
'outline-warning',
|
|
70
|
+
'outline-danger',
|
|
71
|
+
'outline',
|
|
72
|
+
] as const;
|
|
73
|
+
|
|
74
|
+
type Tone = (typeof TYPE_TONES)[number];
|
|
75
|
+
|
|
76
|
+
function typeTone(type: string | undefined, legend: MonthScheduleLegendItem[] | undefined): Tone {
|
|
77
|
+
if (!type) return 'outline';
|
|
78
|
+
const index = legend?.findIndex((item) => item.type === type) ?? -1;
|
|
79
|
+
if (index >= 0) return TYPE_TONES[index % TYPE_TONES.length];
|
|
80
|
+
// Stable hash fallback for types missing from the legend.
|
|
81
|
+
let hash = 0;
|
|
82
|
+
for (let i = 0; i < type.length; i += 1) hash = (hash * 31 + type.charCodeAt(i)) >>> 0;
|
|
83
|
+
return TYPE_TONES[hash % TYPE_TONES.length];
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
function monthOf(key: string): { year: number; month: number } {
|
|
87
|
+
const parts = parseDateKey(`${key}-01`);
|
|
88
|
+
return { year: parts?.year ?? 1970, month: parts?.month ?? 0 };
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
function shiftMonth(monthKey: string, delta: number): string {
|
|
92
|
+
const { year, month } = monthOf(monthKey);
|
|
93
|
+
const shifted = addMonths(`${year}-${String(month + 1).padStart(2, '0')}-01`, delta);
|
|
94
|
+
return shifted.slice(0, 7);
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
/**
|
|
98
|
+
* Month schedule: a month grid with dated events rendered inside each day,
|
|
99
|
+
* plus a legend and a small-screen agenda. Built on the same date utilities
|
|
100
|
+
* as Calendar; `today` stays explicit so server-rendered pages never read the
|
|
101
|
+
* server clock.
|
|
102
|
+
*/
|
|
103
|
+
export function MonthSchedule<T>({
|
|
104
|
+
events,
|
|
105
|
+
getDate,
|
|
106
|
+
getLabel,
|
|
107
|
+
getType,
|
|
108
|
+
getHref,
|
|
109
|
+
month,
|
|
110
|
+
defaultMonth,
|
|
111
|
+
onMonthChange,
|
|
112
|
+
today,
|
|
113
|
+
locale = 'en-US',
|
|
114
|
+
weekStartsOn = 0,
|
|
115
|
+
maxPerDay = 3,
|
|
116
|
+
legend,
|
|
117
|
+
agendaBreakpoint = 'md',
|
|
118
|
+
linkComponent,
|
|
119
|
+
linkHrefProp = 'href',
|
|
120
|
+
'aria-label': ariaLabel,
|
|
121
|
+
className,
|
|
122
|
+
}: MonthScheduleProps<T>) {
|
|
123
|
+
const resolvedToday = today ?? todayKey();
|
|
124
|
+
const Link = linkComponent ?? 'a';
|
|
125
|
+
const [internalMonth, setInternalMonth] = React.useState(
|
|
126
|
+
() => month ?? defaultMonth ?? resolvedToday.slice(0, 7)
|
|
127
|
+
);
|
|
128
|
+
const activeMonth = month ?? internalMonth;
|
|
129
|
+
const { year, month: monthIndex } = monthOf(activeMonth);
|
|
130
|
+
|
|
131
|
+
const byDay = React.useMemo(() => {
|
|
132
|
+
const map = new Map<string, T[]>();
|
|
133
|
+
for (const event of events) {
|
|
134
|
+
const key = getDate(event);
|
|
135
|
+
const list = map.get(key);
|
|
136
|
+
if (list) list.push(event);
|
|
137
|
+
else map.set(key, [event]);
|
|
138
|
+
}
|
|
139
|
+
for (const list of map.values()) {
|
|
140
|
+
list.sort((a, b) => getLabel(a).localeCompare(getLabel(b)));
|
|
141
|
+
}
|
|
142
|
+
return map;
|
|
143
|
+
}, [events, getDate, getLabel]);
|
|
144
|
+
|
|
145
|
+
const weeks = React.useMemo(
|
|
146
|
+
() => calendarWeeks(year, monthIndex, weekStartsOn),
|
|
147
|
+
[year, monthIndex, weekStartsOn]
|
|
148
|
+
);
|
|
149
|
+
const weekdays = React.useMemo(
|
|
150
|
+
() => weekdayLabels(locale, weekStartsOn),
|
|
151
|
+
[locale, weekStartsOn]
|
|
152
|
+
);
|
|
153
|
+
const monthName = monthLabel(year, monthIndex, locale);
|
|
154
|
+
const agendaDays = React.useMemo(
|
|
155
|
+
() =>
|
|
156
|
+
[...byDay.keys()]
|
|
157
|
+
.filter((key) => key.startsWith(activeMonth))
|
|
158
|
+
.sort()
|
|
159
|
+
.map((key) => ({ key, items: byDay.get(key) ?? [] })),
|
|
160
|
+
[byDay, activeMonth]
|
|
161
|
+
);
|
|
162
|
+
|
|
163
|
+
const page = (delta: number) => {
|
|
164
|
+
const next = shiftMonth(activeMonth, delta);
|
|
165
|
+
if (month === undefined) setInternalMonth(next);
|
|
166
|
+
onMonthChange?.(next);
|
|
167
|
+
};
|
|
168
|
+
|
|
169
|
+
const renderEvent = (event: T, key: string) => {
|
|
170
|
+
const label = getLabel(event);
|
|
171
|
+
const type = getType?.(event);
|
|
172
|
+
const tone = typeTone(type, legend);
|
|
173
|
+
const href = getHref?.(event);
|
|
174
|
+
const chip = (
|
|
175
|
+
<Badge variant={tone} size="sm" className="max-w-full truncate">
|
|
176
|
+
{label}
|
|
177
|
+
</Badge>
|
|
178
|
+
);
|
|
179
|
+
if (!href) return <span key={key}>{chip}</span>;
|
|
180
|
+
const destination = linkHrefProp === 'to' ? { to: href } : { href };
|
|
181
|
+
return (
|
|
182
|
+
<Link
|
|
183
|
+
key={key}
|
|
184
|
+
{...destination}
|
|
185
|
+
className="block max-w-full rounded-sm focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring"
|
|
186
|
+
>
|
|
187
|
+
{chip}
|
|
188
|
+
</Link>
|
|
189
|
+
);
|
|
190
|
+
};
|
|
191
|
+
|
|
192
|
+
const gridHidden = agendaBreakpoint === 'sm' ? 'hidden sm:block' : 'hidden md:block';
|
|
193
|
+
const agendaHidden = agendaBreakpoint === 'sm' ? 'sm:hidden' : 'md:hidden';
|
|
194
|
+
|
|
195
|
+
return (
|
|
196
|
+
<div className={cn('w-full select-none', className)}>
|
|
197
|
+
<div className="mb-2 flex items-center justify-between gap-2">
|
|
198
|
+
<Button
|
|
199
|
+
type="button"
|
|
200
|
+
variant="ghost"
|
|
201
|
+
size="icon"
|
|
202
|
+
aria-label="Previous month"
|
|
203
|
+
onClick={() => page(-1)}
|
|
204
|
+
>
|
|
205
|
+
‹
|
|
206
|
+
</Button>
|
|
207
|
+
<div aria-live="polite" className="text-sm font-semibold text-foreground">
|
|
208
|
+
{monthName}
|
|
209
|
+
</div>
|
|
210
|
+
<Button
|
|
211
|
+
type="button"
|
|
212
|
+
variant="ghost"
|
|
213
|
+
size="icon"
|
|
214
|
+
aria-label="Next month"
|
|
215
|
+
onClick={() => page(1)}
|
|
216
|
+
>
|
|
217
|
+
›
|
|
218
|
+
</Button>
|
|
219
|
+
</div>
|
|
220
|
+
|
|
221
|
+
<div
|
|
222
|
+
role="grid"
|
|
223
|
+
aria-label={ariaLabel ?? monthName}
|
|
224
|
+
className={cn('flex flex-col gap-1', gridHidden)}
|
|
225
|
+
>
|
|
226
|
+
<div role="row" className="grid grid-cols-7 gap-1 text-center text-xs text-muted-foreground">
|
|
227
|
+
{weekdays.map((weekday) => (
|
|
228
|
+
<span key={weekday} role="columnheader" aria-label={weekday} className="py-1">
|
|
229
|
+
{weekday}
|
|
230
|
+
</span>
|
|
231
|
+
))}
|
|
232
|
+
</div>
|
|
233
|
+
|
|
234
|
+
{weeks.map((week) => (
|
|
235
|
+
<div key={week[0]?.key} role="row" className="grid grid-cols-7 gap-1">
|
|
236
|
+
{week.map((day) => {
|
|
237
|
+
const dayEvents = byDay.get(day.key) ?? [];
|
|
238
|
+
const visible = dayEvents.slice(0, maxPerDay);
|
|
239
|
+
const overflow = dayEvents.length - visible.length;
|
|
240
|
+
const isToday = day.key === resolvedToday;
|
|
241
|
+
|
|
242
|
+
return (
|
|
243
|
+
<div
|
|
244
|
+
key={day.key}
|
|
245
|
+
role="gridcell"
|
|
246
|
+
aria-current={isToday ? 'date' : undefined}
|
|
247
|
+
className={cn(
|
|
248
|
+
'flex min-h-16 flex-col gap-0.5 rounded-md border border-transparent p-1',
|
|
249
|
+
!day.inMonth && 'opacity-50',
|
|
250
|
+
isToday && 'border-primary/40 bg-primary/5'
|
|
251
|
+
)}
|
|
252
|
+
>
|
|
253
|
+
<span
|
|
254
|
+
className={cn(
|
|
255
|
+
'self-start px-1 text-xs tabular-nums',
|
|
256
|
+
isToday ? 'font-semibold text-primary-ink' : 'text-muted-foreground'
|
|
257
|
+
)}
|
|
258
|
+
>
|
|
259
|
+
{day.day}
|
|
260
|
+
</span>
|
|
261
|
+
{visible.map((event, index) =>
|
|
262
|
+
renderEvent(event, `${day.key}-${index}-${getLabel(event)}`)
|
|
263
|
+
)}
|
|
264
|
+
{overflow > 0 && (
|
|
265
|
+
<span className="px-1 text-[11px] text-muted-foreground">
|
|
266
|
+
+{overflow} more
|
|
267
|
+
</span>
|
|
268
|
+
)}
|
|
269
|
+
</div>
|
|
270
|
+
);
|
|
271
|
+
})}
|
|
272
|
+
</div>
|
|
273
|
+
))}
|
|
274
|
+
</div>
|
|
275
|
+
|
|
276
|
+
<div className={cn('flex flex-col gap-3', agendaHidden)}>
|
|
277
|
+
{agendaDays.length === 0 ? (
|
|
278
|
+
<p className="py-6 text-center text-sm text-muted-foreground">No events this month.</p>
|
|
279
|
+
) : (
|
|
280
|
+
agendaDays.map(({ key, items }) => (
|
|
281
|
+
<section key={key} aria-label={formatDateLabel(key, locale)}>
|
|
282
|
+
<h3 className="mb-1 text-xs font-semibold uppercase tracking-wide text-muted-foreground">
|
|
283
|
+
{formatDateLabel(key, locale)}
|
|
284
|
+
</h3>
|
|
285
|
+
<ul className="flex flex-col gap-1">
|
|
286
|
+
{items.map((event, index) => {
|
|
287
|
+
const label = getLabel(event);
|
|
288
|
+
const type = getType?.(event);
|
|
289
|
+
const tone = typeTone(type, legend);
|
|
290
|
+
const href = getHref?.(event);
|
|
291
|
+
const row = (
|
|
292
|
+
<Badge variant={tone} size="sm" className="max-w-full truncate">
|
|
293
|
+
{label}
|
|
294
|
+
</Badge>
|
|
295
|
+
);
|
|
296
|
+
return (
|
|
297
|
+
<li key={`${key}-${index}-${label}`}>
|
|
298
|
+
{href ? (
|
|
299
|
+
<Link
|
|
300
|
+
{...(linkHrefProp === 'to' ? { to: href } : { href })}
|
|
301
|
+
className="block max-w-full rounded-sm focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring"
|
|
302
|
+
>
|
|
303
|
+
{row}
|
|
304
|
+
</Link>
|
|
305
|
+
) : (
|
|
306
|
+
row
|
|
307
|
+
)}
|
|
308
|
+
</li>
|
|
309
|
+
);
|
|
310
|
+
})}
|
|
311
|
+
</ul>
|
|
312
|
+
</section>
|
|
313
|
+
))
|
|
314
|
+
)}
|
|
315
|
+
</div>
|
|
316
|
+
|
|
317
|
+
{legend && legend.length > 0 && (
|
|
318
|
+
<ul className="mt-3 flex flex-wrap gap-x-4 gap-y-1" aria-label="Event types">
|
|
319
|
+
{legend.map((item) => (
|
|
320
|
+
<li key={item.type} className="flex items-center gap-1.5 text-xs text-muted-foreground">
|
|
321
|
+
<Badge variant={typeTone(item.type, legend)} size="sm">
|
|
322
|
+
{item.label}
|
|
323
|
+
</Badge>
|
|
324
|
+
</li>
|
|
325
|
+
))}
|
|
326
|
+
</ul>
|
|
327
|
+
)}
|
|
328
|
+
</div>
|
|
329
|
+
);
|
|
330
|
+
}
|
|
331
|
+
|
|
332
|
+
MonthSchedule.displayName = 'MonthSchedule';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './MonthSchedule';
|