@primer/react-brand 0.75.0-rc.a3f7dbd6 → 0.75.0-rc.c3abcc84
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/docs/components/SubdomainNavBar/index.md +215 -86
- package/docs/index.md +2 -2
- package/esm/SubdomainNavBar/NavigationVisbilityObserver.d.ts +3 -1
- package/esm/SubdomainNavBar/NavigationVisbilityObserver.d.ts.map +1 -1
- package/esm/SubdomainNavBar/NavigationVisbilityObserver.js +115 -63
- package/esm/SubdomainNavBar/NavigationVisbilityObserver.js.map +1 -1
- package/esm/SubdomainNavBar/SubdomainNavBar.d.ts +155 -18
- package/esm/SubdomainNavBar/SubdomainNavBar.d.ts.map +1 -1
- package/esm/SubdomainNavBar/SubdomainNavBar.js +474 -298
- package/esm/SubdomainNavBar/SubdomainNavBar.js.map +1 -1
- package/esm/SubdomainNavBar/SubdomainNavBar.module-WIrpYyjV.css +1 -0
- package/esm/SubdomainNavBar/SubdomainNavBar.module.js +33 -9
- package/esm/SubdomainNavBar/SubdomainNavBar.module.js.map +1 -1
- package/esm/SubdomainNavBar/SubdomainNavBarLinkContext.d.ts +9 -0
- package/esm/SubdomainNavBar/SubdomainNavBarLinkContext.d.ts.map +1 -0
- package/esm/SubdomainNavBar/SubdomainNavBarLinkContext.js +10 -0
- package/esm/SubdomainNavBar/SubdomainNavBarLinkContext.js.map +1 -0
- package/esm/SubdomainNavBar/useSearchKeyboardShortcut.d.ts +8 -0
- package/esm/SubdomainNavBar/useSearchKeyboardShortcut.d.ts.map +1 -0
- package/esm/SubdomainNavBar/useSearchKeyboardShortcut.js +52 -0
- package/esm/SubdomainNavBar/useSearchKeyboardShortcut.js.map +1 -0
- package/esm/SubdomainNavBar/useSearchResults.d.ts +24 -0
- package/esm/SubdomainNavBar/useSearchResults.d.ts.map +1 -0
- package/esm/SubdomainNavBar/useSearchResults.js +57 -0
- package/esm/SubdomainNavBar/useSearchResults.js.map +1 -0
- package/esm/SubdomainNavBar/useVisibilityObserver.d.ts +1 -1
- package/esm/SubdomainNavBar/useVisibilityObserver.d.ts.map +1 -1
- package/esm/SubdomainNavBar/useVisibilityObserver.js +60 -23
- package/esm/SubdomainNavBar/useVisibilityObserver.js.map +1 -1
- package/esm/packages/design-tokens/lib/design-tokens/css/tokens/functional/components/subdomain-nav-bar/colors-with-modes-BGj0AiDW.css +1 -0
- package/lib/SubdomainNavBar/NavigationVisbilityObserver.d.ts +3 -1
- package/lib/SubdomainNavBar/SubdomainNavBar.d.ts +155 -18
- package/lib/SubdomainNavBar/SubdomainNavBarLinkContext.d.ts +8 -0
- package/lib/SubdomainNavBar/useSearchKeyboardShortcut.d.ts +7 -0
- package/lib/SubdomainNavBar/useSearchResults.d.ts +23 -0
- package/lib/SubdomainNavBar/useVisibilityObserver.d.ts +1 -1
- package/lib/css/main.css +1241 -217
- package/lib/design-tokens/css/tokens/base/colors/color-scales-with-modes.css +1 -1
- package/lib/design-tokens/css/tokens/base/colors/light.css +1 -1
- package/lib/design-tokens/css/tokens/base/size/size.css +1 -1
- package/lib/design-tokens/css/tokens/base/typography/typography.css +1 -1
- package/lib/design-tokens/css/tokens/functional/animation/base.css +1 -1
- package/lib/design-tokens/css/tokens/functional/colors/global-with-modes.css +1 -1
- package/lib/design-tokens/css/tokens/functional/colors/global.css +1 -1
- package/lib/design-tokens/css/tokens/functional/components/accordion/colors-with-modes.css +1 -1
- package/lib/design-tokens/css/tokens/functional/components/action-menu/colors-with-modes.css +1 -1
- package/lib/design-tokens/css/tokens/functional/components/anchor-nav/colors-with-modes.css +1 -1
- package/lib/design-tokens/css/tokens/functional/components/bento/base.css +1 -1
- package/lib/design-tokens/css/tokens/functional/components/blinking-cursor/colors-with-modes.css +1 -1
- package/lib/design-tokens/css/tokens/functional/components/breadcrumbs/colors-with-modes.css +1 -1
- package/lib/design-tokens/css/tokens/functional/components/button/colors-with-modes.css +1 -1
- package/lib/design-tokens/css/tokens/functional/components/card/base.css +1 -1
- package/lib/design-tokens/css/tokens/functional/components/card/colors-with-modes.css +1 -1
- package/lib/design-tokens/css/tokens/functional/components/card/colors.css +1 -1
- package/lib/design-tokens/css/tokens/functional/components/comparison-table/colors-with-modes.css +1 -1
- package/lib/design-tokens/css/tokens/functional/components/comparison-table/comparison-table.css +1 -1
- package/lib/design-tokens/css/tokens/functional/components/control/colors-with-modes.css +1 -1
- package/lib/design-tokens/css/tokens/functional/components/cta-banner/colors-with-modes.css +1 -1
- package/lib/design-tokens/css/tokens/functional/components/eyebrow-banner/colors-with-modes.css +1 -1
- package/lib/design-tokens/css/tokens/functional/components/eyebrow-banner/eyebrow-banner.css +1 -1
- package/lib/design-tokens/css/tokens/functional/components/faq/base.css +1 -1
- package/lib/design-tokens/css/tokens/functional/components/faq/colors-with-modes.css +1 -1
- package/lib/design-tokens/css/tokens/functional/components/faq/colors.css +1 -1
- package/lib/design-tokens/css/tokens/functional/components/faq/faq.css +1 -1
- package/lib/design-tokens/css/tokens/functional/components/footer/base.css +1 -1
- package/lib/design-tokens/css/tokens/functional/components/footer/colors-with-modes.css +1 -1
- package/lib/design-tokens/css/tokens/functional/components/footer/colors.css +1 -1
- package/lib/design-tokens/css/tokens/functional/components/frosted-glass-vfx/base.css +1 -1
- package/lib/design-tokens/css/tokens/functional/components/frosted-glass-vfx/colors-with-modes.css +1 -1
- package/lib/design-tokens/css/tokens/functional/components/grid/colors-with-modes.css +1 -1
- package/lib/design-tokens/css/tokens/functional/components/grid/colors.css +1 -1
- package/lib/design-tokens/css/tokens/functional/components/grid/grid.css +1 -1
- package/lib/design-tokens/css/tokens/functional/components/hero/base.css +1 -1
- package/lib/design-tokens/css/tokens/functional/components/icon/colors-with-modes.css +1 -1
- package/lib/design-tokens/css/tokens/functional/components/icon/colors.css +1 -1
- package/lib/design-tokens/css/tokens/functional/components/ide/base.css +1 -1
- package/lib/design-tokens/css/tokens/functional/components/ide/colors-with-modes.css +1 -1
- package/lib/design-tokens/css/tokens/functional/components/image/base.css +1 -1
- package/lib/design-tokens/css/tokens/functional/components/inline-code/colors-with-modes.css +1 -1
- package/lib/design-tokens/css/tokens/functional/components/inline-code/colors.css +1 -1
- package/lib/design-tokens/css/tokens/functional/components/inline-link/base.css +1 -1
- package/lib/design-tokens/css/tokens/functional/components/inline-link/colors-with-modes.css +1 -1
- package/lib/design-tokens/css/tokens/functional/components/inline-link/colors.css +1 -1
- package/lib/design-tokens/css/tokens/functional/components/label/colors-with-modes.css +1 -1
- package/lib/design-tokens/css/tokens/functional/components/label/colors.css +1 -1
- package/lib/design-tokens/css/tokens/functional/components/link/colors-with-modes.css +1 -1
- package/lib/design-tokens/css/tokens/functional/components/link/colors.css +1 -1
- package/lib/design-tokens/css/tokens/functional/components/logosuite/base.css +1 -1
- package/lib/design-tokens/css/tokens/functional/components/logosuite/colors-with-modes.css +1 -1
- package/lib/design-tokens/css/tokens/functional/components/logosuite/colors.css +1 -1
- package/lib/design-tokens/css/tokens/functional/components/media-playlist/colors-with-modes.css +1 -1
- package/lib/design-tokens/css/tokens/functional/components/media-playlist/colors.css +1 -1
- package/lib/design-tokens/css/tokens/functional/components/nav-list/colors-with-modes.css +1 -1
- package/lib/design-tokens/css/tokens/functional/components/pricing-options/colors-with-modes.css +1 -1
- package/lib/design-tokens/css/tokens/functional/components/pricing-options/colors.css +1 -1
- package/lib/design-tokens/css/tokens/functional/components/pricing-options/pricing-options.css +1 -1
- package/lib/design-tokens/css/tokens/functional/components/prose/base.css +1 -1
- package/lib/design-tokens/css/tokens/functional/components/prose/colors-with-modes.css +1 -1
- package/lib/design-tokens/css/tokens/functional/components/river/base.css +1 -1
- package/lib/design-tokens/css/tokens/functional/components/river/river.css +1 -1
- package/lib/design-tokens/css/tokens/functional/components/river-story-scroll/colors-with-modes.css +1 -1
- package/lib/design-tokens/css/tokens/functional/components/section/section.css +1 -1
- package/lib/design-tokens/css/tokens/functional/components/statistic/base.css +1 -1
- package/lib/design-tokens/css/tokens/functional/components/sub-nav/base.css +1 -1
- package/lib/design-tokens/css/tokens/functional/components/sub-nav/colors-with-modes.css +1 -1
- package/lib/design-tokens/css/tokens/functional/components/subdomain-nav-bar/colors-with-modes.css +7 -1
- package/lib/design-tokens/css/tokens/functional/components/tabs/base.css +1 -1
- package/lib/design-tokens/css/tokens/functional/components/tabs/colors-with-modes.css +1 -1
- package/lib/design-tokens/css/tokens/functional/components/tabs/colors.css +1 -1
- package/lib/design-tokens/css/tokens/functional/components/testimonial/base.css +1 -1
- package/lib/design-tokens/css/tokens/functional/components/testimonial/colors-with-modes.css +1 -1
- package/lib/design-tokens/css/tokens/functional/components/testimonial/colors.css +1 -1
- package/lib/design-tokens/css/tokens/functional/components/text-cursor-animation/base.css +1 -1
- package/lib/design-tokens/css/tokens/functional/components/text-cursor-animation/colors-with-modes.css +1 -1
- package/lib/design-tokens/css/tokens/functional/components/text-cursor-animation/colors.css +1 -1
- package/lib/design-tokens/css/tokens/functional/components/tiles/colors-with-modes.css +1 -1
- package/lib/design-tokens/css/tokens/functional/components/timeline/base.css +1 -1
- package/lib/design-tokens/css/tokens/functional/components/timeline/colors-with-modes.css +1 -1
- package/lib/design-tokens/css/tokens/functional/components/timeline/colors.css +1 -1
- package/lib/design-tokens/css/tokens/functional/components/token/colors-with-modes.css +1 -1
- package/lib/design-tokens/css/tokens/functional/components/token/colors.css +1 -1
- package/lib/design-tokens/css/tokens/functional/components/tooltip/colors-with-modes.css +1 -1
- package/lib/design-tokens/css/tokens/functional/components/tooltip/colors.css +1 -1
- package/lib/design-tokens/css/tokens/functional/components/video-player/base.css +1 -1
- package/lib/design-tokens/css/tokens/functional/components/video-player/colors-with-modes.css +1 -1
- package/lib/design-tokens/css/tokens/functional/size/border.css +1 -1
- package/lib/design-tokens/css/tokens/functional/size/breakpoints.css +1 -1
- package/lib/design-tokens/css/tokens/functional/size/size-coarse.css +1 -1
- package/lib/design-tokens/css/tokens/functional/size/size-fine.css +1 -1
- package/lib/design-tokens/css/tokens/functional/size/size.css +1 -1
- package/lib/design-tokens/css/tokens/functional/size/viewport.css +1 -1
- package/lib/design-tokens/css/tokens/functional/typography/typography-responsive.css +1 -1
- package/lib/design-tokens/css/tokens/functional/typography/typography.css +1 -1
- package/lib/design-tokens/js/module/tokens/base/colors/light.js +1 -1
- package/lib/design-tokens/js/module/tokens/base/size/size.js +1 -1
- package/lib/design-tokens/js/module/tokens/base/typography/typography.js +1 -1
- package/lib/design-tokens/js/module/tokens/functional/animation/base.js +1 -1
- package/lib/design-tokens/js/module/tokens/functional/colors/global.js +1 -1
- package/lib/design-tokens/js/module/tokens/functional/components/bento/base.js +1 -1
- package/lib/design-tokens/js/module/tokens/functional/components/card/base.js +1 -1
- package/lib/design-tokens/js/module/tokens/functional/components/card/colors.js +1 -1
- package/lib/design-tokens/js/module/tokens/functional/components/comparison-table/comparison-table.js +1 -1
- package/lib/design-tokens/js/module/tokens/functional/components/eyebrow-banner/eyebrow-banner.js +1 -1
- package/lib/design-tokens/js/module/tokens/functional/components/faq/base.js +1 -1
- package/lib/design-tokens/js/module/tokens/functional/components/faq/colors.js +1 -1
- package/lib/design-tokens/js/module/tokens/functional/components/faq/faq.js +1 -1
- package/lib/design-tokens/js/module/tokens/functional/components/footer/base.js +1 -1
- package/lib/design-tokens/js/module/tokens/functional/components/footer/colors.js +1 -1
- package/lib/design-tokens/js/module/tokens/functional/components/frosted-glass-vfx/base.js +1 -1
- package/lib/design-tokens/js/module/tokens/functional/components/grid/colors.js +1 -1
- package/lib/design-tokens/js/module/tokens/functional/components/grid/grid.js +1 -1
- package/lib/design-tokens/js/module/tokens/functional/components/hero/base.js +1 -1
- package/lib/design-tokens/js/module/tokens/functional/components/icon/colors.js +1 -1
- package/lib/design-tokens/js/module/tokens/functional/components/ide/base.js +1 -1
- package/lib/design-tokens/js/module/tokens/functional/components/image/base.js +1 -1
- package/lib/design-tokens/js/module/tokens/functional/components/inline-code/colors.js +1 -1
- package/lib/design-tokens/js/module/tokens/functional/components/inline-link/base.js +1 -1
- package/lib/design-tokens/js/module/tokens/functional/components/inline-link/colors.js +1 -1
- package/lib/design-tokens/js/module/tokens/functional/components/label/colors.js +1 -1
- package/lib/design-tokens/js/module/tokens/functional/components/link/colors.js +1 -1
- package/lib/design-tokens/js/module/tokens/functional/components/logosuite/base.js +1 -1
- package/lib/design-tokens/js/module/tokens/functional/components/logosuite/colors.js +1 -1
- package/lib/design-tokens/js/module/tokens/functional/components/media-playlist/colors.js +1 -1
- package/lib/design-tokens/js/module/tokens/functional/components/pricing-options/colors.js +1 -1
- package/lib/design-tokens/js/module/tokens/functional/components/pricing-options/pricing-options.js +1 -1
- package/lib/design-tokens/js/module/tokens/functional/components/prose/base.js +1 -1
- package/lib/design-tokens/js/module/tokens/functional/components/river/base.js +1 -1
- package/lib/design-tokens/js/module/tokens/functional/components/river/river.js +1 -1
- package/lib/design-tokens/js/module/tokens/functional/components/section/section.js +1 -1
- package/lib/design-tokens/js/module/tokens/functional/components/statistic/base.js +1 -1
- package/lib/design-tokens/js/module/tokens/functional/components/sub-nav/base.js +1 -1
- package/lib/design-tokens/js/module/tokens/functional/components/tabs/base.js +1 -1
- package/lib/design-tokens/js/module/tokens/functional/components/tabs/colors.js +1 -1
- package/lib/design-tokens/js/module/tokens/functional/components/testimonial/base.js +1 -1
- package/lib/design-tokens/js/module/tokens/functional/components/testimonial/colors.js +1 -1
- package/lib/design-tokens/js/module/tokens/functional/components/text-cursor-animation/base.js +1 -1
- package/lib/design-tokens/js/module/tokens/functional/components/text-cursor-animation/colors.js +1 -1
- package/lib/design-tokens/js/module/tokens/functional/components/timeline/base.js +1 -1
- package/lib/design-tokens/js/module/tokens/functional/components/timeline/colors.js +1 -1
- package/lib/design-tokens/js/module/tokens/functional/components/token/colors.js +1 -1
- package/lib/design-tokens/js/module/tokens/functional/components/tooltip/colors.js +1 -1
- package/lib/design-tokens/js/module/tokens/functional/components/video-player/base.js +1 -1
- package/lib/design-tokens/js/module/tokens/functional/size/border.js +1 -1
- package/lib/design-tokens/js/module/tokens/functional/size/breakpoints.js +1 -1
- package/lib/design-tokens/js/module/tokens/functional/size/size-coarse.js +1 -1
- package/lib/design-tokens/js/module/tokens/functional/size/size-fine.js +1 -1
- package/lib/design-tokens/js/module/tokens/functional/size/size.js +1 -1
- package/lib/design-tokens/js/module/tokens/functional/size/viewport.js +1 -1
- package/lib/design-tokens/js/module/tokens/functional/typography/typography-responsive.js +1 -1
- package/lib/design-tokens/js/module/tokens/functional/typography/typography.js +1 -1
- package/lib/design-tokens/js/tokens/base/colors/light.js +1 -1
- package/lib/design-tokens/js/tokens/base/size/size.js +1 -1
- package/lib/design-tokens/js/tokens/base/typography/typography.js +1 -1
- package/lib/design-tokens/js/tokens/functional/animation/base.js +1 -1
- package/lib/design-tokens/js/tokens/functional/colors/global.js +1 -1
- package/lib/design-tokens/js/tokens/functional/components/bento/base.js +1 -1
- package/lib/design-tokens/js/tokens/functional/components/card/base.js +1 -1
- package/lib/design-tokens/js/tokens/functional/components/card/colors.js +1 -1
- package/lib/design-tokens/js/tokens/functional/components/comparison-table/comparison-table.js +1 -1
- package/lib/design-tokens/js/tokens/functional/components/eyebrow-banner/eyebrow-banner.js +1 -1
- package/lib/design-tokens/js/tokens/functional/components/faq/base.js +1 -1
- package/lib/design-tokens/js/tokens/functional/components/faq/colors.js +1 -1
- package/lib/design-tokens/js/tokens/functional/components/faq/faq.js +1 -1
- package/lib/design-tokens/js/tokens/functional/components/footer/base.js +1 -1
- package/lib/design-tokens/js/tokens/functional/components/footer/colors.js +1 -1
- package/lib/design-tokens/js/tokens/functional/components/frosted-glass-vfx/base.js +1 -1
- package/lib/design-tokens/js/tokens/functional/components/grid/colors.js +1 -1
- package/lib/design-tokens/js/tokens/functional/components/grid/grid.js +1 -1
- package/lib/design-tokens/js/tokens/functional/components/hero/base.js +1 -1
- package/lib/design-tokens/js/tokens/functional/components/icon/colors.js +1 -1
- package/lib/design-tokens/js/tokens/functional/components/ide/base.js +1 -1
- package/lib/design-tokens/js/tokens/functional/components/image/base.js +1 -1
- package/lib/design-tokens/js/tokens/functional/components/inline-code/colors.js +1 -1
- package/lib/design-tokens/js/tokens/functional/components/inline-link/base.js +1 -1
- package/lib/design-tokens/js/tokens/functional/components/inline-link/colors.js +1 -1
- package/lib/design-tokens/js/tokens/functional/components/label/colors.js +1 -1
- package/lib/design-tokens/js/tokens/functional/components/link/colors.js +1 -1
- package/lib/design-tokens/js/tokens/functional/components/logosuite/base.js +1 -1
- package/lib/design-tokens/js/tokens/functional/components/logosuite/colors.js +1 -1
- package/lib/design-tokens/js/tokens/functional/components/media-playlist/colors.js +1 -1
- package/lib/design-tokens/js/tokens/functional/components/pricing-options/colors.js +1 -1
- package/lib/design-tokens/js/tokens/functional/components/pricing-options/pricing-options.js +1 -1
- package/lib/design-tokens/js/tokens/functional/components/prose/base.js +1 -1
- package/lib/design-tokens/js/tokens/functional/components/river/base.js +1 -1
- package/lib/design-tokens/js/tokens/functional/components/river/river.js +1 -1
- package/lib/design-tokens/js/tokens/functional/components/section/section.js +1 -1
- package/lib/design-tokens/js/tokens/functional/components/statistic/base.js +1 -1
- package/lib/design-tokens/js/tokens/functional/components/sub-nav/base.js +1 -1
- package/lib/design-tokens/js/tokens/functional/components/tabs/base.js +1 -1
- package/lib/design-tokens/js/tokens/functional/components/tabs/colors.js +1 -1
- package/lib/design-tokens/js/tokens/functional/components/testimonial/base.js +1 -1
- package/lib/design-tokens/js/tokens/functional/components/testimonial/colors.js +1 -1
- package/lib/design-tokens/js/tokens/functional/components/text-cursor-animation/base.js +1 -1
- package/lib/design-tokens/js/tokens/functional/components/text-cursor-animation/colors.js +1 -1
- package/lib/design-tokens/js/tokens/functional/components/timeline/base.js +1 -1
- package/lib/design-tokens/js/tokens/functional/components/timeline/colors.js +1 -1
- package/lib/design-tokens/js/tokens/functional/components/token/colors.js +1 -1
- package/lib/design-tokens/js/tokens/functional/components/tooltip/colors.js +1 -1
- package/lib/design-tokens/js/tokens/functional/components/video-player/base.js +1 -1
- package/lib/design-tokens/js/tokens/functional/size/border.js +1 -1
- package/lib/design-tokens/js/tokens/functional/size/breakpoints.js +1 -1
- package/lib/design-tokens/js/tokens/functional/size/size-coarse.js +1 -1
- package/lib/design-tokens/js/tokens/functional/size/size-fine.js +1 -1
- package/lib/design-tokens/js/tokens/functional/size/size.js +1 -1
- package/lib/design-tokens/js/tokens/functional/size/viewport.js +1 -1
- package/lib/design-tokens/js/tokens/functional/typography/typography-responsive.js +1 -1
- package/lib/design-tokens/js/tokens/functional/typography/typography.js +1 -1
- package/lib/design-tokens/json/colors.json +3 -0
- package/lib/design-tokens/scss/tokens/base/colors/light.scss +1 -1
- package/lib/design-tokens/scss/tokens/base/size/size.scss +1 -1
- package/lib/design-tokens/scss/tokens/base/typography/typography.scss +1 -1
- package/lib/design-tokens/scss/tokens/functional/animation/base.scss +1 -1
- package/lib/design-tokens/scss/tokens/functional/colors/global.scss +1 -1
- package/lib/design-tokens/scss/tokens/functional/components/bento/base.scss +1 -1
- package/lib/design-tokens/scss/tokens/functional/components/card/base.scss +1 -1
- package/lib/design-tokens/scss/tokens/functional/components/card/colors.scss +1 -1
- package/lib/design-tokens/scss/tokens/functional/components/comparison-table/comparison-table.scss +1 -1
- package/lib/design-tokens/scss/tokens/functional/components/eyebrow-banner/eyebrow-banner.scss +1 -1
- package/lib/design-tokens/scss/tokens/functional/components/faq/base.scss +1 -1
- package/lib/design-tokens/scss/tokens/functional/components/faq/colors.scss +1 -1
- package/lib/design-tokens/scss/tokens/functional/components/faq/faq.scss +1 -1
- package/lib/design-tokens/scss/tokens/functional/components/footer/base.scss +1 -1
- package/lib/design-tokens/scss/tokens/functional/components/footer/colors.scss +1 -1
- package/lib/design-tokens/scss/tokens/functional/components/frosted-glass-vfx/base.scss +1 -1
- package/lib/design-tokens/scss/tokens/functional/components/grid/colors.scss +1 -1
- package/lib/design-tokens/scss/tokens/functional/components/grid/grid.scss +1 -1
- package/lib/design-tokens/scss/tokens/functional/components/hero/base.scss +1 -1
- package/lib/design-tokens/scss/tokens/functional/components/icon/colors.scss +1 -1
- package/lib/design-tokens/scss/tokens/functional/components/ide/base.scss +1 -1
- package/lib/design-tokens/scss/tokens/functional/components/image/base.scss +1 -1
- package/lib/design-tokens/scss/tokens/functional/components/inline-code/colors.scss +1 -1
- package/lib/design-tokens/scss/tokens/functional/components/inline-link/base.scss +1 -1
- package/lib/design-tokens/scss/tokens/functional/components/inline-link/colors.scss +1 -1
- package/lib/design-tokens/scss/tokens/functional/components/label/colors.scss +1 -1
- package/lib/design-tokens/scss/tokens/functional/components/link/colors.scss +1 -1
- package/lib/design-tokens/scss/tokens/functional/components/logosuite/base.scss +1 -1
- package/lib/design-tokens/scss/tokens/functional/components/logosuite/colors.scss +1 -1
- package/lib/design-tokens/scss/tokens/functional/components/media-playlist/colors.scss +1 -1
- package/lib/design-tokens/scss/tokens/functional/components/pricing-options/colors.scss +1 -1
- package/lib/design-tokens/scss/tokens/functional/components/pricing-options/pricing-options.scss +1 -1
- package/lib/design-tokens/scss/tokens/functional/components/prose/base.scss +1 -1
- package/lib/design-tokens/scss/tokens/functional/components/river/base.scss +1 -1
- package/lib/design-tokens/scss/tokens/functional/components/river/river.scss +1 -1
- package/lib/design-tokens/scss/tokens/functional/components/section/section.scss +1 -1
- package/lib/design-tokens/scss/tokens/functional/components/statistic/base.scss +1 -1
- package/lib/design-tokens/scss/tokens/functional/components/sub-nav/base.scss +1 -1
- package/lib/design-tokens/scss/tokens/functional/components/tabs/base.scss +1 -1
- package/lib/design-tokens/scss/tokens/functional/components/tabs/colors.scss +1 -1
- package/lib/design-tokens/scss/tokens/functional/components/testimonial/base.scss +1 -1
- package/lib/design-tokens/scss/tokens/functional/components/testimonial/colors.scss +1 -1
- package/lib/design-tokens/scss/tokens/functional/components/text-cursor-animation/base.scss +1 -1
- package/lib/design-tokens/scss/tokens/functional/components/text-cursor-animation/colors.scss +1 -1
- package/lib/design-tokens/scss/tokens/functional/components/timeline/base.scss +1 -1
- package/lib/design-tokens/scss/tokens/functional/components/timeline/colors.scss +1 -1
- package/lib/design-tokens/scss/tokens/functional/components/token/colors.scss +1 -1
- package/lib/design-tokens/scss/tokens/functional/components/tooltip/colors.scss +1 -1
- package/lib/design-tokens/scss/tokens/functional/components/video-player/base.scss +1 -1
- package/lib/design-tokens/scss/tokens/functional/size/border.scss +1 -1
- package/lib/design-tokens/scss/tokens/functional/size/breakpoints.scss +1 -1
- package/lib/design-tokens/scss/tokens/functional/size/size-coarse.scss +1 -1
- package/lib/design-tokens/scss/tokens/functional/size/size-fine.scss +1 -1
- package/lib/design-tokens/scss/tokens/functional/size/size.scss +1 -1
- package/lib/design-tokens/scss/tokens/functional/size/viewport.scss +1 -1
- package/lib/design-tokens/scss/tokens/functional/typography/typography-responsive.scss +1 -1
- package/lib/design-tokens/scss/tokens/functional/typography/typography.scss +1 -1
- package/lib/design-tokens/ts/tokens/base/colors/light.d.ts +1 -1
- package/lib/design-tokens/ts/tokens/base/colors/light.js +1 -1
- package/lib/design-tokens/ts/tokens/base/size/size.d.ts +1 -1
- package/lib/design-tokens/ts/tokens/base/size/size.js +1 -1
- package/lib/design-tokens/ts/tokens/base/typography/typography.d.ts +1 -1
- package/lib/design-tokens/ts/tokens/base/typography/typography.js +1 -1
- package/lib/design-tokens/ts/tokens/functional/animation/base.d.ts +1 -1
- package/lib/design-tokens/ts/tokens/functional/animation/base.js +1 -1
- package/lib/design-tokens/ts/tokens/functional/colors/global.d.ts +1 -1
- package/lib/design-tokens/ts/tokens/functional/colors/global.js +1 -1
- package/lib/design-tokens/ts/tokens/functional/components/bento/base.d.ts +1 -1
- package/lib/design-tokens/ts/tokens/functional/components/bento/base.js +1 -1
- package/lib/design-tokens/ts/tokens/functional/components/card/base.d.ts +1 -1
- package/lib/design-tokens/ts/tokens/functional/components/card/base.js +1 -1
- package/lib/design-tokens/ts/tokens/functional/components/card/colors.d.ts +1 -1
- package/lib/design-tokens/ts/tokens/functional/components/card/colors.js +1 -1
- package/lib/design-tokens/ts/tokens/functional/components/comparison-table/comparison-table.d.ts +1 -1
- package/lib/design-tokens/ts/tokens/functional/components/comparison-table/comparison-table.js +1 -1
- package/lib/design-tokens/ts/tokens/functional/components/eyebrow-banner/eyebrow-banner.d.ts +1 -1
- package/lib/design-tokens/ts/tokens/functional/components/eyebrow-banner/eyebrow-banner.js +1 -1
- package/lib/design-tokens/ts/tokens/functional/components/faq/base.d.ts +1 -1
- package/lib/design-tokens/ts/tokens/functional/components/faq/base.js +1 -1
- package/lib/design-tokens/ts/tokens/functional/components/faq/colors.d.ts +1 -1
- package/lib/design-tokens/ts/tokens/functional/components/faq/colors.js +1 -1
- package/lib/design-tokens/ts/tokens/functional/components/faq/faq.d.ts +1 -1
- package/lib/design-tokens/ts/tokens/functional/components/faq/faq.js +1 -1
- package/lib/design-tokens/ts/tokens/functional/components/footer/base.d.ts +1 -1
- package/lib/design-tokens/ts/tokens/functional/components/footer/base.js +1 -1
- package/lib/design-tokens/ts/tokens/functional/components/footer/colors.d.ts +1 -1
- package/lib/design-tokens/ts/tokens/functional/components/footer/colors.js +1 -1
- package/lib/design-tokens/ts/tokens/functional/components/frosted-glass-vfx/base.d.ts +1 -1
- package/lib/design-tokens/ts/tokens/functional/components/frosted-glass-vfx/base.js +1 -1
- package/lib/design-tokens/ts/tokens/functional/components/grid/colors.d.ts +1 -1
- package/lib/design-tokens/ts/tokens/functional/components/grid/colors.js +1 -1
- package/lib/design-tokens/ts/tokens/functional/components/grid/grid.d.ts +1 -1
- package/lib/design-tokens/ts/tokens/functional/components/grid/grid.js +1 -1
- package/lib/design-tokens/ts/tokens/functional/components/hero/base.d.ts +1 -1
- package/lib/design-tokens/ts/tokens/functional/components/hero/base.js +1 -1
- package/lib/design-tokens/ts/tokens/functional/components/icon/colors.d.ts +1 -1
- package/lib/design-tokens/ts/tokens/functional/components/icon/colors.js +1 -1
- package/lib/design-tokens/ts/tokens/functional/components/ide/base.d.ts +1 -1
- package/lib/design-tokens/ts/tokens/functional/components/ide/base.js +1 -1
- package/lib/design-tokens/ts/tokens/functional/components/image/base.d.ts +1 -1
- package/lib/design-tokens/ts/tokens/functional/components/image/base.js +1 -1
- package/lib/design-tokens/ts/tokens/functional/components/inline-code/colors.d.ts +1 -1
- package/lib/design-tokens/ts/tokens/functional/components/inline-code/colors.js +1 -1
- package/lib/design-tokens/ts/tokens/functional/components/inline-link/base.d.ts +1 -1
- package/lib/design-tokens/ts/tokens/functional/components/inline-link/base.js +1 -1
- package/lib/design-tokens/ts/tokens/functional/components/inline-link/colors.d.ts +1 -1
- package/lib/design-tokens/ts/tokens/functional/components/inline-link/colors.js +1 -1
- package/lib/design-tokens/ts/tokens/functional/components/label/colors.d.ts +1 -1
- package/lib/design-tokens/ts/tokens/functional/components/label/colors.js +1 -1
- package/lib/design-tokens/ts/tokens/functional/components/link/colors.d.ts +1 -1
- package/lib/design-tokens/ts/tokens/functional/components/link/colors.js +1 -1
- package/lib/design-tokens/ts/tokens/functional/components/logosuite/base.d.ts +1 -1
- package/lib/design-tokens/ts/tokens/functional/components/logosuite/base.js +1 -1
- package/lib/design-tokens/ts/tokens/functional/components/logosuite/colors.d.ts +1 -1
- package/lib/design-tokens/ts/tokens/functional/components/logosuite/colors.js +1 -1
- package/lib/design-tokens/ts/tokens/functional/components/media-playlist/colors.d.ts +1 -1
- package/lib/design-tokens/ts/tokens/functional/components/media-playlist/colors.js +1 -1
- package/lib/design-tokens/ts/tokens/functional/components/pricing-options/colors.d.ts +1 -1
- package/lib/design-tokens/ts/tokens/functional/components/pricing-options/colors.js +1 -1
- package/lib/design-tokens/ts/tokens/functional/components/pricing-options/pricing-options.d.ts +1 -1
- package/lib/design-tokens/ts/tokens/functional/components/pricing-options/pricing-options.js +1 -1
- package/lib/design-tokens/ts/tokens/functional/components/prose/base.d.ts +1 -1
- package/lib/design-tokens/ts/tokens/functional/components/prose/base.js +1 -1
- package/lib/design-tokens/ts/tokens/functional/components/river/base.d.ts +1 -1
- package/lib/design-tokens/ts/tokens/functional/components/river/base.js +1 -1
- package/lib/design-tokens/ts/tokens/functional/components/river/river.d.ts +1 -1
- package/lib/design-tokens/ts/tokens/functional/components/river/river.js +1 -1
- package/lib/design-tokens/ts/tokens/functional/components/section/section.d.ts +1 -1
- package/lib/design-tokens/ts/tokens/functional/components/section/section.js +1 -1
- package/lib/design-tokens/ts/tokens/functional/components/statistic/base.d.ts +1 -1
- package/lib/design-tokens/ts/tokens/functional/components/statistic/base.js +1 -1
- package/lib/design-tokens/ts/tokens/functional/components/sub-nav/base.d.ts +1 -1
- package/lib/design-tokens/ts/tokens/functional/components/sub-nav/base.js +1 -1
- package/lib/design-tokens/ts/tokens/functional/components/tabs/base.d.ts +1 -1
- package/lib/design-tokens/ts/tokens/functional/components/tabs/base.js +1 -1
- package/lib/design-tokens/ts/tokens/functional/components/tabs/colors.d.ts +1 -1
- package/lib/design-tokens/ts/tokens/functional/components/tabs/colors.js +1 -1
- package/lib/design-tokens/ts/tokens/functional/components/testimonial/base.d.ts +1 -1
- package/lib/design-tokens/ts/tokens/functional/components/testimonial/base.js +1 -1
- package/lib/design-tokens/ts/tokens/functional/components/testimonial/colors.d.ts +1 -1
- package/lib/design-tokens/ts/tokens/functional/components/testimonial/colors.js +1 -1
- package/lib/design-tokens/ts/tokens/functional/components/text-cursor-animation/base.d.ts +1 -1
- package/lib/design-tokens/ts/tokens/functional/components/text-cursor-animation/base.js +1 -1
- package/lib/design-tokens/ts/tokens/functional/components/text-cursor-animation/colors.d.ts +1 -1
- package/lib/design-tokens/ts/tokens/functional/components/text-cursor-animation/colors.js +1 -1
- package/lib/design-tokens/ts/tokens/functional/components/timeline/base.d.ts +1 -1
- package/lib/design-tokens/ts/tokens/functional/components/timeline/base.js +1 -1
- package/lib/design-tokens/ts/tokens/functional/components/timeline/colors.d.ts +1 -1
- package/lib/design-tokens/ts/tokens/functional/components/timeline/colors.js +1 -1
- package/lib/design-tokens/ts/tokens/functional/components/token/colors.d.ts +1 -1
- package/lib/design-tokens/ts/tokens/functional/components/token/colors.js +1 -1
- package/lib/design-tokens/ts/tokens/functional/components/tooltip/colors.d.ts +1 -1
- package/lib/design-tokens/ts/tokens/functional/components/tooltip/colors.js +1 -1
- package/lib/design-tokens/ts/tokens/functional/components/video-player/base.d.ts +1 -1
- package/lib/design-tokens/ts/tokens/functional/components/video-player/base.js +1 -1
- package/lib/design-tokens/ts/tokens/functional/size/border.d.ts +1 -1
- package/lib/design-tokens/ts/tokens/functional/size/border.js +1 -1
- package/lib/design-tokens/ts/tokens/functional/size/breakpoints.d.ts +1 -1
- package/lib/design-tokens/ts/tokens/functional/size/breakpoints.js +1 -1
- package/lib/design-tokens/ts/tokens/functional/size/size-coarse.d.ts +1 -1
- package/lib/design-tokens/ts/tokens/functional/size/size-coarse.js +1 -1
- package/lib/design-tokens/ts/tokens/functional/size/size-fine.d.ts +1 -1
- package/lib/design-tokens/ts/tokens/functional/size/size-fine.js +1 -1
- package/lib/design-tokens/ts/tokens/functional/size/size.d.ts +1 -1
- package/lib/design-tokens/ts/tokens/functional/size/size.js +1 -1
- package/lib/design-tokens/ts/tokens/functional/size/viewport.d.ts +1 -1
- package/lib/design-tokens/ts/tokens/functional/size/viewport.js +1 -1
- package/lib/design-tokens/ts/tokens/functional/typography/typography-responsive.d.ts +1 -1
- package/lib/design-tokens/ts/tokens/functional/typography/typography-responsive.js +1 -1
- package/lib/design-tokens/ts/tokens/functional/typography/typography.d.ts +1 -1
- package/lib/design-tokens/ts/tokens/functional/typography/typography.js +1 -1
- package/lib/index.js +1 -1
- package/llms.txt +2 -2
- package/package.json +1 -2
- package/esm/SubdomainNavBar/SubdomainNavBar.module-Rf4qEDka.css +0 -1
- package/esm/packages/design-tokens/lib/design-tokens/css/tokens/functional/components/subdomain-nav-bar/colors-with-modes-ehJCoExh.css +0 -1
|
@@ -21,116 +21,245 @@ import {SubdomainNavBar} from '@primer/react-brand'
|
|
|
21
21
|
### Basic
|
|
22
22
|
|
|
23
23
|
```jsx
|
|
24
|
-
<
|
|
25
|
-
<SubdomainNavBar
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
</SubdomainNavBar>
|
|
24
|
+
<div style={{width: '100%'}}>
|
|
25
|
+
<SubdomainNavBar title="Subdomain" fixed={false}>
|
|
26
|
+
<SubdomainNavBar.Link href="#">Collections</SubdomainNavBar.Link>
|
|
27
|
+
<SubdomainNavBar.Link href="#">Topics</SubdomainNavBar.Link>
|
|
28
|
+
<SubdomainNavBar.Link href="#">Social</SubdomainNavBar.Link>
|
|
29
|
+
<SubdomainNavBar.PrimaryAction href="#">Primary CTA</SubdomainNavBar.PrimaryAction>
|
|
30
|
+
<SubdomainNavBar.SecondaryAction href="#">Secondary CTA</SubdomainNavBar.SecondaryAction>
|
|
31
|
+
</SubdomainNavBar>
|
|
32
|
+
</div>
|
|
31
33
|
```
|
|
32
34
|
|
|
33
35
|
### Search
|
|
34
36
|
|
|
35
|
-
`SubdomainNavBar` offers an optional search form control
|
|
37
|
+
`SubdomainNavBar` offers an optional search form control that supports both `onSubmit` and `onChange`; use `onChange` to display inline results. The `placeholder` labels the input in the opened dialog and defaults to `Search {title}`, or `Search` when no navigation title is available.
|
|
38
|
+
|
|
39
|
+
Keyboard shortcuts are disabled by default. Pass `keyboardShortcut`, such as `keyboardShortcut="/"`, to opt into a global shortcut that opens the search dialog. For programmatic control with `openSearch()` and `closeSearch()`, see the Imperative Search API Storybook example.
|
|
36
40
|
|
|
37
41
|
```jsx filename="noinline"
|
|
38
|
-
const
|
|
39
|
-
|
|
40
|
-
|
|
42
|
+
const groupedResults = [
|
|
43
|
+
{
|
|
44
|
+
title: 'Recommended',
|
|
45
|
+
results: [
|
|
46
|
+
{
|
|
47
|
+
title: 'Getting started with GitHub',
|
|
48
|
+
description: 'Create an account and learn the basics.',
|
|
49
|
+
url: '/en/get-started',
|
|
50
|
+
date: '2026-07-01',
|
|
51
|
+
category: 'Guide',
|
|
52
|
+
},
|
|
53
|
+
],
|
|
54
|
+
},
|
|
55
|
+
{
|
|
56
|
+
title: 'API reference',
|
|
57
|
+
results: [
|
|
58
|
+
{
|
|
59
|
+
title: 'REST API documentation',
|
|
60
|
+
description: 'Integrate with GitHub using the REST API.',
|
|
61
|
+
url: 'https://docs.github.com/en/rest',
|
|
62
|
+
date: '2026-07-01',
|
|
63
|
+
category: 'Reference',
|
|
64
|
+
isExternal: true,
|
|
65
|
+
},
|
|
66
|
+
],
|
|
67
|
+
},
|
|
68
|
+
]
|
|
69
|
+
|
|
70
|
+
const SearchNav = () => {
|
|
41
71
|
const [searchTerm, setSearchTerm] = React.useState('')
|
|
42
72
|
|
|
43
|
-
|
|
44
|
-
{
|
|
45
|
-
title
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
73
|
+
return (
|
|
74
|
+
<div style={{width: '100%'}}>
|
|
75
|
+
<SubdomainNavBar title="GitHub Docs" fixed={false} fullWidth>
|
|
76
|
+
<SubdomainNavBar.Link href="/en/get-started">Get started</SubdomainNavBar.Link>
|
|
77
|
+
<SubdomainNavBar.Search
|
|
78
|
+
placeholder="Search GitHub Docs"
|
|
79
|
+
keyboardShortcut="/"
|
|
80
|
+
searchTerm={searchTerm}
|
|
81
|
+
searchResults={searchTerm ? groupedResults : []}
|
|
82
|
+
onChange={event => setSearchTerm(event.currentTarget.value)}
|
|
83
|
+
onSubmit={event => {
|
|
84
|
+
event.preventDefault()
|
|
85
|
+
}}
|
|
86
|
+
/>
|
|
87
|
+
</SubdomainNavBar>
|
|
88
|
+
</div>
|
|
89
|
+
)
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
render(<SearchNav />)
|
|
93
|
+
```
|
|
94
|
+
|
|
95
|
+
Search results can be a flat list or grouped by title. Do not mix both formats in the same array.
|
|
96
|
+
|
|
97
|
+
### Localized search
|
|
98
|
+
|
|
99
|
+
Use the `labels` prop to localize search text. Any labels you omit fall back to English.
|
|
100
|
+
|
|
101
|
+
```jsx filename="noinline"
|
|
102
|
+
const searchProps = {
|
|
103
|
+
searchLabel: 'Buscar',
|
|
104
|
+
closeLabel: 'Cerrar',
|
|
105
|
+
resultsLabel: 'Resultados',
|
|
106
|
+
searchResultsLabel: 'Resultados de búsqueda',
|
|
107
|
+
formatSearchWithTitle: title => `Buscar en ${title}`,
|
|
108
|
+
formatSearchTrigger: placeholder => `Abrir ${placeholder}`,
|
|
109
|
+
formatResultsHeading: searchTerm => `Resultados para «${searchTerm}»`,
|
|
110
|
+
formatResultsLabel: searchTerm => `Resultados para ${searchTerm}`,
|
|
111
|
+
formatSuggestions: count => `${count} sugerencia${count === 1 ? '' : 's'}.`,
|
|
112
|
+
placeholder: 'Buscar documentación',
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
const LocalizedSearch = () => {
|
|
116
|
+
const [searchTerm, setSearchTerm] = React.useState('')
|
|
83
117
|
|
|
84
118
|
return (
|
|
85
|
-
<
|
|
86
|
-
<SubdomainNavBar
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
</SubdomainNavBar>
|
|
119
|
+
<div style={{width: '100%'}}>
|
|
120
|
+
<SubdomainNavBar title="Documentación" fixed={false}>
|
|
121
|
+
<SubdomainNavBar.Search
|
|
122
|
+
{...searchProps}
|
|
123
|
+
searchTerm={searchTerm}
|
|
124
|
+
onChange={event => setSearchTerm(event.currentTarget.value)}
|
|
125
|
+
onSubmit={event => event.preventDefault()}
|
|
126
|
+
/>
|
|
127
|
+
</SubdomainNavBar>
|
|
128
|
+
</div>
|
|
96
129
|
)
|
|
97
130
|
}
|
|
98
131
|
|
|
99
|
-
render(
|
|
132
|
+
render(<LocalizedSearch />)
|
|
100
133
|
```
|
|
101
134
|
|
|
102
|
-
|
|
135
|
+
### Localized menu controls
|
|
136
|
+
|
|
137
|
+
Use `menuLabels` to localize the narrow menu control and desktop overflow menu. The narrow menu label changes when the menu opens, and any omitted value falls back to English.
|
|
138
|
+
|
|
139
|
+
```jsx filename="noinline"
|
|
140
|
+
const LocalizedMenu = () => (
|
|
141
|
+
<div style={{width: '100%'}}>
|
|
142
|
+
<SubdomainNavBar
|
|
143
|
+
title="Documentación"
|
|
144
|
+
fixed={false}
|
|
145
|
+
menuLabels={{
|
|
146
|
+
menuLabel: 'Menú',
|
|
147
|
+
closeLabel: 'Cerrar',
|
|
148
|
+
overflowMenuLabel: 'Más',
|
|
149
|
+
}}
|
|
150
|
+
>
|
|
151
|
+
<SubdomainNavBar.Link href="/es/get-started">Primeros pasos</SubdomainNavBar.Link>
|
|
152
|
+
<SubdomainNavBar.PrimaryAction href="/es/signup">Registrarse</SubdomainNavBar.PrimaryAction>
|
|
153
|
+
</SubdomainNavBar>
|
|
154
|
+
</div>
|
|
155
|
+
)
|
|
103
156
|
|
|
104
|
-
|
|
157
|
+
render(<LocalizedMenu />)
|
|
158
|
+
```
|
|
159
|
+
|
|
160
|
+
## Accessibility
|
|
105
161
|
|
|
106
|
-
|
|
162
|
+
- Render `SubdomainNavBar` before other focusable page content so its skip-to-content link is the first keyboard-accessible control.
|
|
163
|
+
- Provide a concise, meaningful `title`. It labels the navigation and communicates the subdomain to assistive technologies.
|
|
164
|
+
- Set `skipToContentTargetId` to the ID of the page's active main content element. Activating the skip link moves focus to that element and clears the fixed navigation bar. When omitted, or if the explicit target is unavailable, the component targets the first rendered `main` that is not hidden from assistive technologies.
|
|
165
|
+
- When the menu opens on narrow viewports, hide the rest of the document from screen readers with `inert` or `aria-hidden="true"`. Use `onNarrowMenuToggle` to track the menu state.
|
|
166
|
+
- Localize the menu controls' visible and accessible labels with `menuLabels`.
|
|
167
|
+
- Only opt into a `keyboardShortcut` that does not conflict with browser, operating system, or application shortcuts. Always provide another visible way to open search.
|
|
168
|
+
- For search, localize its visible text, accessible labels, result headings, and live-region announcements. Supplying only some `labels` values produces a mix of localized text and English defaults.
|
|
107
169
|
|
|
108
170
|
## Component props
|
|
109
171
|
|
|
110
172
|
### SubdomainNavBar `Required`
|
|
111
173
|
|
|
112
|
-
| Name
|
|
113
|
-
|
|
|
114
|
-
| `children`
|
|
115
|
-
| `className`
|
|
116
|
-
| `id`
|
|
117
|
-
| `
|
|
118
|
-
| `
|
|
119
|
-
| `
|
|
120
|
-
| `
|
|
121
|
-
| `
|
|
174
|
+
| Name | Type | Default | Description |
|
|
175
|
+
| :---------------------- | :--------------------------------------------------------------------------------------------------------------------------------------------------- | :------------------- | :---------------------------------------------------------------------- |
|
|
176
|
+
| `children` | `'SubdomainNavBar.Link' \| 'SubdomainNavBar.Search' \| 'SubdomainNavBar.PrimaryAction' \| 'SubdomainNavBar.SecondaryAction' \| 'React.ReactElement'` | | Valid child nodes |
|
|
177
|
+
| `className` | `string` | | Sets a custom class on the root element |
|
|
178
|
+
| `id` | `string` | | Sets a custom ID on the root element |
|
|
179
|
+
| `style` | `React.CSSProperties` | | Forwards custom inline styles to the root element |
|
|
180
|
+
| `fixed` | `boolean` | `true` | Fixes the navigation bar to the top of the viewport |
|
|
181
|
+
| `fullWidth` | `boolean` | `false` | Allows the inner content to fill the available width |
|
|
182
|
+
| `logoHref` | `string` | `https://github.com` | Changes the URL of the GitHub logo |
|
|
183
|
+
| `title` | `string` | | Required subdomain name used visibly and by assistive technologies |
|
|
184
|
+
| `titleHref` | `string` | `/` | Links the title to the subdomain root |
|
|
185
|
+
| `menuLabels` | `Partial<SubdomainNavBarMenuLabels>` | English labels | Overrides the menu controls' visible and accessible labels |
|
|
186
|
+
| `skipToContentTargetId` | `string` | First visible `main` | ID of the element focused by the skip-to-content link |
|
|
187
|
+
| `ref` | `React.Ref<SubdomainNavBarHandle>` | | Ref to the root element with `openSearch()` and `closeSearch()` methods |
|
|
188
|
+
| `onNarrowMenuToggle` | `(isOpen: boolean) => void` | | Called with the new state when the narrow menu opens or closes |
|
|
189
|
+
|
|
190
|
+
`SubdomainNavBarProps`, `SubdomainNavBarHandle`, and `SubdomainNavBarMenuLabels` are exported from `@primer/react-brand`.
|
|
191
|
+
|
|
192
|
+
### Menu labels
|
|
193
|
+
|
|
194
|
+
| Field | Type | English default | Purpose |
|
|
195
|
+
| :------------------ | :------- | :-------------- | :----------------------------------------------------------- |
|
|
196
|
+
| `menuLabel` | `string` | `Menu` | Visible and accessible label while the narrow menu is closed |
|
|
197
|
+
| `closeLabel` | `string` | `Close` | Visible and accessible label while the narrow menu is open |
|
|
198
|
+
| `overflowMenuLabel` | `string` | `More` | Visible and accessible label for the desktop overflow menu |
|
|
199
|
+
|
|
200
|
+
### SubdomainNavBar.Search
|
|
201
|
+
|
|
202
|
+
| Name | Type | Default | Description |
|
|
203
|
+
| :----------------- | :----------------------------------------------- | :--------------- | :-------------------------------------------------------------------- |
|
|
204
|
+
| `onSubmit` | `(event: FormEvent<HTMLFormElement>) => void` | | Required search form submit handler |
|
|
205
|
+
| `onChange` | `(event: ChangeEvent<HTMLInputElement>) => void` | | Required search input change handler |
|
|
206
|
+
| `placeholder` | `string` | `Search {title}` | Text shown in the input trigger and opened search input |
|
|
207
|
+
| `shortcutLabel` | `string` | Shortcut value | Visible input-trigger hint; pass an empty string to hide it |
|
|
208
|
+
| `keyboardShortcut` | `string \| false` | | Optional global key or modifier combination that opens search |
|
|
209
|
+
| `labels` | `Partial<SubdomainNavBarSearchLabels>` | English labels | Overrides visible and accessible search text and formatting functions |
|
|
210
|
+
| `searchResults` | `SubdomainNavBarSearchResults` | | Flat or explicitly grouped results |
|
|
211
|
+
| `searchTerm` | `string` | | Current query used in result headings and accessible labels |
|
|
212
|
+
| `className` | `string` | | Sets a custom class on the search trigger container |
|
|
213
|
+
| `ref` | `React.Ref<HTMLInputElement>` | | Ref to the input inside the opened search dialog |
|
|
214
|
+
|
|
215
|
+
`SubdomainNavBarSearchProps` and `SubdomainNavBarSearchLabels` are exported from `@primer/react-brand`.
|
|
216
|
+
|
|
217
|
+
### Search labels
|
|
218
|
+
|
|
219
|
+
| Field | Type | English default | Purpose |
|
|
220
|
+
| :---------------------- | :-------------------------------- | :---------------------------- | :------------------------------------------------------- |
|
|
221
|
+
| `searchLabel` | `string` | `Search` | Accessible label for the search input |
|
|
222
|
+
| `closeLabel` | `string` | `Close` | Visible and accessible close action |
|
|
223
|
+
| `resultsLabel` | `string` | `Results` | Accessible label for an untitled result group |
|
|
224
|
+
| `searchResultsLabel` | `string` | `Search results` | Accessible label for grouped results without a query |
|
|
225
|
+
| `formatSearchWithTitle` | `(title: string) => string` | `Search ${title}` | Formats the default placeholder and dialog label |
|
|
226
|
+
| `formatSearchTrigger` | `(placeholder: string) => string` | `${placeholder} search` | Formats the responsive search trigger's accessible label |
|
|
227
|
+
| `formatResultsHeading` | `(searchTerm: string) => string` | `Results for “${searchTerm}”` | Formats the visible heading for ungrouped results |
|
|
228
|
+
| `formatResultsLabel` | `(searchTerm: string) => string` | `Results for ${searchTerm}` | Formats the accessible label for grouped results |
|
|
229
|
+
| `formatSuggestions` | `(count: number) => string` | `${count} suggestions.` | Formats the polite live-region result-count announcement |
|
|
230
|
+
|
|
231
|
+
### Search result types
|
|
232
|
+
|
|
233
|
+
`SubdomainNavBarSearchResultProps`, `SubdomainNavBarSearchResultGroupProps`, and `SubdomainNavBarSearchResults` are exported from `@primer/react-brand`.
|
|
234
|
+
|
|
235
|
+
#### `SubdomainNavBarSearchResultProps`
|
|
236
|
+
|
|
237
|
+
| Field | Type | Required | Description |
|
|
238
|
+
| :------------ | :-------- | :------: | :----------------------------------------------------------------------- |
|
|
239
|
+
| `title` | `string` | Yes | Linked result title |
|
|
240
|
+
| `description` | `string` | Yes | Result summary |
|
|
241
|
+
| `url` | `string` | Yes | Link destination |
|
|
242
|
+
| `date` | `string` | Yes | Displayed date string; format it for the user's locale before passing it |
|
|
243
|
+
| `category` | `string` | | Optional metadata displayed after the date |
|
|
244
|
+
| `group` | `string` | | Groups flat results under a shared heading |
|
|
245
|
+
| `isExternal` | `boolean` | | Shows an external-link indicator for grouped results |
|
|
246
|
+
|
|
247
|
+
#### `SubdomainNavBarSearchResultGroupProps`
|
|
248
|
+
|
|
249
|
+
| Field | Type | Required | Description |
|
|
250
|
+
| :-------- | :----------------------------------- | :------: | :-------------------------------- |
|
|
251
|
+
| `title` | `string` | Yes | Visible and accessible group name |
|
|
252
|
+
| `results` | `SubdomainNavBarSearchResultProps[]` | Yes | Results in the group |
|
|
122
253
|
|
|
123
254
|
### SubdomainNavBar.Link `Required`
|
|
124
255
|
|
|
125
|
-
`SubdomainNavBar.Link`
|
|
256
|
+
`SubdomainNavBar.Link` renders an anchor link.
|
|
126
257
|
|
|
127
|
-
| Name | Type | Default | Description
|
|
128
|
-
| :----------- | :---------------- | :-----: |
|
|
129
|
-
| `children` | `
|
|
130
|
-
| `className` | `string` | | Applies a custom class
|
|
131
|
-
| `href` | `string` | | Destination path for the anchor element
|
|
132
|
-
| `
|
|
133
|
-
| `ref` | `React.RefObject` | | Forward a Ref to the underlying DOM node |
|
|
134
|
-
| `isExternal` | `boolean` | `false` | When true, renders a external link icon after to the link |
|
|
258
|
+
| Name | Type | Default | Description |
|
|
259
|
+
| :----------- | :---------------- | :-----: | :------------------------------------------------------- |
|
|
260
|
+
| `children` | `React.ReactNode` | | Link content |
|
|
261
|
+
| `className` | `string` | | Applies a custom class |
|
|
262
|
+
| `href` | `string` | | Destination path for the anchor element |
|
|
263
|
+
| `isExternal` | `boolean` | `false` | Renders an external-link icon after the link when `true` |
|
|
135
264
|
|
|
136
|
-
Additional props
|
|
265
|
+
Additional props are passed to the wrapping `<li>` element. [See MDN for accepted list item attributes](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/li#attributes).
|
package/docs/index.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
# Primer Brand docs (v0.75.0-rc.
|
|
1
|
+
# Primer Brand docs (v0.75.0-rc.c3abcc84)
|
|
2
2
|
|
|
3
|
-
These docs are bundled with `@primer/react-brand@0.75.0-rc.
|
|
3
|
+
These docs are bundled with `@primer/react-brand@0.75.0-rc.c3abcc84` and match your installed version.
|
|
4
4
|
|
|
5
5
|
New here? Start with [Getting started](getting-started/index.md) for installation, global
|
|
6
6
|
stylesheet and font setup. Component directories are named after their import (e.g.
|
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
import React, { PropsWithChildren } from 'react';
|
|
2
2
|
import { BaseProps } from '../component-helpers';
|
|
3
|
-
type NavigationVisibilityObserverProps = PropsWithChildren<BaseProps<HTMLUListElement> & React.HTMLAttributes<HTMLUListElement
|
|
3
|
+
type NavigationVisibilityObserverProps = PropsWithChildren<BaseProps<HTMLUListElement> & React.HTMLAttributes<HTMLUListElement> & {
|
|
4
|
+
overflowMenuLabel: string;
|
|
5
|
+
}>;
|
|
4
6
|
export declare const NavigationVisbilityObserver: React.ForwardRefExoticComponent<Omit<NavigationVisibilityObserverProps, "ref"> & React.RefAttributes<HTMLUListElement>>;
|
|
5
7
|
export {};
|
|
6
8
|
//# sourceMappingURL=NavigationVisbilityObserver.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"NavigationVisbilityObserver.d.ts","sourceRoot":"","sources":["../../src/SubdomainNavBar/NavigationVisbilityObserver.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,
|
|
1
|
+
{"version":3,"file":"NavigationVisbilityObserver.d.ts","sourceRoot":"","sources":["../../src/SubdomainNavBar/NavigationVisbilityObserver.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,EAAuD,iBAAiB,EAAC,MAAM,OAAO,CAAA;AAIpG,OAAO,EAAC,SAAS,EAAC,MAAM,sBAAsB,CAAA;AAa9C,KAAK,iCAAiC,GAAG,iBAAiB,CACxD,SAAS,CAAC,gBAAgB,CAAC,GACzB,KAAK,CAAC,cAAc,CAAC,gBAAgB,CAAC,GAAG;IACvC,iBAAiB,EAAE,MAAM,CAAA;CAC1B,CACJ,CAAA;AAED,eAAO,MAAM,2BAA2B,yHAmIvC,CAAA"}
|
|
@@ -1,73 +1,125 @@
|
|
|
1
1
|
import e from "../node_modules/clsx/dist/clsx.js";
|
|
2
2
|
import { useProvidedRefOrCreate as t } from "../hooks/useRef.js";
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
8
|
-
import
|
|
9
|
-
import
|
|
10
|
-
import {
|
|
3
|
+
import { useAnchoredPosition as n } from "../hooks/useAnchoredPosition.js";
|
|
4
|
+
import { useOnClickOutside as r } from "../hooks/useOnClickOutside.js";
|
|
5
|
+
import { useKeyboardEscape as i } from "../hooks/useKeyboardEscape.js";
|
|
6
|
+
import { TriangleDownIcon as a, TriangleUpIcon as o } from "../node_modules/@primer/octicons-react/dist/index.esm.js";
|
|
7
|
+
import { useWindowSize as s } from "../hooks/useWindowSize.js";
|
|
8
|
+
import { useVisibilityObserver as c } from "./useVisibilityObserver.js";
|
|
9
|
+
import l from "./SubdomainNavBar.module.js";
|
|
10
|
+
import { SubdomainNavBarLinkContext as u } from "./SubdomainNavBarLinkContext.js";
|
|
11
|
+
import d, { forwardRef as f, useCallback as p, useEffect as m, useRef as h, useState as g } from "react";
|
|
12
|
+
import { jsx as _, jsxs as v } from "react/jsx-runtime";
|
|
11
13
|
//#region src/SubdomainNavBar/NavigationVisbilityObserver.tsx
|
|
12
|
-
var
|
|
13
|
-
let
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
return c.cloneElement(t, { className: e(t.props.className, f && r && s["SubdomainNavBar-primary-nav-list-item--visible"], f && r === !1 && s["SubdomainNavBar-primary-nav-list-item--invisible"]) });
|
|
24
|
-
}
|
|
25
|
-
return t;
|
|
26
|
-
}), h && /* @__PURE__ */ p(g, {
|
|
27
|
-
visibilityMap: d,
|
|
28
|
-
children: n
|
|
29
|
-
})]
|
|
30
|
-
});
|
|
31
|
-
});
|
|
32
|
-
function g({ children: t, className: a, visibilityMap: o }) {
|
|
33
|
-
let [l, h] = f(null), g = d(null);
|
|
34
|
-
n(g, () => y());
|
|
35
|
-
let _ = !!l, v = (e) => {
|
|
36
|
-
l ? y() : h(e.currentTarget);
|
|
37
|
-
}, y = u(() => {
|
|
38
|
-
h(null);
|
|
39
|
-
}, []);
|
|
40
|
-
return r(y), /* @__PURE__ */ m("li", {
|
|
41
|
-
className: e(s["SubdomainNavBar-primary-nav-list-item--overflow"], a),
|
|
42
|
-
ref: g,
|
|
43
|
-
children: [/* @__PURE__ */ m("button", {
|
|
44
|
-
"aria-expanded": _ ? "true" : "false",
|
|
45
|
-
"aria-controls": "more-navigation",
|
|
46
|
-
"aria-haspopup": "true",
|
|
47
|
-
onClick: v,
|
|
48
|
-
className: e(s["SubdomainNavBar-link"], s["SubdomainNavBar-more-link"]),
|
|
49
|
-
children: ["More", /* @__PURE__ */ p(i, {})]
|
|
50
|
-
}), /* @__PURE__ */ p("div", {
|
|
51
|
-
id: "more-navigation",
|
|
52
|
-
style: { display: _ ? "block" : "none" },
|
|
53
|
-
className: e(s["SubdomainNavBar-overflow-menu"]),
|
|
54
|
-
children: /* @__PURE__ */ p("ul", {
|
|
55
|
-
className: e(s["SubdomainNavBar-overflow-menu-list"]),
|
|
56
|
-
children: c.Children.map(t, (t) => {
|
|
57
|
-
if (c.isValidElement(t)) {
|
|
58
|
-
let n = t.props["data-navitemid"];
|
|
59
|
-
return !n || o[n] ? null : /* @__PURE__ */ p(c.Fragment, { children: c.cloneElement(t, {
|
|
60
|
-
onClick: y,
|
|
61
|
-
className: e(s["SubdomainNavBar-overflow-menu-item"], t.props.className)
|
|
62
|
-
}) });
|
|
14
|
+
var y = f(({ children: a, className: o, overflowMenuLabel: f, ...y }, S) => {
|
|
15
|
+
let C = t(S), w = h(null), T = h(null), E = h(null), { isMedium: D } = s(), [O] = c(C, w, d.Children.toArray(a).map((e, t) => d.isValidElement(e) ? `${t}:${typeof e.props.children == "string" ? e.props.children : ""}` : `${t}:`).join("|"), !D), [k, A] = g(!1), j = Object.values(O).includes(!1), M = d.useId(), N = d.Children.toArray(a).findIndex((e, t) => d.isValidElement(e) ? O[t] === !1 : !1), P = N === -1 ? d.Children.count(a) * 2 : N * 2 - 1, F = d.Children.map(a, (t, n) => {
|
|
16
|
+
if (d.isValidElement(t)) {
|
|
17
|
+
let r = D && O[n] === !1;
|
|
18
|
+
return /* @__PURE__ */ _(u.Provider, {
|
|
19
|
+
value: { isOverflowed: r },
|
|
20
|
+
children: d.cloneElement(t, {
|
|
21
|
+
className: e(t.props.className, r && l["SubdomainNavBar-primary-nav-list-item--overflowed"]),
|
|
22
|
+
style: {
|
|
23
|
+
...t.props.style,
|
|
24
|
+
order: n * 2
|
|
63
25
|
}
|
|
64
|
-
return null;
|
|
65
26
|
})
|
|
66
|
-
})
|
|
27
|
+
});
|
|
28
|
+
}
|
|
29
|
+
return t;
|
|
30
|
+
}), I = p(() => {
|
|
31
|
+
A(!1);
|
|
32
|
+
}, []), L = () => {
|
|
33
|
+
A((e) => !e);
|
|
34
|
+
}, R = p(() => {
|
|
35
|
+
k && (I(), T.current?.focus());
|
|
36
|
+
}, [I, k]);
|
|
37
|
+
m(() => {
|
|
38
|
+
j || I();
|
|
39
|
+
}, [I, j]), r(w, I, E), i(R);
|
|
40
|
+
let { position: z } = n({
|
|
41
|
+
floatingElementRef: E,
|
|
42
|
+
anchorElementRef: T,
|
|
43
|
+
align: "end",
|
|
44
|
+
side: "outside-bottom"
|
|
45
|
+
}, [
|
|
46
|
+
k,
|
|
47
|
+
j,
|
|
48
|
+
P,
|
|
49
|
+
O
|
|
50
|
+
]);
|
|
51
|
+
return D ? /* @__PURE__ */ v("div", {
|
|
52
|
+
className: e(l["SubdomainNavBar-primary-nav-overflow"], j && l["SubdomainNavBar-primary-nav-overflow--has-overflow"], o),
|
|
53
|
+
children: [/* @__PURE__ */ v("ul", {
|
|
54
|
+
className: l["SubdomainNavBar-primary-nav-list"],
|
|
55
|
+
ref: C,
|
|
56
|
+
...y,
|
|
57
|
+
children: [F, /* @__PURE__ */ _(b, {
|
|
58
|
+
ariaControls: M,
|
|
59
|
+
buttonRef: T,
|
|
60
|
+
menuOpen: k,
|
|
61
|
+
onClick: L,
|
|
62
|
+
order: P,
|
|
63
|
+
overflowMenuLabel: f,
|
|
64
|
+
ref: w,
|
|
65
|
+
visible: j
|
|
66
|
+
})]
|
|
67
|
+
}), /* @__PURE__ */ _(x, {
|
|
68
|
+
id: M,
|
|
69
|
+
menuOpen: k,
|
|
70
|
+
onClose: I,
|
|
71
|
+
position: z,
|
|
72
|
+
ref: E,
|
|
73
|
+
visibilityMap: O,
|
|
74
|
+
children: a
|
|
67
75
|
})]
|
|
76
|
+
}) : /* @__PURE__ */ _("ul", {
|
|
77
|
+
className: e(l["SubdomainNavBar-primary-nav-list"], o),
|
|
78
|
+
ref: C,
|
|
79
|
+
...y,
|
|
80
|
+
children: a
|
|
81
|
+
});
|
|
82
|
+
}), b = f(({ ariaControls: n, buttonRef: r, className: i, menuOpen: s, onClick: c, order: u, overflowMenuLabel: d, visible: f }, p) => {
|
|
83
|
+
let m = t(p);
|
|
84
|
+
return /* @__PURE__ */ _("li", {
|
|
85
|
+
"aria-hidden": f ? void 0 : !0,
|
|
86
|
+
className: e(l["SubdomainNavBar-primary-nav-list-item--overflow"], i),
|
|
87
|
+
ref: m,
|
|
88
|
+
style: { order: u },
|
|
89
|
+
children: /* @__PURE__ */ _("button", {
|
|
90
|
+
"aria-expanded": s ? "true" : "false",
|
|
91
|
+
"aria-controls": n,
|
|
92
|
+
onClick: c,
|
|
93
|
+
className: e(l["SubdomainNavBar-link"], l["SubdomainNavBar-more-link"]),
|
|
94
|
+
ref: r,
|
|
95
|
+
tabIndex: f ? void 0 : -1,
|
|
96
|
+
children: /* @__PURE__ */ v("span", {
|
|
97
|
+
className: l["SubdomainNavBar-link-content"],
|
|
98
|
+
children: [d, _(s ? o : a, {})]
|
|
99
|
+
})
|
|
100
|
+
})
|
|
68
101
|
});
|
|
69
|
-
}
|
|
102
|
+
}), x = f(({ children: t, className: n, id: r, menuOpen: i, onClose: a, position: o, visibilityMap: s }, c) => i ? /* @__PURE__ */ _("div", {
|
|
103
|
+
id: r,
|
|
104
|
+
ref: c,
|
|
105
|
+
style: {
|
|
106
|
+
top: `${o?.top ?? 0}px`,
|
|
107
|
+
left: `${o?.left ?? 0}px`,
|
|
108
|
+
visibility: o ? void 0 : "hidden"
|
|
109
|
+
},
|
|
110
|
+
className: e(l["SubdomainNavBar-overflow-menu"], n),
|
|
111
|
+
children: /* @__PURE__ */ _("ul", {
|
|
112
|
+
className: e(l["SubdomainNavBar-overflow-menu-list"]),
|
|
113
|
+
children: d.Children.map(t, (t, n) => d.isValidElement(t) && s[n] === !1 ? /* @__PURE__ */ _(u.Provider, {
|
|
114
|
+
value: {
|
|
115
|
+
isOverflowed: !1,
|
|
116
|
+
onLinkClick: a
|
|
117
|
+
},
|
|
118
|
+
children: d.cloneElement(t, { className: e(l["SubdomainNavBar-overflow-menu-item"], t.props.className) })
|
|
119
|
+
}) : null)
|
|
120
|
+
})
|
|
121
|
+
}) : null);
|
|
70
122
|
//#endregion
|
|
71
|
-
export {
|
|
123
|
+
export { y as NavigationVisbilityObserver };
|
|
72
124
|
|
|
73
125
|
//# sourceMappingURL=NavigationVisbilityObserver.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"NavigationVisbilityObserver.js","names":[],"sources":["../../src/SubdomainNavBar/NavigationVisbilityObserver.tsx"],"sourcesContent":["import React, {forwardRef, useCallback, useRef, useState, PropsWithChildren} from 'react'\nimport {clsx} from 'clsx'\nimport {ChevronDownIcon} from '@primer/octicons-react'\n\nimport {BaseProps} from '../component-helpers'\nimport {useVisibilityObserver} from './useVisibilityObserver'\nimport {useOnClickOutside} from '../hooks/useOnClickOutside'\nimport type {VisibilityMap} from './useVisibilityObserver'\nimport type {SubdomainNavBarLinkProps} from './SubdomainNavBar'\n\nimport styles from './SubdomainNavBar.module.css'\nimport {useKeyboardEscape} from '../hooks/useKeyboardEscape'\nimport {useWindowSize} from '../hooks/useWindowSize'\nimport {useProvidedRefOrCreate} from '../hooks/useRef'\n\ntype NavigationVisibilityObserverProps = PropsWithChildren<\n BaseProps<HTMLUListElement> & React.HTMLAttributes<HTMLUListElement>\n>\n\nexport const NavigationVisbilityObserver = forwardRef<HTMLUListElement, NavigationVisibilityObserverProps>(\n ({children, className, ...rest}, forwardedRef) => {\n const navRef = useProvidedRefOrCreate<HTMLUListElement>(\n forwardedRef as React.RefObject<HTMLUListElement> | React.RefCallback<HTMLUListElement> | null,\n )\n const [visibilityMap] = useVisibilityObserver(navRef, children)\n const {isMedium} = useWindowSize()\n\n const showOverflow = Object.values(visibilityMap).includes(false)\n\n return (\n <ul className={clsx(styles['SubdomainNavBar-primary-nav-list'], className)} ref={navRef} {...rest}>\n {React.Children.map(children, child => {\n if (React.isValidElement<SubdomainNavBarLinkProps>(child)) {\n const visibilityKey = child.props['data-navitemid']\n if (!visibilityKey) {\n return child\n }\n const isVisible = visibilityMap[visibilityKey]\n return React.cloneElement(child, {\n className: clsx(\n child.props.className,\n isMedium && isVisible && styles['SubdomainNavBar-primary-nav-list-item--visible'],\n isMedium && isVisible === false && styles['SubdomainNavBar-primary-nav-list-item--invisible'],\n ),\n })\n }\n return child\n })}\n\n {showOverflow && <AnchoredOverlay visibilityMap={visibilityMap}>{children}</AnchoredOverlay>}\n </ul>\n )\n },\n)\n\ntype AnchoredOverlayProps = {\n visibilityMap: VisibilityMap\n} & BaseProps<HTMLDivElement>\n\nfunction AnchoredOverlay({children, className, visibilityMap}: React.PropsWithChildren<AnchoredOverlayProps>) {\n const [anchorEl, setAnchorEl] = useState<HTMLButtonElement | null>(null)\n const ref = useRef<HTMLLIElement | null>(null)\n\n useOnClickOutside(ref, () => handleClose())\n\n const open = Boolean(anchorEl)\n\n const handleClick = event => {\n if (anchorEl) {\n handleClose()\n } else {\n setAnchorEl(event.currentTarget)\n }\n }\n\n const handleClose = useCallback(() => {\n setAnchorEl(null)\n }, [])\n\n useKeyboardEscape(handleClose)\n\n return (\n <li className={clsx(styles['SubdomainNavBar-primary-nav-list-item--overflow'], className)} ref={ref}>\n <button\n aria-expanded={open ? 'true' : 'false'}\n aria-controls=\"more-navigation\"\n aria-haspopup=\"true\"\n onClick={handleClick}\n className={clsx(styles['SubdomainNavBar-link'], styles['SubdomainNavBar-more-link'])}\n >\n More\n <ChevronDownIcon />\n </button>\n\n <div\n id=\"more-navigation\"\n style={{display: open ? 'block' : 'none'}}\n className={clsx(styles['SubdomainNavBar-overflow-menu'])}\n >\n <ul className={clsx(styles['SubdomainNavBar-overflow-menu-list'])}>\n {React.Children.map(children, child => {\n if (React.isValidElement<SubdomainNavBarLinkProps>(child)) {\n const navItemChild = child.props['data-navitemid']\n if (!navItemChild || visibilityMap[navItemChild]) {\n return null\n }\n\n return (\n <React.Fragment>\n {React.cloneElement(child, {\n onClick: handleClose,\n className: clsx(styles['SubdomainNavBar-overflow-menu-item'], child.props.className),\n })}\n </React.Fragment>\n )\n }\n return null\n })}\n </ul>\n </div>\n </li>\n )\n}\n"],"mappings":";;;;;;;;;;;AAmBA,IAAa,IAA8B,GACxC,EAAC,aAAU,cAAW,GAAG,KAAO,MAAiB;CAChD,IAAM,IAAS,EACb,EACD,EACK,CAAC,KAAiB,EAAsB,GAAQ,EAAS,EACzD,EAAC,gBAAY,GAAe,EAE5B,IAAe,OAAO,OAAO,EAAc,CAAC,SAAS,GAAM;AAEjE,QACE,kBAAC,MAAD;EAAI,WAAW,EAAK,EAAO,qCAAqC,EAAU;EAAE,KAAK;EAAQ,GAAI;YAA7F,CACG,EAAM,SAAS,IAAI,IAAU,MAAS;AACrC,OAAI,EAAM,eAAyC,EAAM,EAAE;IACzD,IAAM,IAAgB,EAAM,MAAM;AAClC,QAAI,CAAC,EACH,QAAO;IAET,IAAM,IAAY,EAAc;AAChC,WAAO,EAAM,aAAa,GAAO,EAC/B,WAAW,EACT,EAAM,MAAM,WACZ,KAAY,KAAa,EAAO,mDAChC,KAAY,MAAc,MAAS,EAAO,oDAC3C,EACF,CAAC;;AAEJ,UAAO;IACP,EAED,KAAgB,kBAAC,GAAD;GAAgC;GAAgB;GAA2B,CAAA,CACzF;;EAGV;AAMD,SAAS,EAAgB,EAAC,aAAU,cAAW,oBAA+D;CAC5G,IAAM,CAAC,GAAU,KAAe,EAAmC,KAAK,EAClE,IAAM,EAA6B,KAAK;AAE9C,GAAkB,SAAW,GAAa,CAAC;CAE3C,IAAM,IAAO,EAAQ,GAEf,KAAc,MAAS;AAC3B,EAAI,IACF,GAAa,GAEb,EAAY,EAAM,cAAc;IAI9B,IAAc,QAAkB;AACpC,IAAY,KAAK;IAChB,EAAE,CAAC;AAIN,QAFA,EAAkB,EAAY,EAG5B,kBAAC,MAAD;EAAI,WAAW,EAAK,EAAO,oDAAoD,EAAU;EAAO;YAAhG,CACE,kBAAC,UAAD;GACE,iBAAe,IAAO,SAAS;GAC/B,iBAAc;GACd,iBAAc;GACd,SAAS;GACT,WAAW,EAAK,EAAO,yBAAyB,EAAO,6BAA6B;aALtF,CAMC,QAEC,kBAAC,GAAD,EAAmB,CAAA,CACZ;MAET,kBAAC,OAAD;GACE,IAAG;GACH,OAAO,EAAC,SAAS,IAAO,UAAU,QAAO;GACzC,WAAW,EAAK,EAAO,iCAAiC;aAExD,kBAAC,MAAD;IAAI,WAAW,EAAK,EAAO,sCAAsC;cAC9D,EAAM,SAAS,IAAI,IAAU,MAAS;AACrC,SAAI,EAAM,eAAyC,EAAM,EAAE;MACzD,IAAM,IAAe,EAAM,MAAM;AAKjC,aAJI,CAAC,KAAgB,EAAc,KAC1B,OAIP,kBAAC,EAAM,UAAP,EAAA,UACG,EAAM,aAAa,GAAO;OACzB,SAAS;OACT,WAAW,EAAK,EAAO,uCAAuC,EAAM,MAAM,UAAU;OACrF,CAAC,EACa,CAAA;;AAGrB,YAAO;MACP;IACC,CAAA;GACD,CAAA,CACH"}
|
|
1
|
+
{"version":3,"file":"NavigationVisbilityObserver.js","names":[],"sources":["../../src/SubdomainNavBar/NavigationVisbilityObserver.tsx"],"sourcesContent":["import React, {forwardRef, useCallback, useEffect, useRef, useState, PropsWithChildren} from 'react'\nimport {clsx} from 'clsx'\nimport {TriangleDownIcon, TriangleUpIcon} from '@primer/octicons-react'\n\nimport {BaseProps} from '../component-helpers'\nimport {useVisibilityObserver} from './useVisibilityObserver'\nimport {useOnClickOutside} from '../hooks/useOnClickOutside'\nimport type {VisibilityMap} from './useVisibilityObserver'\nimport type {SubdomainNavBarLinkProps} from './SubdomainNavBar'\n\nimport styles from './SubdomainNavBar.module.css'\nimport {useAnchoredPosition} from '../hooks/useAnchoredPosition'\nimport {useKeyboardEscape} from '../hooks/useKeyboardEscape'\nimport {useWindowSize} from '../hooks/useWindowSize'\nimport {useProvidedRefOrCreate} from '../hooks/useRef'\nimport {SubdomainNavBarLinkContext} from './SubdomainNavBarLinkContext'\n\ntype NavigationVisibilityObserverProps = PropsWithChildren<\n BaseProps<HTMLUListElement> &\n React.HTMLAttributes<HTMLUListElement> & {\n overflowMenuLabel: string\n }\n>\n\nexport const NavigationVisbilityObserver = forwardRef<HTMLUListElement, NavigationVisibilityObserverProps>(\n ({children, className, overflowMenuLabel, ...rest}, forwardedRef) => {\n const navRef = useProvidedRefOrCreate<HTMLUListElement>(\n forwardedRef as React.RefObject<HTMLUListElement> | React.RefCallback<HTMLUListElement> | null,\n )\n const overflowRef = useRef<HTMLLIElement | null>(null)\n const overflowButtonRef = useRef<HTMLButtonElement | null>(null)\n const overflowMenuRef = useRef<HTMLDivElement | null>(null)\n const {isMedium} = useWindowSize()\n const measurementKey = React.Children.toArray(children)\n .map((child, index) => {\n if (React.isValidElement<SubdomainNavBarLinkProps>(child)) {\n return `${index}:${typeof child.props.children === 'string' ? child.props.children : ''}`\n }\n\n return `${index}:`\n })\n .join('|')\n const [visibilityMap] = useVisibilityObserver(navRef, overflowRef, measurementKey, !isMedium)\n const [menuOpen, setMenuOpen] = useState(false)\n\n const showOverflow = Object.values(visibilityMap).includes(false)\n const overflowMenuId = React.useId()\n const firstOverflowedItemIndex = React.Children.toArray(children).findIndex((child, index) => {\n if (React.isValidElement<SubdomainNavBarLinkProps>(child)) {\n return visibilityMap[index] === false\n }\n\n return false\n })\n const overflowOrder =\n firstOverflowedItemIndex === -1 ? React.Children.count(children) * 2 : firstOverflowedItemIndex * 2 - 1\n\n const navItems = React.Children.map(children, (child, index) => {\n if (React.isValidElement<SubdomainNavBarLinkProps>(child)) {\n const isOverflowed = isMedium && visibilityMap[index] === false\n return (\n <SubdomainNavBarLinkContext.Provider value={{isOverflowed}}>\n {React.cloneElement(child, {\n className: clsx(\n child.props.className,\n isOverflowed && styles['SubdomainNavBar-primary-nav-list-item--overflowed'],\n ),\n style: {\n ...child.props.style,\n order: index * 2,\n },\n })}\n </SubdomainNavBarLinkContext.Provider>\n )\n }\n\n return child\n })\n\n const handleClose = useCallback(() => {\n setMenuOpen(false)\n }, [])\n\n const handleOverflowButtonClick = () => {\n setMenuOpen(prevMenuOpen => !prevMenuOpen)\n }\n\n const handleEscape = useCallback(() => {\n if (menuOpen) {\n handleClose()\n overflowButtonRef.current?.focus()\n }\n }, [handleClose, menuOpen])\n\n useEffect(() => {\n if (!showOverflow) {\n handleClose()\n }\n }, [handleClose, showOverflow])\n\n useOnClickOutside(overflowRef, handleClose, overflowMenuRef)\n useKeyboardEscape(handleEscape)\n\n const {position} = useAnchoredPosition(\n {\n floatingElementRef: overflowMenuRef,\n anchorElementRef: overflowButtonRef,\n align: 'end',\n side: 'outside-bottom',\n },\n [menuOpen, showOverflow, overflowOrder, visibilityMap],\n )\n\n if (!isMedium) {\n return (\n <ul className={clsx(styles['SubdomainNavBar-primary-nav-list'], className)} ref={navRef} {...rest}>\n {children}\n </ul>\n )\n }\n\n return (\n <div\n className={clsx(\n styles['SubdomainNavBar-primary-nav-overflow'],\n showOverflow && styles['SubdomainNavBar-primary-nav-overflow--has-overflow'],\n className,\n )}\n >\n <ul className={styles['SubdomainNavBar-primary-nav-list']} ref={navRef} {...rest}>\n {navItems}\n <OverflowButton\n ariaControls={overflowMenuId}\n buttonRef={overflowButtonRef}\n menuOpen={menuOpen}\n onClick={handleOverflowButtonClick}\n order={overflowOrder}\n overflowMenuLabel={overflowMenuLabel}\n ref={overflowRef}\n visible={showOverflow}\n />\n </ul>\n <OverflowMenu\n id={overflowMenuId}\n menuOpen={menuOpen}\n onClose={handleClose}\n position={position}\n ref={overflowMenuRef}\n visibilityMap={visibilityMap}\n >\n {children}\n </OverflowMenu>\n </div>\n )\n },\n)\n\ntype OverflowButtonProps = {\n ariaControls: string\n buttonRef: React.RefObject<HTMLButtonElement | null>\n menuOpen: boolean\n onClick: () => void\n order: number\n overflowMenuLabel: string\n visible: boolean\n} & BaseProps<HTMLLIElement>\n\nconst OverflowButton = forwardRef<HTMLLIElement, OverflowButtonProps>(\n ({ariaControls, buttonRef, className, menuOpen, onClick, order, overflowMenuLabel, visible}, forwardedRef) => {\n const ref = useProvidedRefOrCreate<HTMLLIElement>(\n forwardedRef as React.RefObject<HTMLLIElement> | React.RefCallback<HTMLLIElement> | null,\n )\n\n return (\n <li\n aria-hidden={visible ? undefined : true}\n className={clsx(styles['SubdomainNavBar-primary-nav-list-item--overflow'], className)}\n ref={ref}\n style={{order}}\n >\n <button\n aria-expanded={menuOpen ? 'true' : 'false'}\n aria-controls={ariaControls}\n onClick={onClick}\n className={clsx(styles['SubdomainNavBar-link'], styles['SubdomainNavBar-more-link'])}\n ref={buttonRef}\n tabIndex={visible ? undefined : -1}\n >\n <span className={styles['SubdomainNavBar-link-content']}>\n {overflowMenuLabel}\n {menuOpen ? <TriangleUpIcon /> : <TriangleDownIcon />}\n </span>\n </button>\n </li>\n )\n },\n)\n\ntype OverflowMenuProps = {\n id: string\n menuOpen: boolean\n onClose: () => void\n position?: {top: number; left: number}\n visibilityMap: VisibilityMap\n} & BaseProps<HTMLDivElement>\n\nconst OverflowMenu = forwardRef<HTMLDivElement, React.PropsWithChildren<OverflowMenuProps>>(\n ({children, className, id, menuOpen, onClose, position, visibilityMap}, forwardedRef) => {\n if (!menuOpen) {\n return null\n }\n\n return (\n <div\n id={id}\n ref={forwardedRef}\n style={{\n top: `${position?.top ?? 0}px`,\n left: `${position?.left ?? 0}px`,\n visibility: position ? undefined : 'hidden',\n }}\n className={clsx(styles['SubdomainNavBar-overflow-menu'], className)}\n >\n <ul className={clsx(styles['SubdomainNavBar-overflow-menu-list'])}>\n {React.Children.map(children, (child, index) => {\n if (React.isValidElement<SubdomainNavBarLinkProps>(child)) {\n if (visibilityMap[index] !== false) {\n return null\n }\n\n return (\n <SubdomainNavBarLinkContext.Provider value={{isOverflowed: false, onLinkClick: onClose}}>\n {React.cloneElement(child, {\n className: clsx(styles['SubdomainNavBar-overflow-menu-item'], child.props.className),\n })}\n </SubdomainNavBarLinkContext.Provider>\n )\n }\n return null\n })}\n </ul>\n </div>\n )\n },\n)\n"],"mappings":";;;;;;;;;;;;;AAwBA,IAAa,IAA8B,GACxC,EAAC,aAAU,cAAW,sBAAmB,GAAG,KAAO,MAAiB;CACnE,IAAM,IAAS,EACb,EACD,EACK,IAAc,EAA6B,KAAK,EAChD,IAAoB,EAAiC,KAAK,EAC1D,IAAkB,EAA8B,KAAK,EACrD,EAAC,gBAAY,GAAe,EAU5B,CAAC,KAAiB,EAAsB,GAAQ,GAT/B,EAAM,SAAS,QAAQ,EAAS,CACpD,KAAK,GAAO,MACP,EAAM,eAAyC,EAAM,GAChD,GAAG,EAAM,GAAG,OAAO,EAAM,MAAM,YAAa,WAAW,EAAM,MAAM,WAAW,OAGhF,GAAG,EAAM,GAChB,CACD,KAAK,IAC2D,EAAgB,CAAC,EAAS,EACvF,CAAC,GAAU,KAAe,EAAS,GAAM,EAEzC,IAAe,OAAO,OAAO,EAAc,CAAC,SAAS,GAAM,EAC3D,IAAiB,EAAM,OAAO,EAC9B,IAA2B,EAAM,SAAS,QAAQ,EAAS,CAAC,WAAW,GAAO,MAC9E,EAAM,eAAyC,EAAM,GAChD,EAAc,OAAW,KAG3B,GACP,EACI,IACJ,MAA6B,KAAK,EAAM,SAAS,MAAM,EAAS,GAAG,IAAI,IAA2B,IAAI,GAElG,IAAW,EAAM,SAAS,IAAI,IAAW,GAAO,MAAU;AAC9D,MAAI,EAAM,eAAyC,EAAM,EAAE;GACzD,IAAM,IAAe,KAAY,EAAc,OAAW;AAC1D,UACE,kBAAC,EAA2B,UAA5B;IAAqC,OAAO,EAAC,iBAAa;cACvD,EAAM,aAAa,GAAO;KACzB,WAAW,EACT,EAAM,MAAM,WACZ,KAAgB,EAAO,qDACxB;KACD,OAAO;MACL,GAAG,EAAM,MAAM;MACf,OAAO,IAAQ;MAChB;KACF,CAAC;IACkC,CAAA;;AAI1C,SAAO;GACP,EAEI,IAAc,QAAkB;AACpC,IAAY,GAAM;IACjB,EAAE,CAAC,EAEA,UAAkC;AACtC,KAAY,MAAgB,CAAC,EAAa;IAGtC,IAAe,QAAkB;AACrC,EAAI,MACF,GAAa,EACb,EAAkB,SAAS,OAAO;IAEnC,CAAC,GAAa,EAAS,CAAC;AAS3B,CAPA,QAAgB;AACd,EAAK,KACH,GAAa;IAEd,CAAC,GAAa,EAAa,CAAC,EAE/B,EAAkB,GAAa,GAAa,EAAgB,EAC5D,EAAkB,EAAa;CAE/B,IAAM,EAAC,gBAAY,EACjB;EACE,oBAAoB;EACpB,kBAAkB;EAClB,OAAO;EACP,MAAM;EACP,EACD;EAAC;EAAU;EAAc;EAAe;EAAc,CACvD;AAUD,QARK,IASH,kBAAC,OAAD;EACE,WAAW,EACT,EAAO,yCACP,KAAgB,EAAO,uDACvB,EACD;YALH,CAOE,kBAAC,MAAD;GAAI,WAAW,EAAO;GAAqC,KAAK;GAAQ,GAAI;aAA5E,CACG,GACD,kBAAC,GAAD;IACE,cAAc;IACd,WAAW;IACD;IACV,SAAS;IACT,OAAO;IACY;IACnB,KAAK;IACL,SAAS;IACT,CAAA,CACC;MACL,kBAAC,GAAD;GACE,IAAI;GACM;GACV,SAAS;GACC;GACV,KAAK;GACU;GAEd;GACY,CAAA,CACX;MArCJ,kBAAC,MAAD;EAAI,WAAW,EAAK,EAAO,qCAAqC,EAAU;EAAE,KAAK;EAAQ,GAAI;EAC1F;EACE,CAAA;EAsCZ,EAYK,IAAiB,GACpB,EAAC,iBAAc,cAAW,cAAW,aAAU,YAAS,UAAO,sBAAmB,cAAU,MAAiB;CAC5G,IAAM,IAAM,EACV,EACD;AAED,QACE,kBAAC,MAAD;EACE,eAAa,IAAU,KAAA,IAAY;EACnC,WAAW,EAAK,EAAO,oDAAoD,EAAU;EAChF;EACL,OAAO,EAAC,UAAM;YAEd,kBAAC,UAAD;GACE,iBAAe,IAAW,SAAS;GACnC,iBAAe;GACN;GACT,WAAW,EAAK,EAAO,yBAAyB,EAAO,6BAA6B;GACpF,KAAK;GACL,UAAU,IAAU,KAAA,IAAY;aAEhC,kBAAC,QAAD;IAAM,WAAW,EAAO;cAAxB,CACG,GACW,EAAX,IAAY,IAAqB,GAAtB,EAAkB,CAAuB,CAChD;;GACA,CAAA;EACN,CAAA;EAGV,EAUK,IAAe,GAClB,EAAC,aAAU,cAAW,OAAI,aAAU,YAAS,aAAU,oBAAgB,MACjE,IAKH,kBAAC,OAAD;CACM;CACJ,KAAK;CACL,OAAO;EACL,KAAK,GAAG,GAAU,OAAO,EAAE;EAC3B,MAAM,GAAG,GAAU,QAAQ,EAAE;EAC7B,YAAY,IAAW,KAAA,IAAY;EACpC;CACD,WAAW,EAAK,EAAO,kCAAkC,EAAU;WAEnE,kBAAC,MAAD;EAAI,WAAW,EAAK,EAAO,sCAAsC;YAC9D,EAAM,SAAS,IAAI,IAAW,GAAO,MAChC,EAAM,eAAyC,EAAM,IACnD,EAAc,OAAW,KAK3B,kBAAC,EAA2B,UAA5B;GAAqC,OAAO;IAAC,cAAc;IAAO,aAAa;IAAQ;aACpF,EAAM,aAAa,GAAO,EACzB,WAAW,EAAK,EAAO,uCAAuC,EAAM,MAAM,UAAU,EACrF,CAAC;GACkC,CAAA,GAR/B,KAYX;EACC,CAAA;CACD,CAAA,GAhCC,KAmCZ"}
|