@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
|
@@ -3,6 +3,7 @@
|
|
|
3
3
|
import * as React from 'react';
|
|
4
4
|
import { cva } from 'class-variance-authority';
|
|
5
5
|
import { cn } from '../../utils/cn';
|
|
6
|
+
import { linkDestination, type LinkLikeProps } from '../../utils/link';
|
|
6
7
|
|
|
7
8
|
type LinkTabsVariant = 'default' | 'underline' | 'rounded';
|
|
8
9
|
type LinkTabsSize = 'sm' | 'md' | 'lg';
|
|
@@ -20,18 +21,11 @@ export type LinkTabsItem = {
|
|
|
20
21
|
disabled?: boolean;
|
|
21
22
|
};
|
|
22
23
|
|
|
23
|
-
export type LinkTabsProps = Omit<React.HTMLAttributes<HTMLElement>, 'children'> & {
|
|
24
|
+
export type LinkTabsProps = Omit<React.HTMLAttributes<HTMLElement>, 'children'> & LinkLikeProps & {
|
|
24
25
|
/** Tabs in display order. */
|
|
25
26
|
items: LinkTabsItem[];
|
|
26
27
|
/** Current pathname, used to mark the active tab. */
|
|
27
28
|
activeHref?: string;
|
|
28
|
-
/** Router link element (Inertia Link, Next Link, react-router Link). Defaults to `<a>`. */
|
|
29
|
-
linkComponent?: React.ElementType;
|
|
30
|
-
/**
|
|
31
|
-
* Prop used to pass the destination to `linkComponent`. `href` covers
|
|
32
|
-
* anchors and Next.js Link; `to` covers react-router and similar routers.
|
|
33
|
-
*/
|
|
34
|
-
linkHrefProp?: 'href' | 'to';
|
|
35
29
|
/** Visual style. */
|
|
36
30
|
variant?: LinkTabsVariant;
|
|
37
31
|
/** Control density. */
|
|
@@ -134,7 +128,7 @@ export const LinkTabs = React.forwardRef<HTMLElement, LinkTabsProps>(function Li
|
|
|
134
128
|
return (
|
|
135
129
|
<Link
|
|
136
130
|
key={item.href}
|
|
137
|
-
{...(
|
|
131
|
+
{...linkDestination(item.href, linkHrefProp)}
|
|
138
132
|
aria-current={active ? 'page' : undefined}
|
|
139
133
|
data-active={active ? 'true' : 'false'}
|
|
140
134
|
className={itemVariants({ variant, size })}
|
|
@@ -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 LogoItem = {
|
|
5
6
|
/** Accessible name announced for the logo. */
|
|
@@ -10,7 +11,7 @@ export type LogoItem = {
|
|
|
10
11
|
href?: string;
|
|
11
12
|
};
|
|
12
13
|
|
|
13
|
-
export type LogoCloudProps = React.HTMLAttributes<HTMLDivElement> & {
|
|
14
|
+
export type LogoCloudProps = React.HTMLAttributes<HTMLDivElement> & LinkLikeProps & {
|
|
14
15
|
/** Logos to display. */
|
|
15
16
|
items: LogoItem[];
|
|
16
17
|
/** Caption above the strip. */
|
|
@@ -23,10 +24,6 @@ export type LogoCloudProps = React.HTMLAttributes<HTMLDivElement> & {
|
|
|
23
24
|
size?: 'sm' | 'md' | 'lg';
|
|
24
25
|
/** Caption and grid alignment. Default 'center'. */
|
|
25
26
|
align?: 'left' | 'center';
|
|
26
|
-
/** Custom link element for routers. */
|
|
27
|
-
linkComponent?: React.ElementType;
|
|
28
|
-
/** Prop used to pass the destination to linkComponent ('to' for react-router). */
|
|
29
|
-
linkHrefProp?: 'href' | 'to';
|
|
30
27
|
};
|
|
31
28
|
|
|
32
29
|
const columnClasses: Record<NonNullable<LogoCloudProps['columns']>, string> = {
|
|
@@ -96,7 +93,7 @@ export const LogoCloud = React.forwardRef<HTMLDivElement, LogoCloudProps>(functi
|
|
|
96
93
|
<li key={item.name} className={cn('min-w-0', align === 'center' ? 'justify-self-center' : 'justify-self-start')}>
|
|
97
94
|
{item.href ? (
|
|
98
95
|
<Link
|
|
99
|
-
{...(
|
|
96
|
+
{...linkDestination(item.href, linkHrefProp)}
|
|
100
97
|
className="rounded-sm focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 focus-visible:ring-offset-background"
|
|
101
98
|
>
|
|
102
99
|
{content}
|
|
@@ -2,6 +2,7 @@ import * as React from 'react';
|
|
|
2
2
|
import { cn } from '../../utils/cn';
|
|
3
3
|
import { Badge, type BadgeProps } from '../badge/Badge';
|
|
4
4
|
import { CoverImage, type CoverImageProps } from '../cover-image/CoverImage';
|
|
5
|
+
import { linkDestination, type LinkLikeProps } from '../../utils/link';
|
|
5
6
|
|
|
6
7
|
export type MediaCardChip = {
|
|
7
8
|
label: string;
|
|
@@ -11,7 +12,7 @@ export type MediaCardChip = {
|
|
|
11
12
|
dot?: boolean;
|
|
12
13
|
};
|
|
13
14
|
|
|
14
|
-
export type MediaCardProps = Omit<React.HTMLAttributes<HTMLElement>, 'title'> & {
|
|
15
|
+
export type MediaCardProps = Omit<React.HTMLAttributes<HTMLElement>, 'title'> & LinkLikeProps & {
|
|
15
16
|
/** Card title. */
|
|
16
17
|
title: string;
|
|
17
18
|
/** Supporting copy under the title. */
|
|
@@ -28,10 +29,6 @@ export type MediaCardProps = Omit<React.HTMLAttributes<HTMLElement>, 'title'> &
|
|
|
28
29
|
footer?: React.ReactNode;
|
|
29
30
|
/** 'vertical' stacks cover over content; 'row' puts a fixed-width cover beside it. */
|
|
30
31
|
layout?: 'vertical' | 'row';
|
|
31
|
-
/** Custom link element for routers (Next Link, react-router). */
|
|
32
|
-
linkComponent?: React.ElementType;
|
|
33
|
-
/** Prop used to pass the destination to linkComponent ('href' or 'to'). */
|
|
34
|
-
linkHrefProp?: 'href' | 'to';
|
|
35
32
|
};
|
|
36
33
|
|
|
37
34
|
/**
|
|
@@ -59,7 +56,7 @@ export const MediaCard = React.forwardRef<HTMLElement, MediaCardProps>(function
|
|
|
59
56
|
ref
|
|
60
57
|
) {
|
|
61
58
|
const Link = linkComponent ?? 'a';
|
|
62
|
-
const destination = href ? (
|
|
59
|
+
const destination = href ? linkDestination(href, linkHrefProp) : undefined;
|
|
63
60
|
const row = layout === 'row';
|
|
64
61
|
|
|
65
62
|
const body = (
|
|
@@ -13,6 +13,7 @@ import {
|
|
|
13
13
|
} from '../../utils/date';
|
|
14
14
|
import { Badge } from '../badge/Badge';
|
|
15
15
|
import { Button } from '../button';
|
|
16
|
+
import { linkDestination, type LinkLikeProps } from '../../utils/link';
|
|
16
17
|
|
|
17
18
|
export type MonthScheduleLegendItem = {
|
|
18
19
|
/** Type key returned by getType. */
|
|
@@ -21,7 +22,7 @@ export type MonthScheduleLegendItem = {
|
|
|
21
22
|
label: string;
|
|
22
23
|
};
|
|
23
24
|
|
|
24
|
-
export type MonthScheduleProps<T> = {
|
|
25
|
+
export type MonthScheduleProps<T> = LinkLikeProps & {
|
|
25
26
|
/** Events to place inside days; each is dated via getDate. */
|
|
26
27
|
events: T[];
|
|
27
28
|
/** ISO date key (YYYY-MM-DD) for an event. */
|
|
@@ -53,10 +54,6 @@ export type MonthScheduleProps<T> = {
|
|
|
53
54
|
* 'sm' swaps under 640px, 'md' under 768px.
|
|
54
55
|
*/
|
|
55
56
|
agendaBreakpoint?: 'sm' | 'md';
|
|
56
|
-
/** Custom link element for event hrefs (Next Link, react-router). */
|
|
57
|
-
linkComponent?: React.ElementType;
|
|
58
|
-
/** Prop used to pass the destination to linkComponent ('href' or 'to'). */
|
|
59
|
-
linkHrefProp?: 'href' | 'to';
|
|
60
57
|
'aria-label'?: string;
|
|
61
58
|
className?: string;
|
|
62
59
|
};
|
|
@@ -177,7 +174,7 @@ export function MonthSchedule<T>({
|
|
|
177
174
|
</Badge>
|
|
178
175
|
);
|
|
179
176
|
if (!href) return <span key={key}>{chip}</span>;
|
|
180
|
-
const destination =
|
|
177
|
+
const destination = linkDestination(href, linkHrefProp);
|
|
181
178
|
return (
|
|
182
179
|
<Link
|
|
183
180
|
key={key}
|
|
@@ -297,7 +294,7 @@ export function MonthSchedule<T>({
|
|
|
297
294
|
<li key={`${key}-${index}-${label}`}>
|
|
298
295
|
{href ? (
|
|
299
296
|
<Link
|
|
300
|
-
{...(
|
|
297
|
+
{...linkDestination(href, linkHrefProp)}
|
|
301
298
|
className="block max-w-full rounded-sm focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring"
|
|
302
299
|
>
|
|
303
300
|
{row}
|
|
@@ -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
|
|
|
6
7
|
export type PaginationIcons = {
|
|
7
8
|
/** Glyph/slot for the jump-to-first button. */
|
|
@@ -14,7 +15,7 @@ export type PaginationIcons = {
|
|
|
14
15
|
last?: React.ReactNode;
|
|
15
16
|
};
|
|
16
17
|
|
|
17
|
-
export type PaginationProps = React.HTMLAttributes<HTMLElement> & {
|
|
18
|
+
export type PaginationProps = React.HTMLAttributes<HTMLElement> & LinkLikeProps & {
|
|
18
19
|
/** Current page number (1-based). Alias: currentPage. */
|
|
19
20
|
page?: number;
|
|
20
21
|
/** Total number of pages. Alias: totalPages (or derived from total/pageSize). */
|
|
@@ -40,10 +41,6 @@ export type PaginationProps = React.HTMLAttributes<HTMLElement> & {
|
|
|
40
41
|
* the React Server Component boundary.
|
|
41
42
|
*/
|
|
42
43
|
pageHrefs?: Record<number, string>;
|
|
43
|
-
/** Custom link element for routers (Next Link, react-router Link). */
|
|
44
|
-
linkComponent?: React.ElementType;
|
|
45
|
-
/** Prop used to pass the destination to `linkComponent`. */
|
|
46
|
-
linkHrefProp?: 'href' | 'to';
|
|
47
44
|
/** How many page buttons to show around the current page (default 1). */
|
|
48
45
|
siblings?: number;
|
|
49
46
|
/** Show the jump-to-first/last buttons (default false). */
|
|
@@ -136,7 +133,7 @@ const Pagination = React.forwardRef<HTMLElement, PaginationProps>(
|
|
|
136
133
|
|
|
137
134
|
const linkMode = pageHrefs !== undefined;
|
|
138
135
|
const LinkEl = linkComponent ?? 'a';
|
|
139
|
-
const destination = (href: string) => (
|
|
136
|
+
const destination = (href: string) => linkDestination(href, linkHrefProp);
|
|
140
137
|
const hrefFor = (target: number) => pageHrefs?.[target];
|
|
141
138
|
|
|
142
139
|
/** One step control (first/prev/next/last) in either mode. */
|
|
@@ -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
|
|
|
6
7
|
export type SegmentedOption = {
|
|
7
8
|
value: string;
|
|
@@ -24,7 +25,7 @@ export type SegmentedOption = {
|
|
|
24
25
|
href?: string;
|
|
25
26
|
};
|
|
26
27
|
|
|
27
|
-
export type SegmentedControlProps = Omit<React.HTMLAttributes<HTMLDivElement>, 'onChange'> & {
|
|
28
|
+
export type SegmentedControlProps = Omit<React.HTMLAttributes<HTMLDivElement>, 'onChange'> & LinkLikeProps & {
|
|
28
29
|
/** Options rendered as segments. */
|
|
29
30
|
options: SegmentedOption[];
|
|
30
31
|
/** Controlled selected value. Use string[] when multiple. */
|
|
@@ -44,10 +45,6 @@ export type SegmentedControlProps = Omit<React.HTMLAttributes<HTMLDivElement>, '
|
|
|
44
45
|
* responsive pattern for "full-width on mobile, compact on desktop".
|
|
45
46
|
*/
|
|
46
47
|
fullWidth?: boolean | 'sm' | 'md' | 'lg' | 'xl' | '2xl';
|
|
47
|
-
/** Custom link element for routers (Next Link, react-router Link). */
|
|
48
|
-
linkComponent?: React.ElementType;
|
|
49
|
-
/** Prop used to pass the destination to `linkComponent`. */
|
|
50
|
-
linkHrefProp?: 'href' | 'to';
|
|
51
48
|
};
|
|
52
49
|
|
|
53
50
|
const sizeClasses = {
|
|
@@ -118,7 +115,7 @@ export const SegmentedControl = React.forwardRef<HTMLDivElement, SegmentedContro
|
|
|
118
115
|
|
|
119
116
|
const linkMode = options.some((option) => option.href !== undefined);
|
|
120
117
|
const LinkEl = linkComponent ?? 'a';
|
|
121
|
-
const destination = (href: string) => (
|
|
118
|
+
const destination = (href: string) => linkDestination(href, linkHrefProp);
|
|
122
119
|
|
|
123
120
|
const refs = React.useRef<Array<HTMLButtonElement | null>>([]);
|
|
124
121
|
|
|
@@ -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 SiteFooterLink = {
|
|
5
6
|
label: string;
|
|
@@ -12,7 +13,7 @@ export type SiteFooterColumn = {
|
|
|
12
13
|
links: SiteFooterLink[];
|
|
13
14
|
};
|
|
14
15
|
|
|
15
|
-
export type SiteFooterProps = React.HTMLAttributes<HTMLElement> & {
|
|
16
|
+
export type SiteFooterProps = React.HTMLAttributes<HTMLElement> & LinkLikeProps & {
|
|
16
17
|
/** Brand slot (logo/lockup). */
|
|
17
18
|
brand?: React.ReactNode;
|
|
18
19
|
/** Short line under the brand. */
|
|
@@ -22,14 +23,6 @@ export type SiteFooterProps = React.HTMLAttributes<HTMLElement> & {
|
|
|
22
23
|
columns: SiteFooterColumn[];
|
|
23
24
|
/** Bottom bar (copyright, legal links). */
|
|
24
25
|
legal?: React.ReactNode;
|
|
25
|
-
/** Router link element. */
|
|
26
|
-
linkComponent?: React.ElementType;
|
|
27
|
-
/**
|
|
28
|
-
* Prop used to pass the destination to `linkComponent`.
|
|
29
|
-
* `href` (default) covers anchors and Next.js Link; `to` covers
|
|
30
|
-
* react-router and other routers that use a `to` prop.
|
|
31
|
-
*/
|
|
32
|
-
linkHrefProp?: 'href' | 'to';
|
|
33
26
|
/** Current route, used to mark the matching link with aria-current="page". */
|
|
34
27
|
activeHref?: string;
|
|
35
28
|
/** Prefix matching highlights /docs when on /docs/installation (default). */
|
|
@@ -62,8 +55,7 @@ export function SiteFooter({
|
|
|
62
55
|
...props
|
|
63
56
|
}: SiteFooterProps) {
|
|
64
57
|
const Link = linkComponent ?? 'a';
|
|
65
|
-
const destination = (href: string) =>
|
|
66
|
-
linkHrefProp === 'to' ? { to: href } : { href };
|
|
58
|
+
const destination = (href: string) => linkDestination(href, linkHrefProp);
|
|
67
59
|
|
|
68
60
|
return (
|
|
69
61
|
<footer className={cn('border-t border-border bg-muted/30', className)} {...props}>
|
|
@@ -22,6 +22,32 @@ describe('SiteHeader', () => {
|
|
|
22
22
|
expect(external).toHaveAttribute('rel', 'noopener noreferrer');
|
|
23
23
|
});
|
|
24
24
|
|
|
25
|
+
it('renders the topBar utility strip above the nav', () => {
|
|
26
|
+
render(
|
|
27
|
+
<SiteHeader
|
|
28
|
+
brand={<span>Acme</span>}
|
|
29
|
+
items={items}
|
|
30
|
+
topBar={
|
|
31
|
+
<>
|
|
32
|
+
<span>English</span>
|
|
33
|
+
<a href="/submit">Submit an event</a>
|
|
34
|
+
</>
|
|
35
|
+
}
|
|
36
|
+
/>
|
|
37
|
+
);
|
|
38
|
+
const strip = screen.getByText('English').parentElement?.parentElement;
|
|
39
|
+
expect(strip).toHaveClass('border-b');
|
|
40
|
+
expect(strip?.querySelector('a')).toHaveAttribute('href', '/submit');
|
|
41
|
+
// The strip sits before the nav landmark in DOM order.
|
|
42
|
+
const nav = screen.getByRole('navigation', { name: 'Main' });
|
|
43
|
+
expect(strip!.compareDocumentPosition(nav) & Node.DOCUMENT_POSITION_FOLLOWING).toBeTruthy();
|
|
44
|
+
});
|
|
45
|
+
|
|
46
|
+
it('omits the topBar strip when the prop is absent', () => {
|
|
47
|
+
const { container } = render(<SiteHeader brand={<span>Acme</span>} items={items} />);
|
|
48
|
+
expect(container.querySelector('header > div')).toBeNull();
|
|
49
|
+
});
|
|
50
|
+
|
|
25
51
|
it('respects exact matching', () => {
|
|
26
52
|
render(<SiteHeader brand={<span>Acme</span>} items={items} activeHref="/docs/components" match="exact" />);
|
|
27
53
|
expect(screen.getByRole('link', { name: 'Docs' })).not.toHaveAttribute('aria-current');
|
|
@@ -144,6 +170,33 @@ describe('SiteHeader mega menu', () => {
|
|
|
144
170
|
expect(screen.getByText('Every genre in Utah')).toBeInTheDocument();
|
|
145
171
|
});
|
|
146
172
|
|
|
173
|
+
it('keeps a hover bridge between the trigger and the panel', async () => {
|
|
174
|
+
const user = userEvent.setup();
|
|
175
|
+
render(<SiteHeader brand={<span>Acme</span>} items={megaItems} />);
|
|
176
|
+
const trigger = screen.getByRole('button', { name: /Dancers/ });
|
|
177
|
+
await user.hover(trigger);
|
|
178
|
+
const panelId = trigger.getAttribute('aria-controls');
|
|
179
|
+
const wrapper = document.getElementById(panelId!);
|
|
180
|
+
// The padding (not margin) bridge keeps the pointer inside the nav item
|
|
181
|
+
// while it crosses the gap; the visual panel is the wrapper's child.
|
|
182
|
+
expect(wrapper).toHaveClass('pt-2');
|
|
183
|
+
expect(wrapper?.firstElementChild).toHaveClass('rounded-lg');
|
|
184
|
+
expect(wrapper?.firstElementChild).toHaveClass('border');
|
|
185
|
+
});
|
|
186
|
+
|
|
187
|
+
it('clamps the open panel inside the viewport', async () => {
|
|
188
|
+
const user = userEvent.setup();
|
|
189
|
+
render(<SiteHeader brand={<span>Acme</span>} items={megaItems} />);
|
|
190
|
+
const trigger = screen.getByRole('button', { name: /Dancers/ });
|
|
191
|
+
await user.hover(trigger);
|
|
192
|
+
const wrapper = document.getElementById(trigger.getAttribute('aria-controls')!);
|
|
193
|
+
// jsdom reports zero rects, so the clamp lands on the left gutter; the
|
|
194
|
+
// point is that an inline position is applied instead of a fixed anchor.
|
|
195
|
+
expect(wrapper).toHaveStyle({ left: '8px' });
|
|
196
|
+
expect(wrapper?.firstElementChild).toHaveClass('w-[38rem]');
|
|
197
|
+
expect(wrapper?.firstElementChild).toHaveClass('max-w-[calc(100vw-2rem)]');
|
|
198
|
+
});
|
|
199
|
+
|
|
147
200
|
it('closes on Escape and on an outside pointer', async () => {
|
|
148
201
|
const user = userEvent.setup();
|
|
149
202
|
render(
|
|
@@ -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
|
/** A single destination in the header or inside a mega panel. */
|
|
@@ -34,9 +35,15 @@ export type SiteNavItem =
|
|
|
34
35
|
columns: SiteNavColumn[];
|
|
35
36
|
};
|
|
36
37
|
|
|
37
|
-
export type SiteHeaderProps = React.HTMLAttributes<HTMLElement> & {
|
|
38
|
+
export type SiteHeaderProps = React.HTMLAttributes<HTMLElement> & LinkLikeProps & {
|
|
38
39
|
/** Brand slot - logo/lockup or wordmark. Wrapped in a link to "/". */
|
|
39
40
|
brand: React.ReactNode;
|
|
41
|
+
/**
|
|
42
|
+
* Slim utility strip rendered above the brand row (locale switch, feed
|
|
43
|
+
* link, submit link). Content is placed in a container matching the nav
|
|
44
|
+
* metrics; lay out multiple items with justify-between or a flex row.
|
|
45
|
+
*/
|
|
46
|
+
topBar?: React.ReactNode;
|
|
40
47
|
/** Primary navigation items. */
|
|
41
48
|
items: SiteNavItem[];
|
|
42
49
|
/** Current route for active styling (aria-current="page"). */
|
|
@@ -50,14 +57,6 @@ export type SiteHeaderProps = React.HTMLAttributes<HTMLElement> & {
|
|
|
50
57
|
actions?: React.ReactNode;
|
|
51
58
|
/** Actions rendered inside the mobile drawer; defaults to `actions`. */
|
|
52
59
|
mobileActions?: React.ReactNode;
|
|
53
|
-
/** Custom link element for routers (Next Link, react-router Link). */
|
|
54
|
-
linkComponent?: React.ElementType;
|
|
55
|
-
/**
|
|
56
|
-
* Prop used to pass the destination to `linkComponent`.
|
|
57
|
-
* `href` (default) covers anchors and Next.js Link; `to` covers
|
|
58
|
-
* react-router and other routers that use a `to` prop.
|
|
59
|
-
*/
|
|
60
|
-
linkHrefProp?: 'href' | 'to';
|
|
61
60
|
/** Accessible name for the brand link (default "Home"). */
|
|
62
61
|
brandLabel?: string;
|
|
63
62
|
/** Accessible name for the desktop navigation landmark (default "Main"). */
|
|
@@ -122,6 +121,7 @@ function Caret() {
|
|
|
122
121
|
*/
|
|
123
122
|
export function SiteHeader({
|
|
124
123
|
brand,
|
|
124
|
+
topBar,
|
|
125
125
|
items,
|
|
126
126
|
activeHref,
|
|
127
127
|
match = 'prefix',
|
|
@@ -150,8 +150,7 @@ export function SiteHeader({
|
|
|
150
150
|
const menuId = `${generatedId}-menu`;
|
|
151
151
|
const Link = linkComponent ?? 'a';
|
|
152
152
|
|
|
153
|
-
const destination = (href: string) =>
|
|
154
|
-
linkHrefProp === 'to' ? { to: href } : { href };
|
|
153
|
+
const destination = (href: string) => linkDestination(href, linkHrefProp);
|
|
155
154
|
|
|
156
155
|
// Escape and an outside pointer close the desktop panel. Focus movement
|
|
157
156
|
// inside the item is handled by onBlur so tabbing through stays open.
|
|
@@ -219,6 +218,34 @@ export function SiteHeader({
|
|
|
219
218
|
const hasColumns = (item: SiteNavItem): item is SiteNavItem & { columns: SiteNavColumn[] } =>
|
|
220
219
|
Array.isArray(item.columns) && item.columns.length > 0;
|
|
221
220
|
|
|
221
|
+
/*
|
|
222
|
+
* Panels are wider than their triggers, so a fixed left-0 anchor pushes
|
|
223
|
+
* edge menus off-screen. On open we measure the panel and clamp its left
|
|
224
|
+
* edge into the viewport; the inline style wins over the left-0 class.
|
|
225
|
+
* Layout effect keeps the correction ahead of paint.
|
|
226
|
+
*/
|
|
227
|
+
const alignPanel = React.useCallback((panel: HTMLElement) => {
|
|
228
|
+
const item = panel.parentElement;
|
|
229
|
+
if (!item) return;
|
|
230
|
+
const itemRect = item.getBoundingClientRect();
|
|
231
|
+
const width = panel.offsetWidth;
|
|
232
|
+
const gutter = 8;
|
|
233
|
+
const centered = itemRect.left + itemRect.width / 2 - width / 2;
|
|
234
|
+
const left = Math.max(gutter, Math.min(centered, window.innerWidth - gutter - width));
|
|
235
|
+
panel.style.left = `${left - itemRect.left}px`;
|
|
236
|
+
panel.style.right = 'auto';
|
|
237
|
+
}, []);
|
|
238
|
+
|
|
239
|
+
const useIsoLayoutEffect =
|
|
240
|
+
typeof window === 'undefined' ? React.useEffect : React.useLayoutEffect;
|
|
241
|
+
|
|
242
|
+
useIsoLayoutEffect(() => {
|
|
243
|
+
if (!openMenu) return;
|
|
244
|
+
const panelId = `${generatedId}-panel-${openMenu.replace(/\s+/g, '-').toLowerCase()}`;
|
|
245
|
+
const panel = document.getElementById(panelId);
|
|
246
|
+
if (panel) alignPanel(panel);
|
|
247
|
+
}, [openMenu, generatedId, alignPanel]);
|
|
248
|
+
|
|
222
249
|
return (
|
|
223
250
|
<>
|
|
224
251
|
<header
|
|
@@ -229,6 +256,13 @@ export function SiteHeader({
|
|
|
229
256
|
)}
|
|
230
257
|
{...props}
|
|
231
258
|
>
|
|
259
|
+
{topBar && (
|
|
260
|
+
<div className="border-b border-border/60 text-muted-foreground">
|
|
261
|
+
<div className="mx-auto flex h-9 w-full max-w-7xl items-center justify-between gap-4 px-4 text-xs sm:px-6">
|
|
262
|
+
{topBar}
|
|
263
|
+
</div>
|
|
264
|
+
</div>
|
|
265
|
+
)}
|
|
232
266
|
<nav
|
|
233
267
|
aria-label={navLabel}
|
|
234
268
|
className={cn(
|
|
@@ -296,31 +330,42 @@ export function SiteHeader({
|
|
|
296
330
|
{item.label}
|
|
297
331
|
<Caret />
|
|
298
332
|
</button>
|
|
333
|
+
{/*
|
|
334
|
+
* The pt-2 bridge keeps the pointer inside the <li> while
|
|
335
|
+
* it travels from the trigger into the panel - a margin
|
|
336
|
+
* gap would fire onMouseLeave and slam the menu shut.
|
|
337
|
+
*/}
|
|
299
338
|
<div
|
|
300
339
|
id={panelId}
|
|
301
340
|
hidden={!open}
|
|
302
|
-
className=
|
|
303
|
-
'absolute left-0 top-full z-50 mt-2 grid gap-6 rounded-lg border border-border bg-popover p-5 shadow-lg',
|
|
304
|
-
item.columns.length > 1 ? 'grid-cols-2' : 'grid-cols-1',
|
|
305
|
-
'min-w-[22rem]'
|
|
306
|
-
)}
|
|
341
|
+
className="absolute left-0 top-full z-50 pt-2"
|
|
307
342
|
>
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
343
|
+
<div
|
|
344
|
+
className={cn(
|
|
345
|
+
'grid gap-6 rounded-lg border border-border bg-popover p-5 shadow-lg',
|
|
346
|
+
item.columns.length > 1 ? 'grid-cols-2' : 'grid-cols-1',
|
|
347
|
+
item.columns.length > 1
|
|
348
|
+
? 'w-[38rem] max-w-[calc(100vw-2rem)]'
|
|
349
|
+
: 'w-[22rem] max-w-[calc(100vw-2rem)]'
|
|
350
|
+
)}
|
|
351
|
+
>
|
|
352
|
+
{item.columns.map((column, index) => (
|
|
353
|
+
<div key={column.heading ?? index} className="min-w-40">
|
|
354
|
+
{column.heading && (
|
|
355
|
+
<p className="mb-2 text-xs font-medium uppercase tracking-wide text-muted-foreground">
|
|
356
|
+
{column.heading}
|
|
357
|
+
</p>
|
|
358
|
+
)}
|
|
359
|
+
<ul className="flex flex-col gap-0.5">
|
|
360
|
+
{column.items.map((link) => (
|
|
361
|
+
<li key={`${column.heading ?? index}-${link.href}-${link.label}`}>
|
|
362
|
+
{navLink(link, 'panel')}
|
|
363
|
+
</li>
|
|
364
|
+
))}
|
|
365
|
+
</ul>
|
|
366
|
+
</div>
|
|
367
|
+
))}
|
|
368
|
+
</div>
|
|
324
369
|
</div>
|
|
325
370
|
</li>
|
|
326
371
|
);
|
|
@@ -19,6 +19,23 @@ describe('TombstoneCard', () => {
|
|
|
19
19
|
expect(screen.getByRole('link', { name: 'View details' })).toHaveAttribute('href', '/deals/archived');
|
|
20
20
|
});
|
|
21
21
|
|
|
22
|
+
it('passes the destination via linkHrefProp for routers that use "to"', () => {
|
|
23
|
+
const RouterLink = ({ to, children, ...rest }: { to: string; children: React.ReactNode }) => (
|
|
24
|
+
<a href={to} data-router-to={to} {...rest}>
|
|
25
|
+
{children}
|
|
26
|
+
</a>
|
|
27
|
+
);
|
|
28
|
+
render(
|
|
29
|
+
<TombstoneCard
|
|
30
|
+
title="Unavailable"
|
|
31
|
+
href="/deals/1"
|
|
32
|
+
linkComponent={RouterLink}
|
|
33
|
+
linkHrefProp="to"
|
|
34
|
+
/>
|
|
35
|
+
);
|
|
36
|
+
expect(screen.getByRole('link', { name: 'View details' })).toHaveAttribute('data-router-to', '/deals/1');
|
|
37
|
+
});
|
|
38
|
+
|
|
22
39
|
it('has no accessibility violations', async () => {
|
|
23
40
|
const { container } = render(<TombstoneCard title="Unavailable" reason="No longer available." />);
|
|
24
41
|
expect(await axe(container)).toHaveNoViolations();
|
|
@@ -1,11 +1,12 @@
|
|
|
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 { Card, CardContent } from '../card/Card';
|
|
5
6
|
|
|
6
7
|
export type TombstoneStatus = 'archived' | 'unavailable' | 'closed';
|
|
7
8
|
|
|
8
|
-
export type TombstoneCardProps = Omit<React.HTMLAttributes<HTMLElement>, 'title'> & {
|
|
9
|
+
export type TombstoneCardProps = Omit<React.HTMLAttributes<HTMLElement>, 'title'> & LinkLikeProps & {
|
|
9
10
|
/** Listing, deal or document name. */
|
|
10
11
|
title: string;
|
|
11
12
|
/** Why the item is unavailable. */
|
|
@@ -18,8 +19,6 @@ export type TombstoneCardProps = Omit<React.HTMLAttributes<HTMLElement>, 'title'
|
|
|
18
19
|
href?: string;
|
|
19
20
|
/** Link label. Default "View details". */
|
|
20
21
|
actionLabel?: string;
|
|
21
|
-
/** Custom link element for routers. */
|
|
22
|
-
linkComponent?: React.ElementType;
|
|
23
22
|
};
|
|
24
23
|
|
|
25
24
|
const statusConfig: Record<TombstoneStatus, { label: string; variant: 'secondary' | 'warning' | 'outline' }> = {
|
|
@@ -42,6 +41,7 @@ export const TombstoneCard = React.forwardRef<HTMLElement, TombstoneCardProps>(f
|
|
|
42
41
|
href,
|
|
43
42
|
actionLabel = 'View details',
|
|
44
43
|
linkComponent,
|
|
44
|
+
linkHrefProp = 'href',
|
|
45
45
|
className,
|
|
46
46
|
...props
|
|
47
47
|
},
|
|
@@ -65,7 +65,7 @@ export const TombstoneCard = React.forwardRef<HTMLElement, TombstoneCardProps>(f
|
|
|
65
65
|
{reason && <p className="text-sm leading-relaxed text-muted-foreground">{reason}</p>}
|
|
66
66
|
{href && (
|
|
67
67
|
<Link
|
|
68
|
-
|
|
68
|
+
{...linkDestination(href, linkHrefProp)}
|
|
69
69
|
className="mt-auto text-sm font-medium text-primary-ink underline-offset-4 hover:underline focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring"
|
|
70
70
|
>
|
|
71
71
|
{actionLabel}
|
package/src/index.ts
CHANGED
|
@@ -2,6 +2,8 @@ export * from './types/manifest';
|
|
|
2
2
|
export * from './utils/cn';
|
|
3
3
|
export * from './utils/gap';
|
|
4
4
|
export * from './utils/presence';
|
|
5
|
+
export * from './utils/consent';
|
|
6
|
+
export type { LinkLikeProps } from './utils/link';
|
|
5
7
|
export * from './components/app-shell';
|
|
6
8
|
export * from './components/button';
|
|
7
9
|
export * from './components/button-group';
|
|
@@ -39,6 +41,7 @@ export * from './components/calendar';
|
|
|
39
41
|
export * from './components/month-schedule';
|
|
40
42
|
export * from './components/card';
|
|
41
43
|
export * from './components/confirm-dialog';
|
|
44
|
+
export * from './components/consent-banner';
|
|
42
45
|
export * from './components/table-of-contents';
|
|
43
46
|
export * from './components/prose';
|
|
44
47
|
export * from './components/site-footer';
|
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
"tier": "molecule",
|
|
5
5
|
"package": "@slipstream-ui/core",
|
|
6
6
|
"importPath": "@slipstream-ui/core",
|
|
7
|
-
"version": "0.
|
|
7
|
+
"version": "0.12.1",
|
|
8
8
|
"sourceDir": "announcement-bar",
|
|
9
9
|
"exportName": "AnnouncementBar",
|
|
10
10
|
"description": "Dismissible announcement bar with optional action, tone and sticky positioning.",
|
|
@@ -65,6 +65,17 @@
|
|
|
65
65
|
"type": "React.ElementType",
|
|
66
66
|
"required": false,
|
|
67
67
|
"description": "Custom link element for routers."
|
|
68
|
+
},
|
|
69
|
+
{
|
|
70
|
+
"name": "linkHrefProp",
|
|
71
|
+
"type": "'href' | 'to'",
|
|
72
|
+
"required": false,
|
|
73
|
+
"defaultValue": "href",
|
|
74
|
+
"description": "Prop name used to pass the destination to linkComponent ('href' for anchors and most routers, 'to' for react-router).",
|
|
75
|
+
"enum": [
|
|
76
|
+
"href",
|
|
77
|
+
"to"
|
|
78
|
+
]
|
|
68
79
|
}
|
|
69
80
|
],
|
|
70
81
|
"examples": [
|
|
@@ -62,6 +62,17 @@
|
|
|
62
62
|
"defaultValue": "a",
|
|
63
63
|
"description": "Router link component (react-router Link, Next Link) (Sidebar)."
|
|
64
64
|
},
|
|
65
|
+
{
|
|
66
|
+
"name": "linkHrefProp",
|
|
67
|
+
"type": "'href' | 'to'",
|
|
68
|
+
"required": false,
|
|
69
|
+
"defaultValue": "href",
|
|
70
|
+
"description": "Prop name used to pass the destination to linkComponent ('href' for anchors and most routers, 'to' for react-router).",
|
|
71
|
+
"enum": [
|
|
72
|
+
"href",
|
|
73
|
+
"to"
|
|
74
|
+
]
|
|
75
|
+
},
|
|
65
76
|
{
|
|
66
77
|
"name": "label",
|
|
67
78
|
"type": "string",
|
|
@@ -214,7 +225,7 @@
|
|
|
214
225
|
],
|
|
215
226
|
"package": "@slipstream-ui/core",
|
|
216
227
|
"importPath": "@slipstream-ui/core",
|
|
217
|
-
"version": "0.
|
|
228
|
+
"version": "0.12.1",
|
|
218
229
|
"sourceDir": "app-shell",
|
|
219
230
|
"exportName": "AppShell"
|
|
220
231
|
}
|