@slipstream-ui/core 0.6.0 → 0.7.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.d.mts +337 -17
- package/dist/index.d.ts +337 -17
- package/dist/index.js +719 -226
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +713 -226
- 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/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/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/cta-section.manifest.json +1 -1
- package/dist/manifests/data-table.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 +158 -0
- package/dist/manifests/dialog.manifest.json +1 -1
- package/dist/manifests/document-card.manifest.json +108 -0
- package/dist/manifests/drawer.manifest.json +1 -1
- package/dist/manifests/empty-state.manifest.json +1 -1
- package/dist/manifests/entity-card.manifest.json +114 -0
- 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 +40 -8
- 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 +88 -0
- 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 +1 -1
- package/dist/manifests/select-menu.manifest.json +2 -2
- 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 +69 -5
- 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 +26 -5
- 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 +97 -0
- package/dist/manifests/tooltip.manifest.json +1 -1
- package/dist/src/components/date-picker/DatePicker.js +1 -1
- package/dist/src/components/date-picker/DatePicker.js.map +1 -1
- package/dist/src/components/date-picker/DatePicker.mjs +1 -1
- package/dist/src/components/date-picker/DatePicker.mjs.map +1 -1
- package/dist/src/components/deal-card/DealCard.d.ts +72 -0
- package/dist/src/components/deal-card/DealCard.js +108 -0
- package/dist/src/components/deal-card/DealCard.js.map +1 -0
- package/dist/src/components/deal-card/DealCard.mjs +74 -0
- package/dist/src/components/deal-card/DealCard.mjs.map +1 -0
- package/dist/src/components/deal-card/index.d.ts +2 -0
- package/dist/src/components/deal-card/index.js +29 -0
- package/dist/src/components/deal-card/index.js.map +1 -0
- package/dist/src/components/deal-card/index.mjs +5 -0
- package/dist/src/components/deal-card/index.mjs.map +1 -0
- package/dist/src/components/document-card/DocumentCard.d.ts +42 -0
- package/dist/src/components/document-card/DocumentCard.js +84 -0
- package/dist/src/components/document-card/DocumentCard.js.map +1 -0
- package/dist/src/components/document-card/DocumentCard.mjs +50 -0
- package/dist/src/components/document-card/DocumentCard.mjs.map +1 -0
- package/dist/src/components/document-card/index.d.ts +2 -0
- package/dist/src/components/document-card/index.js +29 -0
- package/dist/src/components/document-card/index.js.map +1 -0
- package/dist/src/components/document-card/index.mjs +5 -0
- package/dist/src/components/document-card/index.mjs.map +1 -0
- package/dist/src/components/entity-card/EntityCard.d.ts +78 -0
- package/dist/src/components/entity-card/EntityCard.js +95 -0
- package/dist/src/components/entity-card/EntityCard.js.map +1 -0
- package/dist/src/components/entity-card/EntityCard.mjs +60 -0
- package/dist/src/components/entity-card/EntityCard.mjs.map +1 -0
- package/dist/src/components/entity-card/index.d.ts +2 -0
- package/dist/src/components/entity-card/index.js +31 -0
- package/dist/src/components/entity-card/index.js.map +1 -0
- package/dist/src/components/entity-card/index.mjs +6 -0
- package/dist/src/components/entity-card/index.mjs.map +1 -0
- package/dist/src/components/hero/Hero.d.ts +25 -13
- package/dist/src/components/hero/Hero.js +116 -12
- package/dist/src/components/hero/Hero.js.map +1 -1
- package/dist/src/components/hero/Hero.mjs +116 -12
- package/dist/src/components/hero/Hero.mjs.map +1 -1
- package/dist/src/components/load-more/LoadMore.d.ts +34 -0
- package/dist/src/components/load-more/LoadMore.js +55 -0
- package/dist/src/components/load-more/LoadMore.js.map +1 -0
- package/dist/src/components/load-more/LoadMore.mjs +21 -0
- package/dist/src/components/load-more/LoadMore.mjs.map +1 -0
- package/dist/src/components/load-more/index.d.ts +2 -0
- package/dist/src/components/load-more/index.js +29 -0
- package/dist/src/components/load-more/index.js.map +1 -0
- package/dist/src/components/load-more/index.mjs +5 -0
- package/dist/src/components/load-more/index.mjs.map +1 -0
- package/dist/src/components/range-slider/RangeSlider.js +6 -6
- package/dist/src/components/range-slider/RangeSlider.js.map +1 -1
- package/dist/src/components/range-slider/RangeSlider.mjs +6 -6
- package/dist/src/components/range-slider/RangeSlider.mjs.map +1 -1
- package/dist/src/components/select-menu/SelectMenu.js +2 -0
- package/dist/src/components/select-menu/SelectMenu.js.map +1 -1
- package/dist/src/components/select-menu/SelectMenu.mjs +2 -0
- package/dist/src/components/select-menu/SelectMenu.mjs.map +1 -1
- package/dist/src/components/separator/Separator.js +1 -1
- package/dist/src/components/separator/Separator.js.map +1 -1
- package/dist/src/components/separator/Separator.mjs +1 -1
- package/dist/src/components/separator/Separator.mjs.map +1 -1
- package/dist/src/components/stepper/Stepper.d.ts +35 -0
- package/dist/src/components/stepper/Stepper.js +118 -25
- package/dist/src/components/stepper/Stepper.js.map +1 -1
- package/dist/src/components/stepper/Stepper.mjs +118 -25
- package/dist/src/components/stepper/Stepper.mjs.map +1 -1
- package/dist/src/components/table-of-contents/TableOfContents.d.ts +10 -2
- package/dist/src/components/table-of-contents/TableOfContents.js +13 -0
- package/dist/src/components/table-of-contents/TableOfContents.js.map +1 -1
- package/dist/src/components/table-of-contents/TableOfContents.mjs +13 -0
- package/dist/src/components/table-of-contents/TableOfContents.mjs.map +1 -1
- package/dist/src/components/tabs/Tabs.js +43 -3
- package/dist/src/components/tabs/Tabs.js.map +1 -1
- package/dist/src/components/tabs/Tabs.mjs +43 -3
- package/dist/src/components/tabs/Tabs.mjs.map +1 -1
- package/dist/src/components/time-picker/TimePicker.js +1 -1
- package/dist/src/components/time-picker/TimePicker.js.map +1 -1
- package/dist/src/components/time-picker/TimePicker.mjs +1 -1
- package/dist/src/components/time-picker/TimePicker.mjs.map +1 -1
- package/dist/src/components/timeline/Timeline.js +2 -2
- package/dist/src/components/timeline/Timeline.js.map +1 -1
- package/dist/src/components/timeline/Timeline.mjs +2 -2
- package/dist/src/components/timeline/Timeline.mjs.map +1 -1
- package/dist/src/components/tombstone-card/TombstoneCard.d.ts +39 -0
- package/dist/src/components/tombstone-card/TombstoneCard.js +86 -0
- package/dist/src/components/tombstone-card/TombstoneCard.js.map +1 -0
- package/dist/src/components/tombstone-card/TombstoneCard.mjs +52 -0
- package/dist/src/components/tombstone-card/TombstoneCard.mjs.map +1 -0
- package/dist/src/components/tombstone-card/index.d.ts +2 -0
- package/dist/src/components/tombstone-card/index.js +29 -0
- package/dist/src/components/tombstone-card/index.js.map +1 -0
- package/dist/src/components/tombstone-card/index.mjs +5 -0
- package/dist/src/components/tombstone-card/index.mjs.map +1 -0
- package/dist/src/index.d.ts +5 -0
- package/dist/src/utils/modal-layer.js +3 -2
- package/dist/src/utils/modal-layer.js.map +1 -1
- package/dist/src/utils/modal-layer.mjs +3 -2
- package/dist/src/utils/modal-layer.mjs.map +1 -1
- package/dist/styles-full.css +1 -1
- package/dist/styles.css +1 -1
- package/package.json +4 -4
- package/src/components/date-picker/DatePicker.tsx +1 -1
- package/src/components/deal-card/DealCard.test.tsx +54 -0
- package/src/components/deal-card/DealCard.tsx +138 -0
- package/src/components/deal-card/index.ts +2 -0
- package/src/components/document-card/DocumentCard.test.tsx +41 -0
- package/src/components/document-card/DocumentCard.tsx +82 -0
- package/src/components/document-card/index.ts +2 -0
- package/src/components/entity-card/EntityCard.test.tsx +38 -0
- package/src/components/entity-card/EntityCard.tsx +133 -0
- package/src/components/entity-card/index.ts +2 -0
- package/src/components/hero/Hero.test.tsx +14 -0
- package/src/components/hero/Hero.tsx +111 -19
- package/src/components/load-more/LoadMore.test.tsx +28 -0
- package/src/components/load-more/LoadMore.tsx +53 -0
- package/src/components/load-more/index.ts +2 -0
- package/src/components/range-slider/RangeSlider.test.tsx +8 -0
- package/src/components/range-slider/RangeSlider.tsx +10 -6
- package/src/components/select-menu/SelectMenu.test.tsx +20 -10
- package/src/components/select-menu/SelectMenu.tsx +2 -0
- package/src/components/separator/Separator.test.tsx +9 -1
- package/src/components/separator/Separator.tsx +1 -1
- package/src/components/stepper/Stepper.test.tsx +19 -0
- package/src/components/stepper/Stepper.tsx +169 -37
- package/src/components/table-of-contents/TableOfContents.test.tsx +12 -1
- package/src/components/table-of-contents/TableOfContents.tsx +25 -1
- package/src/components/tabs/Tabs.test.tsx +12 -0
- package/src/components/tabs/Tabs.tsx +48 -4
- package/src/components/time-picker/TimePicker.tsx +1 -1
- package/src/components/timeline/Timeline.tsx +2 -2
- package/src/components/tombstone-card/TombstoneCard.test.tsx +26 -0
- package/src/components/tombstone-card/TombstoneCard.tsx +77 -0
- package/src/components/tombstone-card/index.ts +2 -0
- package/src/index.ts +5 -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/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/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/cta-section.manifest.json +1 -1
- package/src/manifests/data-table.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 +158 -0
- package/src/manifests/dialog.manifest.json +1 -1
- package/src/manifests/document-card.manifest.json +108 -0
- package/src/manifests/drawer.manifest.json +1 -1
- package/src/manifests/empty-state.manifest.json +1 -1
- package/src/manifests/entity-card.manifest.json +114 -0
- 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 +40 -8
- 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 +88 -0
- 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 +1 -1
- package/src/manifests/select-menu.manifest.json +2 -2
- 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 +69 -5
- 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 +26 -5
- 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 +97 -0
- package/src/manifests/tooltip.manifest.json +1 -1
- package/src/test/jest-axe.d.ts +6 -1
- package/src/utils/modal-layer.ts +3 -2
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
2
|
import { cn } from '../../utils/cn';
|
|
3
3
|
|
|
4
|
+
export type HeroVariant = 'split' | 'centered' | 'stacked' | 'overlay';
|
|
5
|
+
|
|
4
6
|
export type HeroProps = Omit<React.HTMLAttributes<HTMLElement>, 'title'> & {
|
|
5
7
|
/** Main headline. Accepts inline markup for a highlighted phrase. */
|
|
6
8
|
title: React.ReactNode;
|
|
@@ -12,9 +14,9 @@ export type HeroProps = Omit<React.HTMLAttributes<HTMLElement>, 'title'> & {
|
|
|
12
14
|
badge?: React.ReactNode;
|
|
13
15
|
/** Primary and secondary calls to action. */
|
|
14
16
|
actions?: React.ReactNode;
|
|
15
|
-
/** Product shot, illustration, video or form shown beside the copy. */
|
|
17
|
+
/** Product shot, illustration, video or form shown beside or behind the copy. */
|
|
16
18
|
media?: React.ReactNode;
|
|
17
|
-
/** Which side the media sits on at lg and up. Default 'right'. */
|
|
19
|
+
/** Which side the media sits on at lg and up in the split layout. Default 'right'. */
|
|
18
20
|
mediaPosition?: 'left' | 'right';
|
|
19
21
|
/** Copy alignment. Centered is typically used without media. */
|
|
20
22
|
align?: 'left' | 'center';
|
|
@@ -23,10 +25,13 @@ export type HeroProps = Omit<React.HTMLAttributes<HTMLElement>, 'title'> & {
|
|
|
23
25
|
/** Heading level. Default 1; use 2 when the hero is nested under a page h1. */
|
|
24
26
|
level?: 1 | 2;
|
|
25
27
|
/**
|
|
26
|
-
*
|
|
27
|
-
*
|
|
28
|
+
* Layout:
|
|
29
|
+
* - `split` places copy and media side by side at lg and up (default with media).
|
|
30
|
+
* - `centered` stacks copy in a narrow centered column (default without media).
|
|
31
|
+
* - `stacked` puts copy above full-width media, left aligned unless `align` says otherwise.
|
|
32
|
+
* - `overlay` places media behind the copy with a scrim; copy stays readable in both themes.
|
|
28
33
|
*/
|
|
29
|
-
variant?:
|
|
34
|
+
variant?: HeroVariant;
|
|
30
35
|
/** Semantic element (default 'div'). */
|
|
31
36
|
as?: 'div' | 'section' | 'header';
|
|
32
37
|
/** Extra classes for the headline, for host display typography. */
|
|
@@ -37,18 +42,21 @@ export type HeroProps = Omit<React.HTMLAttributes<HTMLElement>, 'title'> & {
|
|
|
37
42
|
eyebrowClassName?: string;
|
|
38
43
|
/** Extra classes for the badge wrapper. */
|
|
39
44
|
badgeClassName?: string;
|
|
45
|
+
/** Extra classes for the media wrapper. */
|
|
46
|
+
mediaClassName?: string;
|
|
40
47
|
};
|
|
41
48
|
|
|
42
49
|
const titleSizes = {
|
|
43
|
-
md: 'text-
|
|
44
|
-
lg: 'text-4xl sm:text-5xl
|
|
50
|
+
md: 'text-3xl sm:text-4xl md:text-5xl',
|
|
51
|
+
lg: 'text-4xl sm:text-5xl md:text-6xl lg:leading-[1.05]',
|
|
45
52
|
} as const;
|
|
46
53
|
|
|
47
54
|
/**
|
|
48
55
|
* Marketing hero: optional badge/eyebrow, a large headline, supporting copy,
|
|
49
|
-
* calls to action and an optional media slot.
|
|
50
|
-
*
|
|
51
|
-
*
|
|
56
|
+
* calls to action and an optional media slot. Four responsive layouts cover
|
|
57
|
+
* the common landing-page shapes: split, centered, stacked and overlay. Use it
|
|
58
|
+
* inside Section so the band owns its tone and vertical padding. For a
|
|
59
|
+
* documentation page title without media, use PageHeader instead.
|
|
52
60
|
*/
|
|
53
61
|
export const Hero = React.forwardRef<HTMLElement, HeroProps>(function Hero(
|
|
54
62
|
{
|
|
@@ -68,6 +76,7 @@ export const Hero = React.forwardRef<HTMLElement, HeroProps>(function Hero(
|
|
|
68
76
|
descriptionClassName,
|
|
69
77
|
eyebrowClassName,
|
|
70
78
|
badgeClassName,
|
|
79
|
+
mediaClassName,
|
|
71
80
|
className,
|
|
72
81
|
...props
|
|
73
82
|
},
|
|
@@ -77,38 +86,119 @@ export const Hero = React.forwardRef<HTMLElement, HeroProps>(function Hero(
|
|
|
77
86
|
const layout = variant ?? (media ? 'split' : 'centered');
|
|
78
87
|
const Heading = `h${level}` as 'h1' | 'h2';
|
|
79
88
|
const centered = layout === 'centered' || align === 'center';
|
|
89
|
+
const overlay = layout === 'overlay';
|
|
80
90
|
|
|
81
91
|
const copy = (
|
|
82
|
-
<div
|
|
92
|
+
<div
|
|
93
|
+
className={cn(
|
|
94
|
+
'min-w-0',
|
|
95
|
+
centered && 'mx-auto flex max-w-3xl flex-col items-center text-center',
|
|
96
|
+
overlay && 'max-w-2xl'
|
|
97
|
+
)}
|
|
98
|
+
>
|
|
83
99
|
{badge && (
|
|
84
|
-
<div
|
|
100
|
+
<div
|
|
101
|
+
className={cn(
|
|
102
|
+
'mb-5 inline-flex rounded-full border px-3 py-1 text-xs font-medium',
|
|
103
|
+
overlay
|
|
104
|
+
? 'border-background/30 bg-background/10 text-background'
|
|
105
|
+
: 'border-primary/30 bg-primary/10 text-primary',
|
|
106
|
+
badgeClassName
|
|
107
|
+
)}
|
|
108
|
+
>
|
|
85
109
|
{badge}
|
|
86
110
|
</div>
|
|
87
111
|
)}
|
|
88
112
|
{eyebrow && (
|
|
89
|
-
<p
|
|
113
|
+
<p
|
|
114
|
+
className={cn(
|
|
115
|
+
'mb-3 text-xs font-semibold uppercase tracking-widest',
|
|
116
|
+
overlay ? 'text-background/90' : 'text-primary',
|
|
117
|
+
eyebrowClassName
|
|
118
|
+
)}
|
|
119
|
+
>
|
|
120
|
+
{eyebrow}
|
|
121
|
+
</p>
|
|
90
122
|
)}
|
|
91
|
-
<Heading
|
|
123
|
+
<Heading
|
|
124
|
+
className={cn(
|
|
125
|
+
'font-semibold tracking-tight text-balance',
|
|
126
|
+
titleSizes[size],
|
|
127
|
+
overlay && 'text-background',
|
|
128
|
+
titleClassName
|
|
129
|
+
)}
|
|
130
|
+
>
|
|
92
131
|
{title}
|
|
93
132
|
</Heading>
|
|
94
133
|
{description && (
|
|
95
|
-
<p
|
|
134
|
+
<p
|
|
135
|
+
className={cn(
|
|
136
|
+
'mt-5 text-base leading-relaxed sm:text-lg',
|
|
137
|
+
overlay ? 'text-background/80' : 'text-muted-foreground',
|
|
138
|
+
centered ? 'max-w-2xl' : 'max-w-xl',
|
|
139
|
+
descriptionClassName
|
|
140
|
+
)}
|
|
141
|
+
>
|
|
96
142
|
{description}
|
|
97
143
|
</p>
|
|
98
144
|
)}
|
|
99
145
|
{actions && (
|
|
100
|
-
<div
|
|
146
|
+
<div
|
|
147
|
+
className={cn(
|
|
148
|
+
'mt-8 flex flex-wrap items-center gap-3',
|
|
149
|
+
centered && 'justify-center'
|
|
150
|
+
)}
|
|
151
|
+
>
|
|
101
152
|
{actions}
|
|
102
153
|
</div>
|
|
103
154
|
)}
|
|
104
155
|
</div>
|
|
105
156
|
);
|
|
106
157
|
|
|
158
|
+
if (overlay) {
|
|
159
|
+
return (
|
|
160
|
+
<Tag
|
|
161
|
+
ref={ref as never}
|
|
162
|
+
className={cn(
|
|
163
|
+
'relative isolate flex min-h-[22rem] w-full items-center overflow-hidden rounded-lg py-12 sm:min-h-[26rem] sm:py-16 lg:min-h-[32rem] lg:py-20',
|
|
164
|
+
className
|
|
165
|
+
)}
|
|
166
|
+
{...props}
|
|
167
|
+
>
|
|
168
|
+
{media && (
|
|
169
|
+
<div
|
|
170
|
+
className={cn(
|
|
171
|
+
'absolute inset-0 -z-20 [&>*]:h-full [&>*]:w-full [&>*]:object-cover',
|
|
172
|
+
mediaClassName
|
|
173
|
+
)}
|
|
174
|
+
>
|
|
175
|
+
{media}
|
|
176
|
+
</div>
|
|
177
|
+
)}
|
|
178
|
+
<div aria-hidden="true" className="absolute inset-0 -z-10 bg-foreground/60" />
|
|
179
|
+
<div className="relative w-full px-4 sm:px-6 lg:px-10">{copy}</div>
|
|
180
|
+
</Tag>
|
|
181
|
+
);
|
|
182
|
+
}
|
|
183
|
+
|
|
107
184
|
if (layout === 'centered') {
|
|
108
185
|
return (
|
|
109
186
|
<Tag ref={ref as never} className={cn('w-full', className)} {...props}>
|
|
110
187
|
{copy}
|
|
111
|
-
{media && <div className=
|
|
188
|
+
{media && <div className={cn('mt-12 min-w-0', mediaClassName)}>{media}</div>}
|
|
189
|
+
</Tag>
|
|
190
|
+
);
|
|
191
|
+
}
|
|
192
|
+
|
|
193
|
+
if (layout === 'stacked') {
|
|
194
|
+
return (
|
|
195
|
+
<Tag
|
|
196
|
+
ref={ref as never}
|
|
197
|
+
className={cn('flex w-full flex-col gap-10 lg:gap-14', className)}
|
|
198
|
+
{...props}
|
|
199
|
+
>
|
|
200
|
+
{copy}
|
|
201
|
+
{media && <div className={cn('min-w-0 w-full', mediaClassName)}>{media}</div>}
|
|
112
202
|
</Tag>
|
|
113
203
|
);
|
|
114
204
|
}
|
|
@@ -116,12 +206,14 @@ export const Hero = React.forwardRef<HTMLElement, HeroProps>(function Hero(
|
|
|
116
206
|
return (
|
|
117
207
|
<Tag
|
|
118
208
|
ref={ref as never}
|
|
119
|
-
className={cn('grid w-full items-center gap-10 lg:grid-cols-2 lg:gap-16', className)}
|
|
209
|
+
className={cn('grid w-full items-center gap-10 lg:grid-cols-2 lg:gap-16 xl:gap-20', className)}
|
|
120
210
|
{...props}
|
|
121
211
|
>
|
|
122
212
|
<div className={cn(mediaPosition === 'left' && 'lg:order-2')}>{copy}</div>
|
|
123
213
|
{media && (
|
|
124
|
-
<div className={cn('min-w-0', mediaPosition === 'left' && 'lg:order-1')}>
|
|
214
|
+
<div className={cn('min-w-0', mediaPosition === 'left' && 'lg:order-1', mediaClassName)}>
|
|
215
|
+
{media}
|
|
216
|
+
</div>
|
|
125
217
|
)}
|
|
126
218
|
</Tag>
|
|
127
219
|
);
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { fireEvent, render, screen } from '@testing-library/react';
|
|
2
|
+
import { axe } from 'jest-axe';
|
|
3
|
+
import { describe, expect, it, vi } from 'vitest';
|
|
4
|
+
import { LoadMore } from './LoadMore';
|
|
5
|
+
|
|
6
|
+
describe('LoadMore', () => {
|
|
7
|
+
it('requests the next page', () => {
|
|
8
|
+
const onLoadMore = vi.fn();
|
|
9
|
+
render(<LoadMore hasMore onLoadMore={onLoadMore} />);
|
|
10
|
+
fireEvent.click(screen.getByRole('button', { name: 'Load more' }));
|
|
11
|
+
expect(onLoadMore).toHaveBeenCalled();
|
|
12
|
+
});
|
|
13
|
+
|
|
14
|
+
it('shows a loading state', () => {
|
|
15
|
+
render(<LoadMore hasMore loading onLoadMore={() => {}} />);
|
|
16
|
+
expect(screen.getByRole('button', { name: /Loading/ })).toBeDisabled();
|
|
17
|
+
});
|
|
18
|
+
|
|
19
|
+
it('announces the end of the list', () => {
|
|
20
|
+
render(<LoadMore hasMore={false} onLoadMore={() => {}} />);
|
|
21
|
+
expect(screen.getByRole('status')).toHaveTextContent("You're all caught up.");
|
|
22
|
+
});
|
|
23
|
+
|
|
24
|
+
it('has no accessibility violations', async () => {
|
|
25
|
+
const { container } = render(<LoadMore hasMore onLoadMore={() => {}} />);
|
|
26
|
+
expect(await axe(container)).toHaveNoViolations();
|
|
27
|
+
});
|
|
28
|
+
});
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
|
|
3
|
+
import * as React from 'react';
|
|
4
|
+
import { cn } from '../../utils/cn';
|
|
5
|
+
import { Button } from '../button/Button';
|
|
6
|
+
|
|
7
|
+
export type LoadMoreProps = React.HTMLAttributes<HTMLDivElement> & {
|
|
8
|
+
/** Whether another page is available. */
|
|
9
|
+
hasMore: boolean;
|
|
10
|
+
/** Request the next page. */
|
|
11
|
+
onLoadMore: () => void;
|
|
12
|
+
/** Loading state. */
|
|
13
|
+
loading?: boolean;
|
|
14
|
+
/** Button label. Default "Load more". */
|
|
15
|
+
loadLabel?: string;
|
|
16
|
+
/** Loading label. Default "Loading...". */
|
|
17
|
+
loadingLabel?: string;
|
|
18
|
+
/** End-of-list message. Default "You're all caught up." */
|
|
19
|
+
endLabel?: string;
|
|
20
|
+
};
|
|
21
|
+
|
|
22
|
+
/**
|
|
23
|
+
* Load-more control for paginated lists without page numbers. While loading it
|
|
24
|
+
* disables the button and sets aria-busy; at the end it replaces the button
|
|
25
|
+
* with a polite status message.
|
|
26
|
+
*/
|
|
27
|
+
export const LoadMore = React.forwardRef<HTMLDivElement, LoadMoreProps>(function LoadMore(
|
|
28
|
+
{
|
|
29
|
+
hasMore,
|
|
30
|
+
onLoadMore,
|
|
31
|
+
loading = false,
|
|
32
|
+
loadLabel = 'Load more',
|
|
33
|
+
loadingLabel = 'Loading...',
|
|
34
|
+
endLabel = "You're all caught up.",
|
|
35
|
+
className,
|
|
36
|
+
...props
|
|
37
|
+
},
|
|
38
|
+
ref
|
|
39
|
+
) {
|
|
40
|
+
return (
|
|
41
|
+
<div ref={ref} aria-live="polite" className={cn('flex w-full justify-center py-4', className)} {...props}>
|
|
42
|
+
{hasMore ? (
|
|
43
|
+
<Button type="button" variant="outline" onClick={onLoadMore} loading={loading}>
|
|
44
|
+
{loading ? loadingLabel : loadLabel}
|
|
45
|
+
</Button>
|
|
46
|
+
) : (
|
|
47
|
+
<p role="status" className="text-sm text-muted-foreground">
|
|
48
|
+
{endLabel}
|
|
49
|
+
</p>
|
|
50
|
+
)}
|
|
51
|
+
</div>
|
|
52
|
+
);
|
|
53
|
+
});
|
|
@@ -33,6 +33,14 @@ describe('RangeSlider', () => {
|
|
|
33
33
|
expect(onValueChange).toHaveBeenLastCalledWith([80, 80]);
|
|
34
34
|
});
|
|
35
35
|
|
|
36
|
+
it('centres the WebKit thumb on the track', () => {
|
|
37
|
+
const { container } = render(<RangeSlider defaultValue={[25, 75]} />);
|
|
38
|
+
const inputs = container.querySelectorAll<HTMLInputElement>('input[type="range"]');
|
|
39
|
+
// Track is 4px tall, thumb 16px: -6px keeps the thumb centred instead of
|
|
40
|
+
// flush with the track's top edge.
|
|
41
|
+
expect(inputs[0]?.className).toContain('[&::-webkit-slider-thumb]:mt-[-6px]');
|
|
42
|
+
});
|
|
43
|
+
|
|
36
44
|
it('has no accessibility violations', async () => {
|
|
37
45
|
const { container } = render(<RangeSlider defaultValue={[25, 75]} />);
|
|
38
46
|
expect(await axe(container)).toHaveNoViolations();
|
|
@@ -27,12 +27,16 @@ export type RangeSliderProps = Omit<React.HTMLAttributes<HTMLDivElement>, 'onCha
|
|
|
27
27
|
disabled?: boolean;
|
|
28
28
|
};
|
|
29
29
|
|
|
30
|
+
// The track is 4px (h-1) and the thumb is 16px (h-4). WebKit positions the
|
|
31
|
+
// thumb from the top of the track, so it needs a -6px margin to share the
|
|
32
|
+
// track's centre line instead of sitting flush against its top edge. Firefox
|
|
33
|
+
// centres the thumb on the track by itself.
|
|
30
34
|
const rangeInputClass = cn(
|
|
31
|
-
'pointer-events-none absolute inset-x-0 top-1/2 h-
|
|
32
|
-
'[&::-webkit-slider-runnable-track]:h-1 [&::-webkit-slider-runnable-track]:bg-transparent',
|
|
33
|
-
'[&::-webkit-slider-thumb]:pointer-events-auto [&::-webkit-slider-thumb]:h-4 [&::-webkit-slider-thumb]:w-4 [&::-webkit-slider-thumb]:appearance-none [&::-webkit-slider-thumb]:rounded-full [&::-webkit-slider-thumb]:border-2 [&::-webkit-slider-thumb]:border-primary [&::-webkit-slider-thumb]:bg-background [&::-webkit-slider-thumb]:shadow',
|
|
34
|
-
'[&::-moz-range-track]:h-1 [&::-moz-range-track]:bg-transparent',
|
|
35
|
-
'[&::-moz-range-thumb]:pointer-events-auto [&::-moz-range-thumb]:h-4 [&::-moz-range-thumb]:w-4 [&::-moz-range-thumb]:rounded-full [&::-moz-range-thumb]:border-2 [&::-moz-range-thumb]:border-primary [&::-moz-range-thumb]:bg-background [&::-moz-range-thumb]:shadow',
|
|
35
|
+
'pointer-events-none absolute inset-x-0 top-1/2 h-6 w-full -translate-y-1/2 appearance-none bg-transparent',
|
|
36
|
+
'[&::-webkit-slider-runnable-track]:h-1 [&::-webkit-slider-runnable-track]:rounded-full [&::-webkit-slider-runnable-track]:bg-transparent',
|
|
37
|
+
'[&::-webkit-slider-thumb]:pointer-events-auto [&::-webkit-slider-thumb]:mt-[-6px] [&::-webkit-slider-thumb]:h-4 [&::-webkit-slider-thumb]:w-4 [&::-webkit-slider-thumb]:cursor-grab [&::-webkit-slider-thumb]:appearance-none [&::-webkit-slider-thumb]:rounded-full [&::-webkit-slider-thumb]:border-2 [&::-webkit-slider-thumb]:border-primary [&::-webkit-slider-thumb]:bg-background [&::-webkit-slider-thumb]:shadow',
|
|
38
|
+
'[&::-moz-range-track]:h-1 [&::-moz-range-track]:rounded-full [&::-moz-range-track]:bg-transparent',
|
|
39
|
+
'[&::-moz-range-thumb]:pointer-events-auto [&::-moz-range-thumb]:h-4 [&::-moz-range-thumb]:w-4 [&::-moz-range-thumb]:cursor-grab [&::-moz-range-thumb]:rounded-full [&::-moz-range-thumb]:border-2 [&::-moz-range-thumb]:border-primary [&::-moz-range-thumb]:bg-background [&::-moz-range-thumb]:shadow',
|
|
36
40
|
'focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 focus-visible:ring-offset-background',
|
|
37
41
|
'disabled:cursor-not-allowed disabled:opacity-50'
|
|
38
42
|
);
|
|
@@ -87,7 +91,7 @@ export const RangeSlider = React.forwardRef<HTMLDivElement, RangeSliderProps>(fu
|
|
|
87
91
|
<span>{formatValue(high)}</span>
|
|
88
92
|
</div>
|
|
89
93
|
)}
|
|
90
|
-
<div className="relative h-
|
|
94
|
+
<div className="relative h-6 w-full">
|
|
91
95
|
<div className="absolute inset-x-0 top-1/2 h-1 -translate-y-1/2 rounded-full bg-muted" />
|
|
92
96
|
<div
|
|
93
97
|
className="absolute top-1/2 h-1 -translate-y-1/2 rounded-full bg-primary"
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { render, screen } from '@testing-library/react';
|
|
2
2
|
import userEvent from '@testing-library/user-event';
|
|
3
|
-
import { axe } from 'jest-axe';
|
|
3
|
+
import { axe, configureAxe } from 'jest-axe';
|
|
4
4
|
import { describe, expect, it, vi } from 'vitest';
|
|
5
5
|
import { SelectMenu, type SelectMenuItem } from './SelectMenu';
|
|
6
6
|
|
|
@@ -15,7 +15,7 @@ describe('SelectMenu', () => {
|
|
|
15
15
|
it('opens a listbox with rich rows and groups', async () => {
|
|
16
16
|
const user = userEvent.setup();
|
|
17
17
|
render(<SelectMenu aria-label="Plan" items={items} placeholder="Choose a plan" />);
|
|
18
|
-
const trigger = screen.getByRole('
|
|
18
|
+
const trigger = screen.getByRole('combobox', { name: 'Plan' });
|
|
19
19
|
expect(trigger).toHaveAttribute('aria-haspopup', 'listbox');
|
|
20
20
|
expect(trigger).toHaveAttribute('aria-expanded', 'false');
|
|
21
21
|
await user.click(trigger);
|
|
@@ -29,18 +29,18 @@ describe('SelectMenu', () => {
|
|
|
29
29
|
const user = userEvent.setup();
|
|
30
30
|
const onValueChange = vi.fn();
|
|
31
31
|
render(<SelectMenu aria-label="Plan" items={items} onValueChange={onValueChange} />);
|
|
32
|
-
await user.click(screen.getByRole('
|
|
32
|
+
await user.click(screen.getByRole('combobox'));
|
|
33
33
|
await user.click(screen.getByRole('option', { name: /Pro/ }));
|
|
34
34
|
expect(onValueChange).toHaveBeenCalledWith('pro');
|
|
35
35
|
expect(screen.queryByRole('listbox')).not.toBeInTheDocument();
|
|
36
|
-
expect(screen.getByRole('
|
|
36
|
+
expect(screen.getByRole('combobox')).toHaveTextContent('Pro');
|
|
37
37
|
});
|
|
38
38
|
|
|
39
39
|
it('supports keyboard navigation and selection', async () => {
|
|
40
40
|
const user = userEvent.setup();
|
|
41
41
|
const onValueChange = vi.fn();
|
|
42
42
|
render(<SelectMenu aria-label="Plan" items={items} onValueChange={onValueChange} />);
|
|
43
|
-
const trigger = screen.getByRole('
|
|
43
|
+
const trigger = screen.getByRole('combobox');
|
|
44
44
|
trigger.focus();
|
|
45
45
|
await user.keyboard('{ArrowDown}'); // open
|
|
46
46
|
expect(screen.getByRole('listbox')).toBeInTheDocument();
|
|
@@ -54,20 +54,20 @@ describe('SelectMenu', () => {
|
|
|
54
54
|
const user = userEvent.setup();
|
|
55
55
|
const onValueChange = vi.fn();
|
|
56
56
|
render(<SelectMenu aria-label="Tags" multiple items={items} defaultValue={['free']} onValueChange={onValueChange} />);
|
|
57
|
-
const trigger = screen.getByRole('
|
|
57
|
+
const trigger = screen.getByRole('combobox');
|
|
58
58
|
expect(trigger).toHaveTextContent('Free');
|
|
59
59
|
await user.click(trigger);
|
|
60
60
|
await user.click(screen.getByRole('option', { name: /Pro/ }));
|
|
61
61
|
expect(onValueChange).toHaveBeenLastCalledWith(['free', 'pro']);
|
|
62
62
|
expect(screen.getByRole('listbox')).toBeInTheDocument();
|
|
63
|
-
expect(screen.getByRole('
|
|
63
|
+
expect(screen.getByRole('combobox')).toHaveTextContent('2 selected');
|
|
64
64
|
});
|
|
65
65
|
|
|
66
66
|
it('skips disabled options and exposes aria-disabled', async () => {
|
|
67
67
|
const user = userEvent.setup();
|
|
68
68
|
const onValueChange = vi.fn();
|
|
69
69
|
render(<SelectMenu aria-label="Plan" items={items} onValueChange={onValueChange} />);
|
|
70
|
-
await user.click(screen.getByRole('
|
|
70
|
+
await user.click(screen.getByRole('combobox'));
|
|
71
71
|
const disabled = screen.getByRole('option', { name: /Enterprise/ });
|
|
72
72
|
expect(disabled).toHaveAttribute('aria-disabled', 'true');
|
|
73
73
|
await user.click(disabled);
|
|
@@ -84,8 +84,8 @@ describe('SelectMenu', () => {
|
|
|
84
84
|
renderValue={(selected) => <em>{selected.length ? selected[0].label : 'Pick'}</em>}
|
|
85
85
|
/>
|
|
86
86
|
);
|
|
87
|
-
expect(screen.getByRole('
|
|
88
|
-
await user.click(screen.getByRole('
|
|
87
|
+
expect(screen.getByRole('combobox')).toHaveTextContent('Pick');
|
|
88
|
+
await user.click(screen.getByRole('combobox'));
|
|
89
89
|
expect(screen.getByText('★ Free')).toBeInTheDocument();
|
|
90
90
|
});
|
|
91
91
|
|
|
@@ -102,4 +102,14 @@ describe('SelectMenu', () => {
|
|
|
102
102
|
const { container } = render(<SelectMenu aria-label="Plan" items={items} />);
|
|
103
103
|
expect(await axe(container)).toHaveNoViolations();
|
|
104
104
|
});
|
|
105
|
+
|
|
106
|
+
it('has no accessibility violations while the listbox is open', async () => {
|
|
107
|
+
const user = userEvent.setup();
|
|
108
|
+
render(<SelectMenu aria-label="Plan" items={items} />);
|
|
109
|
+
await user.click(screen.getByRole('combobox'));
|
|
110
|
+
// The open listbox is portalled outside the render container, so check the
|
|
111
|
+
// body. The region rule is disabled because this is a fragment, not a page.
|
|
112
|
+
const check = configureAxe({ rules: { region: { enabled: false } } });
|
|
113
|
+
expect(await check(document.body)).toHaveNoViolations();
|
|
114
|
+
});
|
|
105
115
|
});
|
|
@@ -265,6 +265,7 @@ export const SelectMenu = React.forwardRef<HTMLButtonElement, SelectMenuProps>(f
|
|
|
265
265
|
<button
|
|
266
266
|
ref={setTriggerRef}
|
|
267
267
|
type="button"
|
|
268
|
+
role="combobox"
|
|
268
269
|
aria-haspopup="listbox"
|
|
269
270
|
aria-expanded={open}
|
|
270
271
|
aria-controls={open ? listboxId : undefined}
|
|
@@ -292,6 +293,7 @@ export const SelectMenu = React.forwardRef<HTMLButtonElement, SelectMenuProps>(f
|
|
|
292
293
|
ref={listRef}
|
|
293
294
|
id={listboxId}
|
|
294
295
|
role="listbox"
|
|
296
|
+
tabIndex={-1}
|
|
295
297
|
aria-labelledby={labelId}
|
|
296
298
|
aria-multiselectable={multiple || undefined}
|
|
297
299
|
style={{
|
|
@@ -22,7 +22,15 @@ describe('Separator', () => {
|
|
|
22
22
|
it('applies the vertical orientation class', () => {
|
|
23
23
|
const { container } = render(<Separator orientation="vertical" />);
|
|
24
24
|
expect(container.firstChild).toHaveClass('w-px');
|
|
25
|
-
|
|
25
|
+
});
|
|
26
|
+
|
|
27
|
+
it('only exposes aria-orientation on a semantic separator', () => {
|
|
28
|
+
const { container } = render(<Separator orientation="vertical" />);
|
|
29
|
+
expect(container.firstChild).not.toHaveAttribute('aria-orientation');
|
|
30
|
+
|
|
31
|
+
const { container: semantic } = render(<Separator orientation="vertical" label="Toolbar sections" />);
|
|
32
|
+
expect(semantic.firstChild).toHaveAttribute('role', 'separator');
|
|
33
|
+
expect(semantic.firstChild).toHaveAttribute('aria-orientation', 'vertical');
|
|
26
34
|
});
|
|
27
35
|
|
|
28
36
|
it('forwards className', () => {
|
|
@@ -30,7 +30,7 @@ const Separator = React.forwardRef<HTMLDivElement, SeparatorProps>(
|
|
|
30
30
|
ref={ref}
|
|
31
31
|
role={label ? 'separator' : 'none'}
|
|
32
32
|
aria-label={label}
|
|
33
|
-
aria-orientation={orientation === 'vertical' ? 'vertical' : undefined}
|
|
33
|
+
aria-orientation={label && orientation === 'vertical' ? 'vertical' : undefined}
|
|
34
34
|
className={cn(separatorVariants({ orientation }), className)}
|
|
35
35
|
{...props}
|
|
36
36
|
/>
|
|
@@ -28,6 +28,25 @@ describe('Stepper', () => {
|
|
|
28
28
|
expect(container.querySelector('ol')).toHaveClass('flex-col');
|
|
29
29
|
});
|
|
30
30
|
|
|
31
|
+
it('centers a title vertically when the step has no description', () => {
|
|
32
|
+
const { container } = render(<Stepper steps={steps} current={0} />);
|
|
33
|
+
const rows = container.querySelectorAll('li > button, li > div[aria-current], li > div');
|
|
34
|
+
// Account has no description, so marker and title are centred; Details has
|
|
35
|
+
// a description and stays top aligned.
|
|
36
|
+
expect(rows[0]).toHaveClass('items-center');
|
|
37
|
+
expect(rows[1]).toHaveClass('items-start');
|
|
38
|
+
});
|
|
39
|
+
|
|
40
|
+
it('supports labels below the markers and a compact dots variant', () => {
|
|
41
|
+
const { container } = render(
|
|
42
|
+
<Stepper steps={steps} current={1} labelPlacement="below" variant="dots" size="sm" />
|
|
43
|
+
);
|
|
44
|
+
const row = container.querySelector('li > div[aria-current]');
|
|
45
|
+
expect(row).toHaveClass('flex-col');
|
|
46
|
+
expect(container.textContent).not.toContain('1');
|
|
47
|
+
expect(container.querySelectorAll('li')[0]).toHaveClass('flex-1');
|
|
48
|
+
});
|
|
49
|
+
|
|
31
50
|
it('has no accessibility violations', async () => {
|
|
32
51
|
const { container } = render(<Stepper steps={steps} current={1} />);
|
|
33
52
|
expect(await axe(container)).toHaveNoViolations();
|