@slipstream-ui/core 0.11.10 → 0.12.1
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 +154 -163
- package/dist/index.d.ts +154 -163
- package/dist/index.js +1358 -1165
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +1355 -1165
- 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 +12 -1
- package/dist/manifests/app-shell.manifest.json +12 -1
- package/dist/manifests/applied-filters.manifest.json +1 -1
- package/dist/manifests/article-card.manifest.json +12 -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/consent-banner.manifest.json +130 -0
- package/dist/manifests/contact-strip.manifest.json +12 -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 +12 -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 +12 -1
- package/dist/manifests/feature-grid.manifest.json +12 -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 +1 -1
- package/dist/manifests/menu.manifest.json +1 -1
- package/dist/manifests/metric-card.manifest.json +1 -1
- package/dist/manifests/month-schedule.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 +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 +7 -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 +12 -1
- package/dist/manifests/tooltip.manifest.json +1 -1
- package/dist/src/components/announcement-bar/AnnouncementBar.d.ts +3 -6
- package/dist/src/components/announcement-bar/AnnouncementBar.js +3 -1
- package/dist/src/components/announcement-bar/AnnouncementBar.js.map +1 -1
- package/dist/src/components/announcement-bar/AnnouncementBar.mjs +3 -1
- package/dist/src/components/announcement-bar/AnnouncementBar.mjs.map +1 -1
- package/dist/src/components/app-shell/AppShell.d.ts +3 -4
- package/dist/src/components/app-shell/AppShell.js +3 -1
- package/dist/src/components/app-shell/AppShell.js.map +1 -1
- package/dist/src/components/app-shell/AppShell.mjs +3 -1
- package/dist/src/components/app-shell/AppShell.mjs.map +1 -1
- package/dist/src/components/article-card/ArticleCard.d.ts +3 -6
- package/dist/src/components/article-card/ArticleCard.js +3 -1
- package/dist/src/components/article-card/ArticleCard.js.map +1 -1
- package/dist/src/components/article-card/ArticleCard.mjs +3 -1
- package/dist/src/components/article-card/ArticleCard.mjs.map +1 -1
- package/dist/src/components/bottom-nav/BottomNav.d.ts +2 -5
- package/dist/src/components/bottom-nav/BottomNav.js +2 -1
- package/dist/src/components/bottom-nav/BottomNav.js.map +1 -1
- package/dist/src/components/bottom-nav/BottomNav.mjs +2 -1
- package/dist/src/components/bottom-nav/BottomNav.mjs.map +1 -1
- package/dist/src/components/breadcrumb/Breadcrumb.d.ts +3 -16
- package/dist/src/components/breadcrumb/Breadcrumb.js +2 -1
- package/dist/src/components/breadcrumb/Breadcrumb.js.map +1 -1
- package/dist/src/components/breadcrumb/Breadcrumb.mjs +2 -1
- package/dist/src/components/breadcrumb/Breadcrumb.mjs.map +1 -1
- package/dist/src/components/consent-banner/ConsentBanner.d.ts +53 -0
- package/dist/src/components/consent-banner/ConsentBanner.js +83 -0
- package/dist/src/components/consent-banner/ConsentBanner.js.map +1 -0
- package/dist/src/components/consent-banner/ConsentBanner.mjs +49 -0
- package/dist/src/components/consent-banner/ConsentBanner.mjs.map +1 -0
- package/dist/src/components/consent-banner/index.d.ts +1 -0
- package/dist/src/components/consent-banner/index.js +23 -0
- package/dist/src/components/consent-banner/index.js.map +1 -0
- package/dist/src/components/consent-banner/index.mjs +2 -0
- package/dist/src/components/consent-banner/index.mjs.map +1 -0
- package/dist/src/components/contact-strip/ContactStrip.d.ts +3 -6
- package/dist/src/components/contact-strip/ContactStrip.js +3 -2
- package/dist/src/components/contact-strip/ContactStrip.js.map +1 -1
- package/dist/src/components/contact-strip/ContactStrip.mjs +3 -2
- package/dist/src/components/contact-strip/ContactStrip.mjs.map +1 -1
- package/dist/src/components/deal-card/DealCard.d.ts +3 -6
- package/dist/src/components/deal-card/DealCard.js +3 -1
- package/dist/src/components/deal-card/DealCard.js.map +1 -1
- package/dist/src/components/deal-card/DealCard.mjs +3 -1
- package/dist/src/components/deal-card/DealCard.mjs.map +1 -1
- package/dist/src/components/empty-state/EmptyState.d.ts +3 -10
- package/dist/src/components/empty-state/EmptyState.js +2 -1
- package/dist/src/components/empty-state/EmptyState.js.map +1 -1
- package/dist/src/components/empty-state/EmptyState.mjs +2 -1
- package/dist/src/components/empty-state/EmptyState.mjs.map +1 -1
- package/dist/src/components/entity-card/EntityCard.d.ts +4 -9
- package/dist/src/components/entity-card/EntityCard.js +4 -2
- package/dist/src/components/entity-card/EntityCard.js.map +1 -1
- package/dist/src/components/entity-card/EntityCard.mjs +4 -2
- package/dist/src/components/entity-card/EntityCard.mjs.map +1 -1
- package/dist/src/components/feature-grid/FeatureGrid.d.ts +3 -6
- package/dist/src/components/feature-grid/FeatureGrid.js +3 -2
- package/dist/src/components/feature-grid/FeatureGrid.js.map +1 -1
- package/dist/src/components/feature-grid/FeatureGrid.mjs +3 -2
- package/dist/src/components/feature-grid/FeatureGrid.mjs.map +1 -1
- package/dist/src/components/link-tabs/LinkTabs.d.ts +3 -16
- package/dist/src/components/link-tabs/LinkTabs.js +2 -1
- package/dist/src/components/link-tabs/LinkTabs.js.map +1 -1
- package/dist/src/components/link-tabs/LinkTabs.mjs +2 -1
- package/dist/src/components/link-tabs/LinkTabs.mjs.map +1 -1
- package/dist/src/components/logo-cloud/LogoCloud.d.ts +3 -10
- package/dist/src/components/logo-cloud/LogoCloud.js +2 -1
- package/dist/src/components/logo-cloud/LogoCloud.js.map +1 -1
- package/dist/src/components/logo-cloud/LogoCloud.mjs +2 -1
- package/dist/src/components/logo-cloud/LogoCloud.mjs.map +1 -1
- package/dist/src/components/media-card/MediaCard.d.ts +3 -10
- package/dist/src/components/media-card/MediaCard.js +2 -1
- package/dist/src/components/media-card/MediaCard.js.map +1 -1
- package/dist/src/components/media-card/MediaCard.mjs +2 -1
- package/dist/src/components/media-card/MediaCard.mjs.map +1 -1
- package/dist/src/components/month-schedule/MonthSchedule.d.ts +2 -5
- package/dist/src/components/month-schedule/MonthSchedule.js +3 -2
- package/dist/src/components/month-schedule/MonthSchedule.js.map +1 -1
- package/dist/src/components/month-schedule/MonthSchedule.mjs +3 -2
- package/dist/src/components/month-schedule/MonthSchedule.mjs.map +1 -1
- package/dist/src/components/pagination/Pagination.d.ts +3 -10
- package/dist/src/components/pagination/Pagination.js +2 -1
- package/dist/src/components/pagination/Pagination.js.map +1 -1
- package/dist/src/components/pagination/Pagination.mjs +2 -1
- package/dist/src/components/pagination/Pagination.mjs.map +1 -1
- package/dist/src/components/segmented-control/SegmentedControl.d.ts +3 -10
- package/dist/src/components/segmented-control/SegmentedControl.js +2 -1
- package/dist/src/components/segmented-control/SegmentedControl.js.map +1 -1
- package/dist/src/components/segmented-control/SegmentedControl.mjs +2 -1
- package/dist/src/components/segmented-control/SegmentedControl.mjs.map +1 -1
- package/dist/src/components/site-footer/SiteFooter.d.ts +2 -9
- package/dist/src/components/site-footer/SiteFooter.js +2 -1
- package/dist/src/components/site-footer/SiteFooter.js.map +1 -1
- package/dist/src/components/site-footer/SiteFooter.mjs +2 -1
- package/dist/src/components/site-footer/SiteFooter.mjs.map +1 -1
- package/dist/src/components/site-header/SiteHeader.d.ts +9 -10
- package/dist/src/components/site-header/SiteHeader.js +162 -133
- package/dist/src/components/site-header/SiteHeader.js.map +1 -1
- package/dist/src/components/site-header/SiteHeader.mjs +162 -133
- package/dist/src/components/site-header/SiteHeader.mjs.map +1 -1
- package/dist/src/components/tombstone-card/TombstoneCard.d.ts +3 -6
- package/dist/src/components/tombstone-card/TombstoneCard.js +3 -1
- package/dist/src/components/tombstone-card/TombstoneCard.js.map +1 -1
- package/dist/src/components/tombstone-card/TombstoneCard.mjs +3 -1
- package/dist/src/components/tombstone-card/TombstoneCard.mjs.map +1 -1
- package/dist/src/index.d.ts +3 -0
- package/dist/src/utils/consent.d.ts +42 -0
- package/dist/src/utils/consent.js +142 -0
- package/dist/src/utils/consent.js.map +1 -0
- package/dist/src/utils/consent.mjs +107 -0
- package/dist/src/utils/consent.mjs.map +1 -0
- package/dist/src/utils/link.d.ts +21 -0
- package/dist/src/utils/link.js +31 -0
- package/dist/src/utils/link.js.map +1 -0
- package/dist/src/utils/link.mjs +7 -0
- package/dist/src/utils/link.mjs.map +1 -0
- package/dist/styles-full.css +1 -1
- package/dist/styles.css +1 -1
- package/package.json +4 -4
- package/src/components/announcement-bar/AnnouncementBar.test.tsx +18 -0
- package/src/components/announcement-bar/AnnouncementBar.tsx +4 -4
- package/src/components/app-shell/AppShell.test.tsx +10 -0
- package/src/components/app-shell/AppShell.tsx +4 -4
- package/src/components/article-card/ArticleCard.test.tsx +10 -0
- package/src/components/article-card/ArticleCard.tsx +4 -4
- package/src/components/bottom-nav/BottomNav.tsx +3 -6
- package/src/components/breadcrumb/Breadcrumb.tsx +3 -9
- package/src/components/consent-banner/ConsentBanner.test.tsx +58 -0
- package/src/components/consent-banner/ConsentBanner.tsx +93 -0
- package/src/components/consent-banner/index.ts +1 -0
- package/src/components/contact-strip/ContactStrip.test.tsx +16 -0
- package/src/components/contact-strip/ContactStrip.tsx +4 -5
- package/src/components/deal-card/DealCard.test.tsx +19 -0
- package/src/components/deal-card/DealCard.tsx +4 -4
- package/src/components/empty-state/EmptyState.tsx +3 -6
- package/src/components/entity-card/EntityCard.test.tsx +8 -0
- package/src/components/entity-card/EntityCard.tsx +5 -5
- package/src/components/feature-grid/FeatureGrid.test.tsx +16 -0
- package/src/components/feature-grid/FeatureGrid.tsx +4 -5
- package/src/components/link-tabs/LinkTabs.tsx +3 -9
- package/src/components/logo-cloud/LogoCloud.tsx +3 -6
- package/src/components/media-card/MediaCard.tsx +3 -6
- package/src/components/month-schedule/MonthSchedule.tsx +4 -7
- package/src/components/pagination/Pagination.tsx +3 -6
- package/src/components/segmented-control/SegmentedControl.tsx +3 -6
- package/src/components/site-footer/SiteFooter.tsx +3 -11
- package/src/components/site-header/SiteHeader.test.tsx +53 -0
- package/src/components/site-header/SiteHeader.tsx +77 -32
- package/src/components/tombstone-card/TombstoneCard.test.tsx +17 -0
- package/src/components/tombstone-card/TombstoneCard.tsx +4 -4
- package/src/index.ts +3 -0
- package/src/manifests/accordion.manifest.json +1 -1
- package/src/manifests/alert.manifest.json +1 -1
- package/src/manifests/announcement-bar.manifest.json +12 -1
- package/src/manifests/app-shell.manifest.json +12 -1
- package/src/manifests/applied-filters.manifest.json +1 -1
- package/src/manifests/article-card.manifest.json +12 -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/consent-banner.manifest.json +130 -0
- package/src/manifests/contact-strip.manifest.json +12 -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 +12 -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 +12 -1
- package/src/manifests/feature-grid.manifest.json +12 -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 +1 -1
- package/src/manifests/menu.manifest.json +1 -1
- package/src/manifests/metric-card.manifest.json +1 -1
- package/src/manifests/month-schedule.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 +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 +7 -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 +12 -1
- package/src/manifests/tooltip.manifest.json +1 -1
- package/src/utils/consent.test.ts +112 -0
- package/src/utils/consent.ts +169 -0
- package/src/utils/link.ts +19 -0
|
@@ -40,6 +40,16 @@ describe('Sidebar', () => {
|
|
|
40
40
|
expect(screen.getByRole('link', { name: 'Dashboard' })).toHaveAttribute('data-router');
|
|
41
41
|
});
|
|
42
42
|
|
|
43
|
+
it('passes destinations via linkHrefProp for routers that use "to"', () => {
|
|
44
|
+
const RouterLink = ({ to, children, ...rest }: { to: string; children: React.ReactNode }) => (
|
|
45
|
+
<a href={to} data-router-to={to} {...rest}>
|
|
46
|
+
{children}
|
|
47
|
+
</a>
|
|
48
|
+
);
|
|
49
|
+
render(<Sidebar sections={sections} linkComponent={RouterLink} linkHrefProp="to" />);
|
|
50
|
+
expect(screen.getByRole('link', { name: 'Dashboard' })).toHaveAttribute('data-router-to', '/dashboard');
|
|
51
|
+
});
|
|
52
|
+
|
|
43
53
|
it('honours an explicit active flag', () => {
|
|
44
54
|
render(
|
|
45
55
|
<Sidebar
|
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
import * as React from 'react';
|
|
4
4
|
import { cn } from '../../utils/cn';
|
|
5
|
+
import { linkDestination, type LinkLikeProps } from '../../utils/link';
|
|
5
6
|
import { Drawer } from '../drawer/Drawer';
|
|
6
7
|
|
|
7
8
|
export type SidebarItem = {
|
|
@@ -21,7 +22,7 @@ export type SidebarSection = {
|
|
|
21
22
|
items: SidebarItem[];
|
|
22
23
|
};
|
|
23
24
|
|
|
24
|
-
export type SidebarProps = Omit<React.HTMLAttributes<HTMLElement>, 'children'> & {
|
|
25
|
+
export type SidebarProps = Omit<React.HTMLAttributes<HTMLElement>, 'children'> & LinkLikeProps & {
|
|
25
26
|
sections: SidebarSection[];
|
|
26
27
|
/** Brand/mark rendered at the top. */
|
|
27
28
|
heading?: React.ReactNode;
|
|
@@ -29,8 +30,6 @@ export type SidebarProps = Omit<React.HTMLAttributes<HTMLElement>, 'children'> &
|
|
|
29
30
|
footer?: React.ReactNode;
|
|
30
31
|
/** Current route — items with a matching href get aria-current="page". */
|
|
31
32
|
activeHref?: string;
|
|
32
|
-
/** Custom link element for routers (react-router `Link`, Next `Link`). */
|
|
33
|
-
linkComponent?: React.ElementType;
|
|
34
33
|
/** Accessible name of the nav landmark. Default 'Primary'. */
|
|
35
34
|
label?: string;
|
|
36
35
|
/** Show the collapse/expand control (icon-only rail when collapsed). */
|
|
@@ -69,6 +68,7 @@ export function Sidebar({
|
|
|
69
68
|
footer,
|
|
70
69
|
activeHref,
|
|
71
70
|
linkComponent,
|
|
71
|
+
linkHrefProp = 'href',
|
|
72
72
|
label = 'Primary',
|
|
73
73
|
collapsible = false,
|
|
74
74
|
defaultCollapsed = false,
|
|
@@ -133,7 +133,7 @@ export function Sidebar({
|
|
|
133
133
|
return (
|
|
134
134
|
<li key={item.href}>
|
|
135
135
|
<Link
|
|
136
|
-
|
|
136
|
+
{...linkDestination(item.href, linkHrefProp)}
|
|
137
137
|
aria-current={active ? 'page' : undefined}
|
|
138
138
|
title={collapsed ? item.label : undefined}
|
|
139
139
|
className={cn(itemClass, active ? activeClass : idleClass, collapsed && 'justify-center px-0')}
|
|
@@ -32,6 +32,16 @@ describe('ArticleCard', () => {
|
|
|
32
32
|
expect(screen.getByRole('link', { name: 'Post' })).toHaveAttribute('data-router', 'true');
|
|
33
33
|
});
|
|
34
34
|
|
|
35
|
+
it('passes the destination via linkHrefProp for routers that use "to"', () => {
|
|
36
|
+
const RouterLink = ({ to, children, ...props }: { to: string; children: ReactNode }) => (
|
|
37
|
+
<a href={to} data-router-to={to} {...props}>
|
|
38
|
+
{children}
|
|
39
|
+
</a>
|
|
40
|
+
);
|
|
41
|
+
render(<ArticleCard href="/post" title="Post" linkComponent={RouterLink} linkHrefProp="to" />);
|
|
42
|
+
expect(screen.getByRole('link', { name: 'Post' })).toHaveAttribute('data-router-to', '/post');
|
|
43
|
+
});
|
|
44
|
+
|
|
35
45
|
it('has no accessibility violations', async () => {
|
|
36
46
|
const { container } = render(<ArticleCard href="/post" title="Post" description="Copy" />);
|
|
37
47
|
expect(await axe(container)).toHaveNoViolations();
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
2
|
import { cn } from '../../utils/cn';
|
|
3
|
+
import { linkDestination, type LinkLikeProps } from '../../utils/link';
|
|
3
4
|
|
|
4
|
-
export type ArticleCardProps = Omit<React.HTMLAttributes<HTMLElement>, 'title'> & {
|
|
5
|
+
export type ArticleCardProps = Omit<React.HTMLAttributes<HTMLElement>, 'title'> & LinkLikeProps & {
|
|
5
6
|
/** Article title. */
|
|
6
7
|
title: string;
|
|
7
8
|
/** Summary copy. */
|
|
@@ -14,8 +15,6 @@ export type ArticleCardProps = Omit<React.HTMLAttributes<HTMLElement>, 'title'>
|
|
|
14
15
|
media?: React.ReactNode;
|
|
15
16
|
/** Date, read time, author or other metadata. */
|
|
16
17
|
meta?: React.ReactNode;
|
|
17
|
-
/** Custom link element for routers. */
|
|
18
|
-
linkComponent?: React.ElementType;
|
|
19
18
|
/** Standard card or a denser compact card. */
|
|
20
19
|
variant?: 'default' | 'compact';
|
|
21
20
|
};
|
|
@@ -34,6 +33,7 @@ export const ArticleCard = React.forwardRef<HTMLElement, ArticleCardProps>(funct
|
|
|
34
33
|
media,
|
|
35
34
|
meta,
|
|
36
35
|
linkComponent,
|
|
36
|
+
linkHrefProp = 'href',
|
|
37
37
|
variant = 'default',
|
|
38
38
|
className,
|
|
39
39
|
...props
|
|
@@ -46,7 +46,7 @@ export const ArticleCard = React.forwardRef<HTMLElement, ArticleCardProps>(funct
|
|
|
46
46
|
return (
|
|
47
47
|
<article ref={ref as never} className={cn('h-full', className)} {...props}>
|
|
48
48
|
<Link
|
|
49
|
-
|
|
49
|
+
{...linkDestination(href, linkHrefProp)}
|
|
50
50
|
className={cn(
|
|
51
51
|
'group flex h-full flex-col overflow-hidden rounded-xl border border-border bg-card shadow-sm transition-colors hover:border-primary/40',
|
|
52
52
|
'focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 focus-visible:ring-offset-background'
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
2
|
import { cn } from '../../utils/cn';
|
|
3
|
+
import { linkDestination, type LinkLikeProps } from '../../utils/link';
|
|
3
4
|
|
|
4
5
|
export type BottomNavItem = {
|
|
5
6
|
/** Destination URL for the tab. */
|
|
@@ -16,13 +17,9 @@ export type BottomNavItem = {
|
|
|
16
17
|
disabled?: boolean;
|
|
17
18
|
};
|
|
18
19
|
|
|
19
|
-
export type BottomNavProps = React.HTMLAttributes<HTMLElement> & {
|
|
20
|
+
export type BottomNavProps = React.HTMLAttributes<HTMLElement> & LinkLikeProps & {
|
|
20
21
|
/** Tabs in order. Keep to 3-5 so every target stays thumb-reachable. */
|
|
21
22
|
items: BottomNavItem[];
|
|
22
|
-
/** Router link component (Next Link, react-router Link). */
|
|
23
|
-
linkComponent?: React.ElementType;
|
|
24
|
-
/** Prop used to pass the destination to `linkComponent`. */
|
|
25
|
-
linkHrefProp?: 'href' | 'to';
|
|
26
23
|
/** Landmark label. Default "Primary". */
|
|
27
24
|
label?: string;
|
|
28
25
|
/** Pin the bar to the bottom edge with safe-area padding (default true). */
|
|
@@ -51,7 +48,7 @@ export function BottomNav({
|
|
|
51
48
|
...props
|
|
52
49
|
}: BottomNavProps) {
|
|
53
50
|
const LinkEl = linkComponent ?? 'a';
|
|
54
|
-
const destination = (href: string) => (
|
|
51
|
+
const destination = (href: string) => linkDestination(href, linkHrefProp);
|
|
55
52
|
|
|
56
53
|
return (
|
|
57
54
|
<nav
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
2
|
import { cn } from '../../utils/cn';
|
|
3
|
+
import { linkDestination, type LinkLikeProps } from '../../utils/link';
|
|
3
4
|
|
|
4
5
|
export type BreadcrumbItem = {
|
|
5
6
|
/** Display label. */
|
|
@@ -8,7 +9,7 @@ export type BreadcrumbItem = {
|
|
|
8
9
|
href?: string;
|
|
9
10
|
};
|
|
10
11
|
|
|
11
|
-
export type BreadcrumbProps = React.HTMLAttributes<HTMLElement> & {
|
|
12
|
+
export type BreadcrumbProps = React.HTMLAttributes<HTMLElement> & LinkLikeProps & {
|
|
12
13
|
/** Ordered list of breadcrumb items; the last item is the current page. */
|
|
13
14
|
items: BreadcrumbItem[];
|
|
14
15
|
/** Accessible name of the navigation landmark. Default 'Breadcrumb'. */
|
|
@@ -21,13 +22,6 @@ export type BreadcrumbProps = React.HTMLAttributes<HTMLElement> & {
|
|
|
21
22
|
* (e.g. via a router, state machine, or analytics wrapper).
|
|
22
23
|
*/
|
|
23
24
|
onItemClick?: (item: BreadcrumbItem, index: number) => void;
|
|
24
|
-
/** Custom link element for routers (Next Link, react-router Link). */
|
|
25
|
-
linkComponent?: React.ElementType;
|
|
26
|
-
/**
|
|
27
|
-
* Prop used to pass the destination to `linkComponent`. `href` covers
|
|
28
|
-
* anchors and Next.js Link; `to` covers react-router and similar routers.
|
|
29
|
-
*/
|
|
30
|
-
linkHrefProp?: 'href' | 'to';
|
|
31
25
|
/** Truncate the current page label and expose the full text as a title. */
|
|
32
26
|
truncateCurrent?: boolean;
|
|
33
27
|
};
|
|
@@ -59,7 +53,7 @@ const Breadcrumb = React.forwardRef<HTMLElement, BreadcrumbProps>(
|
|
|
59
53
|
)}
|
|
60
54
|
{item.href && !isLast ? (
|
|
61
55
|
<LinkEl
|
|
62
|
-
{...(
|
|
56
|
+
{...linkDestination(item.href, linkHrefProp)}
|
|
63
57
|
className="transition-colors hover:text-foreground"
|
|
64
58
|
onClick={
|
|
65
59
|
onItemClick
|
|
@@ -0,0 +1,58 @@
|
|
|
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 { ConsentBanner } from './ConsentBanner';
|
|
6
|
+
|
|
7
|
+
describe('ConsentBanner', () => {
|
|
8
|
+
it('renders a labelled region with default actions', async () => {
|
|
9
|
+
const { container } = render(
|
|
10
|
+
<ConsentBanner onAccept={vi.fn()} onDecline={vi.fn()}>
|
|
11
|
+
We use cookies for analytics.
|
|
12
|
+
</ConsentBanner>
|
|
13
|
+
);
|
|
14
|
+
expect(screen.getByRole('region', { name: 'Cookie consent' })).toBeInTheDocument();
|
|
15
|
+
expect(screen.getByRole('button', { name: 'Accept' })).toBeInTheDocument();
|
|
16
|
+
expect(screen.getByRole('button', { name: 'Decline' })).toBeInTheDocument();
|
|
17
|
+
expect(screen.queryByRole('button', { name: 'Manage' })).not.toBeInTheDocument();
|
|
18
|
+
expect(await axe(container)).toHaveNoViolations();
|
|
19
|
+
});
|
|
20
|
+
|
|
21
|
+
it('fires onAccept, onDecline and onManage', async () => {
|
|
22
|
+
const user = userEvent.setup();
|
|
23
|
+
const onAccept = vi.fn();
|
|
24
|
+
const onDecline = vi.fn();
|
|
25
|
+
const onManage = vi.fn();
|
|
26
|
+
render(
|
|
27
|
+
<ConsentBanner
|
|
28
|
+
title="We use cookies"
|
|
29
|
+
onAccept={onAccept}
|
|
30
|
+
onDecline={onDecline}
|
|
31
|
+
onManage={onManage}
|
|
32
|
+
>
|
|
33
|
+
Body copy
|
|
34
|
+
</ConsentBanner>
|
|
35
|
+
);
|
|
36
|
+
await user.click(screen.getByRole('button', { name: 'Accept' }));
|
|
37
|
+
await user.click(screen.getByRole('button', { name: 'Decline' }));
|
|
38
|
+
await user.click(screen.getByRole('button', { name: 'Manage' }));
|
|
39
|
+
expect(onAccept).toHaveBeenCalledTimes(1);
|
|
40
|
+
expect(onDecline).toHaveBeenCalledTimes(1);
|
|
41
|
+
expect(onManage).toHaveBeenCalledTimes(1);
|
|
42
|
+
});
|
|
43
|
+
|
|
44
|
+
it('supports custom labels and region name', () => {
|
|
45
|
+
render(
|
|
46
|
+
<ConsentBanner
|
|
47
|
+
label="Datenschutz"
|
|
48
|
+
acceptLabel="Alle akzeptieren"
|
|
49
|
+
declineLabel="Ablehnen"
|
|
50
|
+
onAccept={vi.fn()}
|
|
51
|
+
onDecline={vi.fn()}
|
|
52
|
+
/>
|
|
53
|
+
);
|
|
54
|
+
expect(screen.getByRole('region', { name: 'Datenschutz' })).toBeInTheDocument();
|
|
55
|
+
expect(screen.getByRole('button', { name: 'Alle akzeptieren' })).toBeInTheDocument();
|
|
56
|
+
expect(screen.getByRole('button', { name: 'Ablehnen' })).toBeInTheDocument();
|
|
57
|
+
});
|
|
58
|
+
});
|
|
@@ -0,0 +1,93 @@
|
|
|
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 ConsentBannerProps = React.HTMLAttributes<HTMLDivElement> & {
|
|
8
|
+
/** Called when the visitor accepts (all purposes granted). */
|
|
9
|
+
onAccept: () => void;
|
|
10
|
+
/** Called when the visitor declines (all purposes denied). */
|
|
11
|
+
onDecline: () => void;
|
|
12
|
+
/** Optional "manage preferences" action for granular consent dialogs. */
|
|
13
|
+
onManage?: () => void;
|
|
14
|
+
/** Banner heading. Omit for a single-line notice. */
|
|
15
|
+
title?: React.ReactNode;
|
|
16
|
+
/** Body copy; put privacy-policy links here. */
|
|
17
|
+
children?: React.ReactNode;
|
|
18
|
+
/** Accessible name for the banner region. Default 'Cookie consent'. */
|
|
19
|
+
label?: string;
|
|
20
|
+
acceptLabel?: React.ReactNode;
|
|
21
|
+
declineLabel?: React.ReactNode;
|
|
22
|
+
manageLabel?: React.ReactNode;
|
|
23
|
+
};
|
|
24
|
+
|
|
25
|
+
/**
|
|
26
|
+
* Styled cookie/consent banner: a fixed bottom bar with accept, decline and
|
|
27
|
+
* an optional manage-preferences action. Presentational only — wire it to
|
|
28
|
+
* `useConsent` (or your own store) and render it conditionally:
|
|
29
|
+
*
|
|
30
|
+
* ```tsx
|
|
31
|
+
* const consent = useConsent({ purposes: ['analytics'] });
|
|
32
|
+
* {!consent.decided && (
|
|
33
|
+
* <ConsentBanner
|
|
34
|
+
* onAccept={() => consent.setAll(true)}
|
|
35
|
+
* onDecline={() => consent.setAll(false)}
|
|
36
|
+
* >
|
|
37
|
+
* We use cookies for analytics.{' '}
|
|
38
|
+
* <a href="/privacy">Privacy policy</a>
|
|
39
|
+
* </ConsentBanner>
|
|
40
|
+
* )}
|
|
41
|
+
* ```
|
|
42
|
+
*/
|
|
43
|
+
export const ConsentBanner = React.forwardRef<HTMLDivElement, ConsentBannerProps>(
|
|
44
|
+
function ConsentBanner(
|
|
45
|
+
{
|
|
46
|
+
onAccept,
|
|
47
|
+
onDecline,
|
|
48
|
+
onManage,
|
|
49
|
+
title,
|
|
50
|
+
children,
|
|
51
|
+
label = 'Cookie consent',
|
|
52
|
+
acceptLabel = 'Accept',
|
|
53
|
+
declineLabel = 'Decline',
|
|
54
|
+
manageLabel = 'Manage',
|
|
55
|
+
className,
|
|
56
|
+
...props
|
|
57
|
+
},
|
|
58
|
+
ref
|
|
59
|
+
) {
|
|
60
|
+
return (
|
|
61
|
+
<div
|
|
62
|
+
ref={ref}
|
|
63
|
+
role="region"
|
|
64
|
+
aria-label={label}
|
|
65
|
+
className={cn(
|
|
66
|
+
'fixed inset-x-0 bottom-0 z-50 border-t border-border bg-card px-4 py-4 pb-[calc(1rem+env(safe-area-inset-bottom))] shadow-lg sm:px-6',
|
|
67
|
+
className
|
|
68
|
+
)}
|
|
69
|
+
{...props}
|
|
70
|
+
>
|
|
71
|
+
<div className="mx-auto flex max-w-5xl flex-col gap-3 sm:flex-row sm:items-center sm:justify-between">
|
|
72
|
+
<div className="min-w-0">
|
|
73
|
+
{title && <p className="text-sm font-medium text-foreground">{title}</p>}
|
|
74
|
+
{children && <div className="text-sm text-muted-foreground">{children}</div>}
|
|
75
|
+
</div>
|
|
76
|
+
<div className="flex shrink-0 flex-wrap gap-2">
|
|
77
|
+
{onManage && (
|
|
78
|
+
<Button type="button" variant="ghost" size="sm" onClick={onManage}>
|
|
79
|
+
{manageLabel}
|
|
80
|
+
</Button>
|
|
81
|
+
)}
|
|
82
|
+
<Button type="button" variant="outline" size="sm" onClick={onDecline}>
|
|
83
|
+
{declineLabel}
|
|
84
|
+
</Button>
|
|
85
|
+
<Button type="button" size="sm" onClick={onAccept}>
|
|
86
|
+
{acceptLabel}
|
|
87
|
+
</Button>
|
|
88
|
+
</div>
|
|
89
|
+
</div>
|
|
90
|
+
</div>
|
|
91
|
+
);
|
|
92
|
+
}
|
|
93
|
+
);
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './ConsentBanner';
|
|
@@ -18,6 +18,22 @@ describe('ContactStrip', () => {
|
|
|
18
18
|
expect(screen.getByRole('link', { name: 'info@axial.net' })).toHaveAttribute('href', 'mailto:info@axial.net');
|
|
19
19
|
});
|
|
20
20
|
|
|
21
|
+
it('passes destinations via linkHrefProp for routers that use "to"', () => {
|
|
22
|
+
const RouterLink = ({ to, children, ...rest }: { to: string; children: React.ReactNode }) => (
|
|
23
|
+
<a href={to} data-router-to={to} {...rest}>
|
|
24
|
+
{children}
|
|
25
|
+
</a>
|
|
26
|
+
);
|
|
27
|
+
render(
|
|
28
|
+
<ContactStrip
|
|
29
|
+
items={[{ label: 'Site', value: 'Example', href: '/about' }]}
|
|
30
|
+
linkComponent={RouterLink}
|
|
31
|
+
linkHrefProp="to"
|
|
32
|
+
/>
|
|
33
|
+
);
|
|
34
|
+
expect(screen.getByRole('link', { name: 'Example' })).toHaveAttribute('data-router-to', '/about');
|
|
35
|
+
});
|
|
36
|
+
|
|
21
37
|
it('has no accessibility violations', async () => {
|
|
22
38
|
const { container } = render(<ContactStrip items={[{ label: 'Address', value: 'New York, NY' }]} />);
|
|
23
39
|
expect(await axe(container)).toHaveNoViolations();
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
2
|
import { cn } from '../../utils/cn';
|
|
3
|
+
import { linkDestination, type LinkLikeProps } from '../../utils/link';
|
|
3
4
|
|
|
4
5
|
export type ContactItem = {
|
|
5
6
|
label: string;
|
|
@@ -8,15 +9,13 @@ export type ContactItem = {
|
|
|
8
9
|
icon?: React.ReactNode;
|
|
9
10
|
};
|
|
10
11
|
|
|
11
|
-
export type ContactStripProps = React.HTMLAttributes<HTMLUListElement> & {
|
|
12
|
+
export type ContactStripProps = React.HTMLAttributes<HTMLUListElement> & LinkLikeProps & {
|
|
12
13
|
/** Contact rows to display. */
|
|
13
14
|
items: ContactItem[];
|
|
14
15
|
/** Desktop column count (2-3). Default 2. */
|
|
15
16
|
columns?: 2 | 3;
|
|
16
17
|
/** Content alignment. Default 'left'. */
|
|
17
18
|
align?: 'left' | 'center';
|
|
18
|
-
/** Custom link element for routers. */
|
|
19
|
-
linkComponent?: React.ElementType;
|
|
20
19
|
};
|
|
21
20
|
|
|
22
21
|
const columnClasses: Record<NonNullable<ContactStripProps['columns']>, string> = {
|
|
@@ -29,7 +28,7 @@ const columnClasses: Record<NonNullable<ContactStripProps['columns']>, string> =
|
|
|
29
28
|
* pairs a short label with a phone, email, address or link.
|
|
30
29
|
*/
|
|
31
30
|
export const ContactStrip = React.forwardRef<HTMLUListElement, ContactStripProps>(function ContactStrip(
|
|
32
|
-
{ items, columns = 2, align = 'left', linkComponent, className, ...props },
|
|
31
|
+
{ items, columns = 2, align = 'left', linkComponent, linkHrefProp = 'href', className, ...props },
|
|
33
32
|
ref
|
|
34
33
|
) {
|
|
35
34
|
const Link = linkComponent ?? 'a';
|
|
@@ -46,7 +45,7 @@ export const ContactStrip = React.forwardRef<HTMLUListElement, ContactStripProps
|
|
|
46
45
|
<div className="min-w-0">
|
|
47
46
|
<p className="text-xs font-semibold uppercase tracking-wider text-muted-foreground">{item.label}</p>
|
|
48
47
|
{item.href ? (
|
|
49
|
-
<Link
|
|
48
|
+
<Link {...linkDestination(item.href, linkHrefProp)} className="mt-0.5 block break-words text-sm font-medium text-primary-ink underline-offset-4 hover:underline">
|
|
50
49
|
{item.value}
|
|
51
50
|
</Link>
|
|
52
51
|
) : (
|
|
@@ -47,6 +47,25 @@ describe('DealCard', () => {
|
|
|
47
47
|
expect(onRequestAccess).toHaveBeenCalled();
|
|
48
48
|
});
|
|
49
49
|
|
|
50
|
+
it('passes the destination via linkHrefProp for routers that use "to"', () => {
|
|
51
|
+
const RouterLink = ({ to, children, ...rest }: { to: string; children: React.ReactNode }) => (
|
|
52
|
+
<a href={to} data-router-to={to} {...rest}>
|
|
53
|
+
{children}
|
|
54
|
+
</a>
|
|
55
|
+
);
|
|
56
|
+
render(
|
|
57
|
+
<DealCard
|
|
58
|
+
title="Deal"
|
|
59
|
+
sector="Technology"
|
|
60
|
+
metrics={metrics}
|
|
61
|
+
href="/deals/1"
|
|
62
|
+
linkComponent={RouterLink}
|
|
63
|
+
linkHrefProp="to"
|
|
64
|
+
/>
|
|
65
|
+
);
|
|
66
|
+
expect(screen.getByRole('link', { name: 'Deal' })).toHaveAttribute('data-router-to', '/deals/1');
|
|
67
|
+
});
|
|
68
|
+
|
|
50
69
|
it('has no accessibility violations', async () => {
|
|
51
70
|
const { container } = render(<DealCard title="Deal" sector="Technology" metrics={metrics} />);
|
|
52
71
|
expect(await axe(container)).toHaveNoViolations();
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
2
|
import { cn } from '../../utils/cn';
|
|
3
|
+
import { linkDestination, type LinkLikeProps } from '../../utils/link';
|
|
3
4
|
import { Badge } from '../badge/Badge';
|
|
4
5
|
import { Button } from '../button/Button';
|
|
5
6
|
import { Card, CardContent, CardFooter, CardHeader } from '../card/Card';
|
|
@@ -11,7 +12,7 @@ export type DealMetric = {
|
|
|
11
12
|
|
|
12
13
|
export type DealStatus = 'available' | 'under-nda' | 'closed' | 'draft';
|
|
13
14
|
|
|
14
|
-
export type DealCardProps = Omit<React.HTMLAttributes<HTMLElement>, 'title'> & {
|
|
15
|
+
export type DealCardProps = Omit<React.HTMLAttributes<HTMLElement>, 'title'> & LinkLikeProps & {
|
|
15
16
|
/** Deal headline. */
|
|
16
17
|
title: string;
|
|
17
18
|
/** Sector or industry label. */
|
|
@@ -30,8 +31,6 @@ export type DealCardProps = Omit<React.HTMLAttributes<HTMLElement>, 'title'> & {
|
|
|
30
31
|
cimAvailable?: boolean;
|
|
31
32
|
/** Optional deal detail link. */
|
|
32
33
|
href?: string;
|
|
33
|
-
/** Custom link element for routers. */
|
|
34
|
-
linkComponent?: React.ElementType;
|
|
35
34
|
/** Save toggle state. */
|
|
36
35
|
saved?: boolean;
|
|
37
36
|
onSave?: () => void;
|
|
@@ -66,6 +65,7 @@ export const DealCard = React.forwardRef<HTMLElement, DealCardProps>(function De
|
|
|
66
65
|
cimAvailable,
|
|
67
66
|
href,
|
|
68
67
|
linkComponent,
|
|
68
|
+
linkHrefProp = 'href',
|
|
69
69
|
saved = false,
|
|
70
70
|
onSave,
|
|
71
71
|
saveLabel = 'Save',
|
|
@@ -88,7 +88,7 @@ export const DealCard = React.forwardRef<HTMLElement, DealCardProps>(function De
|
|
|
88
88
|
</div>
|
|
89
89
|
<h3 className="text-lg font-semibold leading-snug tracking-tight">
|
|
90
90
|
{href ? (
|
|
91
|
-
<Link
|
|
91
|
+
<Link {...linkDestination(href, linkHrefProp)} className="rounded-sm hover:text-primary-ink focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring">
|
|
92
92
|
{title}
|
|
93
93
|
</Link>
|
|
94
94
|
) : (
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
2
|
import { cn } from '../../utils/cn';
|
|
3
3
|
import { Button, type ButtonProps } from '../button/Button';
|
|
4
|
+
import { linkDestination, type LinkLikeProps } from '../../utils/link';
|
|
4
5
|
|
|
5
6
|
/** Object form of `action`: EmptyState renders the button/link for you. */
|
|
6
7
|
export type EmptyStateAction = {
|
|
@@ -11,7 +12,7 @@ export type EmptyStateAction = {
|
|
|
11
12
|
variant?: ButtonProps['variant'];
|
|
12
13
|
};
|
|
13
14
|
|
|
14
|
-
export type EmptyStateProps = React.HTMLAttributes<HTMLDivElement> & {
|
|
15
|
+
export type EmptyStateProps = React.HTMLAttributes<HTMLDivElement> & LinkLikeProps & {
|
|
15
16
|
/** Icon or illustration shown above the title. */
|
|
16
17
|
icon?: React.ReactNode;
|
|
17
18
|
title: string;
|
|
@@ -34,10 +35,6 @@ export type EmptyStateProps = React.HTMLAttributes<HTMLDivElement> & {
|
|
|
34
35
|
* default dashed outline. Default 'plain'.
|
|
35
36
|
*/
|
|
36
37
|
tone?: 'plain' | 'panel';
|
|
37
|
-
/** Custom link element for action hrefs (Next Link, react-router Link). */
|
|
38
|
-
linkComponent?: React.ElementType;
|
|
39
|
-
/** Prop used to pass the destination to `linkComponent`. */
|
|
40
|
-
linkHrefProp?: 'href' | 'to';
|
|
41
38
|
};
|
|
42
39
|
|
|
43
40
|
function isActionObject(value: unknown): value is EmptyStateAction {
|
|
@@ -59,7 +56,7 @@ function renderAction(
|
|
|
59
56
|
const { label, onClick, href, variant } = action;
|
|
60
57
|
if (href) {
|
|
61
58
|
const LinkEl = linkComponent ?? 'a';
|
|
62
|
-
const destination =
|
|
59
|
+
const destination = linkDestination(href, linkHrefProp);
|
|
63
60
|
return (
|
|
64
61
|
<Button variant={variant} asChild>
|
|
65
62
|
<LinkEl {...destination}>{label}</LinkEl>
|
|
@@ -53,6 +53,14 @@ describe('EntityCard', () => {
|
|
|
53
53
|
expect(screen.getByRole('link', { name: 'North Park' })).toHaveAttribute('data-router-link');
|
|
54
54
|
});
|
|
55
55
|
|
|
56
|
+
it('passes destinations via linkHrefProp for routers that use "to"', () => {
|
|
57
|
+
const RouterLink = ({ to, children, ...rest }: { to: string; children: ReactNode }) => (
|
|
58
|
+
<a href={to} data-router-to={to} {...rest}>{children}</a>
|
|
59
|
+
);
|
|
60
|
+
render(<EntityCard name="North Park" entityType="Private equity" href="/members/north-park" linkComponent={RouterLink} linkHrefProp="to" />);
|
|
61
|
+
expect(screen.getByRole('link', { name: 'North Park' })).toHaveAttribute('data-router-to', '/members/north-park');
|
|
62
|
+
});
|
|
63
|
+
|
|
56
64
|
it('falls back to initials and exposes the ProfileCard alias', () => {
|
|
57
65
|
render(<ProfileCard name="North Park" entityType="Private equity" />);
|
|
58
66
|
expect(screen.getByText('NP')).toBeInTheDocument();
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
2
|
import { cn } from '../../utils/cn';
|
|
3
|
+
import { linkDestination, type LinkLikeProps } from '../../utils/link';
|
|
3
4
|
import { Avatar, AvatarFallback } from '../avatar/Avatar';
|
|
4
5
|
import { Badge } from '../badge/Badge';
|
|
5
6
|
import { Card, CardContent, CardFooter, CardHeader } from '../card/Card';
|
|
@@ -9,7 +10,7 @@ export type EntityStat = {
|
|
|
9
10
|
value: string;
|
|
10
11
|
};
|
|
11
12
|
|
|
12
|
-
export type EntityCardProps = React.HTMLAttributes<HTMLElement> & {
|
|
13
|
+
export type EntityCardProps = React.HTMLAttributes<HTMLElement> & LinkLikeProps & {
|
|
13
14
|
/** Firm or member name. */
|
|
14
15
|
name: string;
|
|
15
16
|
/** Firm type, role or member category. */
|
|
@@ -33,8 +34,6 @@ export type EntityCardProps = React.HTMLAttributes<HTMLElement> & {
|
|
|
33
34
|
* the overlay; the redundant footer "View profile" link is suppressed.
|
|
34
35
|
*/
|
|
35
36
|
cardHref?: string;
|
|
36
|
-
/** Custom link element for routers. */
|
|
37
|
-
linkComponent?: React.ElementType;
|
|
38
37
|
/** Extra footer actions. */
|
|
39
38
|
actions?: React.ReactNode;
|
|
40
39
|
};
|
|
@@ -65,6 +64,7 @@ export const EntityCard = React.forwardRef<HTMLElement, EntityCardProps>(functio
|
|
|
65
64
|
href,
|
|
66
65
|
cardHref,
|
|
67
66
|
linkComponent,
|
|
67
|
+
linkHrefProp = 'href',
|
|
68
68
|
actions,
|
|
69
69
|
className,
|
|
70
70
|
...props
|
|
@@ -89,7 +89,7 @@ export const EntityCard = React.forwardRef<HTMLElement, EntityCardProps>(functio
|
|
|
89
89
|
<h3 className="truncate text-base font-semibold tracking-tight">
|
|
90
90
|
{nameHref ? (
|
|
91
91
|
<Link
|
|
92
|
-
|
|
92
|
+
{...linkDestination(nameHref, linkHrefProp)}
|
|
93
93
|
className={cn(
|
|
94
94
|
'rounded-sm hover:text-primary-ink focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring',
|
|
95
95
|
stretched && 'after:absolute after:inset-0 after:content-[""]'
|
|
@@ -131,7 +131,7 @@ export const EntityCard = React.forwardRef<HTMLElement, EntityCardProps>(functio
|
|
|
131
131
|
<CardFooter className={cn('flex flex-wrap items-center gap-2 border-t border-border px-5 py-3', stretched && 'relative z-10')}>
|
|
132
132
|
{href && !stretched && (
|
|
133
133
|
<Link
|
|
134
|
-
|
|
134
|
+
{...linkDestination(href, linkHrefProp)}
|
|
135
135
|
className="text-sm font-medium text-primary-ink underline-offset-4 hover:underline focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring"
|
|
136
136
|
>
|
|
137
137
|
View profile
|
|
@@ -26,6 +26,22 @@ describe('FeatureGrid', () => {
|
|
|
26
26
|
expect(screen.getByRole('heading', { name: 'One' }).parentElement).toHaveClass('items-center', 'text-center');
|
|
27
27
|
});
|
|
28
28
|
|
|
29
|
+
it('passes destinations via linkHrefProp for routers that use "to"', () => {
|
|
30
|
+
const RouterLink = ({ to, children, ...rest }: { to: string; children: React.ReactNode }) => (
|
|
31
|
+
<a href={to} data-router-to={to} {...rest}>
|
|
32
|
+
{children}
|
|
33
|
+
</a>
|
|
34
|
+
);
|
|
35
|
+
render(
|
|
36
|
+
<FeatureGrid
|
|
37
|
+
features={[{ title: 'Feature', href: '/features/1', actionLabel: 'Learn more' }]}
|
|
38
|
+
linkComponent={RouterLink}
|
|
39
|
+
linkHrefProp="to"
|
|
40
|
+
/>
|
|
41
|
+
);
|
|
42
|
+
expect(screen.getByRole('link', { name: /Learn more/ })).toHaveAttribute('data-router-to', '/features/1');
|
|
43
|
+
});
|
|
44
|
+
|
|
29
45
|
it('has no accessibility violations', async () => {
|
|
30
46
|
const { container } = render(<FeatureGrid features={[{ title: 'Feature', description: 'Copy' }]} />);
|
|
31
47
|
expect(await axe(container)).toHaveNoViolations();
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
2
|
import { cn } from '../../utils/cn';
|
|
3
|
+
import { linkDestination, type LinkLikeProps } from '../../utils/link';
|
|
3
4
|
|
|
4
5
|
export type FeatureItem = {
|
|
5
6
|
title: string;
|
|
@@ -10,7 +11,7 @@ export type FeatureItem = {
|
|
|
10
11
|
actionLabel?: string;
|
|
11
12
|
};
|
|
12
13
|
|
|
13
|
-
export type FeatureGridProps = React.HTMLAttributes<HTMLUListElement> & {
|
|
14
|
+
export type FeatureGridProps = React.HTMLAttributes<HTMLUListElement> & LinkLikeProps & {
|
|
14
15
|
/** Features to display. */
|
|
15
16
|
features: FeatureItem[];
|
|
16
17
|
/** Desktop column count (2-4). Default 3. */
|
|
@@ -19,8 +20,6 @@ export type FeatureGridProps = React.HTMLAttributes<HTMLUListElement> & {
|
|
|
19
20
|
variant?: 'card' | 'plain';
|
|
20
21
|
/** Content alignment. Default 'left'. */
|
|
21
22
|
align?: 'left' | 'center';
|
|
22
|
-
/** Custom link element for routers. */
|
|
23
|
-
linkComponent?: React.ElementType;
|
|
24
23
|
};
|
|
25
24
|
|
|
26
25
|
const columnClasses: Record<NonNullable<FeatureGridProps['columns']>, string> = {
|
|
@@ -35,7 +34,7 @@ const columnClasses: Record<NonNullable<FeatureGridProps['columns']>, string> =
|
|
|
35
34
|
* marketing pages. Each card is a list item, so the group is announced as a list.
|
|
36
35
|
*/
|
|
37
36
|
export const FeatureGrid = React.forwardRef<HTMLUListElement, FeatureGridProps>(function FeatureGrid(
|
|
38
|
-
{ features, columns = 3, variant = 'card', align = 'left', linkComponent, className, ...props },
|
|
37
|
+
{ features, columns = 3, variant = 'card', align = 'left', linkComponent, linkHrefProp = 'href', className, ...props },
|
|
39
38
|
ref
|
|
40
39
|
) {
|
|
41
40
|
const Link = linkComponent ?? 'a';
|
|
@@ -67,7 +66,7 @@ export const FeatureGrid = React.forwardRef<HTMLUListElement, FeatureGridProps>(
|
|
|
67
66
|
{features.map((feature) => (
|
|
68
67
|
<li key={feature.title} className="min-w-0">
|
|
69
68
|
{feature.href ? (
|
|
70
|
-
<Link
|
|
69
|
+
<Link {...linkDestination(feature.href, linkHrefProp)} className={cn(cardClass, 'focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 focus-visible:ring-offset-background')}>
|
|
71
70
|
{content(feature)}
|
|
72
71
|
</Link>
|
|
73
72
|
) : (
|