@nswds/ui 9.3.0 → 9.3.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/components/badge.d.ts +1 -1
- package/dist/components/breadcrumb.d.ts +1 -1
- package/dist/components/breadcrumb.js +5 -4
- package/dist/components/breadcrumb.js.map +1 -1
- package/dist/components/button-group.d.ts +1 -1
- package/dist/components/button-group.js +3 -2
- package/dist/components/button-group.js.map +1 -1
- package/dist/components/button.d.ts +4 -4
- package/dist/components/callout.d.ts +2 -2
- package/dist/components/callout.js +4 -3
- package/dist/components/callout.js.map +1 -1
- package/dist/components/description-list.js +7 -4
- package/dist/components/description-list.js.map +1 -1
- package/dist/components/expandable-search.js +5 -4
- package/dist/components/expandable-search.js.map +1 -1
- package/dist/components/footer.d.ts +1 -1
- package/dist/components/footer.js +9 -5
- package/dist/components/footer.js.map +1 -1
- package/dist/components/header.d.ts +1 -1
- package/dist/components/header.js +9 -5
- package/dist/components/header.js.map +1 -1
- package/dist/components/hero.d.ts +2 -2
- package/dist/components/hero.js +22 -11
- package/dist/components/hero.js.map +1 -1
- package/dist/components/input-group.d.ts +2 -2
- package/dist/components/link.d.ts +1 -1
- package/dist/components/main-nav.d.ts +1 -1
- package/dist/components/main-nav.js +9 -5
- package/dist/components/main-nav.js.map +1 -1
- package/dist/components/masthead.d.ts +1 -1
- package/dist/components/masthead.js +8 -4
- package/dist/components/masthead.js.map +1 -1
- package/dist/components/native-select.js +9 -6
- package/dist/components/native-select.js.map +1 -1
- package/dist/components/page-header.d.ts +1 -1
- package/dist/components/page-header.js +8 -5
- package/dist/components/page-header.js.map +1 -1
- package/dist/components/select.js +6 -3
- package/dist/components/select.js.map +1 -1
- package/dist/components/skeleton.js +4 -3
- package/dist/components/skeleton.js.map +1 -1
- package/dist/components/tabs.js +7 -5
- package/dist/components/tabs.js.map +1 -1
- package/dist/components/tag.d.ts +1 -1
- package/dist/lib/resolve-variant.d.ts +23 -0
- package/dist/lib/resolve-variant.js +7 -0
- package/dist/lib/resolve-variant.js.map +1 -0
- package/package.json +5 -4
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/components/main-nav.tsx"],"names":[],"mappings":";;;;;;;AAoCA,MAAM,aAAA,GAAgB;AAAA,EACpB,aAAA;AAAA,EACA,aAAA;AAAA,EACA,aAAA;AAAA,EACA,aAAA;AAAA,EACA,UAAA;AAAA,EACA,UAAA;AAAA,EACA,UAAA;AAAA,EACA,UAAA;AAAA,EACA,YAAA;AAAA,EACA,YAAA;AAAA,EACA,YAAA;AAAA,EACA,YAAA;AAAA,EACA;AACF;AAMA,MAAM,sBAAA,GAAuC,OAAA;AAE7C,MAAM,eAAA,GAAkB,GAAA;AAAA,EACtB;AAAA,IACE,QAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,IAUA;AAAA,GACF;AAAA,EACA;AAAA,IACE,QAAA,EAAU;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,MAeR,KAAA,EAAO;AAAA,QACL,aAAA,EACE,mFAAA;AAAA,QACF,aAAA,EACE,mFAAA;AAAA,QACF,aAAA,EACE,kJAAA;AAAA,QACF,aAAA,EACE,kJAAA;AAAA,QACF,UAAA,EAAY,6EAAA;AAAA,QACZ,UAAA,EAAY,6EAAA;AAAA,QACZ,UAAA,EACE,sIAAA;AAAA,QACF,UAAA,EACE,sIAAA;AAAA,QACF,YAAA,EACE,iFAAA;AAAA,QACF,YAAA,EACE,iFAAA;AAAA,QACF,YAAA,EACE,8IAAA;AAAA,QACF,YAAA,EACE,8IAAA;AAAA,QACF,KAAA,EACE;AAAA,OACJ;AAAA;AAAA;AAAA;AAAA;AAAA,MAKA,MAAA,EAAQ;AAAA,QACN,IAAA,EAAM,EAAA;AAAA,QACN,GAAA,EAAK,qCAAA;AAAA,QACL,MAAA,EAAQ,qCAAA;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AAA;AAAA,cACL,UAAA,EAAY,CAAA;AAAA,cACZ,KAAA,EAAM,OAAA;AAAA,cACN,WAAA;AAAA,cACA,gBAAA,EAAkB,CAAA;AAAA,cAClB,kBAAA,EAAoB,EAAE,IAAA,EAAM,MAAA,EAAQ,OAAO,MAAA,EAAO;AAAA,cAClD,UAAA,EAAY,GAAA;AAAA,cAGZ,cAAA,EAAe,yBAAA;AAAA,cAMf,YAAY,UAAA,KAAe,IAAA,GAAO,MAAA,GAAY,EAAE,OAAO,UAAA,EAAW;AAAA,cAElE,8BAAC,kBAAA,EAAA,EAAmB,SAAA,EAAU,yCAC3B,QAAA,EAAA,UAAA,CAAW,GAAA,CAAI,CAAC,IAAA,qBACf,GAAA;AAAA,gBAAC,eAAA;AAAA,gBAAA;AAAA,kBAEC,IAAA;AAAA,kBACA,OAAO,KAAA,IAAS,sBAAA;AAAA,kBAChB,WAAA;AAAA,kBACA;AAAA,iBAAA;AAAA,gBAJK,GAAG,IAAA,CAAK,KAAK,CAAA,CAAA,EAAI,IAAA,CAAK,QAAQ,SAAS,CAAA;AAAA,eAM/C,CAAA,EACH;AAAA;AAAA,WACF,EACF;AAAA;AAAA;AAEJ;AAAA,GACF;AAEJ","file":"main-nav.js","sourcesContent":["'use client'\n\nimport { cva, type VariantProps } from 'class-variance-authority'\nimport React from 'react'\n\nimport { IconEast } from '../icons/east.js'\nimport { cn } from '../lib/utils.js'\n\nimport {\n NavigationMenu,\n NavigationMenuContent,\n NavigationMenuItem,\n NavigationMenuLink,\n NavigationMenuList,\n NavigationMenuTrigger,\n} from '../components/navigation-menu.js'\n\n/**\n * Surface colours the main navigation can be themed with — exactly the\n * Footer's thirteen-name vocabulary, so a service that themes its footer\n * `primary-800` writes the same word here. Each name is the LIGHT-mode\n * surface; dark mode deepens it onto the same family's dark steps (see the\n * `color` variants below), so `color` expresses tonal weight rather than a\n * literal colour.\n *\n * The bar's text/background pairs are identical to the Footer's, so its\n * contrast conclusions carry over verbatim: every light pair clears WCAG 2.2\n * AA (1.4.3, 4.5:1) for the bar's text and 11 of the 13 also clear AAA\n * (1.4.6, 7:1). The two AA-only pairs are `primary-600` (4.57:1) and\n * `accent-600` (5.18:1), both with white ink; prefer the `-800` steps when a\n * service is held to AAA. In dark mode all thirteen clear AAA (worst 13.6:1).\n *\n * The mega panels always render on the house popup surface (`bg-popover`),\n * matching the nswds-app source where every dropdown was white regardless of\n * bar colour — only the panel's accent ink follows the colour family.\n */\nconst mainNavColors = [\n 'primary-800',\n 'primary-600',\n 'primary-400',\n 'primary-200',\n 'grey-800',\n 'grey-600',\n 'grey-400',\n 'grey-200',\n 'accent-800',\n 'accent-600',\n 'accent-400',\n 'accent-200',\n 'white',\n] as const\n\ntype MainNavColor = (typeof mainNavColors)[number]\n\n// Shared by cva's defaultVariants, the data-color attribute and the panel\n// variant lookup, so the three can't drift apart.\nconst DEFAULT_MAIN_NAV_COLOR: MainNavColor = 'white'\n\nconst mainNavVariants = cva(\n [\n 'w-full',\n // Every derived colour on the bar resolves from a single --main-nav-ink\n // token, so a colour variant only has to declare the surface utilities and\n // that one value — this replaces the nswds-app source's hand-written\n // 13-variant × 8-slot style table. The border derivation is written\n // literally here (once) rather than per-variant: Tailwind scans source\n // text for class names, so a template-built arbitrary property would\n // never be emitted. Hover/active halos are not derived here — the\n // triggers ride navigation-menu.tsx's --nav-menu-halo chain, re-pointed\n // at this ink (see mainNavItemInk), so there is exactly one halo recipe.\n '[--main-nav-border:color-mix(in_oklch,var(--main-nav-ink)_15%,transparent)]',\n ],\n {\n variants: {\n // Ink values use the RAW masterbrand tokens (--primary-800, --grey-800,\n // --accent-800) rather than Tailwind's --color-* bridge aliases. Tailwind\n // v4 tree-shakes an unreferenced @theme key, and referencing one from\n // inside an arbitrary property is not a usage signal — the raw tokens are\n // plain :root declarations from @nswds/tokens and always resolve.\n // (--color-white is safe: `text-white` / `bg-white` below are real\n // utilities, so that key is always emitted.)\n //\n // Dark mode deepens every surface onto the same family's dark steps —\n // -800→-950, -600→-900, -400→-850, -200→-800, white→grey-900 — the\n // Footer's exact mapping, so the luminance ORDER within a family is\n // preserved and a stacked Footer + MainNav sharing one colour word stay\n // in step in both themes. Ink goes white on all thirteen; every dark\n // pair is WCAG 2.2 AAA (worst 13.6:1).\n color: {\n 'primary-800':\n 'bg-primary-800 text-white [--main-nav-ink:var(--color-white)] dark:bg-primary-950',\n 'primary-600':\n 'bg-primary-600 text-white [--main-nav-ink:var(--color-white)] dark:bg-primary-900',\n 'primary-400':\n 'bg-primary-400 text-primary-800 [--main-nav-ink:var(--primary-800)] dark:bg-primary-850 dark:text-white dark:[--main-nav-ink:var(--color-white)]',\n 'primary-200':\n 'bg-primary-200 text-primary-800 [--main-nav-ink:var(--primary-800)] dark:bg-primary-800 dark:text-white dark:[--main-nav-ink:var(--color-white)]',\n 'grey-800': 'bg-grey-800 text-white [--main-nav-ink:var(--color-white)] dark:bg-grey-950',\n 'grey-600': 'bg-grey-600 text-white [--main-nav-ink:var(--color-white)] dark:bg-grey-900',\n 'grey-400':\n 'bg-grey-400 text-grey-800 [--main-nav-ink:var(--grey-800)] dark:bg-grey-850 dark:text-white dark:[--main-nav-ink:var(--color-white)]',\n 'grey-200':\n 'bg-grey-200 text-grey-800 [--main-nav-ink:var(--grey-800)] dark:bg-grey-800 dark:text-white dark:[--main-nav-ink:var(--color-white)]',\n 'accent-800':\n 'bg-accent-800 text-white [--main-nav-ink:var(--color-white)] dark:bg-accent-950',\n 'accent-600':\n 'bg-accent-600 text-white [--main-nav-ink:var(--color-white)] dark:bg-accent-900',\n 'accent-400':\n 'bg-accent-400 text-accent-800 [--main-nav-ink:var(--accent-800)] dark:bg-accent-850 dark:text-white dark:[--main-nav-ink:var(--color-white)]',\n 'accent-200':\n 'bg-accent-200 text-accent-800 [--main-nav-ink:var(--accent-800)] dark:bg-accent-800 dark:text-white dark:[--main-nav-ink:var(--color-white)]',\n white:\n 'bg-white text-grey-800 [--main-nav-ink:var(--grey-800)] dark:bg-grey-900 dark:text-white dark:[--main-nav-ink:var(--color-white)]',\n },\n // Rules along the bar's edges, drawn from the ink-derived border token so\n // they follow every colour variant and both themes. Replaces the app\n // source's deprecated showTopBorder/showBottomBorder booleans, which are\n // deliberately not ported.\n border: {\n none: '',\n top: 'border-t border-(--main-nav-border)',\n bottom: 'border-b border-(--main-nav-border)',\n both: 'border-y border-(--main-nav-border)',\n },\n },\n defaultVariants: {\n color: DEFAULT_MAIN_NAV_COLOR,\n border: 'none',\n },\n },\n)\n\nconst mainNavContainerVariants = cva(\n [\n 'mx-auto flex w-full items-center',\n // Lateral padding funnels through --main-nav-padding-x so an app can\n // retune it once (via the `style` prop or a utility class) without a new\n // variant. Same mechanism, and the same 16px → 24px → 48px rhythm, as\n // Masthead, Header and Footer.\n 'px-(--main-nav-padding-x)',\n '[--main-nav-padding-x:--spacing(4)] sm:[--main-nav-padding-x:--spacing(6)] lg:[--main-nav-padding-x:--spacing(12)]',\n ],\n {\n variants: {\n container: {\n // Full-bleed (nswds-app fullBleed parity). --main-nav-max-width is\n // still read so a shell app can constrain the inner wrapper without\n // switching variants.\n fluid: 'max-w-[var(--main-nav-max-width,none)]',\n // Centred content column, legacy nsw-container parity (1200px).\n contained: 'max-w-[var(--main-nav-max-width,75rem)]',\n },\n },\n defaultVariants: {\n container: 'fluid',\n },\n },\n)\n\n/**\n * Mega-panel accent ink, keyed by the same thirteen colour names as the bar.\n * The panel itself is always the house popup surface (`bg-popover`, white in\n * light mode) — parity with the app source, whose dropdown was white for\n * every variant — so the family only tints the featured lead link, hover ink\n * and cell borders. Declared on the Content element (not inherited from the\n * bar) because Base UI portals the panel to `document.body`: a custom\n * property set on the `<nav>` can never reach it.\n *\n * Light inks are the family's -800 step on white — grey-800 on white is\n * 15.1:1 and white on primary-800 is 14.4:1 (both AAA; contrast is symmetric,\n * ratios from header.tsx); accent-800 on white clears AAA per the Footer's\n * verified pairs. Dark inks step to the family's -200 — the same dark-mode\n * interactive ink link.tsx and navigation-menu.tsx already use on this\n * popover surface. The featured lead is text-xl bold, so even the softest\n * pair is far above the large-text AA floor (1.4.3, 3:1).\n */\nconst mainNavPanelVariants = cva(\n [\n 'p-0 whitespace-normal',\n // The sibling Content (and the shared popup, via popupClassName below)\n // cap themselves at --available-width, which Base UI measures from the\n // active trigger — for a mid-bar trigger that is less than the nav's\n // width, which would shrink right-hand panels. The panel's width is\n // container-measured and can never exceed the viewport, so the cap is\n // safely lifted.\n 'max-w-none',\n '[--main-nav-panel-border:color-mix(in_oklch,var(--main-nav-panel-ink)_15%,transparent)]',\n ],\n {\n variants: {\n color: {\n 'primary-800':\n '[--main-nav-panel-ink:var(--primary-800)] dark:[--main-nav-panel-ink:var(--primary-200)]',\n 'primary-600':\n '[--main-nav-panel-ink:var(--primary-800)] dark:[--main-nav-panel-ink:var(--primary-200)]',\n 'primary-400':\n '[--main-nav-panel-ink:var(--primary-800)] dark:[--main-nav-panel-ink:var(--primary-200)]',\n 'primary-200':\n '[--main-nav-panel-ink:var(--primary-800)] dark:[--main-nav-panel-ink:var(--primary-200)]',\n 'grey-800':\n '[--main-nav-panel-ink:var(--grey-800)] dark:[--main-nav-panel-ink:var(--grey-200)]',\n 'grey-600':\n '[--main-nav-panel-ink:var(--grey-800)] dark:[--main-nav-panel-ink:var(--grey-200)]',\n 'grey-400':\n '[--main-nav-panel-ink:var(--grey-800)] dark:[--main-nav-panel-ink:var(--grey-200)]',\n 'grey-200':\n '[--main-nav-panel-ink:var(--grey-800)] dark:[--main-nav-panel-ink:var(--grey-200)]',\n 'accent-800':\n '[--main-nav-panel-ink:var(--accent-800)] dark:[--main-nav-panel-ink:var(--accent-200)]',\n 'accent-600':\n '[--main-nav-panel-ink:var(--accent-800)] dark:[--main-nav-panel-ink:var(--accent-200)]',\n 'accent-400':\n '[--main-nav-panel-ink:var(--accent-800)] dark:[--main-nav-panel-ink:var(--accent-200)]',\n 'accent-200':\n '[--main-nav-panel-ink:var(--accent-800)] dark:[--main-nav-panel-ink:var(--accent-200)]',\n white: '[--main-nav-panel-ink:var(--grey-800)] dark:[--main-nav-panel-ink:var(--grey-200)]',\n },\n },\n defaultVariants: {\n color: DEFAULT_MAIN_NAV_COLOR,\n },\n },\n)\n\n// Re-points the sibling navigation-menu's ink at the bar's surface ink. The\n// trigger/link halos and focus outlines in navigation-menu.tsx all derive\n// from --nav-menu-ink via color-mix ON THE SAME ELEMENT, so overriding the\n// one token retargets the whole chain: hover/active halos and the\n// focus-visible outline become surface-relative, guaranteeing the indicator\n// contrasts on all thirteen surfaces (WCAG 2.2, 2.4.13 Focus Appearance).\n// Both light and dark are overridden because the sibling pins its own\n// dark-mode ink (primary-200); --main-nav-ink is already theme-aware.\nconst mainNavItemInk =\n '[--nav-menu-ink:var(--main-nav-ink)] dark:[--nav-menu-ink:var(--main-nav-ink)]'\n\n// Same re-point for links INSIDE the portalled panel, where the bar's ink\n// cannot reach — these derive from the panel accent ink instead.\nconst mainNavPanelInk =\n '[--nav-menu-ink:var(--main-nav-panel-ink)] dark:[--nav-menu-ink:var(--main-nav-panel-ink)]'\n\n// Restyles the sibling trigger to the app source's bar metrics: 56px min\n// height, square corners, bold base text, wider gutters from lg up. The open\n// panel is marked with the app's 4px inset underline (data-popup-open comes\n// from Base UI); data-current draws the same underline persistently when\n// `currentHref` falls inside this section, so the underline means \"you are\n// here\" at rest and \"this panel is open\" during use.\nconst mainNavTriggerClassName = [\n mainNavItemInk,\n 'mb-0 h-auto min-h-14 w-auto justify-start rounded-none max-lg:px-4 py-2 text-base leading-6 font-bold text-(--main-nav-ink)',\n 'lg:px-8',\n '[&_svg]:size-6',\n // Inset focus ring: the sibling list is a horizontal scroll container, and\n // a scroll container clips everything drawn outside a child's border box —\n // the house outward `outline-offset-2` would simply vanish on the first and\n // last triggers. Same reasoning (and same fix) as push-menu.tsx's rows.\n 'focus-visible:-outline-offset-2',\n 'data-popup-open:shadow-[inset_0_-4px_0_0_currentColor]',\n 'data-current:shadow-[inset_0_-4px_0_0_currentColor]',\n].join(' ')\n\n// A panel-less item, restyled from the sibling link to sit visually beside\n// the triggers (cn's conflict merge lets these win over the link's stacked\n// defaults). `active` → data-active draws the current-page underline; Base UI\n// pairs it with aria-current='page' on the same element (WCAG 2.4.8).\nconst mainNavTopLinkClassName = [\n mainNavItemInk,\n 'inline-flex min-h-14 flex-row items-center justify-start gap-1 rounded-none max-lg:px-4 py-2 text-base leading-6 font-bold whitespace-nowrap text-(--main-nav-ink)',\n 'lg:px-8',\n // Inset for the same reason as the trigger above — these sit in the\n // scrolling list, not in a portalled panel.\n 'focus-visible:-outline-offset-2',\n 'data-active:shadow-[inset_0_-4px_0_0_currentColor]',\n].join(' ')\n\n// The featured lead link at the top of a mega panel: the section title,\n// oversized, with an east arrow that nudges forward on hover (the app\n// source's exact affordance, on the house easing curve; the nudge is a\n// transition, so motion-reduce users get an instant state change — WCAG\n// 2.3.3). `group` scopes the icon's group-hover to this anchor — the panel is\n// portalled, so no other `group` ancestor can capture it.\nconst mainNavFeaturedLinkClassName = [\n mainNavPanelInk,\n 'group relative flex-row items-center rounded-none px-8 py-8 text-xl font-bold whitespace-normal text-(--main-nav-panel-ink)',\n].join(' ')\n\n// The lead when the section has no `href`: the same visual weight as the\n// featured link, but a plain heading row — no anchor (a dead link announced\n// as a link fails the reader who activates it), no hover halo, and no east\n// arrow (an arrow on a non-link promises navigation that never happens). No\n// mainNavPanelInk re-point either: that chain only feeds interactive halos.\nconst mainNavFeaturedHeadingClassName =\n 'flex flex-row items-center px-8 py-8 text-xl font-bold whitespace-normal text-(--main-nav-panel-ink)'\n\n// One bordered grid cell per section link. The anchor itself is the cell —\n// the app source wrapped a div around a stretched-link span, but making the\n// whole cell the anchor gives the same hit area with one element and no\n// aria-hidden overlay. Cells draw a top hairline from the panel ink; the last\n// grid row closes with a bottom hairline via the app's :nth-last-child(-n+3)\n// selector (tuned to the widest, 3-column layout — at narrower widths the\n// final one or two cells simply carry the closing rule, matching the app).\nconst mainNavSectionLinkClassName = [\n mainNavPanelInk,\n 'relative mx-2 justify-center rounded-none border-t border-(--main-nav-panel-border) p-4 text-base font-semibold whitespace-normal text-popover-foreground',\n 'hover:text-(--main-nav-panel-ink)',\n '[&:nth-last-child(-n+3)]:border-b',\n].join(' ')\n\n/** One link inside a mega panel. */\ntype MainNavLinkItem = {\n /** Visible link text, e.g. \"Find support near you\". */\n title: string\n href: string\n}\n\n/**\n * One top-level navigation item. With `links` it renders as a trigger opening\n * a mega panel (with `href` becoming the panel's featured lead link; without\n * an `href` the lead is a plain heading row — dev builds warn); without\n * `links` it renders as a plain link styled like the triggers. Recursion is\n * deliberately one level deep — mega panels list flat links, per the app\n * source's NavigationSection shape.\n */\ntype MainNavItem = {\n title: string\n href?: string\n links?: MainNavLinkItem[]\n}\n\n/**\n * Dev-only guard, mirroring the icon-only Button check in button.tsx: an item\n * with neither `href` nor `links` renders a dead `\"#\"` link — almost always a\n * data mistake, and a trap for keyboard and screen-reader users who activate\n * it and go nowhere. A section (`links`, no `href`) is legal but demoted —\n * its panel lead renders as a plain heading instead of the featured link —\n * so it gets its own nudge. No-op in production.\n */\nfunction warnIfItemUnlinked(item: MainNavItem) {\n if (process.env.NODE_ENV === 'production') {\n return\n }\n if (!item.href && !item.links?.length) {\n console.warn(\n `[nswds/ui] MainNav item \"${item.title}\" has no href and no links — it will render as a dead \"#\" link.`,\n )\n }\n if (!item.href && item.links?.length) {\n console.warn(\n `[nswds/ui] MainNav section \"${item.title}\" has links but no href — its panel lead renders as a plain heading; pass href to make it a link.`,\n )\n }\n}\n\ntype MainNavMenuItemProps = {\n item: MainNavItem\n color: MainNavColor\n currentHref?: string\n /** Measured container width, forwarded as the panel's inline width. */\n panelWidth: number | null\n}\n\n/**\n * One bar entry: a plain link for items without `links`, a trigger + mega\n * panel for items with them. Internal — the data-driven `MainNav` API is the\n * public surface; compose the navigation-menu primitives directly for layouts\n * this doesn't cover.\n */\nfunction MainNavMenuItem({ item, color, currentHref, panelWidth }: MainNavMenuItemProps) {\n warnIfItemUnlinked(item)\n\n const links = item.links\n const isExactCurrent = item.href !== undefined && item.href === currentHref\n const isSectionCurrent =\n isExactCurrent ||\n (currentHref !== undefined && (links?.some((link) => link.href === currentHref) ?? false))\n\n if (!links?.length) {\n return (\n <NavigationMenuItem className='shrink-0'>\n <NavigationMenuLink\n data-slot='main-nav-top-link'\n href={item.href ?? '#'}\n active={isExactCurrent}\n className={mainNavTopLinkClassName}\n >\n {item.title}\n </NavigationMenuLink>\n </NavigationMenuItem>\n )\n }\n\n return (\n <NavigationMenuItem className='shrink-0'>\n {/* The trigger is a button (it discloses, it doesn't navigate), so it\n can't carry aria-current — data-current draws the visual \"you are\n here\" underline while the aria-current announcement lives on the\n exact matching link inside the panel. */}\n <NavigationMenuTrigger\n data-current={isSectionCurrent || undefined}\n className={mainNavTriggerClassName}\n >\n {item.title}\n </NavigationMenuTrigger>\n {/* Inline width (not a CSS var): the panel is portalled to\n document.body, so a custom property set on the nav can't reach it.\n Before the first measurement resolves the panel falls back to the\n sibling's natural w-max sizing. */}\n <NavigationMenuContent\n data-slot='main-nav-panel'\n className={mainNavPanelVariants({ color })}\n style={panelWidth === null ? undefined : { width: panelWidth }}\n >\n <div className='grid w-full'>\n {/* No section href → no featured LINK: an `href=\"#\"` fallback here\n would be a dead link announced as a link. The heading row keeps\n the lead's visual weight without the anchor, halo or arrow — see\n mainNavFeaturedHeadingClassName. */}\n {item.href === undefined ? (\n <div data-slot='main-nav-featured-heading' className={mainNavFeaturedHeadingClassName}>\n {item.title}\n </div>\n ) : (\n <NavigationMenuLink\n data-slot='main-nav-featured-link'\n href={item.href}\n active={isExactCurrent}\n className={mainNavFeaturedLinkClassName}\n >\n {item.title}\n <IconEast\n aria-hidden='true'\n className='ml-4 size-6 shrink-0 text-current duration-300 ease-[cubic-bezier(0.22,1,0.36,1)] group-hover:translate-x-1 motion-safe:transition-transform'\n />\n </NavigationMenuLink>\n )}\n <div\n data-slot='main-nav-panel-links'\n className='grid overflow-hidden px-4 pb-12 max-sm:grid-cols-1 sm:max-lg:grid-cols-2 lg:grid-cols-3'\n >\n {links.map((link, index) => (\n <NavigationMenuLink\n key={`${link.title}-${link.href}-${index}`}\n data-slot='main-nav-section-link'\n href={link.href}\n active={link.href === currentHref}\n className={mainNavSectionLinkClassName}\n >\n {link.title}\n </NavigationMenuLink>\n ))}\n </div>\n </div>\n </NavigationMenuContent>\n </NavigationMenuItem>\n )\n}\n\ntype MainNavProps = Omit<React.ComponentPropsWithoutRef<'nav'>, 'children'> &\n VariantProps<typeof mainNavVariants> &\n VariantProps<typeof mainNavContainerVariants> & {\n /** Top-level items; items with `links` open mega panels. */\n navigation: MainNavItem[]\n /**\n * The current page's href. The exact matching link gets\n * `aria-current=\"page\"`, and the top-level item it belongs to (a plain\n * link, or the trigger whose panel contains it) gets the current-item\n * underline. The app source read this from next/navigation's\n * `usePathname` — a framework API this package must not import; compare\n * in the consumer and pass the result down.\n */\n currentHref?: string\n /**\n * Stick to the top of the viewport as the page scrolls. Defaults to\n * `false`. When the nav renders below a sticky `Header`, set\n * `--main-nav-top` to the header's height so the two stack instead of\n * overlapping — this custom property replaces the app source's\n * `useSelectorHeight` DOM-measuring hook (the app measured `#nsw-header`\n * on every resize; a consumer that needs a live value can still measure\n * its own header and write the property, see the Sticky story).\n */\n sticky?: boolean\n /** Drop shadow under the bar. Defaults to `true`. */\n shadow?: boolean\n /** Classes applied to the inner width-constraining wrapper. */\n containerClassName?: string\n /**\n * Shown in the bar when `navigation` is empty. Defaults to\n * \"No navigation items available.\"; pass `null` to render an empty bar.\n *\n * An empty `navigation` array is a legitimate runtime state, not a data\n * mistake — a CMS with nothing published, a menu filtered down to nothing\n * by the reader's permissions, or a failed nav fetch all produce it. The\n * bar keeps its themed surface either way, so with no message it reads as\n * an unexplained coloured strip.\n */\n emptyMessage?: React.ReactNode\n ref?: React.Ref<HTMLElement>\n }\n\n/**\n * Full-width NSW site navigation bar with mega-menu panels — the data-driven\n * consolidation of the nswds-app `NavigationMenuMainNavigation` /\n * `MainNavigation` components, rebuilt on this package's `NavigationMenu`\n * (Base UI underneath).\n *\n * - `navigation` drives everything: items with `links` render a trigger whose\n * mega panel shows a featured lead link (the section `href`; with no `href`\n * the lead demotes to a plain heading row — dev builds warn) above a\n * responsive 1/2/3-column grid of bordered section links; items without\n * `links` render plain links styled like the triggers. All anchors render\n * through `Link`, so a framework link injected via `LinkProvider`\n * (e.g. next/link) is used automatically.\n * - `color` themes the bar with the Footer's thirteen-name vocabulary and its\n * exact dark-mode deepening; every derived colour (halos, borders, focus\n * outlines) resolves from a single `--main-nav-ink` per variant. Contrast\n * conclusions are the Footer's, verbatim (see `mainNavColors`).\n * - Panels span the nav container's full width: a ResizeObserver on the inner\n * container feeds each panel's inline width, and an `alignOffset` function\n * shifts Base UI's trigger-anchored positioner back to the container's left\n * edge (measured at position time from the open trigger, so it is exact for\n * every trigger — this replaces the app source's panelMetrics state).\n * The offset is physical and correct in BOTH directions: Base UI passes\n * `align` to floating-ui as a physical placement and only mirrors a logical\n * `side`, so nothing about this anchoring flips under RTL. See the comment\n * on `alignOffset`, and the RightToLeft story that pins it.\n * - `container`, `border`, `shadow`, `sticky` mirror the house chrome\n * components; the app's deprecated `showTopBorder`/`showBottomBorder` and\n * `responsive` props are not ported (use `border` and\n * `className=\"hidden lg:block\"`).\n *\n * Accessibility: the outer `<nav>` is the landmark (default label \"Main\n * navigation\"; Base UI's own root is demoted to a `<div>` via `render` so the\n * page doesn't gain a nested nav landmark). Everything interactive is\n * inherited from Base UI via the sibling: triggers are real buttons with\n * `aria-expanded`/`aria-controls`, ArrowDown/Enter opens, arrow keys rove,\n * Escape and focus-out close, and the current page announces\n * `aria-current=\"page\"` (WCAG 2.4.8). Focus indicators are 2px ink-derived\n * outlines that contrast on all thirteen surfaces and on the panel surface\n * (2.4.7, 2.4.13). The 220ms `closeDelay` reproduces the app's hover-out\n * grace timer through Base UI instead of a hand-rolled setTimeout.\n *\n * The default `id=\"nsw-main-navigation\"` is kept for compatibility with\n * existing shells that target it (override via the `id` prop).\n */\nfunction MainNav({\n className,\n containerClassName,\n color,\n container,\n border,\n navigation,\n currentHref,\n sticky = false,\n shadow = true,\n emptyMessage = 'No navigation items available.',\n 'aria-label': ariaLabel = 'Main navigation',\n ref,\n ...props\n}: MainNavProps) {\n const containerRef = React.useRef<HTMLDivElement>(null)\n const [panelWidth, setPanelWidth] = React.useState<number | null>(null)\n\n React.useEffect(() => {\n const element = containerRef.current\n if (!element) {\n return\n }\n const measure = () => {\n setPanelWidth(element.getBoundingClientRect().width)\n }\n // Read once on mount: panels can open before the first resize.\n measure()\n const observer = new ResizeObserver(measure)\n observer.observe(element)\n return () => observer.disconnect()\n }, [])\n\n // Shifts the popup from Base UI's anchor (the open trigger) to the\n // container's left edge. Called by the positioner at position time, when\n // the open trigger is findable via data-popup-open — so the offset is exact\n // per trigger with no per-trigger state.\n //\n // PHYSICAL, and correct in both directions — this is deliberate, and the\n // opposite of what the comment here used to claim (\"Assumes LTR; RTL would\n // need the mirrored calculation\"). Base UI's useAnchorPositioning consults\n // the direction ONLY to map a logical `side` (`inline-start`/`inline-end`);\n // `align` is passed through to floating-ui as a physical placement, so\n // `side='bottom' align='start'` anchors the popup's LEFT edge to the\n // trigger's left in RTL exactly as in LTR, and `alignOffset` is applied on\n // floating-ui's physical cross axis. Nothing mirrors, so neither should this.\n //\n // Verified, not assumed: adding the mirror (trigger.right - container.right)\n // and rendering the bar under `dir='rtl'` WITH a DirectionProvider put the\n // panel at left=914 against a container at left=0 — the mirror moved an\n // already-left-anchored panel. The RightToLeft story pins the correct\n // geometry so a future Base UI release that starts mirroring `align` fails\n // here instead of in a consumer's RTL site.\n //\n // The ref caches the last successful offset for the windows when NO trigger\n // carries data-popup-open — chiefly the ~300ms close fade, when a recompute\n // (scroll/resize mid-fade) returning 0 would snap the still-visible\n // full-width panel back to the trigger's edge. Repeating the last real\n // offset holds the fading panel where it was.\n const lastAlignOffsetRef = React.useRef(0)\n const alignOffset = React.useCallback(() => {\n const element = containerRef.current\n if (!element) {\n return lastAlignOffsetRef.current\n }\n const trigger = element.querySelector('[data-popup-open]')\n if (!trigger) {\n return lastAlignOffsetRef.current\n }\n lastAlignOffsetRef.current =\n element.getBoundingClientRect().left - trigger.getBoundingClientRect().left\n return lastAlignOffsetRef.current\n }, [])\n\n return (\n <nav\n id='nsw-main-navigation'\n data-slot='main-nav'\n data-color={color ?? DEFAULT_MAIN_NAV_COLOR}\n aria-label={ariaLabel}\n {...props}\n className={cn(\n mainNavVariants({ color, border }),\n // z-40 matches Header (both sit below the z-50 SkipLinks). An app\n // stacking this under a sticky Header sets --main-nav-top to the\n // header's height.\n sticky && 'sticky top-[var(--main-nav-top,0px)] z-40',\n // House scrolled-header shadow; in dark mode borders carry separation.\n shadow && 'shadow-md shadow-black/5 dark:shadow-none',\n className,\n )}\n ref={ref}\n >\n <div\n ref={containerRef}\n data-slot='main-nav-container'\n className={cn(mainNavContainerVariants({ container }), containerClassName)}\n >\n {navigation.length === 0 ? (\n // No items: render the message directly rather than an empty\n // NavigationMenu, which would still mount the portal, positioner and\n // popup surface for a menubar that can never open.\n emptyMessage != null && (\n <p\n data-slot='main-nav-empty'\n className='flex min-h-14 items-center py-2 text-base leading-6 text-(--main-nav-ink)'\n >\n {emptyMessage}\n </p>\n )\n ) : (\n <>\n {/* render={<div/>}: Base UI's root is itself a <nav>; demoting it\n keeps this component to ONE navigation landmark. sideOffset 0\n seats the panel flush under the bar; collision handling is off\n because alignOffset/width already pin the panel inside the\n viewport. closeDelay 220 = the app's PANEL_CLOSE_DELAY_MS. */}\n <NavigationMenu\n render={<div />}\n className='w-full max-w-none justify-start'\n side='bottom'\n sideOffset={0}\n align='start'\n alignOffset={alignOffset}\n collisionPadding={0}\n collisionAvoidance={{ side: 'none', align: 'none' }}\n closeDelay={220}\n // Square corners (the full-width panel meets the bar edge-to-edge)\n // and no --available-width cap — see mainNavPanelVariants.\n popupClassName='max-w-none rounded-none'\n // The popup itself must follow the measured width too: Base UI\n // sizes it from --popup-width, measured once when a section\n // activates, so a panel opened before the first measurement lands\n // (or resized while open) would keep a stale popup width and clip\n // the full-width panel to a sliver. An inline width stays reactive.\n popupStyle={panelWidth === null ? undefined : { width: panelWidth }}\n >\n <NavigationMenuList className='w-full justify-start gap-0 border-b-0'>\n {navigation.map((item) => (\n <MainNavMenuItem\n key={`${item.title}-${item.href ?? 'section'}`}\n item={item}\n color={color ?? DEFAULT_MAIN_NAV_COLOR}\n currentHref={currentHref}\n panelWidth={panelWidth}\n />\n ))}\n </NavigationMenuList>\n </NavigationMenu>\n </>\n )}\n </div>\n </nav>\n )\n}\n\nexport { MainNav, mainNavColors, mainNavContainerVariants, mainNavPanelVariants, mainNavVariants }\nexport type { MainNavColor, MainNavItem, MainNavLinkItem, MainNavProps }\n"]}
|
|
1
|
+
{"version":3,"sources":["../../src/components/main-nav.tsx"],"names":[],"mappings":";;;;;;;;AAqCA,MAAM,aAAA,GAAgB;AAAA,EACpB,aAAA;AAAA,EACA,aAAA;AAAA,EACA,aAAA;AAAA,EACA,aAAA;AAAA,EACA,UAAA;AAAA,EACA,UAAA;AAAA,EACA,UAAA;AAAA,EACA,UAAA;AAAA,EACA,YAAA;AAAA,EACA,YAAA;AAAA,EACA,YAAA;AAAA,EACA,YAAA;AAAA,EACA;AACF;AAMA,MAAM,sBAAA,GAAuC,OAAA;AAE7C,MAAM,0BAAA,GAA6B,OAAA;AAEnC,MAAM,eAAA,GAAkB,GAAA;AAAA,EACtB;AAAA,IACE,QAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,IAUA;AAAA,GACF;AAAA,EACA;AAAA,IACE,QAAA,EAAU;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,MAeR,KAAA,EAAO;AAAA,QACL,aAAA,EACE,mFAAA;AAAA,QACF,aAAA,EACE,mFAAA;AAAA,QACF,aAAA,EACE,kJAAA;AAAA,QACF,aAAA,EACE,kJAAA;A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,EACH;AAAA;AAAA,WACF,EACF;AAAA;AAAA;AAEJ;AAAA,GACF;AAEJ","file":"main-nav.js","sourcesContent":["'use client'\n\nimport { cva, type VariantProps } from 'class-variance-authority'\nimport React from 'react'\n\nimport { IconEast } from '../icons/east.js'\nimport { resolveVariant } from '../lib/resolve-variant.js'\nimport { cn } from '../lib/utils.js'\n\nimport {\n NavigationMenu,\n NavigationMenuContent,\n NavigationMenuItem,\n NavigationMenuLink,\n NavigationMenuList,\n NavigationMenuTrigger,\n} from '../components/navigation-menu.js'\n\n/**\n * Surface colours the main navigation can be themed with — exactly the\n * Footer's thirteen-name vocabulary, so a service that themes its footer\n * `primary-800` writes the same word here. Each name is the LIGHT-mode\n * surface; dark mode deepens it onto the same family's dark steps (see the\n * `color` variants below), so `color` expresses tonal weight rather than a\n * literal colour.\n *\n * The bar's text/background pairs are identical to the Footer's, so its\n * contrast conclusions carry over verbatim: every light pair clears WCAG 2.2\n * AA (1.4.3, 4.5:1) for the bar's text and 11 of the 13 also clear AAA\n * (1.4.6, 7:1). The two AA-only pairs are `primary-600` (4.57:1) and\n * `accent-600` (5.18:1), both with white ink; prefer the `-800` steps when a\n * service is held to AAA. In dark mode all thirteen clear AAA (worst 13.6:1).\n *\n * The mega panels always render on the house popup surface (`bg-popover`),\n * matching the nswds-app source where every dropdown was white regardless of\n * bar colour — only the panel's accent ink follows the colour family.\n */\nconst mainNavColors = [\n 'primary-800',\n 'primary-600',\n 'primary-400',\n 'primary-200',\n 'grey-800',\n 'grey-600',\n 'grey-400',\n 'grey-200',\n 'accent-800',\n 'accent-600',\n 'accent-400',\n 'accent-200',\n 'white',\n] as const\n\ntype MainNavColor = (typeof mainNavColors)[number]\n\n// Shared by the bar's and the panel's cva defaultVariants and the\n// `resolveVariant` call in `MainNav`, so they can't drift apart.\nconst DEFAULT_MAIN_NAV_COLOR: MainNavColor = 'white'\n// Shared by cva's defaultVariants and the `resolveVariant` call in `MainNav`.\nconst DEFAULT_MAIN_NAV_CONTAINER = 'fluid'\n\nconst mainNavVariants = cva(\n [\n 'w-full',\n // Every derived colour on the bar resolves from a single --main-nav-ink\n // token, so a colour variant only has to declare the surface utilities and\n // that one value — this replaces the nswds-app source's hand-written\n // 13-variant × 8-slot style table. The border derivation is written\n // literally here (once) rather than per-variant: Tailwind scans source\n // text for class names, so a template-built arbitrary property would\n // never be emitted. Hover/active halos are not derived here — the\n // triggers ride navigation-menu.tsx's --nav-menu-halo chain, re-pointed\n // at this ink (see mainNavItemInk), so there is exactly one halo recipe.\n '[--main-nav-border:color-mix(in_oklch,var(--main-nav-ink)_15%,transparent)]',\n ],\n {\n variants: {\n // Ink values use the RAW masterbrand tokens (--primary-800, --grey-800,\n // --accent-800) rather than Tailwind's --color-* bridge aliases. Tailwind\n // v4 tree-shakes an unreferenced @theme key, and referencing one from\n // inside an arbitrary property is not a usage signal — the raw tokens are\n // plain :root declarations from @nswds/tokens and always resolve.\n // (--color-white is safe: `text-white` / `bg-white` below are real\n // utilities, so that key is always emitted.)\n //\n // Dark mode deepens every surface onto the same family's dark steps —\n // -800→-950, -600→-900, -400→-850, -200→-800, white→grey-900 — the\n // Footer's exact mapping, so the luminance ORDER within a family is\n // preserved and a stacked Footer + MainNav sharing one colour word stay\n // in step in both themes. Ink goes white on all thirteen; every dark\n // pair is WCAG 2.2 AAA (worst 13.6:1).\n color: {\n 'primary-800':\n 'bg-primary-800 text-white [--main-nav-ink:var(--color-white)] dark:bg-primary-950',\n 'primary-600':\n 'bg-primary-600 text-white [--main-nav-ink:var(--color-white)] dark:bg-primary-900',\n 'primary-400':\n 'bg-primary-400 text-primary-800 [--main-nav-ink:var(--primary-800)] dark:bg-primary-850 dark:text-white dark:[--main-nav-ink:var(--color-white)]',\n 'primary-200':\n 'bg-primary-200 text-primary-800 [--main-nav-ink:var(--primary-800)] dark:bg-primary-800 dark:text-white dark:[--main-nav-ink:var(--color-white)]',\n 'grey-800': 'bg-grey-800 text-white [--main-nav-ink:var(--color-white)] dark:bg-grey-950',\n 'grey-600': 'bg-grey-600 text-white [--main-nav-ink:var(--color-white)] dark:bg-grey-900',\n 'grey-400':\n 'bg-grey-400 text-grey-800 [--main-nav-ink:var(--grey-800)] dark:bg-grey-850 dark:text-white dark:[--main-nav-ink:var(--color-white)]',\n 'grey-200':\n 'bg-grey-200 text-grey-800 [--main-nav-ink:var(--grey-800)] dark:bg-grey-800 dark:text-white dark:[--main-nav-ink:var(--color-white)]',\n 'accent-800':\n 'bg-accent-800 text-white [--main-nav-ink:var(--color-white)] dark:bg-accent-950',\n 'accent-600':\n 'bg-accent-600 text-white [--main-nav-ink:var(--color-white)] dark:bg-accent-900',\n 'accent-400':\n 'bg-accent-400 text-accent-800 [--main-nav-ink:var(--accent-800)] dark:bg-accent-850 dark:text-white dark:[--main-nav-ink:var(--color-white)]',\n 'accent-200':\n 'bg-accent-200 text-accent-800 [--main-nav-ink:var(--accent-800)] dark:bg-accent-800 dark:text-white dark:[--main-nav-ink:var(--color-white)]',\n white:\n 'bg-white text-grey-800 [--main-nav-ink:var(--grey-800)] dark:bg-grey-900 dark:text-white dark:[--main-nav-ink:var(--color-white)]',\n },\n // Rules along the bar's edges, drawn from the ink-derived border token so\n // they follow every colour variant and both themes. Replaces the app\n // source's deprecated showTopBorder/showBottomBorder booleans, which are\n // deliberately not ported.\n border: {\n none: '',\n top: 'border-t border-(--main-nav-border)',\n bottom: 'border-b border-(--main-nav-border)',\n both: 'border-y border-(--main-nav-border)',\n },\n },\n defaultVariants: {\n color: DEFAULT_MAIN_NAV_COLOR,\n border: 'none',\n },\n },\n)\n\nconst mainNavContainerVariants = cva(\n [\n 'mx-auto flex w-full items-center',\n // Lateral padding funnels through --main-nav-padding-x so an app can\n // retune it once (via the `style` prop or a utility class) without a new\n // variant. Same mechanism, and the same 16px → 24px → 48px rhythm, as\n // Masthead, Header and Footer.\n 'px-(--main-nav-padding-x)',\n '[--main-nav-padding-x:--spacing(4)] sm:[--main-nav-padding-x:--spacing(6)] lg:[--main-nav-padding-x:--spacing(12)]',\n ],\n {\n variants: {\n container: {\n // Full-bleed (nswds-app fullBleed parity). --main-nav-max-width is\n // still read so a shell app can constrain the inner wrapper without\n // switching variants.\n fluid: 'max-w-[var(--main-nav-max-width,none)]',\n // Centred content column, legacy nsw-container parity (1200px).\n contained: 'max-w-[var(--main-nav-max-width,75rem)]',\n },\n },\n defaultVariants: {\n container: DEFAULT_MAIN_NAV_CONTAINER,\n },\n },\n)\n\n/**\n * Mega-panel accent ink, keyed by the same thirteen colour names as the bar.\n * The panel itself is always the house popup surface (`bg-popover`, white in\n * light mode) — parity with the app source, whose dropdown was white for\n * every variant — so the family only tints the featured lead link, hover ink\n * and cell borders. Declared on the Content element (not inherited from the\n * bar) because Base UI portals the panel to `document.body`: a custom\n * property set on the `<nav>` can never reach it.\n *\n * Light inks are the family's -800 step on white — grey-800 on white is\n * 15.1:1 and white on primary-800 is 14.4:1 (both AAA; contrast is symmetric,\n * ratios from header.tsx); accent-800 on white clears AAA per the Footer's\n * verified pairs. Dark inks step to the family's -200 — the same dark-mode\n * interactive ink link.tsx and navigation-menu.tsx already use on this\n * popover surface. The featured lead is text-xl bold, so even the softest\n * pair is far above the large-text AA floor (1.4.3, 3:1).\n */\nconst mainNavPanelVariants = cva(\n [\n 'p-0 whitespace-normal',\n // The sibling Content (and the shared popup, via popupClassName below)\n // cap themselves at --available-width, which Base UI measures from the\n // active trigger — for a mid-bar trigger that is less than the nav's\n // width, which would shrink right-hand panels. The panel's width is\n // container-measured and can never exceed the viewport, so the cap is\n // safely lifted.\n 'max-w-none',\n '[--main-nav-panel-border:color-mix(in_oklch,var(--main-nav-panel-ink)_15%,transparent)]',\n ],\n {\n variants: {\n color: {\n 'primary-800':\n '[--main-nav-panel-ink:var(--primary-800)] dark:[--main-nav-panel-ink:var(--primary-200)]',\n 'primary-600':\n '[--main-nav-panel-ink:var(--primary-800)] dark:[--main-nav-panel-ink:var(--primary-200)]',\n 'primary-400':\n '[--main-nav-panel-ink:var(--primary-800)] dark:[--main-nav-panel-ink:var(--primary-200)]',\n 'primary-200':\n '[--main-nav-panel-ink:var(--primary-800)] dark:[--main-nav-panel-ink:var(--primary-200)]',\n 'grey-800':\n '[--main-nav-panel-ink:var(--grey-800)] dark:[--main-nav-panel-ink:var(--grey-200)]',\n 'grey-600':\n '[--main-nav-panel-ink:var(--grey-800)] dark:[--main-nav-panel-ink:var(--grey-200)]',\n 'grey-400':\n '[--main-nav-panel-ink:var(--grey-800)] dark:[--main-nav-panel-ink:var(--grey-200)]',\n 'grey-200':\n '[--main-nav-panel-ink:var(--grey-800)] dark:[--main-nav-panel-ink:var(--grey-200)]',\n 'accent-800':\n '[--main-nav-panel-ink:var(--accent-800)] dark:[--main-nav-panel-ink:var(--accent-200)]',\n 'accent-600':\n '[--main-nav-panel-ink:var(--accent-800)] dark:[--main-nav-panel-ink:var(--accent-200)]',\n 'accent-400':\n '[--main-nav-panel-ink:var(--accent-800)] dark:[--main-nav-panel-ink:var(--accent-200)]',\n 'accent-200':\n '[--main-nav-panel-ink:var(--accent-800)] dark:[--main-nav-panel-ink:var(--accent-200)]',\n white: '[--main-nav-panel-ink:var(--grey-800)] dark:[--main-nav-panel-ink:var(--grey-200)]',\n },\n },\n defaultVariants: {\n color: DEFAULT_MAIN_NAV_COLOR,\n },\n },\n)\n\n// Re-points the sibling navigation-menu's ink at the bar's surface ink. The\n// trigger/link halos and focus outlines in navigation-menu.tsx all derive\n// from --nav-menu-ink via color-mix ON THE SAME ELEMENT, so overriding the\n// one token retargets the whole chain: hover/active halos and the\n// focus-visible outline become surface-relative, guaranteeing the indicator\n// contrasts on all thirteen surfaces (WCAG 2.2, 2.4.13 Focus Appearance).\n// Both light and dark are overridden because the sibling pins its own\n// dark-mode ink (primary-200); --main-nav-ink is already theme-aware.\nconst mainNavItemInk =\n '[--nav-menu-ink:var(--main-nav-ink)] dark:[--nav-menu-ink:var(--main-nav-ink)]'\n\n// Same re-point for links INSIDE the portalled panel, where the bar's ink\n// cannot reach — these derive from the panel accent ink instead.\nconst mainNavPanelInk =\n '[--nav-menu-ink:var(--main-nav-panel-ink)] dark:[--nav-menu-ink:var(--main-nav-panel-ink)]'\n\n// Restyles the sibling trigger to the app source's bar metrics: 56px min\n// height, square corners, bold base text, wider gutters from lg up. The open\n// panel is marked with the app's 4px inset underline (data-popup-open comes\n// from Base UI); data-current draws the same underline persistently when\n// `currentHref` falls inside this section, so the underline means \"you are\n// here\" at rest and \"this panel is open\" during use.\nconst mainNavTriggerClassName = [\n mainNavItemInk,\n 'mb-0 h-auto min-h-14 w-auto justify-start rounded-none max-lg:px-4 py-2 text-base leading-6 font-bold text-(--main-nav-ink)',\n 'lg:px-8',\n '[&_svg]:size-6',\n // Inset focus ring: the sibling list is a horizontal scroll container, and\n // a scroll container clips everything drawn outside a child's border box —\n // the house outward `outline-offset-2` would simply vanish on the first and\n // last triggers. Same reasoning (and same fix) as push-menu.tsx's rows.\n 'focus-visible:-outline-offset-2',\n 'data-popup-open:shadow-[inset_0_-4px_0_0_currentColor]',\n 'data-current:shadow-[inset_0_-4px_0_0_currentColor]',\n].join(' ')\n\n// A panel-less item, restyled from the sibling link to sit visually beside\n// the triggers (cn's conflict merge lets these win over the link's stacked\n// defaults). `active` → data-active draws the current-page underline; Base UI\n// pairs it with aria-current='page' on the same element (WCAG 2.4.8).\nconst mainNavTopLinkClassName = [\n mainNavItemInk,\n 'inline-flex min-h-14 flex-row items-center justify-start gap-1 rounded-none max-lg:px-4 py-2 text-base leading-6 font-bold whitespace-nowrap text-(--main-nav-ink)',\n 'lg:px-8',\n // Inset for the same reason as the trigger above — these sit in the\n // scrolling list, not in a portalled panel.\n 'focus-visible:-outline-offset-2',\n 'data-active:shadow-[inset_0_-4px_0_0_currentColor]',\n].join(' ')\n\n// The featured lead link at the top of a mega panel: the section title,\n// oversized, with an east arrow that nudges forward on hover (the app\n// source's exact affordance, on the house easing curve; the nudge is a\n// transition, so motion-reduce users get an instant state change — WCAG\n// 2.3.3). `group` scopes the icon's group-hover to this anchor — the panel is\n// portalled, so no other `group` ancestor can capture it.\nconst mainNavFeaturedLinkClassName = [\n mainNavPanelInk,\n 'group relative flex-row items-center rounded-none px-8 py-8 text-xl font-bold whitespace-normal text-(--main-nav-panel-ink)',\n].join(' ')\n\n// The lead when the section has no `href`: the same visual weight as the\n// featured link, but a plain heading row — no anchor (a dead link announced\n// as a link fails the reader who activates it), no hover halo, and no east\n// arrow (an arrow on a non-link promises navigation that never happens). No\n// mainNavPanelInk re-point either: that chain only feeds interactive halos.\nconst mainNavFeaturedHeadingClassName =\n 'flex flex-row items-center px-8 py-8 text-xl font-bold whitespace-normal text-(--main-nav-panel-ink)'\n\n// One bordered grid cell per section link. The anchor itself is the cell —\n// the app source wrapped a div around a stretched-link span, but making the\n// whole cell the anchor gives the same hit area with one element and no\n// aria-hidden overlay. Cells draw a top hairline from the panel ink; the last\n// grid row closes with a bottom hairline via the app's :nth-last-child(-n+3)\n// selector (tuned to the widest, 3-column layout — at narrower widths the\n// final one or two cells simply carry the closing rule, matching the app).\nconst mainNavSectionLinkClassName = [\n mainNavPanelInk,\n 'relative mx-2 justify-center rounded-none border-t border-(--main-nav-panel-border) p-4 text-base font-semibold whitespace-normal text-popover-foreground',\n 'hover:text-(--main-nav-panel-ink)',\n '[&:nth-last-child(-n+3)]:border-b',\n].join(' ')\n\n/** One link inside a mega panel. */\ntype MainNavLinkItem = {\n /** Visible link text, e.g. \"Find support near you\". */\n title: string\n href: string\n}\n\n/**\n * One top-level navigation item. With `links` it renders as a trigger opening\n * a mega panel (with `href` becoming the panel's featured lead link; without\n * an `href` the lead is a plain heading row — dev builds warn); without\n * `links` it renders as a plain link styled like the triggers. Recursion is\n * deliberately one level deep — mega panels list flat links, per the app\n * source's NavigationSection shape.\n */\ntype MainNavItem = {\n title: string\n href?: string\n links?: MainNavLinkItem[]\n}\n\n/**\n * Dev-only guard, mirroring the icon-only Button check in button.tsx: an item\n * with neither `href` nor `links` renders a dead `\"#\"` link — almost always a\n * data mistake, and a trap for keyboard and screen-reader users who activate\n * it and go nowhere. A section (`links`, no `href`) is legal but demoted —\n * its panel lead renders as a plain heading instead of the featured link —\n * so it gets its own nudge. No-op in production.\n */\nfunction warnIfItemUnlinked(item: MainNavItem) {\n if (process.env.NODE_ENV === 'production') {\n return\n }\n if (!item.href && !item.links?.length) {\n console.warn(\n `[nswds/ui] MainNav item \"${item.title}\" has no href and no links — it will render as a dead \"#\" link.`,\n )\n }\n if (!item.href && item.links?.length) {\n console.warn(\n `[nswds/ui] MainNav section \"${item.title}\" has links but no href — its panel lead renders as a plain heading; pass href to make it a link.`,\n )\n }\n}\n\ntype MainNavMenuItemProps = {\n item: MainNavItem\n color: MainNavColor\n currentHref?: string\n /** Measured container width, forwarded as the panel's inline width. */\n panelWidth: number | null\n}\n\n/**\n * One bar entry: a plain link for items without `links`, a trigger + mega\n * panel for items with them. Internal — the data-driven `MainNav` API is the\n * public surface; compose the navigation-menu primitives directly for layouts\n * this doesn't cover.\n */\nfunction MainNavMenuItem({ item, color, currentHref, panelWidth }: MainNavMenuItemProps) {\n warnIfItemUnlinked(item)\n\n const links = item.links\n const isExactCurrent = item.href !== undefined && item.href === currentHref\n const isSectionCurrent =\n isExactCurrent ||\n (currentHref !== undefined && (links?.some((link) => link.href === currentHref) ?? false))\n\n if (!links?.length) {\n return (\n <NavigationMenuItem className='shrink-0'>\n <NavigationMenuLink\n data-slot='main-nav-top-link'\n href={item.href ?? '#'}\n active={isExactCurrent}\n className={mainNavTopLinkClassName}\n >\n {item.title}\n </NavigationMenuLink>\n </NavigationMenuItem>\n )\n }\n\n return (\n <NavigationMenuItem className='shrink-0'>\n {/* The trigger is a button (it discloses, it doesn't navigate), so it\n can't carry aria-current — data-current draws the visual \"you are\n here\" underline while the aria-current announcement lives on the\n exact matching link inside the panel. */}\n <NavigationMenuTrigger\n data-current={isSectionCurrent || undefined}\n className={mainNavTriggerClassName}\n >\n {item.title}\n </NavigationMenuTrigger>\n {/* Inline width (not a CSS var): the panel is portalled to\n document.body, so a custom property set on the nav can't reach it.\n Before the first measurement resolves the panel falls back to the\n sibling's natural w-max sizing. */}\n <NavigationMenuContent\n data-slot='main-nav-panel'\n className={mainNavPanelVariants({ color })}\n style={panelWidth === null ? undefined : { width: panelWidth }}\n >\n <div className='grid w-full'>\n {/* No section href → no featured LINK: an `href=\"#\"` fallback here\n would be a dead link announced as a link. The heading row keeps\n the lead's visual weight without the anchor, halo or arrow — see\n mainNavFeaturedHeadingClassName. */}\n {item.href === undefined ? (\n <div data-slot='main-nav-featured-heading' className={mainNavFeaturedHeadingClassName}>\n {item.title}\n </div>\n ) : (\n <NavigationMenuLink\n data-slot='main-nav-featured-link'\n href={item.href}\n active={isExactCurrent}\n className={mainNavFeaturedLinkClassName}\n >\n {item.title}\n <IconEast\n aria-hidden='true'\n className='ml-4 size-6 shrink-0 text-current duration-300 ease-[cubic-bezier(0.22,1,0.36,1)] group-hover:translate-x-1 motion-safe:transition-transform'\n />\n </NavigationMenuLink>\n )}\n <div\n data-slot='main-nav-panel-links'\n className='grid overflow-hidden px-4 pb-12 max-sm:grid-cols-1 sm:max-lg:grid-cols-2 lg:grid-cols-3'\n >\n {links.map((link, index) => (\n <NavigationMenuLink\n key={`${link.title}-${link.href}-${index}`}\n data-slot='main-nav-section-link'\n href={link.href}\n active={link.href === currentHref}\n className={mainNavSectionLinkClassName}\n >\n {link.title}\n </NavigationMenuLink>\n ))}\n </div>\n </div>\n </NavigationMenuContent>\n </NavigationMenuItem>\n )\n}\n\n// The native `color` attribute is omitted so the prop type admits the `null`\n// cva's `VariantProps` allows and the component resolves.\ntype MainNavProps = Omit<React.ComponentPropsWithoutRef<'nav'>, 'children' | 'color'> &\n VariantProps<typeof mainNavVariants> &\n VariantProps<typeof mainNavContainerVariants> & {\n /** Top-level items; items with `links` open mega panels. */\n navigation: MainNavItem[]\n /**\n * The current page's href. The exact matching link gets\n * `aria-current=\"page\"`, and the top-level item it belongs to (a plain\n * link, or the trigger whose panel contains it) gets the current-item\n * underline. The app source read this from next/navigation's\n * `usePathname` — a framework API this package must not import; compare\n * in the consumer and pass the result down.\n */\n currentHref?: string\n /**\n * Stick to the top of the viewport as the page scrolls. Defaults to\n * `false`. When the nav renders below a sticky `Header`, set\n * `--main-nav-top` to the header's height so the two stack instead of\n * overlapping — this custom property replaces the app source's\n * `useSelectorHeight` DOM-measuring hook (the app measured `#nsw-header`\n * on every resize; a consumer that needs a live value can still measure\n * its own header and write the property, see the Sticky story).\n */\n sticky?: boolean\n /** Drop shadow under the bar. Defaults to `true`. */\n shadow?: boolean\n /** Classes applied to the inner width-constraining wrapper. */\n containerClassName?: string\n /**\n * Shown in the bar when `navigation` is empty. Defaults to\n * \"No navigation items available.\"; pass `null` to render an empty bar.\n *\n * An empty `navigation` array is a legitimate runtime state, not a data\n * mistake — a CMS with nothing published, a menu filtered down to nothing\n * by the reader's permissions, or a failed nav fetch all produce it. The\n * bar keeps its themed surface either way, so with no message it reads as\n * an unexplained coloured strip.\n */\n emptyMessage?: React.ReactNode\n ref?: React.Ref<HTMLElement>\n }\n\n/**\n * Full-width NSW site navigation bar with mega-menu panels — the data-driven\n * consolidation of the nswds-app `NavigationMenuMainNavigation` /\n * `MainNavigation` components, rebuilt on this package's `NavigationMenu`\n * (Base UI underneath).\n *\n * - `navigation` drives everything: items with `links` render a trigger whose\n * mega panel shows a featured lead link (the section `href`; with no `href`\n * the lead demotes to a plain heading row — dev builds warn) above a\n * responsive 1/2/3-column grid of bordered section links; items without\n * `links` render plain links styled like the triggers. All anchors render\n * through `Link`, so a framework link injected via `LinkProvider`\n * (e.g. next/link) is used automatically.\n * - `color` themes the bar with the Footer's thirteen-name vocabulary and its\n * exact dark-mode deepening; every derived colour (halos, borders, focus\n * outlines) resolves from a single `--main-nav-ink` per variant. Contrast\n * conclusions are the Footer's, verbatim (see `mainNavColors`).\n * - Panels span the nav container's full width: a ResizeObserver on the inner\n * container feeds each panel's inline width, and an `alignOffset` function\n * shifts Base UI's trigger-anchored positioner back to the container's left\n * edge (measured at position time from the open trigger, so it is exact for\n * every trigger — this replaces the app source's panelMetrics state).\n * The offset is physical and correct in BOTH directions: Base UI passes\n * `align` to floating-ui as a physical placement and only mirrors a logical\n * `side`, so nothing about this anchoring flips under RTL. See the comment\n * on `alignOffset`, and the RightToLeft story that pins it.\n * - `container`, `border`, `shadow`, `sticky` mirror the house chrome\n * components; the app's deprecated `showTopBorder`/`showBottomBorder` and\n * `responsive` props are not ported (use `border` and\n * `className=\"hidden lg:block\"`).\n *\n * Accessibility: the outer `<nav>` is the landmark (default label \"Main\n * navigation\"; Base UI's own root is demoted to a `<div>` via `render` so the\n * page doesn't gain a nested nav landmark). Everything interactive is\n * inherited from Base UI via the sibling: triggers are real buttons with\n * `aria-expanded`/`aria-controls`, ArrowDown/Enter opens, arrow keys rove,\n * Escape and focus-out close, and the current page announces\n * `aria-current=\"page\"` (WCAG 2.4.8). Focus indicators are 2px ink-derived\n * outlines that contrast on all thirteen surfaces and on the panel surface\n * (2.4.7, 2.4.13). The 220ms `closeDelay` reproduces the app's hover-out\n * grace timer through Base UI instead of a hand-rolled setTimeout.\n *\n * The default `id=\"nsw-main-navigation\"` is kept for compatibility with\n * existing shells that target it (override via the `id` prop).\n */\nfunction MainNav({\n className,\n containerClassName,\n color,\n container,\n border,\n navigation,\n currentHref,\n sticky = false,\n shadow = true,\n emptyMessage = 'No navigation items available.',\n 'aria-label': ariaLabel = 'Main navigation',\n ref,\n ...props\n}: MainNavProps) {\n const containerRef = React.useRef<HTMLDivElement>(null)\n const [panelWidth, setPanelWidth] = React.useState<number | null>(null)\n\n React.useEffect(() => {\n const element = containerRef.current\n if (!element) {\n return\n }\n const measure = () => {\n setPanelWidth(element.getBoundingClientRect().width)\n }\n // Read once on mount: panels can open before the first resize.\n measure()\n const observer = new ResizeObserver(measure)\n observer.observe(element)\n return () => observer.disconnect()\n }, [])\n\n // Shifts the popup from Base UI's anchor (the open trigger) to the\n // container's left edge. Called by the positioner at position time, when\n // the open trigger is findable via data-popup-open — so the offset is exact\n // per trigger with no per-trigger state.\n //\n // PHYSICAL, and correct in both directions — this is deliberate, and the\n // opposite of what the comment here used to claim (\"Assumes LTR; RTL would\n // need the mirrored calculation\"). Base UI's useAnchorPositioning consults\n // the direction ONLY to map a logical `side` (`inline-start`/`inline-end`);\n // `align` is passed through to floating-ui as a physical placement, so\n // `side='bottom' align='start'` anchors the popup's LEFT edge to the\n // trigger's left in RTL exactly as in LTR, and `alignOffset` is applied on\n // floating-ui's physical cross axis. Nothing mirrors, so neither should this.\n //\n // Verified, not assumed: adding the mirror (trigger.right - container.right)\n // and rendering the bar under `dir='rtl'` WITH a DirectionProvider put the\n // panel at left=914 against a container at left=0 — the mirror moved an\n // already-left-anchored panel. The RightToLeft story pins the correct\n // geometry so a future Base UI release that starts mirroring `align` fails\n // here instead of in a consumer's RTL site.\n //\n // The ref caches the last successful offset for the windows when NO trigger\n // carries data-popup-open — chiefly the ~300ms close fade, when a recompute\n // (scroll/resize mid-fade) returning 0 would snap the still-visible\n // full-width panel back to the trigger's edge. Repeating the last real\n // offset holds the fading panel where it was.\n const lastAlignOffsetRef = React.useRef(0)\n const alignOffset = React.useCallback(() => {\n const element = containerRef.current\n if (!element) {\n return lastAlignOffsetRef.current\n }\n const trigger = element.querySelector('[data-popup-open]')\n if (!trigger) {\n return lastAlignOffsetRef.current\n }\n lastAlignOffsetRef.current =\n element.getBoundingClientRect().left - trigger.getBoundingClientRect().left\n return lastAlignOffsetRef.current\n }, [])\n\n // Resolved once (see `resolveVariant`), so cva, `data-color` and the panel\n // colourway agree for `null` and `''` as well as the default spelling, and\n // `container={null}` keeps the inner wrapper's max-width class, which reads\n // `--main-nav-max-width`, instead of dropping it.\n const colorway = resolveVariant(color, DEFAULT_MAIN_NAV_COLOR)\n const containerway = resolveVariant(container, DEFAULT_MAIN_NAV_CONTAINER)\n\n return (\n <nav\n id='nsw-main-navigation'\n data-slot='main-nav'\n aria-label={ariaLabel}\n {...props}\n // After the spread, so a consumer's own `data-*` cannot desync the\n // attribute from the classes both derive from the resolved value.\n data-color={colorway}\n className={cn(\n mainNavVariants({ color: colorway, border }),\n // z-40 matches Header (both sit below the z-50 SkipLinks). An app\n // stacking this under a sticky Header sets --main-nav-top to the\n // header's height.\n sticky && 'sticky top-[var(--main-nav-top,0px)] z-40',\n // House scrolled-header shadow; in dark mode borders carry separation.\n shadow && 'shadow-md shadow-black/5 dark:shadow-none',\n className,\n )}\n ref={ref}\n >\n <div\n ref={containerRef}\n data-slot='main-nav-container'\n className={cn(mainNavContainerVariants({ container: containerway }), containerClassName)}\n >\n {navigation.length === 0 ? (\n // No items: render the message directly rather than an empty\n // NavigationMenu, which would still mount the portal, positioner and\n // popup surface for a menubar that can never open.\n emptyMessage != null && (\n <p\n data-slot='main-nav-empty'\n className='flex min-h-14 items-center py-2 text-base leading-6 text-(--main-nav-ink)'\n >\n {emptyMessage}\n </p>\n )\n ) : (\n <>\n {/* render={<div/>}: Base UI's root is itself a <nav>; demoting it\n keeps this component to ONE navigation landmark. sideOffset 0\n seats the panel flush under the bar; collision handling is off\n because alignOffset/width already pin the panel inside the\n viewport. closeDelay 220 = the app's PANEL_CLOSE_DELAY_MS. */}\n <NavigationMenu\n render={<div />}\n className='w-full max-w-none justify-start'\n side='bottom'\n sideOffset={0}\n align='start'\n alignOffset={alignOffset}\n collisionPadding={0}\n collisionAvoidance={{ side: 'none', align: 'none' }}\n closeDelay={220}\n // Square corners (the full-width panel meets the bar edge-to-edge)\n // and no --available-width cap — see mainNavPanelVariants.\n popupClassName='max-w-none rounded-none'\n // The popup itself must follow the measured width too: Base UI\n // sizes it from --popup-width, measured once when a section\n // activates, so a panel opened before the first measurement lands\n // (or resized while open) would keep a stale popup width and clip\n // the full-width panel to a sliver. An inline width stays reactive.\n popupStyle={panelWidth === null ? undefined : { width: panelWidth }}\n >\n <NavigationMenuList className='w-full justify-start gap-0 border-b-0'>\n {navigation.map((item) => (\n <MainNavMenuItem\n key={`${item.title}-${item.href ?? 'section'}`}\n item={item}\n color={colorway}\n currentHref={currentHref}\n panelWidth={panelWidth}\n />\n ))}\n </NavigationMenuList>\n </NavigationMenu>\n </>\n )}\n </div>\n </nav>\n )\n}\n\nexport { MainNav, mainNavColors, mainNavContainerVariants, mainNavPanelVariants, mainNavVariants }\nexport type { MainNavColor, MainNavItem, MainNavLinkItem, MainNavProps }\n"]}
|
|
@@ -15,7 +15,7 @@ declare const mastheadVariants: (props?: ({
|
|
|
15
15
|
declare const mastheadContainerVariants: (props?: ({
|
|
16
16
|
container?: "fluid" | "contained" | null | undefined;
|
|
17
17
|
} & class_variance_authority_types.ClassProp) | undefined) => string;
|
|
18
|
-
type MastheadProps = React__default.ComponentPropsWithoutRef<'div'> & VariantProps<typeof mastheadVariants> & VariantProps<typeof mastheadContainerVariants> & {
|
|
18
|
+
type MastheadProps = Omit<React__default.ComponentPropsWithoutRef<'div'>, 'color'> & VariantProps<typeof mastheadVariants> & VariantProps<typeof mastheadContainerVariants> & {
|
|
19
19
|
/** Classes applied to the inner width-constraining wrapper. */
|
|
20
20
|
containerClassName?: string;
|
|
21
21
|
ref?: React__default.Ref<HTMLDivElement>;
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { jsx } from 'react/jsx-runtime';
|
|
2
2
|
import { cva } from 'class-variance-authority';
|
|
3
|
+
import { resolveVariant } from '../lib/resolve-variant.js';
|
|
3
4
|
import { cn } from '../lib/utils.js';
|
|
4
5
|
|
|
5
6
|
const mastheadColors = {
|
|
@@ -12,6 +13,7 @@ const mastheadColors = {
|
|
|
12
13
|
grey: "bg-grey-800 text-white dark:bg-grey-950"
|
|
13
14
|
};
|
|
14
15
|
const DEFAULT_MASTHEAD_COLOR = "dark";
|
|
16
|
+
const DEFAULT_MASTHEAD_CONTAINER = "fluid";
|
|
15
17
|
const mastheadVariants = cva("w-full text-xs", {
|
|
16
18
|
variants: {
|
|
17
19
|
color: mastheadColors
|
|
@@ -41,7 +43,7 @@ const mastheadContainerVariants = cva(
|
|
|
41
43
|
}
|
|
42
44
|
},
|
|
43
45
|
defaultVariants: {
|
|
44
|
-
container:
|
|
46
|
+
container: DEFAULT_MASTHEAD_CONTAINER
|
|
45
47
|
}
|
|
46
48
|
}
|
|
47
49
|
);
|
|
@@ -54,20 +56,22 @@ function Masthead({
|
|
|
54
56
|
ref,
|
|
55
57
|
...props
|
|
56
58
|
}) {
|
|
59
|
+
const colorway = resolveVariant(color, DEFAULT_MASTHEAD_COLOR);
|
|
60
|
+
const containerway = resolveVariant(container, DEFAULT_MASTHEAD_CONTAINER);
|
|
57
61
|
return /* @__PURE__ */ jsx(
|
|
58
62
|
"div",
|
|
59
63
|
{
|
|
60
64
|
id: "nsw-masthead",
|
|
61
65
|
"data-slot": "masthead",
|
|
62
|
-
"data-color": color ?? DEFAULT_MASTHEAD_COLOR,
|
|
63
66
|
...props,
|
|
64
|
-
|
|
67
|
+
"data-color": colorway,
|
|
68
|
+
className: cn(mastheadVariants({ color: colorway }), className),
|
|
65
69
|
ref,
|
|
66
70
|
children: /* @__PURE__ */ jsx(
|
|
67
71
|
"div",
|
|
68
72
|
{
|
|
69
73
|
"data-slot": "masthead-container",
|
|
70
|
-
className: cn(mastheadContainerVariants({ container }), containerClassName),
|
|
74
|
+
className: cn(mastheadContainerVariants({ container: containerway }), containerClassName),
|
|
71
75
|
children: children ?? "A NSW Government website"
|
|
72
76
|
}
|
|
73
77
|
)
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/components/masthead.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"sources":["../../src/components/masthead.tsx"],"names":[],"mappings":";;;;;AAsBA,MAAM,cAAA,GAAiB;AAAA;AAAA,EAErB,IAAA,EAAM,+CAAA;AAAA;AAAA;AAAA,EAGN,KAAA,EAAO,4DAAA;AAAA,EACP,KAAA,EAAO,yDAAA;AAAA,EACP,IAAA,EAAM;AACR,CAAA;AAMA,MAAM,sBAAA,GAAwC,MAAA;AAE9C,MAAM,0BAAA,GAA6B,OAAA;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AAA,EAAc,GAAG,kBAAkB,CAAA;AAAA,UAEvF,QAAA,EAAA,QAAA,IAAY;AAAA;AAAA;AACf;AAAA,GACF;AAEJ","file":"masthead.js","sourcesContent":["import { cva, type VariantProps } from 'class-variance-authority'\nimport React from 'react'\n\nimport { resolveVariant } from '../lib/resolve-variant.js'\nimport { cn } from '../lib/utils.js'\n\n// Colour pairs are curated for WCAG 2.2 AAA (1.4.6 Contrast Enhanced): every\n// text/background combination below resolves to at least 7:1, in BOTH themes.\n// This is why the Masthead does not accept the full Button colour palette —\n// accent/danger/warning backgrounds with white text sit under 7:1 and would\n// silently break the AAA guarantee. Add new colours only with a verified pair.\n//\n// Light mode: 14.4 (dark), 17.4 (light), 19.0 (white), 15.1 (grey).\n// Dark mode: 20.0 (dark), 17.2 (light), 19.0 (white), 20.2 (grey).\n//\n// Every variant deepens in dark mode, on the same ramp steps `Header` uses —\n// -100→-850, white→-900, -800→-950 — because the two are designed to be themed\n// together and sit flush against each other. Only `dark` used to flip: a\n// `white` masthead stayed pure white above a `grey-900` header, an 18.9:1 band\n// across the top of a dark page, and `light` did the same at 15.8:1. The\n// asymmetry was the tell that this was an omission rather than a policy — a\n// deliberately theme-invariant set would not have flipped one of its four.\nconst mastheadColors = {\n // Legacy .nsw-masthead (brand dark).\n dark: 'bg-primary-800 text-white dark:bg-primary-950',\n // Legacy .nsw-masthead--light (off-white). grey-100 is the same value as\n // the legacy --nsw-off-white (#f2f2f2).\n light: 'bg-grey-100 text-grey-900 dark:bg-grey-850 dark:text-white',\n white: 'bg-white text-grey-900 dark:bg-grey-900 dark:text-white',\n grey: 'bg-grey-800 text-white dark:bg-grey-950',\n}\n\ntype MastheadColor = keyof typeof mastheadColors\n\n// Shared by cva's defaultVariants and the data-color attribute, so the two\n// can't drift apart — the same arrangement as Header, Footer and MainNav.\nconst DEFAULT_MASTHEAD_COLOR: MastheadColor = 'dark'\n// Shared by cva's defaultVariants and the `resolveVariant` call in `Masthead`.\nconst DEFAULT_MASTHEAD_CONTAINER = 'fluid'\n\nconst mastheadVariants = cva('w-full text-xs', {\n variants: {\n color: mastheadColors,\n },\n defaultVariants: {\n color: DEFAULT_MASTHEAD_COLOR,\n },\n})\n\nconst mastheadContainerVariants = cva(\n [\n 'mx-auto flex w-full items-center justify-between gap-x-4 py-2',\n // Lateral padding funnels through --masthead-padding-x so an app can\n // retune it once (via the `style` prop or a utility class) without a new\n // variant. Defaults reproduce the nswds-app rhythm: 16px → 24px → 48px.\n 'px-(--masthead-padding-x)',\n '[--masthead-padding-x:--spacing(4)] sm:[--masthead-padding-x:--spacing(6)] lg:[--masthead-padding-x:--spacing(12)]',\n ],\n {\n variants: {\n container: {\n // Full-bleed (nswds-app style). --masthead-max-width is still read so\n // a shell app can constrain the inner wrapper without switching\n // variants (the archive/practice `#nsw-masthead > div` override).\n fluid: 'max-w-[var(--masthead-max-width,none)]',\n // Centred content column, legacy nsw-container parity (1200px).\n contained: 'max-w-[var(--masthead-max-width,75rem)]',\n },\n },\n defaultVariants: {\n container: DEFAULT_MASTHEAD_CONTAINER,\n },\n },\n)\n\n// The native `color` attribute is omitted so the prop type admits the `null`\n// cva's `VariantProps` allows and the component resolves.\ntype MastheadProps = Omit<React.ComponentPropsWithoutRef<'div'>, 'color'> &\n VariantProps<typeof mastheadVariants> &\n VariantProps<typeof mastheadContainerVariants> & {\n /** Classes applied to the inner width-constraining wrapper. */\n containerClassName?: string\n ref?: React.Ref<HTMLDivElement>\n }\n\n/**\n * The \"A NSW Government website\" strip shown above the site header on every\n * NSW Government page. Successor to the legacy `.nsw-masthead`.\n *\n * - `color` selects a WCAG 2.2 AAA text/background pair (`dark` matches the\n * legacy default, `light` matches the legacy `--light` theme).\n * - `container` selects the inner wrapper layout: `fluid` (full-bleed,\n * nswds-app parity) or `contained` (centred 1200px column, legacy\n * `nsw-container` parity). Fine-tune either with the `--masthead-max-width`\n * and `--masthead-padding-x` custom properties.\n * - Children replace the default message; pass a `SkipLinks` sibling before\n * the Masthead for bypass-blocks support.\n *\n * The default `id=\"nsw-masthead\"` is kept for compatibility with existing\n * shells that target it (override via the `id` prop).\n */\nfunction Masthead({\n className,\n color,\n container,\n containerClassName,\n children,\n ref,\n ...props\n}: MastheadProps) {\n // Resolved once (see `resolveVariant`), so cva and `data-color` agree for\n // `null` and `''` as well as the default spelling, and\n // `container={null}` keeps the inner wrapper's max-width class, which reads\n // `--masthead-max-width`, instead of dropping it.\n const colorway = resolveVariant(color, DEFAULT_MASTHEAD_COLOR)\n const containerway = resolveVariant(container, DEFAULT_MASTHEAD_CONTAINER)\n return (\n <div\n id='nsw-masthead'\n data-slot='masthead'\n {...props}\n // Named surface, exposed for styling hooks and test diagnostics — the\n // convention Header, Footer and MainNav already follow. After the\n // spread, so a consumer's own `data-color` cannot desync it from the\n // classes both derive from the resolved value.\n data-color={colorway}\n className={cn(mastheadVariants({ color: colorway }), className)}\n ref={ref}\n >\n <div\n data-slot='masthead-container'\n className={cn(mastheadContainerVariants({ container: containerway }), containerClassName)}\n >\n {children ?? 'A NSW Government website'}\n </div>\n </div>\n )\n}\n\nexport { Masthead, mastheadContainerVariants, mastheadVariants }\nexport type { MastheadColor, MastheadProps }\n"]}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { jsxs, jsx } from 'react/jsx-runtime';
|
|
2
2
|
import { cva } from 'class-variance-authority';
|
|
3
3
|
import { IconExpandMore } from '../icons/expand-more.js';
|
|
4
|
+
import { resolveVariant } from '../lib/resolve-variant.js';
|
|
4
5
|
import { cn } from '../lib/utils.js';
|
|
5
6
|
|
|
6
7
|
const nativeSelectVariants = cva(
|
|
@@ -27,6 +28,8 @@ const nativeSelectVariants = cva(
|
|
|
27
28
|
}
|
|
28
29
|
);
|
|
29
30
|
function NativeSelect({ className, variant, size, ...props }) {
|
|
31
|
+
const variantway = resolveVariant(variant, "default");
|
|
32
|
+
const sizeway = resolveVariant(size, "default");
|
|
30
33
|
return /* @__PURE__ */ jsxs(
|
|
31
34
|
"div",
|
|
32
35
|
{
|
|
@@ -35,17 +38,17 @@ function NativeSelect({ className, variant, size, ...props }) {
|
|
|
35
38
|
className
|
|
36
39
|
),
|
|
37
40
|
"data-slot": "native-select-wrapper",
|
|
38
|
-
"data-size":
|
|
39
|
-
"data-variant":
|
|
41
|
+
"data-size": sizeway,
|
|
42
|
+
"data-variant": variantway,
|
|
40
43
|
children: [
|
|
41
44
|
/* @__PURE__ */ jsx(
|
|
42
45
|
"select",
|
|
43
46
|
{
|
|
44
47
|
"data-slot": "native-select",
|
|
45
|
-
|
|
46
|
-
"data-
|
|
47
|
-
|
|
48
|
-
|
|
48
|
+
...props,
|
|
49
|
+
"data-size": sizeway,
|
|
50
|
+
"data-variant": variantway,
|
|
51
|
+
className: cn(nativeSelectVariants({ variant: variantway, size: sizeway }))
|
|
49
52
|
}
|
|
50
53
|
),
|
|
51
54
|
/* @__PURE__ */ jsx(
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/components/native-select.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"sources":["../../src/components/native-select.tsx"],"names":[],"mappings":";;;;;;AAOA,MAAM,oBAAA,GAAuB,GAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAM3B,8gBAAA;AAAA,EACA;AAAA,IACE,QAAA,EAAU;AAAA,MACR,OAAA,EAAS;AAAA;AAAA,QAEP,OAAA,EACE,sFAAA;AAAA;AAAA,QAEF,MAAA,EAAQ;AAAA,OACV;AAAA,MACA,IAAA,EAAM;AAAA,QACJ,OAAA,EAAS,iBAAA;AAAA,QACT,EAAA,EAAI;AAAA;AACN,KACF;AAAA,IACA,eAAA,EAAiB,EAAE,OAAA,EAAS,SAAA,EAAW,MAAM,SAAA;AAAU;AAE3D;AAKA,SAAS,aAAa,EAAE,SAAA,EAAW,SAAS,IAAA,EAAM,GAAG,OAAM,EAAsB;AAG/E,EAAA,MAAM,UAAA,GAAa,cAAA,CAAe,OAAA,EAAS,SAAS,CAAA;AACpD,EAAA,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GACN;AAEJ","file":"native-select.js","sourcesContent":["import { cva, type VariantProps } from 'class-variance-authority'\nimport * as React from 'react'\n\nimport { IconExpandMore } from '../icons/expand-more.js'\nimport { resolveVariant } from '../lib/resolve-variant.js'\nimport { cn } from '../lib/utils.js'\n\nconst nativeSelectVariants = cva(\n // Field foundation shared with Input (input.tsx) and the Select trigger: the\n // same --input-* semantic tokens, 16px text, and an outline-based focus ring.\n // appearance-none hides the native arrow so our chevron shows; no outline-none\n // (it would suppress the focus-visible outline). Dark mode and brand themes\n // restyle via tokens, so there are no dark: variants.\n 'w-full min-w-0 appearance-none rounded-sm text-base text-(--input-foreground) select-none selection:bg-primary selection:text-primary-foreground focus-visible:outline focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-(--input-ring) disabled:pointer-events-none disabled:cursor-not-allowed aria-invalid:border-2 aria-invalid:border-(--input-invalid-border) aria-invalid:hover:bg-(--input-invalid-surface-hover) aria-invalid:focus-visible:outline-(--input-invalid-ring) motion-safe:transition-colors',\n {\n variants: {\n variant: {\n // Crisp field — bordered white box; matches Input and Select's default.\n default:\n 'border border-(--input-border) bg-(--input-surface) hover:bg-(--input-surface-hover)',\n // Filled band — borderless tinted surface that reveals its border on hover.\n filled: 'border border-transparent bg-secondary hover:border-(--input-border)',\n },\n size: {\n default: 'h-12 ps-4 pe-10',\n sm: 'h-10 ps-3 pe-9',\n },\n },\n defaultVariants: { variant: 'default', size: 'default' },\n },\n)\n\ntype NativeSelectProps = Omit<React.ComponentProps<'select'>, 'size'> &\n VariantProps<typeof nativeSelectVariants>\n\nfunction NativeSelect({ className, variant, size, ...props }: NativeSelectProps) {\n // Resolved once (see `resolveVariant`), so cva and the four data attributes\n // agree for `null` and `''` as well as the default spelling.\n const variantway = resolveVariant(variant, 'default')\n const sizeway = resolveVariant(size, 'default')\n return (\n <div\n className={cn(\n 'group/native-select relative w-fit has-[select:disabled]:opacity-50',\n className,\n )}\n data-slot='native-select-wrapper'\n data-size={sizeway}\n data-variant={variantway}\n >\n <select\n data-slot='native-select'\n {...props}\n // After the spread, so a consumer's own `data-*` cannot desync the\n // attributes from the classes both derive from the resolved values.\n data-size={sizeway}\n data-variant={variantway}\n className={cn(nativeSelectVariants({ variant: variantway, size: sizeway }))}\n />\n <IconExpandMore\n className='pointer-events-none absolute end-3 top-1/2 size-5 -translate-y-1/2 text-primary select-none'\n aria-hidden='true'\n data-slot='native-select-icon'\n />\n </div>\n )\n}\n\nfunction NativeSelectOption({ className, ...props }: React.ComponentProps<'option'>) {\n return (\n <option\n data-slot='native-select-option'\n className={cn('bg-[Canvas] text-[CanvasText]', className)}\n {...props}\n />\n )\n}\n\nfunction NativeSelectOptGroup({ className, ...props }: React.ComponentProps<'optgroup'>) {\n return (\n <optgroup\n data-slot='native-select-optgroup'\n className={cn('bg-[Canvas] text-[CanvasText]', className)}\n {...props}\n />\n )\n}\n\nexport { NativeSelect, NativeSelectOptGroup, NativeSelectOption, nativeSelectVariants }\n"]}
|
|
@@ -49,7 +49,7 @@ declare const pageHeaderVariants: (props?: ({
|
|
|
49
49
|
declare const pageHeaderInnerVariants: (props?: ({
|
|
50
50
|
container?: "fluid" | "contained" | null | undefined;
|
|
51
51
|
} & class_variance_authority_types.ClassProp) | undefined) => string;
|
|
52
|
-
type PageHeaderProps = React.ComponentPropsWithoutRef<'section'> & VariantProps<typeof pageHeaderVariants> & VariantProps<typeof pageHeaderInnerVariants> & {
|
|
52
|
+
type PageHeaderProps = Omit<React.ComponentPropsWithoutRef<'section'>, 'color'> & VariantProps<typeof pageHeaderVariants> & VariantProps<typeof pageHeaderInnerVariants> & {
|
|
53
53
|
/**
|
|
54
54
|
* `id` of the `PageHeaderTitle`. Names the section so it is exposed as a
|
|
55
55
|
* `region` landmark; as with `Section` and `Hero`, no fallback name is
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { jsx } from 'react/jsx-runtime';
|
|
2
2
|
import { cva } from 'class-variance-authority';
|
|
3
3
|
import { overlayInk } from '../lib/overlay.js';
|
|
4
|
+
import { resolveVariant } from '../lib/resolve-variant.js';
|
|
4
5
|
import { cn } from '../lib/utils.js';
|
|
5
6
|
|
|
6
7
|
const pageHeaderColors = {
|
|
@@ -12,6 +13,7 @@ const pageHeaderColors = {
|
|
|
12
13
|
red: "[--page-header-box:var(--accent-600)] [--page-header-rule:var(--accent-600)]"
|
|
13
14
|
};
|
|
14
15
|
const DEFAULT_PAGE_HEADER_COLOR = "blue";
|
|
16
|
+
const DEFAULT_PAGE_HEADER_CONTAINER = "fluid";
|
|
15
17
|
const pageHeaderVariants = cva(
|
|
16
18
|
[
|
|
17
19
|
"w-full text-foreground",
|
|
@@ -51,7 +53,7 @@ const pageHeaderInnerVariants = cva(
|
|
|
51
53
|
}
|
|
52
54
|
},
|
|
53
55
|
defaultVariants: {
|
|
54
|
-
container:
|
|
56
|
+
container: DEFAULT_PAGE_HEADER_CONTAINER
|
|
55
57
|
}
|
|
56
58
|
}
|
|
57
59
|
);
|
|
@@ -65,21 +67,22 @@ function PageHeader({
|
|
|
65
67
|
children,
|
|
66
68
|
...props
|
|
67
69
|
}) {
|
|
68
|
-
const colorway = color
|
|
70
|
+
const colorway = resolveVariant(color, DEFAULT_PAGE_HEADER_COLOR);
|
|
71
|
+
const containerway = resolveVariant(container, DEFAULT_PAGE_HEADER_CONTAINER);
|
|
69
72
|
return /* @__PURE__ */ jsx(
|
|
70
73
|
"section",
|
|
71
74
|
{
|
|
72
75
|
ref,
|
|
73
76
|
"data-slot": "page-header",
|
|
74
|
-
"data-color": colorway,
|
|
75
77
|
"aria-labelledby": labelledBy,
|
|
76
|
-
className: cn(pageHeaderVariants({ color: colorway, className })),
|
|
77
78
|
...props,
|
|
79
|
+
"data-color": colorway,
|
|
80
|
+
className: cn(pageHeaderVariants({ color: colorway, className })),
|
|
78
81
|
children: /* @__PURE__ */ jsx(
|
|
79
82
|
"div",
|
|
80
83
|
{
|
|
81
84
|
"data-slot": "page-header-inner",
|
|
82
|
-
className: cn(pageHeaderInnerVariants({ container }), innerClassName),
|
|
85
|
+
className: cn(pageHeaderInnerVariants({ container: containerway }), innerClassName),
|
|
83
86
|
children
|
|
84
87
|
}
|
|
85
88
|
)
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/components/page-header.tsx"],"names":[],"mappings":";;;;;AAkCA,MAAM,gBAAA,GAAmB;AAAA,EACvB,IAAA,EAAM,oFAAA;AAAA,EACN,IAAA,EAAM;AAAA,IACJ,oFAAA;AAAA,IACA;AAAA,GACF,CAAE,KAAK,GAAG,CAAA;AAAA,EACV,GAAA,EAAK;AACP;AAIA,MAAM,yBAAA,GAA6C,MAAA;AAEnD,MAAM,kBAAA,GAAqB,GAAA;AAAA,EACzB;AAAA,IACE,wBAAA;AAAA;AAAA;AAAA;AAAA,IAIA,UAAA;AAAA,IACA;AAAA,GACF;AAAA,EACA;AAAA,IACE,QAAA,EAAU;AAAA,MACR,KAAA,EAAO;AAAA,KACT;AAAA,IACA,eAAA,EAAiB;AAAA,MACf,KAAA,EAAO;AAAA;AACT;AAEJ;AAUA,MAAM,uBAAA,GAA0B,GAAA;AAAA,EAC9B;AAAA,IACE,gBAAA;AAAA,IACA,8BAAA;AAAA,IACA,6HAAA;AAAA;AAAA;AAAA,IAGA;AAAA,GACF;AAAA,EACA;AAAA,IACE,QAAA,EAAU;AAAA,MACR,SAAA,EAAW;AAAA;AAAA;AAAA;AAAA,QAIT,KAAA,EAAO,2CAAA;AAAA;AAAA,QAEP,SAAA,EAAW;AAAA;AACb,KACF;AAAA,IACA,eAAA,EAAiB;AAAA,MACf,SAAA,EAAW;AAAA;AACb;AAEJ;AAoCA,SAAS,UAAA,CAAW;AAAA,EAClB,SAAA;AAAA,EACA,cAAA;AAAA,EACA,KAAA;AAAA,EACA,SAAA;AAAA,EACA,UAAA;AAAA,EACA,GAAA;AAAA,EACA,QAAA;AAAA,EACA,GAAG;AACL,CAAA,EAAoB;AAIlB,EAAA,MAAM,WAAW,KAAA,IAAS,yBAAA;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AA;AAAA,IAAA;AAAA,MACC,GAAA;AAAA,MACA,WAAA,EAAU,yBAAA;AAAA,MACV,SAAA,EAAW,EAAA;AAAA,QACT,qCAAA;AAAA,QACA,2DAAA;AAAA,QACA;AAAA,OACF;AAAA,MACC,GAAG;AAAA;AAAA,GACN;AAEJ;AAWA,SAAS,eAAe,EAAE,SAAA,EAAW,GAAA,EAAK,GAAG,OAAM,EAAwB;AACzE,EAAA,uBACE,GAAA;AAAA,IAAC,KAAA;AAAA,IAAA;AAAA,MACC,GAAA;AAAA,MACA,aAAA,EAAY,MAAA;AAAA,MACZ,WAAA,EAAU,kBAAA;AAAA,MACV,SAAA,EAAW,EAAA;AAAA;AAAA;AAAA,QAGT,wEAAA;AAAA,QACA;AAAA,OACF;AAAA,MACC,GAAG;AAAA;AAAA,GACN;AAEJ;AAWA,SAAS,eAAe,EAAE,SAAA,EAAW,GAAA,EAAK,GAAG,OAAM,EAAwB;AACzE,EAAA,uBACE,GAAA;AAAA,IAAC,KAAA;AAAA,IAAA;AAAA,MACC,GAAA;AAAA,MACA,WAAA,EAAU,kBAAA;AAAA,MACV,SAAA,EAAW,EAAA;AAAA;AAAA;AAAA,QAGT,uFAAA;AAAA,QACA,2FAAA;AAAA,QACA;AAAA,OACF;AAAA,MACC,GAAG;AAAA;AAAA,GACN;AAEJ","file":"page-header.js","sourcesContent":["import type * as React from 'react'\n\nimport { cva, type VariantProps } from 'class-variance-authority'\n\nimport { overlayInk } from '../lib/overlay.js'\nimport { cn } from '../lib/utils.js'\n\n/**\n * The colourways a page header's title box can wear. Each sets two custom\n * properties the slots read: `--page-header-box`, the flat band the title is\n * painted on, and `--page-header-rule`, the colour of the short rule under\n * the standfirst. A third, `--page-header-ink`, is the interactive ink\n * (`primary-800` light / `primary-200` dark, the Role-Flip Rule) and is the\n * same in every colourway: the meta row's hairline is drawn in it, and so is\n * the rule everywhere except `red`, where the rule follows the box. The ink\n * is not declared here: it aliases `--overlay-ink` from `overlayInk`\n * (`src/lib/overlay.ts`), the one declaration Breadcrumb and the overlays\n * share, so a retune of the ink stays one edit (AGENTS.md §3).\n *\n * The box fills are palette steps, not role tokens (AGENTS.md §3, recorded\n * exception): `blue` is `primary-600`, the masterbrand's Blue 02 and the\n * colour the Transport for NSW reference uses, which no semantic role\n * carries — `--primary` is the interactive fill and flips to a brighter\n * blue in dark mode, where a brand band should hold still. White on it\n * measures 4.57:1 (the same step Footer and MainNav record), which clears\n * the 4.5:1 normal-text bar of WCAG 2.2 AA 1.4.3 with almost no headroom;\n * the title being large text (32px and up, semibold), where the bar is 3:1,\n * is the safety net under a retuned palette, not what makes it pass. It is\n * theme-invariant, as `red` (`accent-600`, the waratah red) is; `navy`\n * (`primary-800`, the brand band) lifts one step in dark mode, to\n * `primary-700`, so the box stays distinct from a Header `dark` band above\n * it, which deepens to `primary-950`. That partial flip is deliberate and\n * recorded against DESIGN.md's Whole-Set Flip Rule.\n */\nconst pageHeaderColors = {\n blue: '[--page-header-box:var(--primary-600)] [--page-header-rule:var(--page-header-ink)]',\n navy: [\n '[--page-header-box:var(--primary-800)] dark:[--page-header-box:var(--primary-700)]',\n '[--page-header-rule:var(--page-header-ink)]',\n ].join(' '),\n red: '[--page-header-box:var(--accent-600)] [--page-header-rule:var(--accent-600)]',\n}\n\ntype PageHeaderColor = keyof typeof pageHeaderColors\n\nconst DEFAULT_PAGE_HEADER_COLOR: PageHeaderColor = 'blue'\n\nconst pageHeaderVariants = cva(\n [\n 'w-full text-foreground',\n // The interactive ink, flipping for dark mode (DESIGN.md, The Role-Flip\n // Rule), read from the shared declaration rather than restated. The\n // hairline and, outside `red`, the rule read the alias.\n overlayInk,\n '[--page-header-ink:var(--overlay-ink)]',\n ],\n {\n variants: {\n color: pageHeaderColors,\n },\n defaultVariants: {\n color: DEFAULT_PAGE_HEADER_COLOR,\n },\n },\n)\n\n/**\n * The inner column, carrying the same lateral rhythm as `Container`, `Hero`\n * and the chrome components (16px → 24px → 48px, funnelled through\n * `--page-header-padding-x`), so the title's text lines up with the Header\n * and Breadcrumb above it. The title box hangs back into that padding by its\n * own horizontal padding, which is why the inset is a property and not a bare\n * utility: a consumer who retunes the column keeps the box on the margin.\n */\nconst pageHeaderInnerVariants = cva(\n [\n 'mx-auto w-full',\n 'px-(--page-header-padding-x)',\n '[--page-header-padding-x:--spacing(4)] sm:[--page-header-padding-x:--spacing(6)] lg:[--page-header-padding-x:--spacing(12)]',\n // Vertical rhythm, on the 4px grid: a little air under the breadcrumb,\n // and a full step before the page's first body heading.\n 'pt-2 pb-10',\n ],\n {\n variants: {\n container: {\n // Full-bleed, matching the chrome's default. `--page-header-max-width`\n // is still read so a shell app can constrain the column without\n // switching variants.\n fluid: 'max-w-[var(--page-header-max-width,none)]',\n // Centred content column, legacy nsw-container parity (1200px).\n contained: 'max-w-[var(--page-header-max-width,75rem)]',\n },\n },\n defaultVariants: {\n container: 'fluid',\n },\n },\n)\n\ntype PageHeaderProps = React.ComponentPropsWithoutRef<'section'> &\n VariantProps<typeof pageHeaderVariants> &\n VariantProps<typeof pageHeaderInnerVariants> & {\n /**\n * `id` of the `PageHeaderTitle`. Names the section so it is exposed as a\n * `region` landmark; as with `Section` and `Hero`, no fallback name is\n * invented.\n */\n labelledBy?: string\n /** Classes applied to the inner column. */\n innerClassName?: string\n ref?: React.Ref<HTMLElement>\n }\n\n/**\n * The opening of a content page: the page title wearing its own flat colour\n * band, one box per wrapped line, then a standfirst and optionally a short\n * rule or a meta row. It sits under the site's Header and Breadcrumb, which\n * are separate components — a page header renders no breadcrumb of its own.\n * For the opening band of a landing page, with actions and an illustration,\n * use `Hero`.\n *\n * Compose it from its slots:\n *\n * ```tsx\n * <PageHeader labelledBy='page-title'>\n * <PageHeaderTitle id='page-title'>Discovery Pass</PageHeaderTitle>\n * <PageHeaderDescription>\n * Get unlimited travel on NSW TrainLink Regional trains and coaches.\n * </PageHeaderDescription>\n * <PageHeaderRule />\n * </PageHeader>\n * ```\n */\nfunction PageHeader({\n className,\n innerClassName,\n color,\n container,\n labelledBy,\n ref,\n children,\n ...props\n}: PageHeaderProps) {\n // Normalised once: cva treats an explicit `null` as \"no colourway\" where\n // `undefined` takes the default, so the classes and `data-color` would\n // otherwise disagree for `color={null}`.\n const colorway = color ?? DEFAULT_PAGE_HEADER_COLOR\n return (\n <section\n ref={ref}\n data-slot='page-header'\n data-color={colorway}\n aria-labelledby={labelledBy}\n className={cn(pageHeaderVariants({ color: colorway, className }))}\n {...props}\n >\n <div\n data-slot='page-header-inner'\n className={cn(pageHeaderInnerVariants({ container }), innerClassName)}\n >\n {children}\n </div>\n </section>\n )\n}\n\ntype PageHeaderTitleProps = React.ComponentPropsWithoutRef<'h1'> & {\n /**\n * The heading element. `1` by default, because a page header opens the\n * page and its title is the page's title; `2` for a header that opens a\n * section of a page whose `h1` sits elsewhere, so the outline stays in\n * order (WCAG 1.3.1).\n */\n headingLevel?: 1 | 2\n ref?: React.Ref<HTMLHeadingElement>\n}\n\n/**\n * The page title on its band. The heading is inline, so the band is drawn\n * per line (`box-decoration-break: clone`) and each box fits its own line's\n * words: a short title is one box, a long one a stack of boxes that touch.\n * Semibold at 48px from `sm:` and 32px below, with the tracking the\n * masterbrand's display setting asks for, and sentence case — the brand sets\n * nothing in uppercase.\n *\n * The box hangs back into the margin by its own horizontal padding, so the\n * TEXT sits on the column, lined up with the breadcrumb above and the body\n * below, and the colour reaches out past it. A block wrapper gives the title\n * its measure (40rem, retuned through `--page-header-title-max-width` like\n * the column's own `--page-header-max-width`), holds the air between it and\n * the breadcrumb above (24px, 16px on a phone), and puts the slots after it\n * on a new line.\n */\nfunction PageHeaderTitle({ className, headingLevel = 1, ref, ...props }: PageHeaderTitleProps) {\n const Heading = `h${headingLevel}` as const\n return (\n <div\n data-slot='page-header-title-row'\n // wrap-break-word so one unbreakable token (a URL, an acronym) wraps\n // inside a 320px viewport instead of pushing past it (WCAG 1.4.10).\n // text-balance lives here, not on the heading: balancing is a property\n // of the block container, and on the inline heading it does nothing.\n className='max-w-[var(--page-header-title-max-width,40rem)] text-balance wrap-break-word max-sm:mt-4 sm:mt-6'\n >\n <Heading\n ref={ref}\n data-slot='page-header-title'\n className={cn(\n // The box colour falls back to `blue`'s step so a title rendered\n // outside a PageHeader (or copied without it) still paints. It is a\n // literal because Tailwind only emits complete class strings; keep\n // it in step with `pageHeaderColors.blue`.\n 'inline bg-[var(--page-header-box,var(--primary-600))] box-decoration-clone font-semibold tracking-tight text-white',\n // 1.46 is the line-height at which the boxes of a wrapped title\n // touch with neither a gap nor an overlap — the box is the line box\n // plus the vertical padding, so the two are tuned together for\n // Public Sans' ascent and descent; another `--font-sans` shows a\n // seam or an overlap of a pixel or two between lines.\n 'max-sm:text-[2rem]/[1.46] sm:text-5xl/[1.46]',\n 'max-sm:px-3 max-sm:py-1 sm:px-4 sm:py-1.5',\n // The hang is capped at the column inset, so a shell app that\n // retunes --page-header-padding-x to 0 gets a box on the column\n // rather than one poking out of the section.\n 'max-sm:-ms-[min(--spacing(3),var(--page-header-padding-x))] sm:-ms-[min(--spacing(4),var(--page-header-padding-x))]',\n className,\n )}\n {...props}\n />\n </div>\n )\n}\n\ntype PageHeaderDescriptionProps = React.ComponentPropsWithoutRef<'p'> & {\n ref?: React.Ref<HTMLParagraphElement>\n}\n\n/**\n * The standfirst: one or two light sentences under the title, 20/30 at a\n * 62ch measure, stepping to 18px on a phone.\n */\nfunction PageHeaderDescription({ className, ref, ...props }: PageHeaderDescriptionProps) {\n return (\n <p\n ref={ref}\n data-slot='page-header-description'\n className={cn(\n 'max-w-[62ch] font-light text-pretty',\n 'max-sm:mt-4 max-sm:text-lg/[1.5] sm:mt-5 sm:text-xl/[1.5]',\n className,\n )}\n {...props}\n />\n )\n}\n\ntype PageHeaderRuleProps = React.ComponentPropsWithoutRef<'div'> & {\n ref?: React.Ref<HTMLDivElement>\n}\n\n/**\n * A short rule closing the header, 48×4px in the ink — or, in the `red`\n * colourway, in the box's red. Square-cornered: the brand is flat. Decorative,\n * so it is hidden from assistive technology.\n */\nfunction PageHeaderRule({ className, ref, ...props }: PageHeaderRuleProps) {\n return (\n <div\n ref={ref}\n aria-hidden='true'\n data-slot='page-header-rule'\n className={cn(\n // Outside a PageHeader the rule takes the text colour, which is\n // theme-correct on its own, rather than a restated ink.\n 'h-1 w-12 bg-[var(--page-header-rule,currentColor)] max-sm:mt-6 sm:mt-7',\n className,\n )}\n {...props}\n />\n )\n}\n\ntype PageHeaderMetaProps = React.ComponentPropsWithoutRef<'div'> & {\n ref?: React.Ref<HTMLDivElement>\n}\n\n/**\n * An optional row of facts about the page under a hairline in the ink — when\n * it was last updated, which site it belongs to. Its children are the\n * consumer's `span`s, spread to the row's two ends and stacked on a phone.\n */\nfunction PageHeaderMeta({ className, ref, ...props }: PageHeaderMetaProps) {\n return (\n <div\n ref={ref}\n data-slot='page-header-meta'\n className={cn(\n // The hairline falls back to the row's own (muted) text colour when\n // there is no PageHeader ink above it.\n 'flex border-t border-[var(--page-header-ink,currentColor)] pt-3 text-muted-foreground',\n 'max-sm:mt-6 max-sm:flex-col max-sm:gap-1 sm:mt-9 sm:flex-wrap sm:justify-between sm:gap-4',\n className,\n )}\n {...props}\n />\n )\n}\n\nexport {\n PageHeader,\n pageHeaderColors,\n PageHeaderDescription,\n pageHeaderInnerVariants,\n PageHeaderMeta,\n PageHeaderRule,\n PageHeaderTitle,\n pageHeaderVariants,\n}\nexport type {\n PageHeaderColor,\n PageHeaderDescriptionProps,\n PageHeaderMetaProps,\n PageHeaderProps,\n PageHeaderRuleProps,\n PageHeaderTitleProps,\n}\n"]}
|
|
1
|
+
{"version":3,"sources":["../../src/components/page-header.tsx"],"names":[],"mappings":";;;;;;AAmCA,MAAM,gBAAA,GAAmB;AAAA,EACvB,IAAA,EAAM,oFAAA;AAAA,EACN,IAAA,EAAM;AAAA,IACJ,oFAAA;AAAA,IACA;AAAA,GACF,CAAE,KAAK,GAAG,CAAA;AAAA,EACV,GAAA,EAAK;AACP;AAIA,MAAM,yBAAA,GAA6C,MAAA;AAEnD,MAAM,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AAA,IAAC,KAAA;AAAA,IAAA;AAAA,MACC,GAAA;AAAA,MACA,aAAA,EAAY,MAAA;AAAA,MACZ,WAAA,EAAU,kBAAA;AAAA,MACV,SAAA,EAAW,EAAA;AAAA;AAAA;AAAA,QAGT,wEAAA;AAAA,QACA;AAAA,OACF;AAAA,MACC,GAAG;AAAA;AAAA,GACN;AAEJ;AAWA,SAAS,eAAe,EAAE,SAAA,EAAW,GAAA,EAAK,GAAG,OAAM,EAAwB;AACzE,EAAA,uBACE,GAAA;AAAA,IAAC,KAAA;AAAA,IAAA;AAAA,MACC,GAAA;AAAA,MACA,WAAA,EAAU,kBAAA;AAAA,MACV,SAAA,EAAW,EAAA;AAAA;AAAA;AAAA,QAGT,uFAAA;AAAA,QACA,2FAAA;AAAA,QACA;AAAA,OACF;AAAA,MACC,GAAG;AAAA;AAAA,GACN;AAEJ","file":"page-header.js","sourcesContent":["import type * as React from 'react'\n\nimport { cva, type VariantProps } from 'class-variance-authority'\n\nimport { overlayInk } from '../lib/overlay.js'\nimport { resolveVariant } from '../lib/resolve-variant.js'\nimport { cn } from '../lib/utils.js'\n\n/**\n * The colourways a page header's title box can wear. Each sets two custom\n * properties the slots read: `--page-header-box`, the flat band the title is\n * painted on, and `--page-header-rule`, the colour of the short rule under\n * the standfirst. A third, `--page-header-ink`, is the interactive ink\n * (`primary-800` light / `primary-200` dark, the Role-Flip Rule) and is the\n * same in every colourway: the meta row's hairline is drawn in it, and so is\n * the rule everywhere except `red`, where the rule follows the box. The ink\n * is not declared here: it aliases `--overlay-ink` from `overlayInk`\n * (`src/lib/overlay.ts`), the one declaration Breadcrumb and the overlays\n * share, so a retune of the ink stays one edit (AGENTS.md §3).\n *\n * The box fills are palette steps, not role tokens (AGENTS.md §3, recorded\n * exception): `blue` is `primary-600`, the masterbrand's Blue 02 and the\n * colour the Transport for NSW reference uses, which no semantic role\n * carries — `--primary` is the interactive fill and flips to a brighter\n * blue in dark mode, where a brand band should hold still. White on it\n * measures 4.57:1 (the same step Footer and MainNav record), which clears\n * the 4.5:1 normal-text bar of WCAG 2.2 AA 1.4.3 with almost no headroom;\n * the title being large text (32px and up, semibold), where the bar is 3:1,\n * is the safety net under a retuned palette, not what makes it pass. It is\n * theme-invariant, as `red` (`accent-600`, the waratah red) is; `navy`\n * (`primary-800`, the brand band) lifts one step in dark mode, to\n * `primary-700`, so the box stays distinct from a Header `dark` band above\n * it, which deepens to `primary-950`. That partial flip is deliberate and\n * recorded against DESIGN.md's Whole-Set Flip Rule.\n */\nconst pageHeaderColors = {\n blue: '[--page-header-box:var(--primary-600)] [--page-header-rule:var(--page-header-ink)]',\n navy: [\n '[--page-header-box:var(--primary-800)] dark:[--page-header-box:var(--primary-700)]',\n '[--page-header-rule:var(--page-header-ink)]',\n ].join(' '),\n red: '[--page-header-box:var(--accent-600)] [--page-header-rule:var(--accent-600)]',\n}\n\ntype PageHeaderColor = keyof typeof pageHeaderColors\n\nconst DEFAULT_PAGE_HEADER_COLOR: PageHeaderColor = 'blue'\n// Shared by cva's defaultVariants and the `resolveVariant` call in `PageHeader`.\nconst DEFAULT_PAGE_HEADER_CONTAINER = 'fluid'\n\nconst pageHeaderVariants = cva(\n [\n 'w-full text-foreground',\n // The interactive ink, flipping for dark mode (DESIGN.md, The Role-Flip\n // Rule), read from the shared declaration rather than restated. The\n // hairline and, outside `red`, the rule read the alias.\n overlayInk,\n '[--page-header-ink:var(--overlay-ink)]',\n ],\n {\n variants: {\n color: pageHeaderColors,\n },\n defaultVariants: {\n color: DEFAULT_PAGE_HEADER_COLOR,\n },\n },\n)\n\n/**\n * The inner column, carrying the same lateral rhythm as `Container`, `Hero`\n * and the chrome components (16px → 24px → 48px, funnelled through\n * `--page-header-padding-x`), so the title's text lines up with the Header\n * and Breadcrumb above it. The title box hangs back into that padding by its\n * own horizontal padding, which is why the inset is a property and not a bare\n * utility: a consumer who retunes the column keeps the box on the margin.\n */\nconst pageHeaderInnerVariants = cva(\n [\n 'mx-auto w-full',\n 'px-(--page-header-padding-x)',\n '[--page-header-padding-x:--spacing(4)] sm:[--page-header-padding-x:--spacing(6)] lg:[--page-header-padding-x:--spacing(12)]',\n // Vertical rhythm, on the 4px grid: a little air under the breadcrumb,\n // and a full step before the page's first body heading.\n 'pt-2 pb-10',\n ],\n {\n variants: {\n container: {\n // Full-bleed, matching the chrome's default. `--page-header-max-width`\n // is still read so a shell app can constrain the column without\n // switching variants.\n fluid: 'max-w-[var(--page-header-max-width,none)]',\n // Centred content column, legacy nsw-container parity (1200px).\n contained: 'max-w-[var(--page-header-max-width,75rem)]',\n },\n },\n defaultVariants: {\n container: DEFAULT_PAGE_HEADER_CONTAINER,\n },\n },\n)\n\n// The native `color` attribute is omitted so the prop type admits the `null`\n// cva's `VariantProps` allows and the component resolves.\ntype PageHeaderProps = Omit<React.ComponentPropsWithoutRef<'section'>, 'color'> &\n VariantProps<typeof pageHeaderVariants> &\n VariantProps<typeof pageHeaderInnerVariants> & {\n /**\n * `id` of the `PageHeaderTitle`. Names the section so it is exposed as a\n * `region` landmark; as with `Section` and `Hero`, no fallback name is\n * invented.\n */\n labelledBy?: string\n /** Classes applied to the inner column. */\n innerClassName?: string\n ref?: React.Ref<HTMLElement>\n }\n\n/**\n * The opening of a content page: the page title wearing its own flat colour\n * band, one box per wrapped line, then a standfirst and optionally a short\n * rule or a meta row. It sits under the site's Header and Breadcrumb, which\n * are separate components — a page header renders no breadcrumb of its own.\n * For the opening band of a landing page, with actions and an illustration,\n * use `Hero`.\n *\n * Compose it from its slots:\n *\n * ```tsx\n * <PageHeader labelledBy='page-title'>\n * <PageHeaderTitle id='page-title'>Discovery Pass</PageHeaderTitle>\n * <PageHeaderDescription>\n * Get unlimited travel on NSW TrainLink Regional trains and coaches.\n * </PageHeaderDescription>\n * <PageHeaderRule />\n * </PageHeader>\n * ```\n */\nfunction PageHeader({\n className,\n innerClassName,\n color,\n container,\n labelledBy,\n ref,\n children,\n ...props\n}: PageHeaderProps) {\n // Resolved once (see `resolveVariant`), so cva and `data-color` agree for\n // `null` and `''` as well as the default spelling, and\n // `container={null}` keeps the inner wrapper's max-width class, which reads\n // `--page-header-max-width`, instead of dropping it.\n const colorway = resolveVariant(color, DEFAULT_PAGE_HEADER_COLOR)\n const containerway = resolveVariant(container, DEFAULT_PAGE_HEADER_CONTAINER)\n return (\n <section\n ref={ref}\n data-slot='page-header'\n aria-labelledby={labelledBy}\n {...props}\n // After the spread, so a consumer's own `data-*` cannot desync the\n // attribute from the classes both derive from the resolved value.\n data-color={colorway}\n className={cn(pageHeaderVariants({ color: colorway, className }))}\n >\n <div\n data-slot='page-header-inner'\n className={cn(pageHeaderInnerVariants({ container: containerway }), innerClassName)}\n >\n {children}\n </div>\n </section>\n )\n}\n\ntype PageHeaderTitleProps = React.ComponentPropsWithoutRef<'h1'> & {\n /**\n * The heading element. `1` by default, because a page header opens the\n * page and its title is the page's title; `2` for a header that opens a\n * section of a page whose `h1` sits elsewhere, so the outline stays in\n * order (WCAG 1.3.1).\n */\n headingLevel?: 1 | 2\n ref?: React.Ref<HTMLHeadingElement>\n}\n\n/**\n * The page title on its band. The heading is inline, so the band is drawn\n * per line (`box-decoration-break: clone`) and each box fits its own line's\n * words: a short title is one box, a long one a stack of boxes that touch.\n * Semibold at 48px from `sm:` and 32px below, with the tracking the\n * masterbrand's display setting asks for, and sentence case — the brand sets\n * nothing in uppercase.\n *\n * The box hangs back into the margin by its own horizontal padding, so the\n * TEXT sits on the column, lined up with the breadcrumb above and the body\n * below, and the colour reaches out past it. A block wrapper gives the title\n * its measure (40rem, retuned through `--page-header-title-max-width` like\n * the column's own `--page-header-max-width`), holds the air between it and\n * the breadcrumb above (24px, 16px on a phone), and puts the slots after it\n * on a new line.\n */\nfunction PageHeaderTitle({ className, headingLevel = 1, ref, ...props }: PageHeaderTitleProps) {\n const Heading = `h${headingLevel}` as const\n return (\n <div\n data-slot='page-header-title-row'\n // wrap-break-word so one unbreakable token (a URL, an acronym) wraps\n // inside a 320px viewport instead of pushing past it (WCAG 1.4.10).\n // text-balance lives here, not on the heading: balancing is a property\n // of the block container, and on the inline heading it does nothing.\n className='max-w-[var(--page-header-title-max-width,40rem)] text-balance wrap-break-word max-sm:mt-4 sm:mt-6'\n >\n <Heading\n ref={ref}\n data-slot='page-header-title'\n className={cn(\n // The box colour falls back to `blue`'s step so a title rendered\n // outside a PageHeader (or copied without it) still paints. It is a\n // literal because Tailwind only emits complete class strings; keep\n // it in step with `pageHeaderColors.blue`.\n 'inline bg-[var(--page-header-box,var(--primary-600))] box-decoration-clone font-semibold tracking-tight text-white',\n // 1.46 is the line-height at which the boxes of a wrapped title\n // touch with neither a gap nor an overlap — the box is the line box\n // plus the vertical padding, so the two are tuned together for\n // Public Sans' ascent and descent; another `--font-sans` shows a\n // seam or an overlap of a pixel or two between lines.\n 'max-sm:text-[2rem]/[1.46] sm:text-5xl/[1.46]',\n 'max-sm:px-3 max-sm:py-1 sm:px-4 sm:py-1.5',\n // The hang is capped at the column inset, so a shell app that\n // retunes --page-header-padding-x to 0 gets a box on the column\n // rather than one poking out of the section.\n 'max-sm:-ms-[min(--spacing(3),var(--page-header-padding-x))] sm:-ms-[min(--spacing(4),var(--page-header-padding-x))]',\n className,\n )}\n {...props}\n />\n </div>\n )\n}\n\ntype PageHeaderDescriptionProps = React.ComponentPropsWithoutRef<'p'> & {\n ref?: React.Ref<HTMLParagraphElement>\n}\n\n/**\n * The standfirst: one or two light sentences under the title, 20/30 at a\n * 62ch measure, stepping to 18px on a phone.\n */\nfunction PageHeaderDescription({ className, ref, ...props }: PageHeaderDescriptionProps) {\n return (\n <p\n ref={ref}\n data-slot='page-header-description'\n className={cn(\n 'max-w-[62ch] font-light text-pretty',\n 'max-sm:mt-4 max-sm:text-lg/[1.5] sm:mt-5 sm:text-xl/[1.5]',\n className,\n )}\n {...props}\n />\n )\n}\n\ntype PageHeaderRuleProps = React.ComponentPropsWithoutRef<'div'> & {\n ref?: React.Ref<HTMLDivElement>\n}\n\n/**\n * A short rule closing the header, 48×4px in the ink — or, in the `red`\n * colourway, in the box's red. Square-cornered: the brand is flat. Decorative,\n * so it is hidden from assistive technology.\n */\nfunction PageHeaderRule({ className, ref, ...props }: PageHeaderRuleProps) {\n return (\n <div\n ref={ref}\n aria-hidden='true'\n data-slot='page-header-rule'\n className={cn(\n // Outside a PageHeader the rule takes the text colour, which is\n // theme-correct on its own, rather than a restated ink.\n 'h-1 w-12 bg-[var(--page-header-rule,currentColor)] max-sm:mt-6 sm:mt-7',\n className,\n )}\n {...props}\n />\n )\n}\n\ntype PageHeaderMetaProps = React.ComponentPropsWithoutRef<'div'> & {\n ref?: React.Ref<HTMLDivElement>\n}\n\n/**\n * An optional row of facts about the page under a hairline in the ink — when\n * it was last updated, which site it belongs to. Its children are the\n * consumer's `span`s, spread to the row's two ends and stacked on a phone.\n */\nfunction PageHeaderMeta({ className, ref, ...props }: PageHeaderMetaProps) {\n return (\n <div\n ref={ref}\n data-slot='page-header-meta'\n className={cn(\n // The hairline falls back to the row's own (muted) text colour when\n // there is no PageHeader ink above it.\n 'flex border-t border-[var(--page-header-ink,currentColor)] pt-3 text-muted-foreground',\n 'max-sm:mt-6 max-sm:flex-col max-sm:gap-1 sm:mt-9 sm:flex-wrap sm:justify-between sm:gap-4',\n className,\n )}\n {...props}\n />\n )\n}\n\nexport {\n PageHeader,\n pageHeaderColors,\n PageHeaderDescription,\n pageHeaderInnerVariants,\n PageHeaderMeta,\n PageHeaderRule,\n PageHeaderTitle,\n pageHeaderVariants,\n}\nexport type {\n PageHeaderColor,\n PageHeaderDescriptionProps,\n PageHeaderMetaProps,\n PageHeaderProps,\n PageHeaderRuleProps,\n PageHeaderTitleProps,\n}\n"]}
|
|
@@ -6,6 +6,7 @@ import { IconCheck } from '../icons/check.js';
|
|
|
6
6
|
import { IconExpandLess } from '../icons/expand-less.js';
|
|
7
7
|
import { IconExpandMore } from '../icons/expand-more.js';
|
|
8
8
|
import { ButtonGroupBoundary } from '../lib/button-group-context.js';
|
|
9
|
+
import { resolveVariant } from '../lib/resolve-variant.js';
|
|
9
10
|
import { cn } from '../lib/utils.js';
|
|
10
11
|
|
|
11
12
|
const Select = Select$1.Root;
|
|
@@ -68,14 +69,16 @@ function SelectTrigger({
|
|
|
68
69
|
children,
|
|
69
70
|
...props
|
|
70
71
|
}) {
|
|
72
|
+
const variantway = resolveVariant(variant, "default");
|
|
73
|
+
const sizeway = resolveVariant(size, "default");
|
|
71
74
|
return /* @__PURE__ */ jsxs(
|
|
72
75
|
Select$1.Trigger,
|
|
73
76
|
{
|
|
74
77
|
"data-slot": "select-trigger",
|
|
75
|
-
"data-size": size ?? "default",
|
|
76
|
-
"data-variant": variant ?? "default",
|
|
77
|
-
className: cn(selectTriggerVariants({ variant, size, className })),
|
|
78
78
|
...props,
|
|
79
|
+
"data-size": sizeway,
|
|
80
|
+
"data-variant": variantway,
|
|
81
|
+
className: cn(selectTriggerVariants({ variant: variantway, size: sizeway, className })),
|
|
79
82
|
children: [
|
|
80
83
|
children,
|
|
81
84
|
/* @__PURE__ */ jsx(
|