@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.
Files changed (48) hide show
  1. package/dist/components/badge.d.ts +1 -1
  2. package/dist/components/breadcrumb.d.ts +1 -1
  3. package/dist/components/breadcrumb.js +5 -4
  4. package/dist/components/breadcrumb.js.map +1 -1
  5. package/dist/components/button-group.d.ts +1 -1
  6. package/dist/components/button-group.js +3 -2
  7. package/dist/components/button-group.js.map +1 -1
  8. package/dist/components/button.d.ts +4 -4
  9. package/dist/components/callout.d.ts +2 -2
  10. package/dist/components/callout.js +4 -3
  11. package/dist/components/callout.js.map +1 -1
  12. package/dist/components/description-list.js +7 -4
  13. package/dist/components/description-list.js.map +1 -1
  14. package/dist/components/expandable-search.js +5 -4
  15. package/dist/components/expandable-search.js.map +1 -1
  16. package/dist/components/footer.d.ts +1 -1
  17. package/dist/components/footer.js +9 -5
  18. package/dist/components/footer.js.map +1 -1
  19. package/dist/components/header.d.ts +1 -1
  20. package/dist/components/header.js +9 -5
  21. package/dist/components/header.js.map +1 -1
  22. package/dist/components/hero.d.ts +2 -2
  23. package/dist/components/hero.js +22 -11
  24. package/dist/components/hero.js.map +1 -1
  25. package/dist/components/input-group.d.ts +2 -2
  26. package/dist/components/link.d.ts +1 -1
  27. package/dist/components/main-nav.d.ts +1 -1
  28. package/dist/components/main-nav.js +9 -5
  29. package/dist/components/main-nav.js.map +1 -1
  30. package/dist/components/masthead.d.ts +1 -1
  31. package/dist/components/masthead.js +8 -4
  32. package/dist/components/masthead.js.map +1 -1
  33. package/dist/components/native-select.js +9 -6
  34. package/dist/components/native-select.js.map +1 -1
  35. package/dist/components/page-header.d.ts +1 -1
  36. package/dist/components/page-header.js +8 -5
  37. package/dist/components/page-header.js.map +1 -1
  38. package/dist/components/select.js +6 -3
  39. package/dist/components/select.js.map +1 -1
  40. package/dist/components/skeleton.js +4 -3
  41. package/dist/components/skeleton.js.map +1 -1
  42. package/dist/components/tabs.js +7 -5
  43. package/dist/components/tabs.js.map +1 -1
  44. package/dist/components/tag.d.ts +1 -1
  45. package/dist/lib/resolve-variant.d.ts +23 -0
  46. package/dist/lib/resolve-variant.js +7 -0
  47. package/dist/lib/resolve-variant.js.map +1 -0
  48. package/package.json +5 -4
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/components/header.tsx"],"names":[],"mappings":";;;;;;;;AA4BA,MAAM,YAAA,GAAe;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAMnB,IAAA,EAAM,iFAAA;AAAA,EACN,KAAA,EACE,kIAAA;AAAA,EACF,KAAA,EACE,+HAAA;AAAA,EACF,IAAA,EAAM;AACR;AAMA,MAAM,oBAAA,GAAoC,OAAA;AAE1C,MAAM,cAAA,GAAiB,GAAA;AAAA,EACrB;AAAA,IACE,QAAA;AAAA;AAAA;AAAA;AAAA,IAIA,yEAAA;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;AAEA,MAAM,uBAAA,GAA0B,GAAA;AAAA,EAC9B;AAAA,IACE,+GAAA;AAAA;AAAA;AAAA;AAAA,IAIA,yBAAA;AAAA,IACA;AAAA,GACF;AAAA,EACA;AAAA,IACE,QAAA,EAAU;AAAA,MACR,SAAA,EAAW;AAAA;AAAA;AAAA,QAGT,KAAA,EAAO,sCAAA;AAAA;AAAA,QAEP,SAAA,EAAW;AAAA;AACb,KACF;AAAA,IACA,eAAA,EAAiB;AAAA,MACf,SAAA,EAAW;AAAA;AACb;AAEJ;AASA,MAAM,kBAAA,GAAqB,KAAA,CAAM,aAAA,CAA2B,oBAAoB,CAAA;AAGhF,MAAM,sCAAsB,IAAI,GAAA,CAAiB,CAAC,MAAA,EAAQ,MAAM,CAAC,CAAA;AAyEjE,SAAS,qBAAA,CAAsB;AAAA,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AAA;AAAA,IAAA;AAAA,MACC,EAAA,EAAG,YAAA;AAAA,MACH,WAAA,EAAU,QAAA;AAAA,MACV,cAAY,KAAA,IAAS,oBAAA;AAAA,MAGrB,iBAAe,UAAA,IAAc,MAAA;AAAA,MAC5B,GAAG,KAAA;AAAA,MACJ,SAAA,EAAW,EAAA;AAAA,QACT,cAAA,CAAe,EAAE,KAAA,EAAO,CAAA;AAAA;AAAA;AAAA;AAAA,QAIxB,MAAA,IAAU,mBAAA;AAAA;AAAA,QAEV,MAAA,IAAU,mCAAA;AAAA;AAAA;AAAA,QAGV,MAAA,IACE,qFAAA;AAAA,QACF;AAAA,OACF;AAAA,MACA,GAAA;AAAA,MAEA,8BAAC,kBAAA,CAAmB,QAAA,EAAnB,EAA4B,KAAA,EAAO,SAAS,oBAAA,EAC3C,QAAA,kBAAA,GAAA;AAAA,QAAC,KAAA;AAAA,QAAA;AAAA,UACC,WAAA,EAAU,kBAAA;AAAA,UACV,WAAW,EAAA,CAAG,uBAAA,CAAwB,EAAE,SAAA,EAAW,GAAG,kBAAkB,CAAA;AAAA,UAEvE;AAAA;AAAA,OACH,EACF;AAAA;AAAA,GACF;AAEJ","file":"header.js","sourcesContent":["'use client'\n\nimport { cva, type VariantProps } from 'class-variance-authority'\nimport React from 'react'\n\nimport { cn } from '../lib/utils.js'\n\nimport { Badge, type BadgeProps } from '../components/badge.js'\nimport { Link } from '../components/link.js'\nimport { Logo } from '../components/logo.js'\n\n/**\n * Surface colours the header can be themed with, sharing the Masthead's and\n * SkipLink's four-name vocabulary (`dark`, `light`, `white`, `grey`) — the three\n * components stack at the top of the page and a service picks one word for the\n * whole chrome.\n *\n * Every pair is WCAG 2.2 AAA (1.4.6, 7:1), computed from the masterbrand oklch\n * tokens. Light mode: grey-800 on white 15.1:1, grey-800 on grey-100 13.8:1,\n * white on primary-800 14.4:1, white on grey-800 15.1:1. Dark mode deepens each\n * surface onto the same family's dark step and clears AAA more comfortably\n * still (17.2:1–20.2:1).\n *\n * Unlike the Masthead — a brand strip whose light/white/grey surfaces are frozen\n * across themes — the header is the page's own surface, so all four follow the\n * theme. Pair `Header color=\"dark\"` with `Masthead color=\"dark\"` when a service\n * wants the two to match in both modes.\n */\nconst headerColors = {\n // Ink values use the RAW masterbrand tokens (--grey-800) rather than\n // Tailwind's --color-* bridge aliases: Tailwind v4 tree-shakes an\n // unreferenced @theme key, and referencing one from inside an arbitrary\n // property is not a usage signal. Same reasoning as footer.tsx.\n // (--color-white is safe: `text-white` below is a real utility.)\n dark: 'bg-primary-800 text-white [--header-ink:var(--color-white)] dark:bg-primary-950',\n light:\n 'bg-grey-100 text-grey-800 [--header-ink:var(--grey-800)] dark:bg-grey-850 dark:text-white dark:[--header-ink:var(--color-white)]',\n white:\n 'bg-white text-grey-800 [--header-ink:var(--grey-800)] dark:bg-grey-900 dark:text-white dark:[--header-ink:var(--color-white)]',\n grey: 'bg-grey-800 text-white [--header-ink:var(--color-white)] dark:bg-grey-950',\n}\n\ntype HeaderColor = keyof typeof headerColors\n\n// Shared by cva's defaultVariants, the data-color attribute and the logo\n// context, so the four can't drift apart.\nconst DEFAULT_HEADER_COLOR: HeaderColor = 'white'\n\nconst headerVariants = cva(\n [\n 'w-full',\n // The hairline rule derives from the surface's own ink, so it follows every\n // colour variant and both themes from one value. Mirrors the color-mix\n // derivation in footer.tsx (--footer-border) and link.tsx (--link-halo).\n '[--header-border:color-mix(in_oklch,var(--header-ink)_15%,transparent)]',\n 'duration-300 motion-safe:transition-shadow',\n ],\n {\n variants: {\n color: headerColors,\n },\n defaultVariants: {\n color: DEFAULT_HEADER_COLOR,\n },\n },\n)\n\nconst headerContainerVariants = cva(\n [\n 'mx-auto flex w-full flex-wrap items-center justify-between gap-x-4 gap-y-3 max-sm:py-3 sm:max-lg:py-4 lg:py-5',\n // Lateral padding funnels through --header-padding-x so an app can retune it\n // once (via the `style` prop or a utility class) without a new variant. Same\n // mechanism, and the same 16px → 24px → 48px rhythm, as Masthead and Footer.\n 'px-(--header-padding-x)',\n '[--header-padding-x:--spacing(4)] sm:[--header-padding-x:--spacing(6)] lg:[--header-padding-x:--spacing(12)]',\n ],\n {\n variants: {\n container: {\n // Full-bleed (nswds-app parity). --header-max-width is still read so a\n // shell app can constrain the inner wrapper without switching variants.\n fluid: 'max-w-[var(--header-max-width,none)]',\n // Centred content column, legacy nsw-container parity (1200px).\n contained: 'max-w-[var(--header-max-width,75rem)]',\n },\n },\n defaultVariants: {\n container: 'fluid',\n },\n },\n)\n\n/**\n * Lets `HeaderBrand` adapt its artwork to the surface it is drawn on — the\n * default `Logo` paints its wordmark `nsw-blue-800` and the version `Badge`\n * paints itself `primary-800`, both of which disappear on the `dark`\n * (primary-800) surface. A `logo` node supplied by the consumer overrides the\n * lockup entirely; at that point the choice is theirs.\n */\nconst HeaderColorContext = React.createContext<HeaderColor>(DEFAULT_HEADER_COLOR)\n\n/** Surfaces dark enough to need light-on-dark artwork. */\nconst DARK_SURFACE_COLORS = new Set<HeaderColor>(['dark', 'grey'])\n\ntype HeaderBrandProps = React.ComponentPropsWithoutRef<'div'> & {\n /** Home-page target for the brand link. Defaults to `/`. */\n href?: React.ComponentPropsWithoutRef<typeof Link>['href']\n /**\n * Service or site name shown beside the logo. Renders as a `<span>`, never a\n * heading: the brand sits in the `banner` landmark ahead of `<main>`, so any\n * heading here would land in the outline *before* the page's own `<h1>` —\n * the first heading a screen-reader user meets would be the site name\n * repeated on every page, and the outline would open at a lower level and\n * then jump up to 1. The heading that describes the page belongs to its main\n * content.\n */\n sitename?: React.ReactNode\n /**\n * Version string shown in a Badge beside the brand. Sits outside the link,\n * so it never becomes part of the home link's accessible name.\n */\n version?: React.ReactNode\n /**\n * Visually-hidden prefix announced before `version`, giving the bare number\n * context for screen readers (\"2.1.0\" → \"Version 2.1.0\"). Pass an empty\n * string to suppress.\n */\n versionLabel?: string\n /**\n * Props forwarded to the version `Badge` — `size`, `color`, `variant`,\n * `className` and the rest of its API. Use it when the badge has to meet a\n * house rule the default does not, most often a minimum type size:\n *\n * ```tsx\n * <HeaderBrand version=\"2.1.0\" badgeProps={{ size: 'lg' }} />\n * ```\n *\n * An explicit value always wins — including `color`, whose surface-aware\n * default exists to stop the badge painting itself the same colour as a dark\n * header. Overriding it is the same trade as supplying your own `logo` node:\n * the contrast is then yours to check.\n *\n * `undefined` and `null` do *not* win: they fall back to the defaults, so a\n * conditional like `{ color: cond ? 'accent' : undefined }` keeps the\n * surface-aware colour on the falsy branch rather than dropping the badge to\n * cva's own `primary` default.\n *\n * `children` is excluded — the badge's content is `version` and\n * `versionLabel`.\n */\n badgeProps?: Omit<BadgeProps, 'children'>\n /**\n * `true` (default) renders the NSW Government waratah, `false` omits it, and\n * a node replaces it — pass an agency lockup here.\n */\n logo?: boolean | React.ReactNode\n /**\n * Accessible name for the brand link. Left unset by default: the link's name\n * is then its visible content — \"NSW Government\" (from `Logo`'s\n * visually-hidden text) plus `sitename` — which keeps the visible label\n * inside the accessible name (WCAG 2.2, 2.5.3 Label in Name). Overriding it\n * with something like \"Home page\" would break that, so set it only when the\n * brand renders no text at all.\n */\n label?: string\n ref?: React.Ref<HTMLDivElement>\n}\n\n/**\n * Dev-only guard, mirroring the icon-only Button check in button.tsx: the\n * default `Logo` carries a visually-hidden \"NSW Government\", so a brand with\n * neither it nor a `sitename` renders a link with no text at all, and reaches\n * assistive tech unnamed (WCAG 2.2, 4.1.2 Name, Role, Value). A consumer's own\n * logo node is assumed to carry its own text. No-op in production.\n */\nfunction warnIfBrandUnlabelled({\n logo,\n sitename,\n label,\n}: Pick<HeaderBrandProps, 'logo' | 'sitename' | 'label'>) {\n if (process.env.NODE_ENV === 'production') {\n return\n }\n if (!logo && !sitename && !label) {\n console.warn(\n '[nswds/ui] HeaderBrand has no logo and no sitename, so its home link has no accessible name — pass `label`.',\n )\n }\n}\n\n/**\n * Logo, site name and optional version badge, linked to the home page. Sits at\n * the start of the `Header` row.\n *\n * The link renders through `Link`, so it picks up the framework link component\n * from `LinkProvider` (next/link et al) rather than hardcoding one.\n */\nfunction HeaderBrand({\n className,\n href = '/',\n sitename,\n version,\n versionLabel = 'Version',\n badgeProps,\n logo = true,\n label,\n children,\n ref,\n ...props\n}: HeaderBrandProps) {\n const color = React.useContext(HeaderColorContext)\n const onDarkSurface = DARK_SURFACE_COLORS.has(color)\n\n warnIfBrandUnlabelled({ logo, sitename, label })\n\n const logoNode =\n logo === true ? (\n // Two lockups, one shown per breakpoint. Below sm the phone has no room\n // for the full three-row mark, so it takes the compact `wordmark='nsw'`\n // lockup (waratah + \"NSW\", no \"Government\"); sm and up take the full mark.\n //\n // Each is wrapped in a span carrying the show/hide, not the Logo itself,\n // because Logo emits a visually-hidden \"NSW Government\" span beside its\n // (aria-hidden) svg. Hiding only the svg would leave that label in the\n // tree twice, so the home link's accessible name would read \"NSW\n // Government NSW Government …\". Toggling the wrapper drops the hidden\n // variant's label with it, leaving exactly one.\n //\n // The wrappers hide with a single conditional utility each (`sm:hidden` /\n // `max-sm:hidden`) rather than a `hidden`/`sm:block` pair: a bare `hidden`\n // a consumer also uses is re-emitted after ours by their own Tailwind\n // build and a media query carries no extra specificity, so the pair is\n // not cascade-safe (see AGENTS.md §4) — one conditional is.\n <>\n <span className='sm:hidden'>\n <Logo\n logoType={onDarkSurface ? 'reversed' : 'default'}\n wordmark='nsw'\n className='block h-14 w-auto'\n />\n </span>\n <span className='max-sm:hidden'>\n <Logo\n logoType={onDarkSurface ? 'reversed' : 'default'}\n // 64px from lg, 56px below it — 56px is the floor, so the lockup\n // stays legible. Written as mutually exclusive breakpoint ranges\n // rather than `h-14 lg:h-16`: a bare `h-14` a consumer also uses is\n // re-emitted after ours by their own Tailwind build, and a media\n // query adds no specificity, so it would outrank the lg step and\n // freeze the logo at 56px.\n className='block w-auto max-lg:h-14 lg:h-16'\n />\n </span>\n </>\n ) : (\n // `false` / `null` fall through as the falsy nodes they are; anything\n // else is the consumer's own lockup.\n logo\n )\n\n return (\n <div\n data-slot='header-brand'\n {...props}\n className={cn('flex grow basis-0 items-center max-sm:gap-3 sm:gap-4', className)}\n ref={ref}\n >\n {/* variant='unstyled' — a brand lockup takes no underline or link\n colour. outline-current resolves to the surface's ink on every\n variant, so the focus indicator contrasts with the header\n (WCAG 2.2, 2.4.13 Focus Appearance). The negative margin keeps the\n indicator from nudging the row. */}\n <Link\n variant='unstyled'\n href={href}\n aria-label={label}\n className='-m-1 flex items-center gap-4 rounded-sm p-1 focus-visible:outline focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-current'\n >\n {logoNode}\n {sitename ? (\n // Brand-blue ink on the light surfaces (14.4:1 on white, 13.2:1 on\n // grey-100 — both WCAG 2.2 AAA). The `dark` surface *is* primary-800\n // and `grey` is nearly as deep, so those keep the header's own white\n // ink; dark mode does the same, matching the `dark:text-white` the\n // light/white variants already set on the surface.\n <span\n className={cn(\n 'font-bold text-balance max-sm:text-lg sm:max-lg:text-xl lg:text-2xl',\n !onDarkSurface && 'text-primary-800 dark:text-white',\n )}\n >\n {sitename}\n </span>\n ) : null}\n </Link>\n {version ? (\n // Badge's `primary` ink is primary-800 — the `dark` header's own\n // surface — so dark surfaces take the white badge instead.\n <Badge\n data-slot='header-version'\n {...badgeProps}\n // Derived after the spread rather than before it. Spreading last would\n // let a key that is merely *present* win, so\n // `badgeProps={{ color: cond ? 'accent' : undefined }}` would pass\n // `undefined` through to cva, which falls back to its own\n // `defaultVariants.color` of `primary` — and primary-800 is the dark\n // header's own background, so the badge would vanish into it. `??`\n // keeps explicit values winning while undefined (and null, which\n // cva's VariantProps permits and which would otherwise render an\n // unstyled badge) falls back to the surface-aware default.\n variant={badgeProps?.variant ?? 'soft'}\n color={badgeProps?.color ?? (onDarkSurface ? 'white' : 'primary')}\n >\n {versionLabel ? <span className='sr-only'>{versionLabel} </span> : null}\n {version}\n </Badge>\n ) : null}\n {children}\n </div>\n )\n}\n\ntype HeaderActionsProps = React.ComponentPropsWithoutRef<'div'> & {\n ref?: React.Ref<HTMLDivElement>\n}\n\n/**\n * Trailing cluster of header controls — search, theme switcher, sign-in, and\n * the like. Deliberately unopinionated about what goes in it: site search and\n * theme switching are app concerns (they need routing and a theme provider),\n * so the design system supplies the slot and its spacing rather than the\n * widgets.\n *\n * Not a `nav` landmark: a row of controls is not a set of navigation links, and\n * an extra landmark on every page buries the ones that matter. Wrap genuine\n * navigation in your own `<nav>` inside `Header`.\n */\nfunction HeaderActions({ className, ref, ...props }: HeaderActionsProps) {\n return (\n <div\n data-slot='header-actions'\n {...props}\n className={cn(\n 'flex basis-0 items-center justify-end max-sm:gap-2 sm:gap-4 md:grow',\n className,\n )}\n ref={ref}\n />\n )\n}\n\ntype HeaderProps = React.ComponentPropsWithoutRef<'header'> &\n VariantProps<typeof headerVariants> &\n VariantProps<typeof headerContainerVariants> & {\n /** Stick to the top of the viewport as the page scrolls. Defaults to `true`. */\n sticky?: boolean\n /** Hairline rule along the bottom edge. Defaults to `true`. */\n border?: boolean\n /** Raise the header with a shadow once the page is scrolled. Defaults to `true`. */\n shadow?: boolean\n /** Classes applied to the inner width-constraining wrapper. */\n containerClassName?: string\n ref?: React.Ref<HTMLElement>\n }\n\n/**\n * Top-of-page `banner` landmark: brand, site name and header controls. Render\n * it once in a shared layout, below `SkipLinks` and `Masthead`.\n *\n * - `color` themes the surface; all four pairs are WCAG 2.2 AAA and follow the\n * theme in dark mode (see `headerColors`). The bottom rule derives from the\n * surface's ink, so it follows automatically.\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 `--header-max-width`\n * and `--header-padding-x` custom properties.\n * - Scroll position is tracked and exposed as `data-scrolled`, which is what\n * the `shadow` treatment keys off. Style your own scrolled state with it.\n *\n * Compose the row from `HeaderBrand` and `HeaderActions`:\n *\n * ```tsx\n * <Header>\n * <HeaderBrand sitename=\"Design System\" version=\"2.1.0\" />\n * <HeaderActions>\n * <ThemeSwitcher />\n * </HeaderActions>\n * </Header>\n * ```\n *\n * The `banner` landmark comes from the native `<header>` element, which only\n * carries it outside `article`, `aside`, `main`, `nav` and `section` — wrapping\n * `div`s are fine. Keep it out of `<main>`.\n *\n * The default `id=\"nsw-header\"` is kept for compatibility with existing shells\n * that target it (override via the `id` prop).\n */\nfunction Header({\n className,\n color,\n container,\n containerClassName,\n sticky = true,\n border = true,\n shadow = true,\n children,\n ref,\n ...props\n}: HeaderProps) {\n const [isScrolled, setIsScrolled] = React.useState(false)\n\n React.useEffect(() => {\n function onScroll() {\n setIsScrolled(window.scrollY > 0)\n }\n // Read once on mount too: a page restored mid-scroll (back/forward, or a\n // deep link to a fragment) never fires a scroll event.\n onScroll()\n window.addEventListener('scroll', onScroll, { passive: true })\n return () => window.removeEventListener('scroll', onScroll)\n }, [])\n\n return (\n <header\n id='nsw-header'\n data-slot='header'\n data-color={color ?? DEFAULT_HEADER_COLOR}\n // Present-or-absent rather than \"true\"/\"false\", so it reads like Base\n // UI's data-disabled and Tailwind's bare `data-scrolled:` variant works.\n data-scrolled={isScrolled || undefined}\n {...props}\n className={cn(\n headerVariants({ color }),\n // z-40 sits below the z-50 SkipLinks: a sticky header at the same\n // level comes later in the DOM and would paint over a focused skip\n // link, hiding the page's bypass mechanism (WCAG 2.2, 2.4.1).\n sticky && 'sticky top-0 z-40',\n // Always drawn, so the scrolled state changes no box heights.\n border && 'border-b border-(--header-border)',\n // Shadows read as elevation on light surfaces only; in dark mode the\n // rule above carries the separation.\n shadow &&\n 'data-scrolled:shadow-md data-scrolled:shadow-black/5 dark:data-scrolled:shadow-none',\n className,\n )}\n ref={ref}\n >\n <HeaderColorContext.Provider value={color ?? DEFAULT_HEADER_COLOR}>\n <div\n data-slot='header-container'\n className={cn(headerContainerVariants({ container }), containerClassName)}\n >\n {children}\n </div>\n </HeaderColorContext.Provider>\n </header>\n )\n}\n\nexport { Header, HeaderActions, HeaderBrand, headerColors, headerContainerVariants, headerVariants }\nexport type { HeaderActionsProps, HeaderBrandProps, HeaderColor, HeaderProps }\n"]}
1
+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,YAAA;AAAA,MACH,WAAA,EAAU,QAAA;AAAA,MAKV,iBAAe,UAAA,IAAc,MAAA;AAAA,MAC5B,GAAG,KAAA;AAAA,MAGJ,YAAA,EAAY,QAAA;AAAA,MACZ,SAAA,EAAW,EAAA;AAAA,QACT,cAAA,CAAe,EAAE,KAAA,EAAO,QAAA,EAAU,CAAA;AAAA;AAAA;AAAA;AAAA,QAIlC,MAAA,IAAU,mBAAA;AAAA;AAAA,QAEV,MAAA,IAAU,mCAAA;AAAA;AAAA;AAAA,QAGV,MAAA,IACE,qFAAA;AAAA,QACF;AAAA,OACF;AAAA,MACA,GAAA;AAAA,MAEA,QAAA,kBAAA,GAAA,CAAC,kBAAA,CAAmB,QAAA,EAAnB,EAA4B,OAAO,QAAA,EAClC,QAAA,kBAAA,GAAA;AAAA,QAAC,KAAA;AAAA,QAAA;AAAA,UACC,WAAA,EAAU,kBAAA;AAAA,UACV,SAAA,EAAW,GAAG,uBAAA,CAAwB,EAAE,WAAW,YAAA,EAAc,GAAG,kBAAkB,CAAA;AAAA,UAErF;AAAA;AAAA,OACH,EACF;AAAA;AAAA,GACF;AAEJ","file":"header.js","sourcesContent":["'use client'\n\nimport { 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\nimport { Badge, type BadgeProps } from '../components/badge.js'\nimport { Link } from '../components/link.js'\nimport { Logo } from '../components/logo.js'\n\n/**\n * Surface colours the header can be themed with, sharing the Masthead's and\n * SkipLink's four-name vocabulary (`dark`, `light`, `white`, `grey`) — the three\n * components stack at the top of the page and a service picks one word for the\n * whole chrome.\n *\n * Every pair is WCAG 2.2 AAA (1.4.6, 7:1), computed from the masterbrand oklch\n * tokens. Light mode: grey-800 on white 15.1:1, grey-800 on grey-100 13.8:1,\n * white on primary-800 14.4:1, white on grey-800 15.1:1. Dark mode deepens each\n * surface onto the same family's dark step and clears AAA more comfortably\n * still (17.2:1–20.2:1).\n *\n * Unlike the Masthead — a brand strip whose light/white/grey surfaces are frozen\n * across themes — the header is the page's own surface, so all four follow the\n * theme. Pair `Header color=\"dark\"` with `Masthead color=\"dark\"` when a service\n * wants the two to match in both modes.\n */\nconst headerColors = {\n // Ink values use the RAW masterbrand tokens (--grey-800) rather than\n // Tailwind's --color-* bridge aliases: Tailwind v4 tree-shakes an\n // unreferenced @theme key, and referencing one from inside an arbitrary\n // property is not a usage signal. Same reasoning as footer.tsx.\n // (--color-white is safe: `text-white` below is a real utility.)\n dark: 'bg-primary-800 text-white [--header-ink:var(--color-white)] dark:bg-primary-950',\n light:\n 'bg-grey-100 text-grey-800 [--header-ink:var(--grey-800)] dark:bg-grey-850 dark:text-white dark:[--header-ink:var(--color-white)]',\n white:\n 'bg-white text-grey-800 [--header-ink:var(--grey-800)] dark:bg-grey-900 dark:text-white dark:[--header-ink:var(--color-white)]',\n grey: 'bg-grey-800 text-white [--header-ink:var(--color-white)] dark:bg-grey-950',\n}\n\ntype HeaderColor = keyof typeof headerColors\n\n// Shared by cva's defaultVariants, the data-color attribute and the logo\n// context, so the four can't drift apart.\nconst DEFAULT_HEADER_COLOR: HeaderColor = 'white'\n// Shared by cva's defaultVariants and the `resolveVariant` call in `Header`.\nconst DEFAULT_HEADER_CONTAINER = 'fluid'\n\nconst headerVariants = cva(\n [\n 'w-full',\n // The hairline rule derives from the surface's own ink, so it follows every\n // colour variant and both themes from one value. Mirrors the color-mix\n // derivation in footer.tsx (--footer-border) and link.tsx (--link-halo).\n '[--header-border:color-mix(in_oklch,var(--header-ink)_15%,transparent)]',\n 'duration-300 motion-safe:transition-shadow',\n ],\n {\n variants: {\n color: headerColors,\n },\n defaultVariants: {\n color: DEFAULT_HEADER_COLOR,\n },\n },\n)\n\nconst headerContainerVariants = cva(\n [\n 'mx-auto flex w-full flex-wrap items-center justify-between gap-x-4 gap-y-3 max-sm:py-3 sm:max-lg:py-4 lg:py-5',\n // Lateral padding funnels through --header-padding-x so an app can retune it\n // once (via the `style` prop or a utility class) without a new variant. Same\n // mechanism, and the same 16px → 24px → 48px rhythm, as Masthead and Footer.\n 'px-(--header-padding-x)',\n '[--header-padding-x:--spacing(4)] sm:[--header-padding-x:--spacing(6)] lg:[--header-padding-x:--spacing(12)]',\n ],\n {\n variants: {\n container: {\n // Full-bleed (nswds-app parity). --header-max-width is still read so a\n // shell app can constrain the inner wrapper without switching variants.\n fluid: 'max-w-[var(--header-max-width,none)]',\n // Centred content column, legacy nsw-container parity (1200px).\n contained: 'max-w-[var(--header-max-width,75rem)]',\n },\n },\n defaultVariants: {\n container: DEFAULT_HEADER_CONTAINER,\n },\n },\n)\n\n/**\n * Lets `HeaderBrand` adapt its artwork to the surface it is drawn on — the\n * default `Logo` paints its wordmark `nsw-blue-800` and the version `Badge`\n * paints itself `primary-800`, both of which disappear on the `dark`\n * (primary-800) surface. A `logo` node supplied by the consumer overrides the\n * lockup entirely; at that point the choice is theirs.\n */\nconst HeaderColorContext = React.createContext<HeaderColor>(DEFAULT_HEADER_COLOR)\n\n/** Surfaces dark enough to need light-on-dark artwork. */\nconst DARK_SURFACE_COLORS = new Set<HeaderColor>(['dark', 'grey'])\n\ntype HeaderBrandProps = React.ComponentPropsWithoutRef<'div'> & {\n /** Home-page target for the brand link. Defaults to `/`. */\n href?: React.ComponentPropsWithoutRef<typeof Link>['href']\n /**\n * Service or site name shown beside the logo. Renders as a `<span>`, never a\n * heading: the brand sits in the `banner` landmark ahead of `<main>`, so any\n * heading here would land in the outline *before* the page's own `<h1>` —\n * the first heading a screen-reader user meets would be the site name\n * repeated on every page, and the outline would open at a lower level and\n * then jump up to 1. The heading that describes the page belongs to its main\n * content.\n */\n sitename?: React.ReactNode\n /**\n * Version string shown in a Badge beside the brand. Sits outside the link,\n * so it never becomes part of the home link's accessible name.\n */\n version?: React.ReactNode\n /**\n * Visually-hidden prefix announced before `version`, giving the bare number\n * context for screen readers (\"2.1.0\" → \"Version 2.1.0\"). Pass an empty\n * string to suppress.\n */\n versionLabel?: string\n /**\n * Props forwarded to the version `Badge` — `size`, `color`, `variant`,\n * `className` and the rest of its API. Use it when the badge has to meet a\n * house rule the default does not, most often a minimum type size:\n *\n * ```tsx\n * <HeaderBrand version=\"2.1.0\" badgeProps={{ size: 'lg' }} />\n * ```\n *\n * An explicit value always wins — including `color`, whose surface-aware\n * default exists to stop the badge painting itself the same colour as a dark\n * header. Overriding it is the same trade as supplying your own `logo` node:\n * the contrast is then yours to check.\n *\n * `undefined` and `null` do *not* win: they fall back to the defaults, so a\n * conditional like `{ color: cond ? 'accent' : undefined }` keeps the\n * surface-aware colour on the falsy branch rather than dropping the badge to\n * cva's own `primary` default.\n *\n * `children` is excluded — the badge's content is `version` and\n * `versionLabel`.\n */\n badgeProps?: Omit<BadgeProps, 'children'>\n /**\n * `true` (default) renders the NSW Government waratah, `false` omits it, and\n * a node replaces it — pass an agency lockup here.\n */\n logo?: boolean | React.ReactNode\n /**\n * Accessible name for the brand link. Left unset by default: the link's name\n * is then its visible content — \"NSW Government\" (from `Logo`'s\n * visually-hidden text) plus `sitename` — which keeps the visible label\n * inside the accessible name (WCAG 2.2, 2.5.3 Label in Name). Overriding it\n * with something like \"Home page\" would break that, so set it only when the\n * brand renders no text at all.\n */\n label?: string\n ref?: React.Ref<HTMLDivElement>\n}\n\n/**\n * Dev-only guard, mirroring the icon-only Button check in button.tsx: the\n * default `Logo` carries a visually-hidden \"NSW Government\", so a brand with\n * neither it nor a `sitename` renders a link with no text at all, and reaches\n * assistive tech unnamed (WCAG 2.2, 4.1.2 Name, Role, Value). A consumer's own\n * logo node is assumed to carry its own text. No-op in production.\n */\nfunction warnIfBrandUnlabelled({\n logo,\n sitename,\n label,\n}: Pick<HeaderBrandProps, 'logo' | 'sitename' | 'label'>) {\n if (process.env.NODE_ENV === 'production') {\n return\n }\n if (!logo && !sitename && !label) {\n console.warn(\n '[nswds/ui] HeaderBrand has no logo and no sitename, so its home link has no accessible name — pass `label`.',\n )\n }\n}\n\n/**\n * Logo, site name and optional version badge, linked to the home page. Sits at\n * the start of the `Header` row.\n *\n * The link renders through `Link`, so it picks up the framework link component\n * from `LinkProvider` (next/link et al) rather than hardcoding one.\n */\nfunction HeaderBrand({\n className,\n href = '/',\n sitename,\n version,\n versionLabel = 'Version',\n badgeProps,\n logo = true,\n label,\n children,\n ref,\n ...props\n}: HeaderBrandProps) {\n const color = React.useContext(HeaderColorContext)\n const onDarkSurface = DARK_SURFACE_COLORS.has(color)\n\n warnIfBrandUnlabelled({ logo, sitename, label })\n\n const logoNode =\n logo === true ? (\n // Two lockups, one shown per breakpoint. Below sm the phone has no room\n // for the full three-row mark, so it takes the compact `wordmark='nsw'`\n // lockup (waratah + \"NSW\", no \"Government\"); sm and up take the full mark.\n //\n // Each is wrapped in a span carrying the show/hide, not the Logo itself,\n // because Logo emits a visually-hidden \"NSW Government\" span beside its\n // (aria-hidden) svg. Hiding only the svg would leave that label in the\n // tree twice, so the home link's accessible name would read \"NSW\n // Government NSW Government …\". Toggling the wrapper drops the hidden\n // variant's label with it, leaving exactly one.\n //\n // The wrappers hide with a single conditional utility each (`sm:hidden` /\n // `max-sm:hidden`) rather than a `hidden`/`sm:block` pair: a bare `hidden`\n // a consumer also uses is re-emitted after ours by their own Tailwind\n // build and a media query carries no extra specificity, so the pair is\n // not cascade-safe (see AGENTS.md §4) — one conditional is.\n <>\n <span className='sm:hidden'>\n <Logo\n logoType={onDarkSurface ? 'reversed' : 'default'}\n wordmark='nsw'\n className='block h-14 w-auto'\n />\n </span>\n <span className='max-sm:hidden'>\n <Logo\n logoType={onDarkSurface ? 'reversed' : 'default'}\n // 64px from lg, 56px below it — 56px is the floor, so the lockup\n // stays legible. Written as mutually exclusive breakpoint ranges\n // rather than `h-14 lg:h-16`: a bare `h-14` a consumer also uses is\n // re-emitted after ours by their own Tailwind build, and a media\n // query adds no specificity, so it would outrank the lg step and\n // freeze the logo at 56px.\n className='block w-auto max-lg:h-14 lg:h-16'\n />\n </span>\n </>\n ) : (\n // `false` / `null` fall through as the falsy nodes they are; anything\n // else is the consumer's own lockup.\n logo\n )\n\n return (\n <div\n data-slot='header-brand'\n {...props}\n className={cn('flex grow basis-0 items-center max-sm:gap-3 sm:gap-4', className)}\n ref={ref}\n >\n {/* variant='unstyled' — a brand lockup takes no underline or link\n colour. outline-current resolves to the surface's ink on every\n variant, so the focus indicator contrasts with the header\n (WCAG 2.2, 2.4.13 Focus Appearance). The negative margin keeps the\n indicator from nudging the row. */}\n <Link\n variant='unstyled'\n href={href}\n aria-label={label}\n className='-m-1 flex items-center gap-4 rounded-sm p-1 focus-visible:outline focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-current'\n >\n {logoNode}\n {sitename ? (\n // Brand-blue ink on the light surfaces (14.4:1 on white, 13.2:1 on\n // grey-100 — both WCAG 2.2 AAA). The `dark` surface *is* primary-800\n // and `grey` is nearly as deep, so those keep the header's own white\n // ink; dark mode does the same, matching the `dark:text-white` the\n // light/white variants already set on the surface.\n <span\n className={cn(\n 'font-bold text-balance max-sm:text-lg sm:max-lg:text-xl lg:text-2xl',\n !onDarkSurface && 'text-primary-800 dark:text-white',\n )}\n >\n {sitename}\n </span>\n ) : null}\n </Link>\n {version ? (\n // Badge's `primary` ink is primary-800 — the `dark` header's own\n // surface — so dark surfaces take the white badge instead.\n <Badge\n data-slot='header-version'\n {...badgeProps}\n // Derived after the spread rather than before it. Spreading last would\n // let a key that is merely *present* win, so\n // `badgeProps={{ color: cond ? 'accent' : undefined }}` would pass\n // `undefined` through to cva, which falls back to its own\n // `defaultVariants.color` of `primary` — and primary-800 is the dark\n // header's own background, so the badge would vanish into it. `??`\n // keeps explicit values winning while undefined (and null, which\n // cva's VariantProps permits and which would otherwise render an\n // unstyled badge) falls back to the surface-aware default.\n variant={badgeProps?.variant ?? 'soft'}\n color={badgeProps?.color ?? (onDarkSurface ? 'white' : 'primary')}\n >\n {versionLabel ? <span className='sr-only'>{versionLabel} </span> : null}\n {version}\n </Badge>\n ) : null}\n {children}\n </div>\n )\n}\n\ntype HeaderActionsProps = React.ComponentPropsWithoutRef<'div'> & {\n ref?: React.Ref<HTMLDivElement>\n}\n\n/**\n * Trailing cluster of header controls — search, theme switcher, sign-in, and\n * the like. Deliberately unopinionated about what goes in it: site search and\n * theme switching are app concerns (they need routing and a theme provider),\n * so the design system supplies the slot and its spacing rather than the\n * widgets.\n *\n * Not a `nav` landmark: a row of controls is not a set of navigation links, and\n * an extra landmark on every page buries the ones that matter. Wrap genuine\n * navigation in your own `<nav>` inside `Header`.\n */\nfunction HeaderActions({ className, ref, ...props }: HeaderActionsProps) {\n return (\n <div\n data-slot='header-actions'\n {...props}\n className={cn(\n 'flex basis-0 items-center justify-end max-sm:gap-2 sm:gap-4 md:grow',\n className,\n )}\n ref={ref}\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 HeaderProps = Omit<React.ComponentPropsWithoutRef<'header'>, 'color'> &\n VariantProps<typeof headerVariants> &\n VariantProps<typeof headerContainerVariants> & {\n /** Stick to the top of the viewport as the page scrolls. Defaults to `true`. */\n sticky?: boolean\n /** Hairline rule along the bottom edge. Defaults to `true`. */\n border?: boolean\n /** Raise the header with a shadow once the page is scrolled. Defaults to `true`. */\n shadow?: boolean\n /** Classes applied to the inner width-constraining wrapper. */\n containerClassName?: string\n ref?: React.Ref<HTMLElement>\n }\n\n/**\n * Top-of-page `banner` landmark: brand, site name and header controls. Render\n * it once in a shared layout, below `SkipLinks` and `Masthead`.\n *\n * - `color` themes the surface; all four pairs are WCAG 2.2 AAA and follow the\n * theme in dark mode (see `headerColors`). The bottom rule derives from the\n * surface's ink, so it follows automatically.\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 `--header-max-width`\n * and `--header-padding-x` custom properties.\n * - Scroll position is tracked and exposed as `data-scrolled`, which is what\n * the `shadow` treatment keys off. Style your own scrolled state with it.\n *\n * Compose the row from `HeaderBrand` and `HeaderActions`:\n *\n * ```tsx\n * <Header>\n * <HeaderBrand sitename=\"Design System\" version=\"2.1.0\" />\n * <HeaderActions>\n * <ThemeSwitcher />\n * </HeaderActions>\n * </Header>\n * ```\n *\n * The `banner` landmark comes from the native `<header>` element, which only\n * carries it outside `article`, `aside`, `main`, `nav` and `section` — wrapping\n * `div`s are fine. Keep it out of `<main>`.\n *\n * The default `id=\"nsw-header\"` is kept for compatibility with existing shells\n * that target it (override via the `id` prop).\n */\nfunction Header({\n className,\n color,\n container,\n containerClassName,\n sticky = true,\n border = true,\n shadow = true,\n children,\n ref,\n ...props\n}: HeaderProps) {\n const [isScrolled, setIsScrolled] = React.useState(false)\n\n React.useEffect(() => {\n function onScroll() {\n setIsScrolled(window.scrollY > 0)\n }\n // Read once on mount too: a page restored mid-scroll (back/forward, or a\n // deep link to a fragment) never fires a scroll event.\n onScroll()\n window.addEventListener('scroll', onScroll, { passive: true })\n return () => window.removeEventListener('scroll', onScroll)\n }, [])\n\n // Resolved once (see `resolveVariant`), so cva, `data-color` and the colour\n // context 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 // `--header-max-width`, instead of dropping it.\n const colorway = resolveVariant(color, DEFAULT_HEADER_COLOR)\n const containerway = resolveVariant(container, DEFAULT_HEADER_CONTAINER)\n\n return (\n <header\n id='nsw-header'\n data-slot='header'\n // Present-or-absent rather than \"true\"/\"false\", so it reads like Base\n // UI's data-disabled and Tailwind's bare `data-scrolled:` variant works.\n // Before the spread on purpose: it is state, not a variant, and the\n // docs pin it on (`data-scrolled=''`) to show the scrolled treatment.\n data-scrolled={isScrolled || undefined}\n {...props}\n // After the spread, so a consumer's own `data-color` cannot desync the\n // attribute from the classes both derive from the resolved value.\n data-color={colorway}\n className={cn(\n headerVariants({ color: colorway }),\n // z-40 sits below the z-50 SkipLinks: a sticky header at the same\n // level comes later in the DOM and would paint over a focused skip\n // link, hiding the page's bypass mechanism (WCAG 2.2, 2.4.1).\n sticky && 'sticky top-0 z-40',\n // Always drawn, so the scrolled state changes no box heights.\n border && 'border-b border-(--header-border)',\n // Shadows read as elevation on light surfaces only; in dark mode the\n // rule above carries the separation.\n shadow &&\n 'data-scrolled:shadow-md data-scrolled:shadow-black/5 dark:data-scrolled:shadow-none',\n className,\n )}\n ref={ref}\n >\n <HeaderColorContext.Provider value={colorway}>\n <div\n data-slot='header-container'\n className={cn(headerContainerVariants({ container: containerway }), containerClassName)}\n >\n {children}\n </div>\n </HeaderColorContext.Provider>\n </header>\n )\n}\n\nexport { Header, HeaderActions, HeaderBrand, headerColors, headerContainerVariants, headerVariants }\nexport type { HeaderActionsProps, HeaderBrandProps, HeaderColor, HeaderProps }\n"]}
@@ -41,7 +41,7 @@ declare const heroInnerVariants: (props?: ({
41
41
  layout?: "split" | "stack" | null | undefined;
42
42
  container?: "fluid" | "contained" | null | undefined;
43
43
  } & class_variance_authority_types.ClassProp) | undefined) => string;
44
- type HeroProps = React.ComponentPropsWithoutRef<'section'> & VariantProps<typeof heroVariants> & VariantProps<typeof heroInnerVariants> & {
44
+ type HeroProps = Omit<React.ComponentPropsWithoutRef<'section'>, 'color'> & VariantProps<typeof heroVariants> & VariantProps<typeof heroInnerVariants> & {
45
45
  /**
46
46
  * Where the text sits. `centre` centres the content column and its
47
47
  * title, description and actions — the opener of a landing page.
@@ -138,7 +138,7 @@ declare function HeroRule({ className, ref, ...props }: HeroRuleProps): React.JS
138
138
  * plain `<img>` or their framework's image component.
139
139
  */
140
140
  declare const heroMediaVariants: (props?: ({
141
- fit?: "band" | "bleed" | "framed" | "rise" | null | undefined;
141
+ fit?: "band" | "framed" | "bleed" | "rise" | null | undefined;
142
142
  } & class_variance_authority_types.ClassProp) | undefined) => string;
143
143
  type HeroMediaProps = React.ComponentPropsWithoutRef<'div'> & VariantProps<typeof heroMediaVariants> & {
144
144
  ref?: React.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 heroColors = {
@@ -29,6 +30,9 @@ const heroColors = {
29
30
  ].join(" ")
30
31
  };
31
32
  const DEFAULT_HERO_COLOR = "white";
33
+ const DEFAULT_HERO_LAYOUT = "split";
34
+ const DEFAULT_HERO_CONTAINER = "fluid";
35
+ const DEFAULT_HERO_FIT = "framed";
32
36
  const heroVariants = cva("group/hero w-full text-(--hero-ink)", {
33
37
  variants: {
34
38
  color: heroColors
@@ -62,8 +66,8 @@ const heroInnerVariants = cva(
62
66
  }
63
67
  },
64
68
  defaultVariants: {
65
- layout: "split",
66
- container: "fluid"
69
+ layout: DEFAULT_HERO_LAYOUT,
70
+ container: DEFAULT_HERO_CONTAINER
67
71
  }
68
72
  }
69
73
  );
@@ -79,22 +83,28 @@ function Hero({
79
83
  children,
80
84
  ...props
81
85
  }) {
86
+ const colorway = resolveVariant(color, DEFAULT_HERO_COLOR);
87
+ const layoutway = resolveVariant(layout, DEFAULT_HERO_LAYOUT);
88
+ const containerway = resolveVariant(container, DEFAULT_HERO_CONTAINER);
82
89
  return /* @__PURE__ */ jsx(
83
90
  "section",
84
91
  {
85
92
  ref,
86
93
  "data-slot": "hero",
87
- "data-color": color ?? DEFAULT_HERO_COLOR,
88
- "data-layout": layout ?? "split",
89
- "data-align": align,
90
94
  "aria-labelledby": labelledBy,
91
- className: cn(heroVariants({ color, className })),
92
95
  ...props,
96
+ "data-color": colorway,
97
+ "data-layout": layoutway,
98
+ "data-align": align,
99
+ className: cn(heroVariants({ color: colorway, className })),
93
100
  children: /* @__PURE__ */ jsx(
94
101
  "div",
95
102
  {
96
103
  "data-slot": "hero-inner",
97
- className: cn(heroInnerVariants({ layout, container }), innerClassName),
104
+ className: cn(
105
+ heroInnerVariants({ layout: layoutway, container: containerway }),
106
+ innerClassName
107
+ ),
98
108
  children
99
109
  }
100
110
  )
@@ -205,19 +215,20 @@ const heroMediaVariants = cva(
205
215
  }
206
216
  },
207
217
  defaultVariants: {
208
- fit: "framed"
218
+ fit: DEFAULT_HERO_FIT
209
219
  }
210
220
  }
211
221
  );
212
222
  function HeroMedia({ className, fit, ref, ...props }) {
223
+ const fitway = resolveVariant(fit, DEFAULT_HERO_FIT);
213
224
  return /* @__PURE__ */ jsx(
214
225
  "div",
215
226
  {
216
227
  ref,
217
228
  "data-slot": "hero-media",
218
- "data-fit": fit ?? "framed",
219
- className: cn(heroMediaVariants({ fit, className })),
220
- ...props
229
+ ...props,
230
+ "data-fit": fitway,
231
+ className: cn(heroMediaVariants({ fit: fitway, className }))
221
232
  }
222
233
  );
223
234
  }
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/components/hero.tsx"],"names":[],"mappings":";;;;AAqBA,MAAM,UAAA,GAAa;AAAA;AAAA;AAAA,EAGjB,IAAA,EAAM;AAAA,IACJ,+CAAA;AAAA,IACA;AAAA,GACF,CAAE,KAAK,GAAG,CAAA;AAAA,EACV,KAAA,EAAO;AAAA,IACL,4DAAA;AAAA,IACA,mGAAA;AAAA,IACA;AAAA,GACF,CAAE,KAAK,GAAG,CAAA;AAAA,EACV,KAAA,EAAO;AAAA,IACL,yDAAA;AAAA,IACA,mGAAA;AAAA,IACA;AAAA,GACF,CAAE,KAAK,GAAG,CAAA;AAAA;AAAA;AAAA;AAAA,EAIV,IAAA,EAAM;AAAA,IACJ,kEAAA;AAAA,IACA,iGAAA;AAAA,IACA;AAAA,GACF,CAAE,KAAK,GAAG;AACZ;AAIA,MAAM,kBAAA,GAAgC,OAAA;AAEtC,MAAM,YAAA,GAAe,IAAI,qCAAA,EAAuC;AAAA,EAC9D,QAAA,EAAU;AAAA,IACR,KAAA,EAAO;AAAA,GACT;AAAA,EACA,eAAA,EAAiB;AAAA,IACf,KAAA,EAAO;AAAA;AAEX,CAAC;AAYD,MAAM,iBAAA,GAAoB,GAAA;AAAA,EACxB;AAAA,IACE,g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C,GAAG;AAAA;AAAA,GACN;AAEJ;AAWA,SAAS,SAAS,EAAE,SAAA,EAAW,GAAA,EAAK,GAAG,OAAM,EAAkB;AAC7D,EAAA,uBACE,GAAA;AAAA,IAAC,KAAA;AAAA,IAAA;AAAA,MACC,GAAA;AAAA,MACA,aAAA,EAAY,MAAA;AAAA,MACZ,WAAA,EAAU,WAAA;AAAA,MACV,SAAA,EAAW,EAAA,CAAG,kCAAA,EAAoC,SAAS,CAAA;AAAA,MAC1D,GAAG;AAAA;AAAA,GACN;AAEJ;AAOA,MAAM,iBAAA,GAAoB,GAAA;AAAA,EACxB,4FAAA;AAAA,EACA;AAAA,IACE,QAAA,EAAU;AAAA,MACR,GAAA,EAAK;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,QAQH,KAAA,EACE,qFAAA;AAAA;AAAA,QAEF,MAAA,EAAQ,wEAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,QAMR,IAAA,EAAM,kCAAA;AAAA;AAAA;AAAA;AAAA;AAAA,QAKN,IAAA,EAAM;AAAA;AACR,KACF;AAAA,IACA,eAAA,EAAiB;AAAA,MACf,GAAA,EAAK;AAAA;AACP;AAEJ;AAYA,SAAS,UAAU,EAAE,SAAA,EAAW,KAAK,GAAA,EAAK,GAAG,OAAM,EAAmB;AACpE,EAAA,uBACE,GAAA;AAAA,IAAC,KAAA;AAAA,IAAA;AAAA,MACC,GAAA;AAAA,MACA,WAAA,EAAU,YAAA;AAAA,MACV,YAAU,GAAA,IAAO,QAAA;AAAA,MACjB,WAAW,EAAA,CAAG,iBAAA,CAAkB,EAAE,GAAA,EAAK,SAAA,EAAW,CAAC,CAAA;AAAA,MAClD,GAAG;AAAA;AAAA,GACN;AAEJ","file":"hero.js","sourcesContent":["import type * as React from 'react'\n\nimport { cva, type VariantProps } from 'class-variance-authority'\n\nimport { cn } from '../lib/utils.js'\n\n/**\n * Surface colours a hero can be drawn on, in the Header's and Masthead's\n * four-name vocabulary plus `tint`, the pale brand panel a landing page uses\n * to mark its opening off from a white body.\n *\n * Each surface sets three inks the slots read: `--hero-heading` (the title),\n * `--hero-ink` (body text and anything a consumer adds) and `--hero-muted`\n * (the description). On the light surfaces the heading is the brand navy and\n * the description the muted role token, both of which flip for dark mode on\n * their own; on `dark` everything is white, because white on `primary-800` is\n * the one pairing that clears WCAG 2.2 AAA (14.4:1) and a muted white would\n * not. Dark mode deepens each surface onto its family's dark step, on the\n * same ramp Header uses (`-800 → -950`, white → `grey-900`, `-100 → -850`), so\n * a hero under a themed header never draws a seam.\n */\nconst heroColors = {\n // The brand band, as Header's `dark`: primary-800 with white text,\n // deepening to primary-950 in dark mode (AGENTS.md §3, recorded exception).\n dark: [\n 'bg-primary-800 text-white dark:bg-primary-950',\n '[--hero-ink:var(--color-white)] [--hero-heading:var(--color-white)] [--hero-muted:var(--color-white)]',\n ].join(' '),\n light: [\n 'bg-grey-100 text-grey-800 dark:bg-grey-850 dark:text-white',\n '[--hero-ink:var(--grey-800)] [--hero-heading:var(--primary-800)] [--hero-muted:var(--text-muted)]',\n 'dark:[--hero-ink:var(--color-white)] dark:[--hero-heading:var(--color-white)] dark:[--hero-muted:var(--color-white)]',\n ].join(' '),\n white: [\n 'bg-white text-grey-800 dark:bg-grey-900 dark:text-white',\n '[--hero-ink:var(--grey-800)] [--hero-heading:var(--primary-800)] [--hero-muted:var(--text-muted)]',\n 'dark:[--hero-ink:var(--color-white)] dark:[--hero-heading:var(--color-white)] dark:[--hero-muted:var(--color-white)]',\n ].join(' '),\n // The pale brand panel. primary-200 is the masterbrand's light blue; in dark\n // mode it deepens to primary-900, one step short of the `dark` surface's\n // dark step so the two stay distinguishable when stacked.\n tint: [\n 'bg-primary-200 text-grey-800 dark:bg-primary-900 dark:text-white',\n '[--hero-ink:var(--grey-800)] [--hero-heading:var(--primary-800)] [--hero-muted:var(--grey-800)]',\n 'dark:[--hero-ink:var(--color-white)] dark:[--hero-heading:var(--color-white)] dark:[--hero-muted:var(--color-white)]',\n ].join(' '),\n}\n\ntype HeroColor = keyof typeof heroColors\n\nconst DEFAULT_HERO_COLOR: HeroColor = 'white'\n\nconst heroVariants = cva('group/hero w-full text-(--hero-ink)', {\n variants: {\n color: heroColors,\n },\n defaultVariants: {\n color: DEFAULT_HERO_COLOR,\n },\n})\n\n/**\n * The inner column, carrying the same lateral rhythm as `Container` and the\n * chrome components (16px → 24px → 48px, funnelled through\n * `--hero-padding-x`), so a hero's text lines up with the header above it.\n * The media slots read the same custom property to bleed back out to the\n * edge, which is why it is a property and not a bare padding utility.\n *\n * Vertical rhythm lives on `HeroContent`, not here: a `bleed` image fills the\n * full height of the band, so the band itself cannot carry padding.\n */\nconst heroInnerVariants = cva(\n [\n 'mx-auto w-full',\n 'px-(--hero-padding-x)',\n '[--hero-padding-x:--spacing(4)] sm:[--hero-padding-x:--spacing(6)] lg:[--hero-padding-x:--spacing(12)]',\n ],\n {\n variants: {\n layout: {\n // Content beside media from `lg:`, stacked (content first) below it.\n split: 'grid max-lg:grid-cols-1 lg:grid-cols-2 lg:items-stretch lg:gap-x-16',\n // Content over media, each full width. Also the layout for a hero\n // with no media at all.\n stack: 'flex flex-col',\n },\n container: {\n // Full-bleed, matching the chrome's default. `--hero-max-width` is\n // still read so a shell app can constrain the column without\n // switching variants.\n fluid: 'max-w-[var(--hero-max-width,none)]',\n // Centred content column, legacy nsw-container parity (1200px).\n contained: 'max-w-[var(--hero-max-width,75rem)]',\n },\n },\n defaultVariants: {\n layout: 'split',\n container: 'fluid',\n },\n },\n)\n\ntype HeroProps = React.ComponentPropsWithoutRef<'section'> &\n VariantProps<typeof heroVariants> &\n VariantProps<typeof heroInnerVariants> & {\n /**\n * Where the text sits. `centre` centres the content column and its\n * title, description and actions — the opener of a landing page.\n * `start` is the default, for a hero that reads on from the header.\n */\n align?: 'start' | 'centre'\n /**\n * `id` of the `HeroTitle`. Names the section so it is exposed as a\n * `region` landmark; as with `Section`, no fallback name is 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 band of a page: a title, a short description, up to two\n * actions, and optionally one illustration.\n *\n * Compose it from its slots — `HeroContent` holding `HeroTitle`,\n * `HeroDescription` and `HeroActions`, with an optional `HeroRule` above the\n * title and an optional `HeroMedia` beside or beneath the content:\n *\n * ```tsx\n * <Hero color='dark' layout='split' labelledBy='hero-title'>\n * <HeroContent>\n * <HeroTitle id='hero-title'>Made to send.</HeroTitle>\n * <HeroDescription>Reusable components for NSW Government email.</HeroDescription>\n * <HeroActions>\n * <ButtonLink href='/start' color='white'>Get started</ButtonLink>\n * </HeroActions>\n * </HeroContent>\n * <HeroMedia fit='bleed'>\n * <img src='/illustration.png' alt='' />\n * </HeroMedia>\n * </Hero>\n * ```\n *\n * The five registry blocks (`hero-split`, `hero-framed`, `hero-panel`,\n * `hero-centred`, `hero-statement`) are worked examples of the combinations\n * the NSW Design System recommends; copy one and adapt it.\n */\nfunction Hero({\n className,\n innerClassName,\n color,\n layout,\n container,\n align = 'start',\n labelledBy,\n ref,\n children,\n ...props\n}: HeroProps) {\n return (\n <section\n ref={ref}\n data-slot='hero'\n data-color={color ?? DEFAULT_HERO_COLOR}\n data-layout={layout ?? 'split'}\n data-align={align}\n aria-labelledby={labelledBy}\n className={cn(heroVariants({ color, className }))}\n {...props}\n >\n <div\n data-slot='hero-inner'\n className={cn(heroInnerVariants({ layout, container }), innerClassName)}\n >\n {children}\n </div>\n </section>\n )\n}\n\ntype HeroContentProps = React.ComponentPropsWithoutRef<'div'> & {\n ref?: React.Ref<HTMLDivElement>\n}\n\n/**\n * The text column: title, description and actions, vertically centred\n * against the media beside it and carrying the hero's vertical rhythm.\n */\nfunction HeroContent({ className, ref, ...props }: HeroContentProps) {\n return (\n <div\n ref={ref}\n data-slot='hero-content'\n className={cn(\n 'flex flex-col justify-center gap-6',\n // The band's vertical rhythm, one step tighter than Section's so a\n // hero does not push the page's first content below the fold.\n 'max-sm:py-14 sm:max-lg:py-16 lg:py-24',\n // Centred alignment, driven by the hero's data-align so a consumer\n // sets it once.\n 'group-data-[align=centre]/hero:mx-auto group-data-[align=centre]/hero:max-w-4xl group-data-[align=centre]/hero:items-center group-data-[align=centre]/hero:text-center',\n className,\n )}\n {...props}\n />\n )\n}\n\ntype HeroTitleProps = React.ComponentPropsWithoutRef<'h1'> & {\n /**\n * The heading element. `1` by default, because a hero opens the page and\n * its title is the page's title; `2` for a hero that opens a section of a\n * page whose `h1` sits elsewhere, so the outline stays in order (WCAG\n * 1.3.1).\n */\n headingLevel?: 1 | 2\n ref?: React.Ref<HTMLHeadingElement>\n}\n\n/**\n * The headline. Semibold rather than bold, at 60px from `lg:`, with the\n * tracking the masterbrand's display setting asks for. Sentence case — the\n * brand sets nothing in uppercase.\n */\nfunction HeroTitle({ className, headingLevel = 1, ref, ...props }: HeroTitleProps) {\n const Heading = `h${headingLevel}` as const\n return (\n <Heading\n ref={ref}\n data-slot='hero-title'\n className={cn(\n 'max-w-[20ch] font-semibold tracking-tight text-balance text-(--hero-heading)',\n 'max-sm:text-4xl sm:max-lg:text-5xl lg:text-6xl',\n 'max-sm:leading-tight sm:leading-none',\n className,\n )}\n {...props}\n />\n )\n}\n\ntype HeroDescriptionProps = React.ComponentPropsWithoutRef<'p'> & {\n ref?: React.Ref<HTMLParagraphElement>\n}\n\n/** One or two sentences under the title, at the reading measure. */\nfunction HeroDescription({ className, ref, ...props }: HeroDescriptionProps) {\n return (\n <p\n ref={ref}\n data-slot='hero-description'\n className={cn('max-w-prose text-lg leading-8 text-pretty text-(--hero-muted)', className)}\n {...props}\n />\n )\n}\n\ntype HeroActionsProps = React.ComponentPropsWithoutRef<'div'> & {\n ref?: React.Ref<HTMLDivElement>\n}\n\n/**\n * The row of actions. One or two `ButtonLink`s: the first solid, the second\n * outline. On the `dark` surface give them `color='white'`; elsewhere\n * `primary` (see the note on Button's `color`).\n */\nfunction HeroActions({ className, ref, ...props }: HeroActionsProps) {\n return (\n <div\n ref={ref}\n data-slot='hero-actions'\n className={cn(\n 'flex flex-wrap gap-3 pt-3',\n 'group-data-[align=centre]/hero:justify-center',\n className,\n )}\n {...props}\n />\n )\n}\n\ntype HeroRuleProps = React.ComponentPropsWithoutRef<'div'> & {\n ref?: React.Ref<HTMLDivElement>\n}\n\n/**\n * A short accent rule above the title, for a hero that carries no\n * illustration and wants one mark of the brand colour. Decorative, so it is\n * hidden from assistive technology.\n */\nfunction HeroRule({ className, ref, ...props }: HeroRuleProps) {\n return (\n <div\n ref={ref}\n aria-hidden='true'\n data-slot='hero-rule'\n className={cn('h-1.5 w-16 rounded-sm bg-primary', className)}\n {...props}\n />\n )\n}\n\n/**\n * How the illustration sits against the content. Every fit sizes the image\n * it wraps to fill the slot and crop (`object-cover`), so a consumer passes a\n * plain `<img>` or their framework's image component.\n */\nconst heroMediaVariants = cva(\n 'relative overflow-hidden *:size-full *:object-cover [&_img]:size-full [&_img]:object-cover',\n {\n variants: {\n fit: {\n /**\n * Flush to the band's edge, filling its full height — the opener of\n * email.digital.nsw.gov.au. Reads `--hero-padding-x` back out to the\n * edge on the media side (and both sides when stacked on a phone).\n * With `container='contained'` it reaches the column's edge, not the\n * viewport's.\n */\n bleed:\n 'max-lg:-mx-(--hero-padding-x) max-lg:aspect-3/2 lg:-mr-(--hero-padding-x) lg:h-full',\n /** A rounded picture beside the content, vertically centred. */\n framed: 'aspect-3/2 self-center rounded-md max-sm:mb-14 sm:max-lg:mb-16 lg:mb-0',\n /**\n * Rising from the bottom edge of the band with its top corners\n * rounded, as though the page's first card had been pulled up into\n * the hero. Pair with `color='tint'`.\n */\n rise: 'aspect-4/3 self-end rounded-t-md',\n /**\n * A shallow full-width strip beneath the content, for `layout='stack'`.\n * Reads `--hero-padding-x` back out to the edge on both sides.\n */\n band: '-mx-(--hero-padding-x) max-sm:h-48 sm:max-lg:h-64 lg:h-80',\n },\n },\n defaultVariants: {\n fit: 'framed',\n },\n },\n)\n\ntype HeroMediaProps = React.ComponentPropsWithoutRef<'div'> &\n VariantProps<typeof heroMediaVariants> & {\n ref?: React.Ref<HTMLDivElement>\n }\n\n/**\n * The illustration slot. Wraps one image; the `fit` decides how it sits.\n * The image's `alt` is the consumer's: empty when the picture decorates the\n * title, descriptive when it carries meaning the text does not.\n */\nfunction HeroMedia({ className, fit, ref, ...props }: HeroMediaProps) {\n return (\n <div\n ref={ref}\n data-slot='hero-media'\n data-fit={fit ?? 'framed'}\n className={cn(heroMediaVariants({ fit, className }))}\n {...props}\n />\n )\n}\n\nexport {\n Hero,\n HeroActions,\n heroColors,\n HeroContent,\n HeroDescription,\n heroInnerVariants,\n HeroMedia,\n heroMediaVariants,\n HeroRule,\n HeroTitle,\n heroVariants,\n}\nexport type {\n HeroActionsProps,\n HeroColor,\n HeroContentProps,\n HeroDescriptionProps,\n HeroMediaProps,\n HeroProps,\n HeroRuleProps,\n HeroTitleProps,\n}\n"]}
1
+ {"version":3,"sources":["../../src/components/hero.tsx"],"names":[],"mappings":";;;;;AAsBA,MAAM,UAAA,GAAa;AAAA;AAAA;AAAA,EAGjB,IAAA,EAAM;AAAA,IACJ,+CAAA;AAAA,IACA;AAAA,GACF,CAAE,KAAK,GAAG,CAAA;AAAA,EACV,KAAA,EAAO;AAAA,IACL,4DAAA;AAAA,IACA,mGAAA;AAAA,IACA;AAAA,GACF,CAAE,KAAK,GAAG,CAAA;AAAA,EACV,KAAA,EAAO;AAAA,IACL,yDAAA;AAAA,IACA,mGAAA;AAAA,IACA;AAAA,GACF,CAAE,KAAK,GAAG,CAAA;AAAA;AAAA;AAAA;AAAA,EAIV,IAAA,EAAM;AAAA,IACJ,kEAAA;AAAA,IACA,iGAAA;AAAA,IACA;AAAA,GACF,CAAE,KAAK,GAAG;AACZ;AAIA,MAAM,kBAAA,GAAgC,OAAA;AAItC,MAAM,mBAAA,GAAsB,OAAA;AAC5B,MAAM,sBAAA,GAAyB,OAAA;AAC/B,MAAM,gBAAA,GAAmB,QAAA;AAEzB,MAAM,YAAA,GAAe,IA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,EAAK,GAAG,OAAM,EAAmB;AAEpE,EAAA,MAAM,MAAA,GAAS,cAAA,CAAe,GAAA,EAAK,gBAAgB,CAAA;AACnD,EAAA,uBACE,GAAA;AAAA,IAAC,KAAA;AAAA,IAAA;AAAA,MACC,GAAA;AAAA,MACA,WAAA,EAAU,YAAA;AAAA,MACT,GAAG,KAAA;AAAA,MACJ,UAAA,EAAU,MAAA;AAAA,MACV,SAAA,EAAW,GAAG,iBAAA,CAAkB,EAAE,KAAK,MAAA,EAAQ,SAAA,EAAW,CAAC;AAAA;AAAA,GAC7D;AAEJ","file":"hero.js","sourcesContent":["import type * as React from 'react'\n\nimport { cva, type VariantProps } from 'class-variance-authority'\n\nimport { resolveVariant } from '../lib/resolve-variant.js'\nimport { cn } from '../lib/utils.js'\n\n/**\n * Surface colours a hero can be drawn on, in the Header's and Masthead's\n * four-name vocabulary plus `tint`, the pale brand panel a landing page uses\n * to mark its opening off from a white body.\n *\n * Each surface sets three inks the slots read: `--hero-heading` (the title),\n * `--hero-ink` (body text and anything a consumer adds) and `--hero-muted`\n * (the description). On the light surfaces the heading is the brand navy and\n * the description the muted role token, both of which flip for dark mode on\n * their own; on `dark` everything is white, because white on `primary-800` is\n * the one pairing that clears WCAG 2.2 AAA (14.4:1) and a muted white would\n * not. Dark mode deepens each surface onto its family's dark step, on the\n * same ramp Header uses (`-800 → -950`, white → `grey-900`, `-100 → -850`), so\n * a hero under a themed header never draws a seam.\n */\nconst heroColors = {\n // The brand band, as Header's `dark`: primary-800 with white text,\n // deepening to primary-950 in dark mode (AGENTS.md §3, recorded exception).\n dark: [\n 'bg-primary-800 text-white dark:bg-primary-950',\n '[--hero-ink:var(--color-white)] [--hero-heading:var(--color-white)] [--hero-muted:var(--color-white)]',\n ].join(' '),\n light: [\n 'bg-grey-100 text-grey-800 dark:bg-grey-850 dark:text-white',\n '[--hero-ink:var(--grey-800)] [--hero-heading:var(--primary-800)] [--hero-muted:var(--text-muted)]',\n 'dark:[--hero-ink:var(--color-white)] dark:[--hero-heading:var(--color-white)] dark:[--hero-muted:var(--color-white)]',\n ].join(' '),\n white: [\n 'bg-white text-grey-800 dark:bg-grey-900 dark:text-white',\n '[--hero-ink:var(--grey-800)] [--hero-heading:var(--primary-800)] [--hero-muted:var(--text-muted)]',\n 'dark:[--hero-ink:var(--color-white)] dark:[--hero-heading:var(--color-white)] dark:[--hero-muted:var(--color-white)]',\n ].join(' '),\n // The pale brand panel. primary-200 is the masterbrand's light blue; in dark\n // mode it deepens to primary-900, one step short of the `dark` surface's\n // dark step so the two stay distinguishable when stacked.\n tint: [\n 'bg-primary-200 text-grey-800 dark:bg-primary-900 dark:text-white',\n '[--hero-ink:var(--grey-800)] [--hero-heading:var(--primary-800)] [--hero-muted:var(--grey-800)]',\n 'dark:[--hero-ink:var(--color-white)] dark:[--hero-heading:var(--color-white)] dark:[--hero-muted:var(--color-white)]',\n ].join(' '),\n}\n\ntype HeroColor = keyof typeof heroColors\n\nconst DEFAULT_HERO_COLOR: HeroColor = 'white'\n// Shared by cva's defaultVariants and the `resolveVariant` calls (and, for\n// layout and fit, the data-* attributes), so they can't drift apart — the\n// arrangement Header and Masthead use for their colour.\nconst DEFAULT_HERO_LAYOUT = 'split'\nconst DEFAULT_HERO_CONTAINER = 'fluid'\nconst DEFAULT_HERO_FIT = 'framed'\n\nconst heroVariants = cva('group/hero w-full text-(--hero-ink)', {\n variants: {\n color: heroColors,\n },\n defaultVariants: {\n color: DEFAULT_HERO_COLOR,\n },\n})\n\n/**\n * The inner column, carrying the same lateral rhythm as `Container` and the\n * chrome components (16px → 24px → 48px, funnelled through\n * `--hero-padding-x`), so a hero's text lines up with the header above it.\n * The media slots read the same custom property to bleed back out to the\n * edge, which is why it is a property and not a bare padding utility.\n *\n * Vertical rhythm lives on `HeroContent`, not here: a `bleed` image fills the\n * full height of the band, so the band itself cannot carry padding.\n */\nconst heroInnerVariants = cva(\n [\n 'mx-auto w-full',\n 'px-(--hero-padding-x)',\n '[--hero-padding-x:--spacing(4)] sm:[--hero-padding-x:--spacing(6)] lg:[--hero-padding-x:--spacing(12)]',\n ],\n {\n variants: {\n layout: {\n // Content beside media from `lg:`, stacked (content first) below it.\n split: 'grid max-lg:grid-cols-1 lg:grid-cols-2 lg:items-stretch lg:gap-x-16',\n // Content over media, each full width. Also the layout for a hero\n // with no media at all.\n stack: 'flex flex-col',\n },\n container: {\n // Full-bleed, matching the chrome's default. `--hero-max-width` is\n // still read so a shell app can constrain the column without\n // switching variants.\n fluid: 'max-w-[var(--hero-max-width,none)]',\n // Centred content column, legacy nsw-container parity (1200px).\n contained: 'max-w-[var(--hero-max-width,75rem)]',\n },\n },\n defaultVariants: {\n layout: DEFAULT_HERO_LAYOUT,\n container: DEFAULT_HERO_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 HeroProps = Omit<React.ComponentPropsWithoutRef<'section'>, 'color'> &\n VariantProps<typeof heroVariants> &\n VariantProps<typeof heroInnerVariants> & {\n /**\n * Where the text sits. `centre` centres the content column and its\n * title, description and actions — the opener of a landing page.\n * `start` is the default, for a hero that reads on from the header.\n */\n align?: 'start' | 'centre'\n /**\n * `id` of the `HeroTitle`. Names the section so it is exposed as a\n * `region` landmark; as with `Section`, no fallback name is 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 band of a page: a title, a short description, up to two\n * actions, and optionally one illustration.\n *\n * Compose it from its slots — `HeroContent` holding `HeroTitle`,\n * `HeroDescription` and `HeroActions`, with an optional `HeroRule` above the\n * title and an optional `HeroMedia` beside or beneath the content:\n *\n * ```tsx\n * <Hero color='dark' layout='split' labelledBy='hero-title'>\n * <HeroContent>\n * <HeroTitle id='hero-title'>Made to send.</HeroTitle>\n * <HeroDescription>Reusable components for NSW Government email.</HeroDescription>\n * <HeroActions>\n * <ButtonLink href='/start' color='white'>Get started</ButtonLink>\n * </HeroActions>\n * </HeroContent>\n * <HeroMedia fit='bleed'>\n * <img src='/illustration.png' alt='' />\n * </HeroMedia>\n * </Hero>\n * ```\n *\n * The five registry blocks (`hero-split`, `hero-framed`, `hero-panel`,\n * `hero-centred`, `hero-statement`) are worked examples of the combinations\n * the NSW Design System recommends; copy one and adapt it.\n */\nfunction Hero({\n className,\n innerClassName,\n color,\n layout,\n container,\n align = 'start',\n labelledBy,\n ref,\n children,\n ...props\n}: HeroProps) {\n // Resolved once (see `resolveVariant`), so cva, the data attributes and\n // anything else reading these agree for `null` and `''` as well as the\n // default spelling.\n const colorway = resolveVariant(color, DEFAULT_HERO_COLOR)\n const layoutway = resolveVariant(layout, DEFAULT_HERO_LAYOUT)\n const containerway = resolveVariant(container, DEFAULT_HERO_CONTAINER)\n return (\n <section\n ref={ref}\n data-slot='hero'\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 data-layout={layoutway}\n data-align={align}\n className={cn(heroVariants({ color: colorway, className }))}\n >\n <div\n data-slot='hero-inner'\n className={cn(\n heroInnerVariants({ layout: layoutway, container: containerway }),\n innerClassName,\n )}\n >\n {children}\n </div>\n </section>\n )\n}\n\ntype HeroContentProps = React.ComponentPropsWithoutRef<'div'> & {\n ref?: React.Ref<HTMLDivElement>\n}\n\n/**\n * The text column: title, description and actions, vertically centred\n * against the media beside it and carrying the hero's vertical rhythm.\n */\nfunction HeroContent({ className, ref, ...props }: HeroContentProps) {\n return (\n <div\n ref={ref}\n data-slot='hero-content'\n className={cn(\n 'flex flex-col justify-center gap-6',\n // The band's vertical rhythm, one step tighter than Section's so a\n // hero does not push the page's first content below the fold.\n 'max-sm:py-14 sm:max-lg:py-16 lg:py-24',\n // Centred alignment, driven by the hero's data-align so a consumer\n // sets it once.\n 'group-data-[align=centre]/hero:mx-auto group-data-[align=centre]/hero:max-w-4xl group-data-[align=centre]/hero:items-center group-data-[align=centre]/hero:text-center',\n className,\n )}\n {...props}\n />\n )\n}\n\ntype HeroTitleProps = React.ComponentPropsWithoutRef<'h1'> & {\n /**\n * The heading element. `1` by default, because a hero opens the page and\n * its title is the page's title; `2` for a hero that opens a section of a\n * page whose `h1` sits elsewhere, so the outline stays in order (WCAG\n * 1.3.1).\n */\n headingLevel?: 1 | 2\n ref?: React.Ref<HTMLHeadingElement>\n}\n\n/**\n * The headline. Semibold rather than bold, at 60px from `lg:`, with the\n * tracking the masterbrand's display setting asks for. Sentence case — the\n * brand sets nothing in uppercase.\n */\nfunction HeroTitle({ className, headingLevel = 1, ref, ...props }: HeroTitleProps) {\n const Heading = `h${headingLevel}` as const\n return (\n <Heading\n ref={ref}\n data-slot='hero-title'\n className={cn(\n 'max-w-[20ch] font-semibold tracking-tight text-balance text-(--hero-heading)',\n 'max-sm:text-4xl sm:max-lg:text-5xl lg:text-6xl',\n 'max-sm:leading-tight sm:leading-none',\n className,\n )}\n {...props}\n />\n )\n}\n\ntype HeroDescriptionProps = React.ComponentPropsWithoutRef<'p'> & {\n ref?: React.Ref<HTMLParagraphElement>\n}\n\n/** One or two sentences under the title, at the reading measure. */\nfunction HeroDescription({ className, ref, ...props }: HeroDescriptionProps) {\n return (\n <p\n ref={ref}\n data-slot='hero-description'\n className={cn('max-w-prose text-lg leading-8 text-pretty text-(--hero-muted)', className)}\n {...props}\n />\n )\n}\n\ntype HeroActionsProps = React.ComponentPropsWithoutRef<'div'> & {\n ref?: React.Ref<HTMLDivElement>\n}\n\n/**\n * The row of actions. One or two `ButtonLink`s: the first solid, the second\n * outline. On the `dark` surface give them `color='white'`; elsewhere\n * `primary` (see the note on Button's `color`).\n */\nfunction HeroActions({ className, ref, ...props }: HeroActionsProps) {\n return (\n <div\n ref={ref}\n data-slot='hero-actions'\n className={cn(\n 'flex flex-wrap gap-3 pt-3',\n 'group-data-[align=centre]/hero:justify-center',\n className,\n )}\n {...props}\n />\n )\n}\n\ntype HeroRuleProps = React.ComponentPropsWithoutRef<'div'> & {\n ref?: React.Ref<HTMLDivElement>\n}\n\n/**\n * A short accent rule above the title, for a hero that carries no\n * illustration and wants one mark of the brand colour. Decorative, so it is\n * hidden from assistive technology.\n */\nfunction HeroRule({ className, ref, ...props }: HeroRuleProps) {\n return (\n <div\n ref={ref}\n aria-hidden='true'\n data-slot='hero-rule'\n className={cn('h-1.5 w-16 rounded-sm bg-primary', className)}\n {...props}\n />\n )\n}\n\n/**\n * How the illustration sits against the content. Every fit sizes the image\n * it wraps to fill the slot and crop (`object-cover`), so a consumer passes a\n * plain `<img>` or their framework's image component.\n */\nconst heroMediaVariants = cva(\n 'relative overflow-hidden *:size-full *:object-cover [&_img]:size-full [&_img]:object-cover',\n {\n variants: {\n fit: {\n /**\n * Flush to the band's edge, filling its full height — the opener of\n * email.digital.nsw.gov.au. Reads `--hero-padding-x` back out to the\n * edge on the media side (and both sides when stacked on a phone).\n * With `container='contained'` it reaches the column's edge, not the\n * viewport's.\n */\n bleed:\n 'max-lg:-mx-(--hero-padding-x) max-lg:aspect-3/2 lg:-mr-(--hero-padding-x) lg:h-full',\n /** A rounded picture beside the content, vertically centred. */\n framed: 'aspect-3/2 self-center rounded-md max-sm:mb-14 sm:max-lg:mb-16 lg:mb-0',\n /**\n * Rising from the bottom edge of the band with its top corners\n * rounded, as though the page's first card had been pulled up into\n * the hero. Pair with `color='tint'`.\n */\n rise: 'aspect-4/3 self-end rounded-t-md',\n /**\n * A shallow full-width strip beneath the content, for `layout='stack'`.\n * Reads `--hero-padding-x` back out to the edge on both sides.\n */\n band: '-mx-(--hero-padding-x) max-sm:h-48 sm:max-lg:h-64 lg:h-80',\n },\n },\n defaultVariants: {\n fit: DEFAULT_HERO_FIT,\n },\n },\n)\n\ntype HeroMediaProps = React.ComponentPropsWithoutRef<'div'> &\n VariantProps<typeof heroMediaVariants> & {\n ref?: React.Ref<HTMLDivElement>\n }\n\n/**\n * The illustration slot. Wraps one image; the `fit` decides how it sits.\n * The image's `alt` is the consumer's: empty when the picture decorates the\n * title, descriptive when it carries meaning the text does not.\n */\nfunction HeroMedia({ className, fit, ref, ...props }: HeroMediaProps) {\n // Resolved once, as `Hero` does for `color` and `layout`.\n const fitway = resolveVariant(fit, DEFAULT_HERO_FIT)\n return (\n <div\n ref={ref}\n data-slot='hero-media'\n {...props}\n data-fit={fitway}\n className={cn(heroMediaVariants({ fit: fitway, className }))}\n />\n )\n}\n\nexport {\n Hero,\n HeroActions,\n heroColors,\n HeroContent,\n HeroDescription,\n heroInnerVariants,\n HeroMedia,\n heroMediaVariants,\n HeroRule,\n HeroTitle,\n heroVariants,\n}\nexport type {\n HeroActionsProps,\n HeroColor,\n HeroContentProps,\n HeroDescriptionProps,\n HeroMediaProps,\n HeroProps,\n HeroRuleProps,\n HeroTitleProps,\n}\n"]}
@@ -17,7 +17,7 @@ declare const inputGroupAddonVariants: (props?: ({
17
17
  } & class_variance_authority_types.ClassProp) | undefined) => string;
18
18
  declare function InputGroupAddon({ className, align, ...props }: React.ComponentProps<'div'> & VariantProps<typeof inputGroupAddonVariants>): React.JSX.Element;
19
19
  declare const inputGroupButtonVariants: (props?: ({
20
- size?: "xs" | "sm" | "icon-xs" | "icon-sm" | null | undefined;
20
+ size?: "sm" | "xs" | "icon-xs" | "icon-sm" | null | undefined;
21
21
  } & class_variance_authority_types.ClassProp) | undefined) => string;
22
22
  /**
23
23
  * The inline button inside an addon — a secondary action or an icon
@@ -35,7 +35,7 @@ declare function InputGroupButton({ className, type, variant, size, ...props }:
35
35
  type?: 'button' | 'submit' | 'reset';
36
36
  }): React.JSX.Element;
37
37
  declare const inputGroupActionVariants: (props?: ({
38
- variant?: "solid" | "open" | "subtle" | null | undefined;
38
+ variant?: "open" | "solid" | "subtle" | null | undefined;
39
39
  } & class_variance_authority_types.ClassProp) | undefined) => string;
40
40
  declare function InputGroupAction({ className, type, variant, ...props }: Omit<React.ComponentProps<typeof Button>, 'size' | 'type' | 'variant'> & VariantProps<typeof inputGroupActionVariants> & {
41
41
  type?: 'button' | 'submit' | 'reset';
@@ -3,7 +3,7 @@ import { VariantProps } from 'class-variance-authority';
3
3
  import React__default from 'react';
4
4
 
5
5
  declare const linkVariants: (props?: ({
6
- variant?: "primary" | "secondary" | "white" | "unstyled" | null | undefined;
6
+ variant?: "white" | "primary" | "secondary" | "unstyled" | null | undefined;
7
7
  } & class_variance_authority_types.ClassProp) | undefined) => string;
8
8
  type LinkComponent = React__default.ElementType;
9
9
  /**
@@ -69,7 +69,7 @@ type MainNavItem = {
69
69
  href?: string;
70
70
  links?: MainNavLinkItem[];
71
71
  };
72
- type MainNavProps = Omit<React__default.ComponentPropsWithoutRef<'nav'>, 'children'> & VariantProps<typeof mainNavVariants> & VariantProps<typeof mainNavContainerVariants> & {
72
+ type MainNavProps = Omit<React__default.ComponentPropsWithoutRef<'nav'>, 'children' | 'color'> & VariantProps<typeof mainNavVariants> & VariantProps<typeof mainNavContainerVariants> & {
73
73
  /** Top-level items; items with `links` open mega panels. */
74
74
  navigation: MainNavItem[];
75
75
  /**
@@ -3,6 +3,7 @@ import { jsx, Fragment, jsxs } from 'react/jsx-runtime';
3
3
  import { cva } from 'class-variance-authority';
4
4
  import React from 'react';
5
5
  import { IconEast } from '../icons/east.js';
6
+ import { resolveVariant } from '../lib/resolve-variant.js';
6
7
  import { cn } from '../lib/utils.js';
7
8
  import { NavigationMenu, NavigationMenuList, NavigationMenuItem, NavigationMenuLink, NavigationMenuTrigger, NavigationMenuContent } from '../components/navigation-menu.js';
8
9
 
@@ -22,6 +23,7 @@ const mainNavColors = [
22
23
  "white"
23
24
  ];
24
25
  const DEFAULT_MAIN_NAV_COLOR = "white";
26
+ const DEFAULT_MAIN_NAV_CONTAINER = "fluid";
25
27
  const mainNavVariants = cva(
26
28
  [
27
29
  "w-full",
@@ -106,7 +108,7 @@ const mainNavContainerVariants = cva(
106
108
  }
107
109
  },
108
110
  defaultVariants: {
109
- container: "fluid"
111
+ container: DEFAULT_MAIN_NAV_CONTAINER
110
112
  }
111
113
  }
112
114
  );
@@ -313,16 +315,18 @@ function MainNav({
313
315
  lastAlignOffsetRef.current = element.getBoundingClientRect().left - trigger.getBoundingClientRect().left;
314
316
  return lastAlignOffsetRef.current;
315
317
  }, []);
318
+ const colorway = resolveVariant(color, DEFAULT_MAIN_NAV_COLOR);
319
+ const containerway = resolveVariant(container, DEFAULT_MAIN_NAV_CONTAINER);
316
320
  return /* @__PURE__ */ jsx(
317
321
  "nav",
318
322
  {
319
323
  id: "nsw-main-navigation",
320
324
  "data-slot": "main-nav",
321
- "data-color": color ?? DEFAULT_MAIN_NAV_COLOR,
322
325
  "aria-label": ariaLabel,
323
326
  ...props,
327
+ "data-color": colorway,
324
328
  className: cn(
325
- mainNavVariants({ color, border }),
329
+ mainNavVariants({ color: colorway, border }),
326
330
  // z-40 matches Header (both sit below the z-50 SkipLinks). An app
327
331
  // stacking this under a sticky Header sets --main-nav-top to the
328
332
  // header's height.
@@ -337,7 +341,7 @@ function MainNav({
337
341
  {
338
342
  ref: containerRef,
339
343
  "data-slot": "main-nav-container",
340
- className: cn(mainNavContainerVariants({ container }), containerClassName),
344
+ className: cn(mainNavContainerVariants({ container: containerway }), containerClassName),
341
345
  children: navigation.length === 0 ? (
342
346
  // No items: render the message directly rather than an empty
343
347
  // NavigationMenu, which would still mount the portal, positioner and
@@ -368,7 +372,7 @@ function MainNav({
368
372
  MainNavMenuItem,
369
373
  {
370
374
  item,
371
- color: color ?? DEFAULT_MAIN_NAV_COLOR,
375
+ color: colorway,
372
376
  currentHref,
373
377
  panelWidth
374
378
  },