@slipstream-ui/core 0.11.3 → 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.
- package/dist/index.d.mts +126 -7
- package/dist/index.d.ts +126 -7
- package/dist/index.js +605 -444
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +500 -340
- 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 +151 -0
- 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 +45 -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 +16 -4
- 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 +7 -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.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/menu.manifest.json +1 -1
- package/dist/manifests/metric-card.manifest.json +1 -1
- 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 +29 -2
- 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 +23 -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/cover-image/CoverImage.d.ts +34 -0
- package/dist/src/components/cover-image/CoverImage.js +94 -0
- package/dist/src/components/cover-image/CoverImage.js.map +1 -0
- package/dist/src/components/cover-image/CoverImage.mjs +70 -0
- package/dist/src/components/cover-image/CoverImage.mjs.map +1 -0
- package/dist/src/components/cover-image/index.d.ts +1 -0
- package/dist/src/components/cover-image/index.js +29 -0
- package/dist/src/components/cover-image/index.js.map +1 -0
- package/dist/src/components/cover-image/index.mjs +5 -0
- package/dist/src/components/cover-image/index.mjs.map +1 -0
- package/dist/src/components/empty-state/EmptyState.d.ts +24 -0
- package/dist/src/components/empty-state/EmptyState.js +16 -6
- package/dist/src/components/empty-state/EmptyState.js.map +1 -1
- package/dist/src/components/empty-state/EmptyState.mjs +16 -6
- package/dist/src/components/empty-state/EmptyState.mjs.map +1 -1
- package/dist/src/components/form-layout/FormLayout.d.ts +26 -4
- package/dist/src/components/form-layout/FormLayout.js +16 -3
- package/dist/src/components/form-layout/FormLayout.js.map +1 -1
- package/dist/src/components/form-layout/FormLayout.mjs +16 -3
- package/dist/src/components/form-layout/FormLayout.mjs.map +1 -1
- package/dist/src/components/image/Image.d.ts +3 -1
- package/dist/src/components/image/Image.js +2 -0
- package/dist/src/components/image/Image.js.map +1 -1
- package/dist/src/components/image/Image.mjs +2 -0
- package/dist/src/components/image/Image.mjs.map +1 -1
- package/dist/src/components/segmented-control/SegmentedControl.d.ts +21 -0
- package/dist/src/components/segmented-control/SegmentedControl.js +47 -16
- package/dist/src/components/segmented-control/SegmentedControl.js.map +1 -1
- package/dist/src/components/segmented-control/SegmentedControl.mjs +48 -17
- package/dist/src/components/segmented-control/SegmentedControl.mjs.map +1 -1
- package/dist/src/components/stat-band/StatBand.d.ts +16 -0
- package/dist/src/components/stat-band/StatBand.js +46 -9
- package/dist/src/components/stat-band/StatBand.js.map +1 -1
- package/dist/src/components/stat-band/StatBand.mjs +46 -9
- package/dist/src/components/stat-band/StatBand.mjs.map +1 -1
- package/dist/src/index.d.ts +1 -0
- package/dist/styles-full.css +1 -1
- package/dist/styles.css +1 -1
- package/package.json +1 -1
- package/src/components/cover-image/CoverImage.test.tsx +88 -0
- package/src/components/cover-image/CoverImage.tsx +109 -0
- package/src/components/cover-image/index.ts +1 -0
- package/src/components/empty-state/EmptyState.test.tsx +33 -0
- package/src/components/empty-state/EmptyState.tsx +34 -6
- package/src/components/form-layout/FormLayout.test.tsx +26 -0
- package/src/components/form-layout/FormLayout.tsx +37 -5
- package/src/components/image/Image.tsx +4 -0
- package/src/components/segmented-control/SegmentedControl.test.tsx +64 -0
- package/src/components/segmented-control/SegmentedControl.tsx +69 -15
- package/src/components/stat-band/StatBand.test.tsx +26 -0
- package/src/components/stat-band/StatBand.tsx +52 -7
- package/src/index.ts +1 -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 +151 -0
- 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 +45 -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 +16 -4
- 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 +7 -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.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/menu.manifest.json +1 -1
- package/src/manifests/metric-card.manifest.json +1 -1
- 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 +29 -2
- 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 +23 -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
- package/src/styles.css +5 -0
|
@@ -11,17 +11,47 @@ const GRID_COLUMNS: Record<number, string> = {
|
|
|
11
11
|
4: 'grid-cols-4',
|
|
12
12
|
};
|
|
13
13
|
|
|
14
|
+
const GRID_BREAKPOINTS = ['sm', 'md', 'lg', 'xl'] as const;
|
|
15
|
+
|
|
16
|
+
/** Column count per breakpoint; `base` applies at every width. */
|
|
17
|
+
export type FormLayoutColumns =
|
|
18
|
+
| 1
|
|
19
|
+
| 2
|
|
20
|
+
| 3
|
|
21
|
+
| 4
|
|
22
|
+
| { base?: 1 | 2 | 3 | 4; sm?: 1 | 2 | 3 | 4; md?: 1 | 2 | 3 | 4; lg?: 1 | 2 | 3 | 4; xl?: 1 | 2 | 3 | 4 };
|
|
23
|
+
|
|
24
|
+
function gridColumnClasses(columns: FormLayoutColumns): string {
|
|
25
|
+
if (typeof columns === 'number') return GRID_COLUMNS[columns];
|
|
26
|
+
return [
|
|
27
|
+
columns.base !== undefined ? GRID_COLUMNS[columns.base] : '',
|
|
28
|
+
...GRID_BREAKPOINTS.map((bp) => {
|
|
29
|
+
const count = columns[bp];
|
|
30
|
+
return count !== undefined ? `${bp}:${GRID_COLUMNS[count]}` : '';
|
|
31
|
+
}),
|
|
32
|
+
]
|
|
33
|
+
.filter(Boolean)
|
|
34
|
+
.join(' ');
|
|
35
|
+
}
|
|
36
|
+
|
|
14
37
|
export type FormLayoutProps = React.HTMLAttributes<HTMLElement> & {
|
|
15
38
|
/** Grouping layout: even vertical stack (default), horizontal row, or responsive grid. */
|
|
16
39
|
layout?: 'stack' | 'row' | 'grid';
|
|
17
|
-
/**
|
|
18
|
-
|
|
40
|
+
/**
|
|
41
|
+
* Grid column count (1-4) at every width, or per breakpoint
|
|
42
|
+
* (`{ base: 1, md: 2 }`) for responsive grids without className overrides.
|
|
43
|
+
*/
|
|
44
|
+
columns?: FormLayoutColumns;
|
|
19
45
|
/** Even spacing between children — token ('md') or exact pixels (16). */
|
|
20
46
|
gap?: GapValue;
|
|
21
47
|
/** Group label; renders a semantic <legend> when as="fieldset". */
|
|
22
48
|
legend?: string;
|
|
49
|
+
/** Extra classes for the legend (fieldset mode). */
|
|
50
|
+
legendClassName?: string;
|
|
23
51
|
/** Supporting line under the legend (fieldset mode). */
|
|
24
52
|
description?: string;
|
|
53
|
+
/** Extra classes for the description (fieldset mode). */
|
|
54
|
+
descriptionClassName?: string;
|
|
25
55
|
/** Render as a semantic fieldset (default 'div'). */
|
|
26
56
|
as?: 'div' | 'fieldset';
|
|
27
57
|
};
|
|
@@ -39,7 +69,9 @@ const FormLayout = React.forwardRef<HTMLElement, FormLayoutProps>(
|
|
|
39
69
|
columns = 2,
|
|
40
70
|
gap,
|
|
41
71
|
legend,
|
|
72
|
+
legendClassName,
|
|
42
73
|
description,
|
|
74
|
+
descriptionClassName,
|
|
43
75
|
as = 'div',
|
|
44
76
|
className,
|
|
45
77
|
style,
|
|
@@ -57,7 +89,7 @@ const FormLayout = React.forwardRef<HTMLElement, FormLayoutProps>(
|
|
|
57
89
|
'flex min-w-0',
|
|
58
90
|
layout === 'stack' && 'flex-col',
|
|
59
91
|
layout === 'row' && 'flex-row flex-wrap items-end',
|
|
60
|
-
layout === 'grid' && `grid ${
|
|
92
|
+
layout === 'grid' && `grid ${gridColumnClasses(columns)}`,
|
|
61
93
|
gapResolved.className,
|
|
62
94
|
className
|
|
63
95
|
)}
|
|
@@ -65,10 +97,10 @@ const FormLayout = React.forwardRef<HTMLElement, FormLayoutProps>(
|
|
|
65
97
|
{...props}
|
|
66
98
|
>
|
|
67
99
|
{legend && as === 'fieldset' && (
|
|
68
|
-
<legend className=
|
|
100
|
+
<legend className={cn('col-span-full p-0 text-sm font-medium leading-none', legendClassName)}>{legend}</legend>
|
|
69
101
|
)}
|
|
70
102
|
{description && as === 'fieldset' && (
|
|
71
|
-
<p className=
|
|
103
|
+
<p className={cn('col-span-full text-xs text-muted-foreground', descriptionClassName)}>{description}</p>
|
|
72
104
|
)}
|
|
73
105
|
{children}
|
|
74
106
|
</Tag>
|
|
@@ -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={
|
|
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
|
-
{
|
|
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
|
});
|
|
@@ -21,6 +21,14 @@ export type StatBandProps = React.HTMLAttributes<HTMLDListElement> & {
|
|
|
21
21
|
size?: 'sm' | 'md' | 'lg';
|
|
22
22
|
/** Draw dividers between stats at sm and up. Default true. */
|
|
23
23
|
divided?: boolean;
|
|
24
|
+
/**
|
|
25
|
+
* Surface treatment. 'panel' renders a bordered strip of hairline-separated
|
|
26
|
+
* cells with denser type for data pages; 'plain' is the marketing band.
|
|
27
|
+
* Default 'plain'.
|
|
28
|
+
*/
|
|
29
|
+
variant?: 'plain' | 'panel';
|
|
30
|
+
/** Extra classes for the value element (e.g. font-mono for tabular numerals). */
|
|
31
|
+
valueClassName?: string;
|
|
24
32
|
};
|
|
25
33
|
|
|
26
34
|
const columnClasses: Record<NonNullable<StatBandProps['columns']>, string> = {
|
|
@@ -35,22 +43,43 @@ const valueClasses: Record<NonNullable<StatBandProps['size']>, string> = {
|
|
|
35
43
|
lg: 'text-4xl sm:text-5xl',
|
|
36
44
|
};
|
|
37
45
|
|
|
46
|
+
const panelValueClasses: Record<NonNullable<StatBandProps['size']>, string> = {
|
|
47
|
+
sm: 'text-lg',
|
|
48
|
+
md: 'text-xl sm:text-2xl',
|
|
49
|
+
lg: 'text-2xl sm:text-3xl',
|
|
50
|
+
};
|
|
51
|
+
|
|
38
52
|
/**
|
|
39
53
|
* Marketing stat band: a semantic description list of headline numbers with
|
|
40
54
|
* labels and optional hints. Use it inside a Section; the Section owns the
|
|
41
55
|
* surface tone, so the same band works on white and inverse backgrounds.
|
|
42
56
|
*/
|
|
43
57
|
export const StatBand = React.forwardRef<HTMLDListElement, StatBandProps>(function StatBand(
|
|
44
|
-
{
|
|
58
|
+
{
|
|
59
|
+
items,
|
|
60
|
+
columns = 3,
|
|
61
|
+
align = 'center',
|
|
62
|
+
size = 'md',
|
|
63
|
+
divided = true,
|
|
64
|
+
variant = 'plain',
|
|
65
|
+
valueClassName,
|
|
66
|
+
className,
|
|
67
|
+
...props
|
|
68
|
+
},
|
|
45
69
|
ref
|
|
46
70
|
) {
|
|
71
|
+
const panel = variant === 'panel';
|
|
47
72
|
return (
|
|
48
73
|
<dl
|
|
49
74
|
ref={ref}
|
|
50
75
|
className={cn(
|
|
51
|
-
'grid w-full
|
|
76
|
+
'grid w-full',
|
|
77
|
+
panel ? 'gap-0 rounded-lg border border-border bg-card' : 'gap-8',
|
|
52
78
|
columnClasses[columns],
|
|
53
|
-
divided &&
|
|
79
|
+
divided &&
|
|
80
|
+
(panel
|
|
81
|
+
? 'divide-y divide-border sm:divide-x sm:divide-y-0'
|
|
82
|
+
: 'sm:divide-x sm:divide-border'),
|
|
54
83
|
className
|
|
55
84
|
)}
|
|
56
85
|
{...props}
|
|
@@ -59,15 +88,31 @@ export const StatBand = React.forwardRef<HTMLDListElement, StatBandProps>(functi
|
|
|
59
88
|
<div
|
|
60
89
|
key={item.label}
|
|
61
90
|
className={cn(
|
|
62
|
-
'flex min-w-0 flex-col gap-1
|
|
91
|
+
'flex min-w-0 flex-col gap-1',
|
|
92
|
+
panel ? 'px-4 py-3 sm:px-5 sm:py-4' : 'sm:px-6 sm:first:pl-0 sm:last:pr-0',
|
|
63
93
|
align === 'center' ? 'items-center text-center' : 'items-start text-left'
|
|
64
94
|
)}
|
|
65
95
|
>
|
|
66
|
-
<dt
|
|
96
|
+
<dt
|
|
97
|
+
className={cn(
|
|
98
|
+
'order-2 text-muted-foreground',
|
|
99
|
+
panel ? 'text-xs font-medium uppercase tracking-wide' : 'text-sm font-medium'
|
|
100
|
+
)}
|
|
101
|
+
>
|
|
67
102
|
{item.label}
|
|
68
|
-
{item.hint &&
|
|
103
|
+
{item.hint && (
|
|
104
|
+
<span className={cn('mt-1 block font-normal', panel ? 'text-xs normal-case tracking-normal' : 'text-xs')}>
|
|
105
|
+
{item.hint}
|
|
106
|
+
</span>
|
|
107
|
+
)}
|
|
69
108
|
</dt>
|
|
70
|
-
<dd
|
|
109
|
+
<dd
|
|
110
|
+
className={cn(
|
|
111
|
+
'order-1 m-0 font-semibold tracking-tight tabular-nums',
|
|
112
|
+
panel ? panelValueClasses[size] : valueClasses[size],
|
|
113
|
+
valueClassName
|
|
114
|
+
)}
|
|
115
|
+
>
|
|
71
116
|
{item.value}
|
|
72
117
|
</dd>
|
|
73
118
|
</div>
|
package/src/index.ts
CHANGED
|
@@ -48,6 +48,7 @@ export * from './components/data-table';
|
|
|
48
48
|
export * from './components/list';
|
|
49
49
|
export * from './components/link';
|
|
50
50
|
export * from './components/image';
|
|
51
|
+
export * from './components/cover-image';
|
|
51
52
|
export * from './components/text';
|
|
52
53
|
export * from './components/heading';
|
|
53
54
|
export * from './components/empty-state';
|
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
"tier": "molecule",
|
|
5
5
|
"package": "@slipstream-ui/core",
|
|
6
6
|
"importPath": "@slipstream-ui/core",
|
|
7
|
-
"version": "0.11.
|
|
7
|
+
"version": "0.11.6",
|
|
8
8
|
"sourceDir": "announcement-bar",
|
|
9
9
|
"exportName": "AnnouncementBar",
|
|
10
10
|
"description": "Dismissible announcement bar with optional action, tone and sticky positioning.",
|
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
"tier": "molecule",
|
|
5
5
|
"package": "@slipstream-ui/core",
|
|
6
6
|
"importPath": "@slipstream-ui/core",
|
|
7
|
-
"version": "0.11.
|
|
7
|
+
"version": "0.11.6",
|
|
8
8
|
"sourceDir": "applied-filters",
|
|
9
9
|
"exportName": "AppliedFilters",
|
|
10
10
|
"description": "Applied-filter summary with a live count, removable chips and an edit action.",
|
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
"tier": "molecule",
|
|
5
5
|
"package": "@slipstream-ui/core",
|
|
6
6
|
"importPath": "@slipstream-ui/core",
|
|
7
|
-
"version": "0.11.
|
|
7
|
+
"version": "0.11.6",
|
|
8
8
|
"sourceDir": "article-card",
|
|
9
9
|
"exportName": "ArticleCard",
|
|
10
10
|
"description": "Linked article or resource card with media, eyebrow, title, summary and metadata.",
|
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
"tier": "molecule",
|
|
5
5
|
"package": "@slipstream-ui/core",
|
|
6
6
|
"importPath": "@slipstream-ui/core",
|
|
7
|
-
"version": "0.11.
|
|
7
|
+
"version": "0.11.6",
|
|
8
8
|
"sourceDir": "comparison-table",
|
|
9
9
|
"exportName": "ComparisonTable",
|
|
10
10
|
"description": "Marketing comparison table with check/dash boolean cells, a highlighted column and responsive overflow.",
|