@nswds/ui 9.2.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/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.js +3 -2
- package/dist/components/button-group.js.map +1 -1
- package/dist/components/button.d.ts +2 -2
- 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 +1 -1
- 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 +138 -0
- package/dist/components/page-header.js +181 -0
- package/dist/components/page-header.js.map +1 -0
- 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/index.d.ts +1 -0
- package/dist/index.js +1 -0
- 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/dist/styles.css +1 -1
- package/package.json +5 -4
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/components/expandable-search.tsx"],"names":[],"mappings":";;;;;;AAgCA,MAAM,wBAAA,GAA2B,GAAA;AAAA,EAC/B;AAAA;AAAA;AAAA,IAGE,2DAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,IAcA,uEAAA;AAAA,IACA,8EAAA;AAAA,IACA;AAAA,GACF;AAAA,EACA;AAAA,IACE,QAAA,EAAU;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,MA4BR,OAAA,EAAS;AAAA,QACP,OAAA,EACE,qIAAA;AAAA,QACF,aAAA,EACE,iFAAA;AAAA,QACF,aAAA,EACE,iHAAA;AAAA,QACF,aAAA,EACE,8IAAA;AAAA,QACF,aAAA,EACE,8IAAA;AAAA,QACF,UAAA,EAAY,2EAAA;AAAA,QACZ,UAAA,EAAY,2EAAA;AAAA,QACZ,UAAA,EACE,kIAAA;AAAA,QACF,UAAA,EACE,kIAAA;AAAA,QACF,YAAA,EACE,+EAAA;AAAA,QACF,YAAA,EACE,+GAAA;AAAA,QACF,YAAA,EACE,0KAAA;AAAA,QACF,YAAA,EACE,0IAAA;AAAA,QACF,KAAA,EACE;AAAA;AACJ,KACF;AAAA,IACA,eAAA,EAAiB;AAAA,MACf,OAAA,EAAS;AAAA;AACX;AAEJ;AAaA,MAAM,oBAAA,GACJ,oHAAA;AASF,MAAM,uBAAA,GAA0B,KAAA,CAAM,aAAA,CAAmD,IAAI,CAAA;AA4C7F,SAAS,qBAAA,CAAsB,OAA2B,SAAA,EAA+B;AACvF,EAAA,IAAI,OAAA,CAAQ,GAAA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A,qFAAA;AAAA;AAAA;AAAA,UAGA,mDAAA;AAAA,UACA,oBAAA;AAAA,UACA,QAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,YAMI;AAAA;AAAA;AAAA;AAAA;AAAA,YAIA;AAAA,WAAA;AAAA,UACJ;AAAA,SACF;AAAA,QACA;AAAA;AAAA,KACF;AAAA,oBAEA,GAAA;AAAA,MAAC,QAAA;AAAA,MAAA;AAAA,QACC,WAAA,EAAU,0BAAA;AAAA,QACV,cAAY,eAAA,IAAmB,WAAA;AAAA,QAC9B,GAAG,eAAA;AAAA,QACJ,IAAA,EAAK,QAAA;AAAA,QACL,SAAA,EAAW,EAAA;AAAA,UACT,sEAAA;AAAA,UACA,mEAAA;AAAA;AAAA;AAAA;AAAA,UAIA,qBAAA;AAAA,UACA,wGAAA;AAAA,UACA,oBAAA;AAAA;AAAA,UAEA,WAAW,qBAAA,GAAwB,qBAAA;AAAA,UACnC;AAAA,SACF;AAAA,QAEC,4CACC,GAAA,CAAC,UAAA,EAAA,EAAW,aAAA,EAAY,MAAA,EAAO,WAAU,2CAAA,EAA4C;AAAA;AAAA;AAEzF,GAAA,EACF,CAAA;AAEJ","file":"expandable-search.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 { IconSearch } from '../icons/search.js'\n\n/**\n * Surface colours the search can be themed with — the footer's thirteen-name\n * vocabulary (see `footerColors` in footer.tsx) plus `default`, the nswds-app\n * grey-100 chip that headers embed on a white surface.\n *\n * Every derived colour resolves from a single `--search-ink` token, so a\n * variant only declares its surface utilities and that one value. This map\n * replaces the FOUR parallel 14-entry cva tables in the nswds-app source\n * (surface / collapsed / button / focus): each of those tables was a manual\n * projection of the same underlying ink, so they are collapsed into the\n * derivations below.\n *\n * The derivations are written literally here (once) rather than per-variant:\n * Tailwind scans source text for class names, so a template-built arbitrary\n * property would never be emitted. Mirrors footer.tsx (`--footer-*`) and\n * link.tsx (`--link-halo`).\n *\n * Expanded text/surface pairs are the ones verified for footer.tsx: every\n * light pair clears WCAG 2.2 AA (1.4.3, 4.5:1) — the worst are `primary-600`\n * (4.57:1) and `accent-600` (5.18:1) — and in dark mode all clear AAA (worst\n * 13.6:1). The collapsed chip renders no text, only the icon, which paints in\n * the same ink.\n */\nconst expandableSearchVariants = cva(\n [\n // `group/search` is named so the submit button's group-focus-within hook\n // can't collide with an ancestor's bare `group` (e.g. inside a card).\n 'group/search relative inline-block rounded-sm select-none',\n // Halo for the submit button's hover / the form's focus-within state, a\n // heavier press halo, and the placeholder colour — all mixed down from\n // the ink. 70% ink keeps the placeholder related to but visibly lighter\n // than the entered text (the source used grey-700 / current at 70%\n // opacity). Dilution costs contrast, though, so the percentage routes\n // through --search-placeholder-pct and the surfaces whose 70% composite\n // fails 1.4.3 raise it to 100% in the variant map below. Verified by\n // alpha-compositing the mix over each surface (light mode): at 70%\n // primary-600 is 3.0:1, accent-600 3.1:1 and accent-400 4.48:1 — all\n // AA failures, cured by full ink (4.57 / 5.18 / 8.34:1). The eleven\n // surfaces that keep 70% all clear 4.5:1, the closest being\n // primary-400 (4.57:1) and grey-400 (4.58:1); dark mode's worst 70%\n // composite is 7.0:1.\n '[--search-halo:color-mix(in_oklch,var(--search-ink)_10%,transparent)]',\n '[--search-halo-active:color-mix(in_oklch,var(--search-ink)_18%,transparent)]',\n '[--search-placeholder:color-mix(in_oklch,var(--search-ink)_var(--search-placeholder-pct,70%),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` below is a real utility, so that\n // key is always emitted.) Same reasoning as footer.tsx and header.tsx.\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 — per\n // footer.tsx's family mapping, and `default` follows header.tsx's\n // `light` surface: grey-100→grey-850. Ink goes white on all fourteen.\n //\n // primary-600, accent-600 and accent-400 set --search-placeholder-pct\n // to 100%: their 70% placeholder composite fails AA (3.0 / 3.1 /\n // 4.48:1 — see the derivation comment above), so the placeholder\n // renders full ink there. The override is deliberately not\n // dark-scoped: every dark 70% composite clears 7:1, so 100% in dark\n // is merely a slightly stronger placeholder, not worth a second\n // declaration.\n //\n // `default` is the one variant whose ink is NOT its text colour: the\n // nswds-app chip pairs grey-800 entered text with a primary-blue icon\n // and primary-800/10 halos. Declaring ink as primary-800 reproduces the\n // icon and halos exactly; the text colour is a surface utility, so it\n // stays grey-800. (Side effect, documented: the placeholder mixes from\n // primary-800 instead of the source's grey-700 — a subtle blue shift.)\n variant: {\n default:\n 'bg-grey-100 text-grey-800 [--search-ink:var(--primary-800)] dark:bg-grey-850 dark:text-white dark:[--search-ink:var(--color-white)]',\n 'primary-800':\n 'bg-primary-800 text-white [--search-ink:var(--color-white)] dark:bg-primary-950',\n 'primary-600':\n 'bg-primary-600 text-white [--search-ink:var(--color-white)] [--search-placeholder-pct:100%] dark:bg-primary-900',\n 'primary-400':\n 'bg-primary-400 text-primary-800 [--search-ink:var(--primary-800)] dark:bg-primary-850 dark:text-white dark:[--search-ink:var(--color-white)]',\n 'primary-200':\n 'bg-primary-200 text-primary-800 [--search-ink:var(--primary-800)] dark:bg-primary-800 dark:text-white dark:[--search-ink:var(--color-white)]',\n 'grey-800': 'bg-grey-800 text-white [--search-ink:var(--color-white)] dark:bg-grey-950',\n 'grey-600': 'bg-grey-600 text-white [--search-ink:var(--color-white)] dark:bg-grey-900',\n 'grey-400':\n 'bg-grey-400 text-grey-800 [--search-ink:var(--grey-800)] dark:bg-grey-850 dark:text-white dark:[--search-ink:var(--color-white)]',\n 'grey-200':\n 'bg-grey-200 text-grey-800 [--search-ink:var(--grey-800)] dark:bg-grey-800 dark:text-white dark:[--search-ink:var(--color-white)]',\n 'accent-800':\n 'bg-accent-800 text-white [--search-ink:var(--color-white)] dark:bg-accent-950',\n 'accent-600':\n 'bg-accent-600 text-white [--search-ink:var(--color-white)] [--search-placeholder-pct:100%] dark:bg-accent-900',\n 'accent-400':\n 'bg-accent-400 text-accent-800 [--search-ink:var(--accent-800)] [--search-placeholder-pct:100%] dark:bg-accent-850 dark:text-white dark:[--search-ink:var(--color-white)]',\n 'accent-200':\n 'bg-accent-200 text-accent-800 [--search-ink:var(--accent-800)] dark:bg-accent-800 dark:text-white dark:[--search-ink:var(--color-white)]',\n white:\n 'bg-white text-grey-800 [--search-ink:var(--grey-800)] dark:bg-grey-900 dark:text-white dark:[--search-ink:var(--color-white)]',\n },\n },\n defaultVariants: {\n variant: 'default',\n },\n },\n)\n\ntype ExpandableSearchVariant = NonNullable<VariantProps<typeof expandableSearchVariants>['variant']>\n\n// One focus treatment for the input and the submit button, INSET rather than\n// the source's offset ring. The source ringed each variant in its own surface\n// colour with a hardcoded white offset — on the default chip that was\n// ring-grey-100 around a grey-100 chip on a white page: effectively invisible\n// (a 2.4.7 Focus Visible / 2.4.13 Focus Appearance failure). An outward\n// indicator can only guarantee contrast against the page, which this component\n// cannot know; the ink is guaranteed to contrast with the surface (that is its\n// whole job), so the indicator is drawn 2px INSIDE the chip in ink, where the\n// contrast maths always holds.\nconst searchFocusClassName =\n 'focus-visible:outline focus-visible:outline-2 focus-visible:-outline-offset-2 focus-visible:outline-(--search-ink)'\n\ntype ExpandableSearchContextValue = {\n value: string\n setValue: (value: string) => void\n formHasFocusWithin: boolean\n variant: ExpandableSearchVariant\n}\n\nconst ExpandableSearchContext = React.createContext<ExpandableSearchContextValue | null>(null)\n\ntype ExpandableSearchProps = React.ComponentPropsWithoutRef<'form'> &\n VariantProps<typeof expandableSearchVariants> & {\n /**\n * Called with the current query when the form submits (Enter in the field\n * or a click on the search button). Not called if a supplied `onSubmit`\n * prevented the event's default.\n */\n onAction?: (value: string) => void\n /** Initial query. A non-empty value renders the field expanded. */\n defaultValue?: string\n ref?: React.Ref<HTMLFormElement>\n }\n\ntype ExpandableSearchButtonProps = Omit<React.ComponentPropsWithoutRef<'button'>, 'type'> & {\n [key: `data-${string}`]: string | number | boolean | undefined\n}\n\ntype ExpandableSearchFieldProps = Omit<\n React.ComponentPropsWithoutRef<'input'>,\n // `type` is pinned to `search`; `value`/`defaultValue` are owned by the\n // `ExpandableSearch` context (seed it via the root's `defaultValue` prop).\n 'type' | 'value' | 'defaultValue'\n> & {\n /**\n * Accessible name for the input, rendered as a visually-hidden `<label>`\n * and mirrored as `aria-label`. Defaults to `'Search'`.\n */\n label?: string\n /** Accessible name for the submit button. Defaults to `'Search'`. */\n buttonLabel?: string\n /** Extra props for the submit button (its `type` is pinned to `submit`). */\n buttonProps?: ExpandableSearchButtonProps\n ref?: React.Ref<HTMLInputElement>\n}\n\n/**\n * Dev-only guard, mirroring the icon-only Button check in button.tsx: with\n * `label=''` and no `aria-label` the input reaches assistive tech unnamed\n * (WCAG 2.2, 4.1.2 Name, Role, Value) — and this control leans on its name\n * more than most, since collapsed it looks like a plain icon button. No-op in\n * production.\n */\nfunction warnIfFieldUnlabelled(label: string | undefined, ariaLabel: string | undefined) {\n if (process.env.NODE_ENV === 'production') {\n return\n }\n if (!label && !ariaLabel) {\n console.warn(\n '[nswds/ui] ExpandableSearchField has no label — pass `label` or `aria-label` so the search input has an accessible name.',\n )\n }\n}\n\n/**\n * Site-search disclosure: a 48px search chip that expands into a text field\n * whenever it holds focus or a value, and submits the query to `onAction`.\n * Compose it as `<ExpandableSearch>` (the form root, owning the value and the\n * focus-within state) around one `<ExpandableSearchField>` (the input and its\n * submit button) — typically inside `HeaderActions`.\n *\n * Ported from nswds-app's `ExpandableSearch`. The mechanic is kept verbatim —\n * the collapsed control IS the text input, styled as a chip, so that the very\n * first focus or tap both reveals and focuses the field with no extra step.\n * Expansion is pure CSS keyed on the active state; no Base UI primitive is\n * used because none models this pattern (it is a styled form, not a popup —\n * focus never moves, nothing is portalled, nothing needs ARIA beyond the\n * label).\n *\n * Accessibility contract:\n * - The input carries a visually-hidden `<label>` and an `aria-label`\n * (default \"Search\"), and is `type='search'` with `enterKeyHint='search'`,\n * so its role and purpose are announced while it still looks like a button\n * (WCAG 2.2, 4.1.2; the source input was an unlabelled-by-type text input).\n * - Keyboard focus shows a 2px ink outline drawn inside the chip — the\n * source's ring was its own surface colour against a hardcoded white offset\n * and could vanish entirely (2.4.7, 2.4.13). See `searchFocusClassName`.\n * - Enter submits; Escape clears (native `type='search'` behaviour); an empty\n * blurred field collapses back to the chip.\n * - Expansion and halo transitions honour `prefers-reduced-motion` (2.3.3).\n *\n * Departures from the nswds-app source, beyond those above:\n * - React 19 `ref` prop instead of `forwardRef`.\n * - Four parallel 14-entry variant tables replaced by one ink-driven map —\n * see `expandableSearchVariants`.\n * - Expanded width `w-96` → `w-[min(24rem,80vw)]` so the field can never\n * overflow a small viewport (1.4.10 Reflow).\n * - The expanded state no longer sets `outline-none` (it would have killed\n * the new focus indicator; the source could afford it because its\n * indicator was a box-shadow ring).\n * - Expanded text selection uses `select-text`, not the source's\n * `select-auto` — `auto` computes from the root's `select-none` parent, so\n * the source's expanded field was unselectable.\n * - A consumer `onChange` on the field is chained after the context update\n * instead of replacing it (the source's spread order let it clobber the\n * controlled handler).\n *\n * The root deliberately does not claim `role='search'`: where the component\n * is the page's site search, add it yourself (one search landmark per page).\n */\nfunction ExpandableSearch({\n className,\n onAction,\n defaultValue = '',\n onSubmit,\n onFocusCapture,\n onBlurCapture,\n variant = 'default',\n ref,\n ...props\n}: ExpandableSearchProps) {\n const [value, setValue] = React.useState(defaultValue)\n const [formHasFocusWithin, setFormHasFocusWithin] = React.useState(false)\n const resolvedVariant: ExpandableSearchVariant = variant ?? 'default'\n const isActive = value.length > 0 || formHasFocusWithin\n\n const contextValue = React.useMemo(\n () => ({ value, setValue, formHasFocusWithin, variant: resolvedVariant }),\n [value, formHasFocusWithin, resolvedVariant],\n )\n\n const handleSubmit = (e: React.SubmitEvent<HTMLFormElement>) => {\n onSubmit?.(e)\n\n if (e.defaultPrevented) {\n return\n }\n\n e.preventDefault()\n onAction?.(value)\n }\n\n const handleFocusCapture = (e: React.FocusEvent<HTMLFormElement>) => {\n setFormHasFocusWithin(true)\n onFocusCapture?.(e)\n }\n\n const handleBlurCapture = (e: React.FocusEvent<HTMLFormElement>) => {\n const nextFocusedElement = e.relatedTarget as Node | null\n\n if (!e.currentTarget.contains(nextFocusedElement)) {\n setFormHasFocusWithin(false)\n }\n\n onBlurCapture?.(e)\n }\n\n return (\n <ExpandableSearchContext.Provider value={contextValue}>\n <form\n data-slot='expandable-search'\n data-variant={resolvedVariant}\n // Present-or-absent rather than \"true\"/\"false\", so it reads like Base\n // UI's data-* attributes and Tailwind's bare `data-expanded:` variant\n // works. Same convention as Header's data-scrolled.\n data-expanded={isActive || undefined}\n {...props}\n // The surface (and its ink) lives on the root so BOTH children — the\n // input and the absolutely-positioned submit button — inherit the\n // custom properties. The root shrink-wraps the input, so painting the\n // background here is visually identical to painting it on the input.\n className={cn(expandableSearchVariants({ variant }), className)}\n onBlurCapture={handleBlurCapture}\n onFocusCapture={handleFocusCapture}\n onSubmit={handleSubmit}\n ref={ref}\n />\n </ExpandableSearchContext.Provider>\n )\n}\n\n/**\n * The input and its submit button. Must be rendered inside `ExpandableSearch`,\n * which owns the value and the focus-within state.\n *\n * The submit button is `pointer-events-none` while collapsed — deliberately,\n * per the source: collapsed, the input overlays the exact same 48px square and\n * OWNS the click, so a tap lands on the input, focuses it, and expands the\n * field. Making the button clickable there would submit an empty query\n * instead of opening the field. It also never traps keyboard focus while\n * collapsed: the input precedes it in tab order, and focusing the input\n * expands the field before the button is reached.\n */\nfunction ExpandableSearchField({\n className,\n id,\n label = 'Search',\n 'aria-label': ariaLabel,\n autoComplete = 'off',\n enterKeyHint = 'search',\n onChange,\n buttonLabel = 'Search',\n buttonProps,\n ref,\n ...props\n}: ExpandableSearchFieldProps) {\n const context = React.useContext(ExpandableSearchContext)\n if (!context) throw new Error('ExpandableSearchField must be used within ExpandableSearch')\n\n const generatedId = React.useId()\n const {\n className: buttonClassName,\n children: buttonChildren,\n 'aria-label': buttonAriaLabel,\n ...restButtonProps\n } = buttonProps ?? {}\n\n const isActive = context.value.length > 0 || context.formHasFocusWithin\n const inputId = id ?? generatedId\n\n warnIfFieldUnlabelled(label, ariaLabel)\n\n const handleChange = (e: React.ChangeEvent<HTMLInputElement>) => {\n context.setValue(e.target.value)\n onChange?.(e)\n }\n\n return (\n <div data-slot='expandable-search-field' className='relative flex-1'>\n {label ? (\n // aria-label (below) wins for the accessible name where both exist;\n // the label element is kept for source parity and so a click on any\n // future visible rendering of it focuses the input.\n <label className='sr-only' htmlFor={inputId}>\n {label}\n </label>\n ) : null}\n\n <input\n data-slot='expandable-search-input'\n aria-label={ariaLabel ?? (label || undefined)}\n autoComplete={autoComplete}\n enterKeyHint={enterKeyHint}\n {...props}\n type='search'\n id={inputId}\n value={context.value}\n onChange={handleChange}\n className={cn(\n // Collapsed, the input is a 48px chip: transparent text and\n // placeholder so nothing peeks out, cursor-pointer because it acts\n // as the \"open search\" affordance. The background comes from the\n // form root, which shrink-wraps this element.\n 'flex h-12 w-12 cursor-pointer overflow-hidden rounded-sm border-0 bg-transparent text-transparent',\n 'placeholder:text-transparent placeholder:opacity-0',\n 'duration-300 ease-in-out motion-safe:transition-[width,box-shadow,background-color]',\n // Hide WebKit's native clear affordance: the source field (type\n // text) had none, and Escape already clears a search input.\n '[&::-webkit-search-cancel-button]:appearance-none',\n searchFocusClassName,\n isActive\n ? // Expanded: capped at 80vw so the field cannot overflow small\n // viewports (the source's fixed w-96 could). pr-12 reserves the\n // submit button's square. select-text (not select-auto — see\n // the component JSDoc) re-enables selection under the root's\n // select-none.\n 'w-[min(24rem,80vw)] cursor-auto pt-0 pr-12 pb-0 pl-4 text-inherit select-text placeholder:text-(--search-placeholder) placeholder:opacity-100'\n : // Collapsed: the chip halos on hover exactly like the button\n // does — one visual whether the pointer technically rests on\n // the input overlay or not.\n 'p-0 hover:bg-(--search-halo)',\n className,\n )}\n ref={ref}\n />\n\n <button\n data-slot='expandable-search-button'\n aria-label={buttonAriaLabel ?? buttonLabel}\n {...restButtonProps}\n type='submit'\n className={cn(\n 'absolute top-0 right-0 z-10 flex h-12 w-12 cursor-pointer rounded-sm',\n 'duration-200 motion-safe:transition-[background-color,box-shadow]',\n // Icon and halos all derive from the ink; the whole-form\n // focus-within halo marks the button as the pending action while\n // the user types.\n 'text-(--search-ink)',\n 'group-focus-within/search:bg-(--search-halo) hover:bg-(--search-halo) active:bg-(--search-halo-active)',\n searchFocusClassName,\n // Collapsed, the input overlay owns the click — see the JSDoc.\n isActive ? 'pointer-events-auto' : 'pointer-events-none',\n buttonClassName,\n )}\n >\n {buttonChildren ?? (\n <IconSearch aria-hidden='true' className='m-auto block size-8 shrink-0 fill-current' />\n )}\n </button>\n </div>\n )\n}\n\nexport { ExpandableSearch, ExpandableSearchField, expandableSearchVariants }\nexport type {\n ExpandableSearchButtonProps,\n ExpandableSearchFieldProps,\n ExpandableSearchProps,\n ExpandableSearchVariant,\n}\n"]}
|
|
1
|
+
{"version":3,"sources":["../../src/components/expandable-search.tsx"],"names":[],"mappings":";;;;;;;AAiCA,MAAM,wBAAA,GAA2B,GAAA;AAAA,EAC/B;AAAA;AAAA;AAAA,IAGE,2DAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,IAcA,uEAAA;AAAA,IACA,8EAAA;AAAA,IACA;AAAA,GACF;AAAA,EACA;AAAA,IACE,QAAA,EAAU;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,MA4BR,OAAA,EAAS;AAAA,QACP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GAAwB,qBAAA;AAAA,UACnC;AAAA,SACF;AAAA,QAEC,4CACC,GAAA,CAAC,UAAA,EAAA,EAAW,aAAA,EAAY,MAAA,EAAO,WAAU,2CAAA,EAA4C;AAAA;AAAA;AAEzF,GAAA,EACF,CAAA;AAEJ","file":"expandable-search.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 { IconSearch } from '../icons/search.js'\n\n/**\n * Surface colours the search can be themed with — the footer's thirteen-name\n * vocabulary (see `footerColors` in footer.tsx) plus `default`, the nswds-app\n * grey-100 chip that headers embed on a white surface.\n *\n * Every derived colour resolves from a single `--search-ink` token, so a\n * variant only declares its surface utilities and that one value. This map\n * replaces the FOUR parallel 14-entry cva tables in the nswds-app source\n * (surface / collapsed / button / focus): each of those tables was a manual\n * projection of the same underlying ink, so they are collapsed into the\n * derivations below.\n *\n * The derivations are written literally here (once) rather than per-variant:\n * Tailwind scans source text for class names, so a template-built arbitrary\n * property would never be emitted. Mirrors footer.tsx (`--footer-*`) and\n * link.tsx (`--link-halo`).\n *\n * Expanded text/surface pairs are the ones verified for footer.tsx: every\n * light pair clears WCAG 2.2 AA (1.4.3, 4.5:1) — the worst are `primary-600`\n * (4.57:1) and `accent-600` (5.18:1) — and in dark mode all clear AAA (worst\n * 13.6:1). The collapsed chip renders no text, only the icon, which paints in\n * the same ink.\n */\nconst expandableSearchVariants = cva(\n [\n // `group/search` is named so the submit button's group-focus-within hook\n // can't collide with an ancestor's bare `group` (e.g. inside a card).\n 'group/search relative inline-block rounded-sm select-none',\n // Halo for the submit button's hover / the form's focus-within state, a\n // heavier press halo, and the placeholder colour — all mixed down from\n // the ink. 70% ink keeps the placeholder related to but visibly lighter\n // than the entered text (the source used grey-700 / current at 70%\n // opacity). Dilution costs contrast, though, so the percentage routes\n // through --search-placeholder-pct and the surfaces whose 70% composite\n // fails 1.4.3 raise it to 100% in the variant map below. Verified by\n // alpha-compositing the mix over each surface (light mode): at 70%\n // primary-600 is 3.0:1, accent-600 3.1:1 and accent-400 4.48:1 — all\n // AA failures, cured by full ink (4.57 / 5.18 / 8.34:1). The eleven\n // surfaces that keep 70% all clear 4.5:1, the closest being\n // primary-400 (4.57:1) and grey-400 (4.58:1); dark mode's worst 70%\n // composite is 7.0:1.\n '[--search-halo:color-mix(in_oklch,var(--search-ink)_10%,transparent)]',\n '[--search-halo-active:color-mix(in_oklch,var(--search-ink)_18%,transparent)]',\n '[--search-placeholder:color-mix(in_oklch,var(--search-ink)_var(--search-placeholder-pct,70%),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` below is a real utility, so that\n // key is always emitted.) Same reasoning as footer.tsx and header.tsx.\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 — per\n // footer.tsx's family mapping, and `default` follows header.tsx's\n // `light` surface: grey-100→grey-850. Ink goes white on all fourteen.\n //\n // primary-600, accent-600 and accent-400 set --search-placeholder-pct\n // to 100%: their 70% placeholder composite fails AA (3.0 / 3.1 /\n // 4.48:1 — see the derivation comment above), so the placeholder\n // renders full ink there. The override is deliberately not\n // dark-scoped: every dark 70% composite clears 7:1, so 100% in dark\n // is merely a slightly stronger placeholder, not worth a second\n // declaration.\n //\n // `default` is the one variant whose ink is NOT its text colour: the\n // nswds-app chip pairs grey-800 entered text with a primary-blue icon\n // and primary-800/10 halos. Declaring ink as primary-800 reproduces the\n // icon and halos exactly; the text colour is a surface utility, so it\n // stays grey-800. (Side effect, documented: the placeholder mixes from\n // primary-800 instead of the source's grey-700 — a subtle blue shift.)\n variant: {\n default:\n 'bg-grey-100 text-grey-800 [--search-ink:var(--primary-800)] dark:bg-grey-850 dark:text-white dark:[--search-ink:var(--color-white)]',\n 'primary-800':\n 'bg-primary-800 text-white [--search-ink:var(--color-white)] dark:bg-primary-950',\n 'primary-600':\n 'bg-primary-600 text-white [--search-ink:var(--color-white)] [--search-placeholder-pct:100%] dark:bg-primary-900',\n 'primary-400':\n 'bg-primary-400 text-primary-800 [--search-ink:var(--primary-800)] dark:bg-primary-850 dark:text-white dark:[--search-ink:var(--color-white)]',\n 'primary-200':\n 'bg-primary-200 text-primary-800 [--search-ink:var(--primary-800)] dark:bg-primary-800 dark:text-white dark:[--search-ink:var(--color-white)]',\n 'grey-800': 'bg-grey-800 text-white [--search-ink:var(--color-white)] dark:bg-grey-950',\n 'grey-600': 'bg-grey-600 text-white [--search-ink:var(--color-white)] dark:bg-grey-900',\n 'grey-400':\n 'bg-grey-400 text-grey-800 [--search-ink:var(--grey-800)] dark:bg-grey-850 dark:text-white dark:[--search-ink:var(--color-white)]',\n 'grey-200':\n 'bg-grey-200 text-grey-800 [--search-ink:var(--grey-800)] dark:bg-grey-800 dark:text-white dark:[--search-ink:var(--color-white)]',\n 'accent-800':\n 'bg-accent-800 text-white [--search-ink:var(--color-white)] dark:bg-accent-950',\n 'accent-600':\n 'bg-accent-600 text-white [--search-ink:var(--color-white)] [--search-placeholder-pct:100%] dark:bg-accent-900',\n 'accent-400':\n 'bg-accent-400 text-accent-800 [--search-ink:var(--accent-800)] [--search-placeholder-pct:100%] dark:bg-accent-850 dark:text-white dark:[--search-ink:var(--color-white)]',\n 'accent-200':\n 'bg-accent-200 text-accent-800 [--search-ink:var(--accent-800)] dark:bg-accent-800 dark:text-white dark:[--search-ink:var(--color-white)]',\n white:\n 'bg-white text-grey-800 [--search-ink:var(--grey-800)] dark:bg-grey-900 dark:text-white dark:[--search-ink:var(--color-white)]',\n },\n },\n defaultVariants: {\n variant: 'default',\n },\n },\n)\n\ntype ExpandableSearchVariant = NonNullable<VariantProps<typeof expandableSearchVariants>['variant']>\n\n// One focus treatment for the input and the submit button, INSET rather than\n// the source's offset ring. The source ringed each variant in its own surface\n// colour with a hardcoded white offset — on the default chip that was\n// ring-grey-100 around a grey-100 chip on a white page: effectively invisible\n// (a 2.4.7 Focus Visible / 2.4.13 Focus Appearance failure). An outward\n// indicator can only guarantee contrast against the page, which this component\n// cannot know; the ink is guaranteed to contrast with the surface (that is its\n// whole job), so the indicator is drawn 2px INSIDE the chip in ink, where the\n// contrast maths always holds.\nconst searchFocusClassName =\n 'focus-visible:outline focus-visible:outline-2 focus-visible:-outline-offset-2 focus-visible:outline-(--search-ink)'\n\ntype ExpandableSearchContextValue = {\n value: string\n setValue: (value: string) => void\n formHasFocusWithin: boolean\n variant: ExpandableSearchVariant\n}\n\nconst ExpandableSearchContext = React.createContext<ExpandableSearchContextValue | null>(null)\n\ntype ExpandableSearchProps = React.ComponentPropsWithoutRef<'form'> &\n VariantProps<typeof expandableSearchVariants> & {\n /**\n * Called with the current query when the form submits (Enter in the field\n * or a click on the search button). Not called if a supplied `onSubmit`\n * prevented the event's default.\n */\n onAction?: (value: string) => void\n /** Initial query. A non-empty value renders the field expanded. */\n defaultValue?: string\n ref?: React.Ref<HTMLFormElement>\n }\n\ntype ExpandableSearchButtonProps = Omit<React.ComponentPropsWithoutRef<'button'>, 'type'> & {\n [key: `data-${string}`]: string | number | boolean | undefined\n}\n\ntype ExpandableSearchFieldProps = Omit<\n React.ComponentPropsWithoutRef<'input'>,\n // `type` is pinned to `search`; `value`/`defaultValue` are owned by the\n // `ExpandableSearch` context (seed it via the root's `defaultValue` prop).\n 'type' | 'value' | 'defaultValue'\n> & {\n /**\n * Accessible name for the input, rendered as a visually-hidden `<label>`\n * and mirrored as `aria-label`. Defaults to `'Search'`.\n */\n label?: string\n /** Accessible name for the submit button. Defaults to `'Search'`. */\n buttonLabel?: string\n /** Extra props for the submit button (its `type` is pinned to `submit`). */\n buttonProps?: ExpandableSearchButtonProps\n ref?: React.Ref<HTMLInputElement>\n}\n\n/**\n * Dev-only guard, mirroring the icon-only Button check in button.tsx: with\n * `label=''` and no `aria-label` the input reaches assistive tech unnamed\n * (WCAG 2.2, 4.1.2 Name, Role, Value) — and this control leans on its name\n * more than most, since collapsed it looks like a plain icon button. No-op in\n * production.\n */\nfunction warnIfFieldUnlabelled(label: string | undefined, ariaLabel: string | undefined) {\n if (process.env.NODE_ENV === 'production') {\n return\n }\n if (!label && !ariaLabel) {\n console.warn(\n '[nswds/ui] ExpandableSearchField has no label — pass `label` or `aria-label` so the search input has an accessible name.',\n )\n }\n}\n\n/**\n * Site-search disclosure: a 48px search chip that expands into a text field\n * whenever it holds focus or a value, and submits the query to `onAction`.\n * Compose it as `<ExpandableSearch>` (the form root, owning the value and the\n * focus-within state) around one `<ExpandableSearchField>` (the input and its\n * submit button) — typically inside `HeaderActions`.\n *\n * Ported from nswds-app's `ExpandableSearch`. The mechanic is kept verbatim —\n * the collapsed control IS the text input, styled as a chip, so that the very\n * first focus or tap both reveals and focuses the field with no extra step.\n * Expansion is pure CSS keyed on the active state; no Base UI primitive is\n * used because none models this pattern (it is a styled form, not a popup —\n * focus never moves, nothing is portalled, nothing needs ARIA beyond the\n * label).\n *\n * Accessibility contract:\n * - The input carries a visually-hidden `<label>` and an `aria-label`\n * (default \"Search\"), and is `type='search'` with `enterKeyHint='search'`,\n * so its role and purpose are announced while it still looks like a button\n * (WCAG 2.2, 4.1.2; the source input was an unlabelled-by-type text input).\n * - Keyboard focus shows a 2px ink outline drawn inside the chip — the\n * source's ring was its own surface colour against a hardcoded white offset\n * and could vanish entirely (2.4.7, 2.4.13). See `searchFocusClassName`.\n * - Enter submits; Escape clears (native `type='search'` behaviour); an empty\n * blurred field collapses back to the chip.\n * - Expansion and halo transitions honour `prefers-reduced-motion` (2.3.3).\n *\n * Departures from the nswds-app source, beyond those above:\n * - React 19 `ref` prop instead of `forwardRef`.\n * - Four parallel 14-entry variant tables replaced by one ink-driven map —\n * see `expandableSearchVariants`.\n * - Expanded width `w-96` → `w-[min(24rem,80vw)]` so the field can never\n * overflow a small viewport (1.4.10 Reflow).\n * - The expanded state no longer sets `outline-none` (it would have killed\n * the new focus indicator; the source could afford it because its\n * indicator was a box-shadow ring).\n * - Expanded text selection uses `select-text`, not the source's\n * `select-auto` — `auto` computes from the root's `select-none` parent, so\n * the source's expanded field was unselectable.\n * - A consumer `onChange` on the field is chained after the context update\n * instead of replacing it (the source's spread order let it clobber the\n * controlled handler).\n *\n * The root deliberately does not claim `role='search'`: where the component\n * is the page's site search, add it yourself (one search landmark per page).\n */\nfunction ExpandableSearch({\n className,\n onAction,\n defaultValue = '',\n onSubmit,\n onFocusCapture,\n onBlurCapture,\n variant,\n ref,\n ...props\n}: ExpandableSearchProps) {\n const [value, setValue] = React.useState(defaultValue)\n const [formHasFocusWithin, setFormHasFocusWithin] = React.useState(false)\n // Resolved once (see `resolveVariant`), so cva, `data-variant` and the\n // context agree for `null` and `''` as well as the default spelling.\n const resolvedVariant: ExpandableSearchVariant = resolveVariant(variant, 'default')\n const isActive = value.length > 0 || formHasFocusWithin\n\n const contextValue = React.useMemo(\n () => ({ value, setValue, formHasFocusWithin, variant: resolvedVariant }),\n [value, formHasFocusWithin, resolvedVariant],\n )\n\n const handleSubmit = (e: React.SubmitEvent<HTMLFormElement>) => {\n onSubmit?.(e)\n\n if (e.defaultPrevented) {\n return\n }\n\n e.preventDefault()\n onAction?.(value)\n }\n\n const handleFocusCapture = (e: React.FocusEvent<HTMLFormElement>) => {\n setFormHasFocusWithin(true)\n onFocusCapture?.(e)\n }\n\n const handleBlurCapture = (e: React.FocusEvent<HTMLFormElement>) => {\n const nextFocusedElement = e.relatedTarget as Node | null\n\n if (!e.currentTarget.contains(nextFocusedElement)) {\n setFormHasFocusWithin(false)\n }\n\n onBlurCapture?.(e)\n }\n\n return (\n <ExpandableSearchContext.Provider value={contextValue}>\n <form\n data-slot='expandable-search'\n // Present-or-absent rather than \"true\"/\"false\", so it reads like Base\n // UI's data-* attributes and Tailwind's bare `data-expanded:` variant\n // works. Same convention as Header's data-scrolled.\n data-expanded={isActive || undefined}\n {...props}\n // After the spread, so a consumer's own `data-variant` cannot desync\n // the attribute from the classes both derive from the resolved value.\n data-variant={resolvedVariant}\n // The surface (and its ink) lives on the root so BOTH children — the\n // input and the absolutely-positioned submit button — inherit the\n // custom properties. The root shrink-wraps the input, so painting the\n // background here is visually identical to painting it on the input.\n className={cn(expandableSearchVariants({ variant: resolvedVariant }), className)}\n onBlurCapture={handleBlurCapture}\n onFocusCapture={handleFocusCapture}\n onSubmit={handleSubmit}\n ref={ref}\n />\n </ExpandableSearchContext.Provider>\n )\n}\n\n/**\n * The input and its submit button. Must be rendered inside `ExpandableSearch`,\n * which owns the value and the focus-within state.\n *\n * The submit button is `pointer-events-none` while collapsed — deliberately,\n * per the source: collapsed, the input overlays the exact same 48px square and\n * OWNS the click, so a tap lands on the input, focuses it, and expands the\n * field. Making the button clickable there would submit an empty query\n * instead of opening the field. It also never traps keyboard focus while\n * collapsed: the input precedes it in tab order, and focusing the input\n * expands the field before the button is reached.\n */\nfunction ExpandableSearchField({\n className,\n id,\n label = 'Search',\n 'aria-label': ariaLabel,\n autoComplete = 'off',\n enterKeyHint = 'search',\n onChange,\n buttonLabel = 'Search',\n buttonProps,\n ref,\n ...props\n}: ExpandableSearchFieldProps) {\n const context = React.useContext(ExpandableSearchContext)\n if (!context) throw new Error('ExpandableSearchField must be used within ExpandableSearch')\n\n const generatedId = React.useId()\n const {\n className: buttonClassName,\n children: buttonChildren,\n 'aria-label': buttonAriaLabel,\n ...restButtonProps\n } = buttonProps ?? {}\n\n const isActive = context.value.length > 0 || context.formHasFocusWithin\n const inputId = id ?? generatedId\n\n warnIfFieldUnlabelled(label, ariaLabel)\n\n const handleChange = (e: React.ChangeEvent<HTMLInputElement>) => {\n context.setValue(e.target.value)\n onChange?.(e)\n }\n\n return (\n <div data-slot='expandable-search-field' className='relative flex-1'>\n {label ? (\n // aria-label (below) wins for the accessible name where both exist;\n // the label element is kept for source parity and so a click on any\n // future visible rendering of it focuses the input.\n <label className='sr-only' htmlFor={inputId}>\n {label}\n </label>\n ) : null}\n\n <input\n data-slot='expandable-search-input'\n aria-label={ariaLabel ?? (label || undefined)}\n autoComplete={autoComplete}\n enterKeyHint={enterKeyHint}\n {...props}\n type='search'\n id={inputId}\n value={context.value}\n onChange={handleChange}\n className={cn(\n // Collapsed, the input is a 48px chip: transparent text and\n // placeholder so nothing peeks out, cursor-pointer because it acts\n // as the \"open search\" affordance. The background comes from the\n // form root, which shrink-wraps this element.\n 'flex h-12 w-12 cursor-pointer overflow-hidden rounded-sm border-0 bg-transparent text-transparent',\n 'placeholder:text-transparent placeholder:opacity-0',\n 'duration-300 ease-in-out motion-safe:transition-[width,box-shadow,background-color]',\n // Hide WebKit's native clear affordance: the source field (type\n // text) had none, and Escape already clears a search input.\n '[&::-webkit-search-cancel-button]:appearance-none',\n searchFocusClassName,\n isActive\n ? // Expanded: capped at 80vw so the field cannot overflow small\n // viewports (the source's fixed w-96 could). pr-12 reserves the\n // submit button's square. select-text (not select-auto — see\n // the component JSDoc) re-enables selection under the root's\n // select-none.\n 'w-[min(24rem,80vw)] cursor-auto pt-0 pr-12 pb-0 pl-4 text-inherit select-text placeholder:text-(--search-placeholder) placeholder:opacity-100'\n : // Collapsed: the chip halos on hover exactly like the button\n // does — one visual whether the pointer technically rests on\n // the input overlay or not.\n 'p-0 hover:bg-(--search-halo)',\n className,\n )}\n ref={ref}\n />\n\n <button\n data-slot='expandable-search-button'\n aria-label={buttonAriaLabel ?? buttonLabel}\n {...restButtonProps}\n type='submit'\n className={cn(\n 'absolute top-0 right-0 z-10 flex h-12 w-12 cursor-pointer rounded-sm',\n 'duration-200 motion-safe:transition-[background-color,box-shadow]',\n // Icon and halos all derive from the ink; the whole-form\n // focus-within halo marks the button as the pending action while\n // the user types.\n 'text-(--search-ink)',\n 'group-focus-within/search:bg-(--search-halo) hover:bg-(--search-halo) active:bg-(--search-halo-active)',\n searchFocusClassName,\n // Collapsed, the input overlay owns the click — see the JSDoc.\n isActive ? 'pointer-events-auto' : 'pointer-events-none',\n buttonClassName,\n )}\n >\n {buttonChildren ?? (\n <IconSearch aria-hidden='true' className='m-auto block size-8 shrink-0 fill-current' />\n )}\n </button>\n </div>\n )\n}\n\nexport { ExpandableSearch, ExpandableSearchField, expandableSearchVariants }\nexport type {\n ExpandableSearchButtonProps,\n ExpandableSearchFieldProps,\n ExpandableSearchProps,\n ExpandableSearchVariant,\n}\n"]}
|
|
@@ -183,7 +183,7 @@ type FooterSmallPrintProps = React__default.ComponentPropsWithoutRef<'div'> & {
|
|
|
183
183
|
* copyright sentence when an agency needs different wording.
|
|
184
184
|
*/
|
|
185
185
|
declare function FooterSmallPrint({ className, department, socialLinks, year, children, ref, ...props }: FooterSmallPrintProps): React__default.JSX.Element;
|
|
186
|
-
type FooterProps = React__default.ComponentPropsWithoutRef<'footer'> & VariantProps<typeof footerVariants> & VariantProps<typeof footerContainerVariants> & {
|
|
186
|
+
type FooterProps = Omit<React__default.ComponentPropsWithoutRef<'footer'>, 'color'> & VariantProps<typeof footerVariants> & VariantProps<typeof footerContainerVariants> & {
|
|
187
187
|
/** Supporting/legal links — privacy, accessibility, copyright, etc. */
|
|
188
188
|
legalLinks?: FooterLegalLinkItem[];
|
|
189
189
|
/** Social channels rendered as icon-only links beside the copyright line. */
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { jsx, jsxs, Fragment } 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
|
import { ButtonLink, TouchTarget } from '../components/button.js';
|
|
5
6
|
import { Link } from '../components/link.js';
|
|
@@ -21,6 +22,7 @@ const footerColors = [
|
|
|
21
22
|
"white"
|
|
22
23
|
];
|
|
23
24
|
const DEFAULT_FOOTER_COLOR = "white";
|
|
25
|
+
const DEFAULT_FOOTER_CONTAINER = "fluid";
|
|
24
26
|
const footerReversedLogoColors = /* @__PURE__ */ new Set(["primary-800", "grey-800", "accent-800"]);
|
|
25
27
|
const footerMonoLogoColors = /* @__PURE__ */ new Set(["primary-600", "grey-600", "accent-600"]);
|
|
26
28
|
function warnIfMonoLogoRequired(color) {
|
|
@@ -32,7 +34,7 @@ function warnIfMonoLogoRequired(color) {
|
|
|
32
34
|
);
|
|
33
35
|
}
|
|
34
36
|
function footerLogoType(color) {
|
|
35
|
-
const resolved = color
|
|
37
|
+
const resolved = resolveVariant(color, DEFAULT_FOOTER_COLOR);
|
|
36
38
|
if (footerReversedLogoColors.has(resolved)) {
|
|
37
39
|
return "reversed";
|
|
38
40
|
}
|
|
@@ -115,7 +117,7 @@ const footerContainerVariants = cva(
|
|
|
115
117
|
}
|
|
116
118
|
},
|
|
117
119
|
defaultVariants: {
|
|
118
|
-
container:
|
|
120
|
+
container: DEFAULT_FOOTER_CONTAINER
|
|
119
121
|
}
|
|
120
122
|
}
|
|
121
123
|
);
|
|
@@ -323,19 +325,21 @@ function Footer({
|
|
|
323
325
|
}) {
|
|
324
326
|
const showAcknowledgement = Boolean(acknowledgement);
|
|
325
327
|
const showLegalLinks = legalLinks.length > 0;
|
|
328
|
+
const colorway = resolveVariant(color, DEFAULT_FOOTER_COLOR);
|
|
329
|
+
const containerway = resolveVariant(container, DEFAULT_FOOTER_CONTAINER);
|
|
326
330
|
return /* @__PURE__ */ jsx(
|
|
327
331
|
"footer",
|
|
328
332
|
{
|
|
329
333
|
"data-slot": "footer",
|
|
330
|
-
"data-color": color ?? DEFAULT_FOOTER_COLOR,
|
|
331
334
|
...props,
|
|
332
|
-
|
|
335
|
+
"data-color": colorway,
|
|
336
|
+
className: cn(footerVariants({ color: colorway }), className),
|
|
333
337
|
ref,
|
|
334
338
|
children: /* @__PURE__ */ jsxs(
|
|
335
339
|
"div",
|
|
336
340
|
{
|
|
337
341
|
"data-slot": "footer-container",
|
|
338
|
-
className: cn(footerContainerVariants({ container }), containerClassName),
|
|
342
|
+
className: cn(footerContainerVariants({ container: containerway }), containerClassName),
|
|
339
343
|
children: [
|
|
340
344
|
topBorder && /* @__PURE__ */ jsx(Separator, { decorative: true, className: "mb-4 bg-(--footer-border)" }),
|
|
341
345
|
children,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/components/footer.tsx"],"names":[],"mappings":";;;;;;;AAyBA,MAAM,YAAA,GAAe;AAAA,EACnB,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,oBAAA,GAAoC,OAAA;AAO1C,MAAM,2CAA2B,IAAI,GAAA,CAAiB,CAAC,aAAA,EAAe,UAAA,EAAY,YAAY,CAAC,CAAA;AAO/F,MAAM,uCAAuB,IAAI,GAAA,CAAiB,CAAC,aAAA,EAAe,UAAA,EAAY,YAAY,CAAC,CAAA;AAU3F,SAAS,uBAAuB,KAAA,EAAoB;AAClD,EAAA,IAAI,OAAA,CAAQ,GAAA,CAAI,QAAA,KAAa,YAAA,EAAc;AACzC,IAAA;AAAA,EACF;AACA,EAAA,OAAA,CAAQ,IAAA;AAAA,IACN,4BAA4B,KAAK,CAAA,4PAAA;AAAA,GACnC;AACF;AAiCA,SAAS,eAAe,KAAA,EAAmE;AACzF,EAAA,MAAM,WAAW,KAAA,IAAS,oBAAA;AAC1B,EAAA,IAAI,wBAAA,CAAyB,GAAA,CAAI,QAAQ,CAAA,EAAG;AAC1C,IAAA,OAAO,UAAA;AAAA,EACT;AACA,EAAA,IAAI,oBAAA,CAAqB,GAAA,CAAI,QAAQ,CAAA,EAAG;AACtC,IAAA,sBAAA,CAAuB,QAAQ,CAAA;AAC/B,IAAA,OA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antProps } from 'class-variance-authority'\nimport React from 'react'\n\nimport { cn } from '../lib/utils.js'\n\nimport { ButtonLink, type IconSlot, TouchTarget } from '../components/button.js'\nimport { Link } from '../components/link.js'\nimport { Separator } from '../components/separator.js'\n\n/**\n * Surface colours the footer can be themed with. Each one names its 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 * Every light pair clears WCAG 2.2 AA (1.4.3, 4.5:1) for the footer's smallest\n * text and 11 of the 13 also clear AAA (1.4.6, 7:1). The two AA-only pairs are\n * `primary-600` (4.57:1) and `accent-600` (5.18:1), both with white ink; prefer\n * the `-800` steps when a service is held to AAA. In dark mode all thirteen\n * clear AAA (worst 13.6:1).\n *\n * Unlike `Masthead` — which is restricted to verified AAA pairs because it is\n * legally-mandated identification — the footer carries supporting content, so\n * the full tonal range is offered here.\n */\nconst footerColors = [\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 FooterColor = (typeof footerColors)[number]\n\n// Shared by cva's defaultVariants and the data-color attribute, so the two\n// can't drift apart.\nconst DEFAULT_FOOTER_COLOR: FooterColor = 'white'\n\n/**\n * Surfaces dark enough that the full-colour mark is illegible but the waratah\n * still reads — the `-800` steps. These take the masterbrand's \"full colour\n * reversed\" logo: white wordmark, red waratah.\n */\nconst footerReversedLogoColors = new Set<FooterColor>(['primary-800', 'grey-800', 'accent-800'])\n\n/**\n * Mid-tone surfaces — the `-600` steps — where NEITHER masterbrand colourway is\n * legible, so the restricted mono logo is the only option left. See\n * `footerLogoType` for the approval this carries.\n */\nconst footerMonoLogoColors = new Set<FooterColor>(['primary-600', 'grey-600', 'accent-600'])\n\n/**\n * Dev-only notice that a surface has forced the mark onto the mono logo. The\n * masterbrand guidelines class mono as RESTRICTED USE ONLY — \"only when a\n * design cannot accommodate for the full colour or reverse (red waratah)\n * logos\" — and require approval from the NSW Government Brand Team before it\n * is used. A design system cannot grant that approval, so it says so rather\n * than applying the treatment silently. No-op in production.\n */\nfunction warnIfMonoLogoRequired(color: FooterColor) {\n if (process.env.NODE_ENV === 'production') {\n return\n }\n console.warn(\n `[nswds/ui] Footer color=\"${color}\" leaves the NSW Government logo no legible masterbrand colourway, so the RESTRICTED mono logo is used. The guidelines require NSW Government Brand Team approval for mono. Prefer the \"-800\" step of this family, which takes the sanctioned reversed logo.`,\n )\n}\n\n/**\n * The `Logo` treatment the masterbrand guidelines call for on a given footer\n * surface.\n *\n * The brand mark does not inherit: its wordmark and waratah are painted from\n * fixed palette values under `logoType='default'`, so nothing in the footer's\n * ink chain reaches them and the treatment has to be chosen against the\n * surface. Getting it wrong is not subtle — `--primary-800` and\n * `--nsw-blue-800` are the same value, so `default` on a `primary-800` footer\n * paints the wordmark in exactly its own background at 1:1 contrast.\n *\n * The guidelines rank the colourways, and this follows that order:\n *\n * - **Full colour (`default`)** \"must be given preference over all other\n * versions\". Used on every light surface.\n * - **Full colour reversed (`reversed`)** is the sanctioned alternative \"where\n * the primary logo is illegible\" — the `-800` steps. Measured against those\n * three surfaces the white wordmark runs 13.6–15.1:1 and the waratah\n * 2.6–2.9:1, so both halves of the mark read.\n * - **Mono is RESTRICTED USE ONLY** and needs Brand Team approval. It is the\n * last resort here, not the default, and only the `-600` steps reach it:\n * against those the waratah measures 1.00, 1.13 and 1.59:1 — on\n * `accent-600` it is literally the same value as the surface\n * (`--accent-600` IS `--nsw-red-600`), so a reversed mark would lose its\n * flower exactly the way `default` lost its wordmark. That matches the\n * guidelines' own accessibility table, where the mid-tone row is crossed\n * for full colour AND for reversed.\n *\n * Light mode only, in every case: under `.dark` the mark's waratah flips to\n * white and every surface deepens, so all thirteen render an all-white logo.\n */\nfunction footerLogoType(color?: FooterColor | null): 'default' | 'reversed' | 'mono-white' {\n const resolved = color ?? DEFAULT_FOOTER_COLOR\n if (footerReversedLogoColors.has(resolved)) {\n return 'reversed'\n }\n if (footerMonoLogoColors.has(resolved)) {\n warnIfMonoLogoRequired(resolved)\n return 'mono-white'\n }\n return 'default'\n}\n\nconst footerVariants = cva(\n [\n 'w-full',\n // Every derived colour in the footer resolves from a single --footer-ink\n // token, so a colour variant only has to declare the surface utilities and\n // that one value. The derivations are written literally here (once) rather\n // than per-variant: Tailwind scans source text for class names, so a\n // template-built arbitrary property would never be emitted.\n //\n // Mirrors the color-mix derivation in link.tsx (--link-halo).\n '[--footer-border:color-mix(in_oklch,var(--footer-ink)_15%,transparent)]',\n '[--footer-halo:color-mix(in_oklch,var(--footer-ink)_10%,transparent)]',\n '[--footer-halo-active:color-mix(in_oklch,var(--footer-ink)_18%,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 // Note: a bracketed example in a comment here would itself be scanned by\n // Tailwind and emitted as a dead rule — keep such examples out of prose.\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 — so the\n // luminance ORDER within a family is preserved: the variant named for the\n // heaviest tone stays the heaviest. Ink goes white on all thirteen, and\n // every dark pair is WCAG 2.2 AAA (worst 13.6:1) — better than light\n // mode, where primary-600 and accent-600 are AA-only.\n color: {\n 'primary-800':\n 'bg-primary-800 text-white [--footer-ink:var(--color-white)] dark:bg-primary-950',\n 'primary-600':\n 'bg-primary-600 text-white [--footer-ink:var(--color-white)] dark:bg-primary-900',\n 'primary-400':\n 'bg-primary-400 text-primary-800 [--footer-ink:var(--primary-800)] dark:bg-primary-850 dark:text-white dark:[--footer-ink:var(--color-white)]',\n 'primary-200':\n 'bg-primary-200 text-primary-800 [--footer-ink:var(--primary-800)] dark:bg-primary-800 dark:text-white dark:[--footer-ink:var(--color-white)]',\n 'grey-800': 'bg-grey-800 text-white [--footer-ink:var(--color-white)] dark:bg-grey-950',\n 'grey-600': 'bg-grey-600 text-white [--footer-ink:var(--color-white)] dark:bg-grey-900',\n 'grey-400':\n 'bg-grey-400 text-grey-800 [--footer-ink:var(--grey-800)] dark:bg-grey-850 dark:text-white dark:[--footer-ink:var(--color-white)]',\n 'grey-200':\n 'bg-grey-200 text-grey-800 [--footer-ink:var(--grey-800)] dark:bg-grey-800 dark:text-white dark:[--footer-ink:var(--color-white)]',\n 'accent-800':\n 'bg-accent-800 text-white [--footer-ink:var(--color-white)] dark:bg-accent-950',\n 'accent-600':\n 'bg-accent-600 text-white [--footer-ink:var(--color-white)] dark:bg-accent-900',\n 'accent-400':\n 'bg-accent-400 text-accent-800 [--footer-ink:var(--accent-800)] dark:bg-accent-850 dark:text-white dark:[--footer-ink:var(--color-white)]',\n 'accent-200':\n 'bg-accent-200 text-accent-800 [--footer-ink:var(--accent-800)] dark:bg-accent-800 dark:text-white dark:[--footer-ink:var(--color-white)]',\n white:\n 'bg-white text-grey-800 [--footer-ink:var(--grey-800)] dark:bg-grey-900 dark:text-white dark:[--footer-ink:var(--color-white)]',\n },\n },\n defaultVariants: {\n color: DEFAULT_FOOTER_COLOR,\n },\n },\n)\n\nconst footerContainerVariants = cva(\n [\n 'mx-auto flex w-full flex-col max-sm:py-6 sm:py-8',\n // Lateral padding funnels through --footer-padding-x so an app can retune\n // it once (via the `style` prop or a utility class) without a new variant.\n // Same mechanism, and the same 16px → 24px → 48px rhythm, as the Masthead.\n 'px-(--footer-padding-x)',\n '[--footer-padding-x:--spacing(4)] sm:[--footer-padding-x:--spacing(6)] lg:[--footer-padding-x:--spacing(12)]',\n ],\n {\n variants: {\n container: {\n // Full-bleed (nswds-app parity). --footer-max-width is still read so a\n // shell app can constrain the inner wrapper without switching variants.\n fluid: 'max-w-[var(--footer-max-width,none)]',\n // Centred content column, legacy nsw-container parity (1200px).\n contained: 'max-w-[var(--footer-max-width,75rem)]',\n },\n },\n defaultVariants: {\n container: 'fluid',\n },\n },\n)\n\n/** A link rendered anywhere in the footer — legal row or site-map column. */\ntype FooterLinkItem = {\n /** Visible link text, e.g. \"Privacy\". */\n name: string\n href: string\n}\n\n/** Alias kept for the legal-links context, where the name reads better. */\ntype FooterLegalLinkItem = FooterLinkItem\n\n/** A social channel rendered as an icon-only link in the small print row. */\ntype FooterSocialLinkItem = {\n /** Channel name, e.g. \"LinkedIn\". Used to build the accessible name. */\n name: string\n href: string\n /**\n * Icon for the channel — the component (`IconLinkedIn`) or an element\n * (`<IconLinkedIn />`). Rendered through `ButtonLink`'s `leadingVisual` slot,\n * which sizes and colours it.\n *\n * Brand marks are not in the NSWDS icon set — which is Material Symbols — but\n * the six the NSW Government uses ship in the package's own `icons/brands`\n * subpath, already client-safe. (Registry consumers copy source, so they get\n * them from the `icon-brands` registry item instead; see the README.)\n *\n * `Footer` is server-compatible but `ButtonLink` is not, so a React Server\n * Component assembling `socialLinks` from its OWN plain icon modules must use\n * the element form — a bare function cannot cross the RSC boundary. The marks\n * above are client references, so either form works for them. See `IconSlot`.\n */\n icon: IconSlot\n /**\n * Accessible name for the link. Defaults to `Follow us on {name}`.\n */\n label?: string\n}\n\n// One link treatment for the whole footer — legal row and site-map columns\n// alike — so a consumer never has to reason about which kind they are styling.\nconst footerLinkClassName = [\n // Negative margin + padding keeps the hover/focus halo from shifting layout.\n '-m-1 rounded-sm p-1 text-(--footer-ink)',\n // relative + inline-flex position the TouchTarget expansion layer these links\n // render (see FooterNavLink / FooterLegalLinks). At text-sm the visible box is\n // 28px — 20px line box plus the 8px of padding above — which clears WCAG 2.2\n // AA 2.5.8 (24px) but sits well under the 44px floor DESIGN.md commits the\n // system to, and which the sibling FooterSocialLink already gets for free by\n // going through ButtonLink. Growing the box instead would have pushed a\n // mobile site map roughly 300px taller and broken the icon alignment in\n // FooterContact, so the hit area grows and the layout does not. inline-flex\n // (not inline) gives the absolutely-positioned layer a predictable box to\n // measure 100% against — an inline <a> that wraps has no single box.\n //\n // The list gaps are deliberately NOT widened to stop adjacent expansions\n // overlapping. In a site-map column the 28px boxes sit 8px apart, so 44px\n // layers overlap by 8px and each link's exclusive area is the 36px between\n // midpoints — still better than 28px boxes separated by 8px of dead gap,\n // and it leaves no unclickable band at all. Widening the gap under\n // `pointer:coarse` would also mean pairing a bare utility with a conditional\n // override of the same property, which check:cascade rejects, and guarding\n // it with `pointer:fine` instead would drop the gap to zero on `pointer:none`\n // devices.\n 'relative inline-flex items-center',\n 'underline decoration-current underline-offset-4',\n 'motion-safe:transition-colors',\n 'hover:bg-(--footer-halo) hover:decoration-2',\n 'active:bg-(--footer-halo-active) active:decoration-2',\n // outline-(--footer-ink) guarantees the indicator contrasts with the surface\n // on every colour variant (2.4.13 Focus Appearance).\n 'focus-visible:outline focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-(--footer-ink)',\n].join(' ')\n\n// Repoints ButtonLink's ghost-variant tokens at the footer's ink and halos so\n// the social buttons follow the surface colour instead of the button palette.\n// The `dark:` repeat is load-bearing, not redundant: `styles.colors` in\n// button.tsx gives each colour a `dark:[--btn-bg:…]` ink counterpart, which\n// would otherwise outrank the bare declaration here and repaint these glyphs in\n// the palette's ink. Restating it under the same variant makes the two\n// equal-specificity, and tailwind-merge keeps this one because the component's\n// className is merged last. `--footer-ink` already resolves per theme.\nconst footerSocialLinkClassName = [\n '[--btn-bg:var(--footer-ink)] dark:[--btn-bg:var(--footer-ink)]',\n '[--btn-icon:var(--footer-ink)]',\n '[--btn-transparent:transparent]',\n '[--btn-hover-overlay:var(--footer-halo)]',\n '[--btn-active-overlay:var(--footer-halo-active)]',\n].join(' ')\n\ntype FooterSocialLinkProps = Omit<\n React.ComponentPropsWithoutRef<typeof ButtonLink>,\n 'children' | 'color' | 'leadingVisual' | 'size' | 'variant'\n> & {\n /** Channel mark — component or element. See `IconSlot`. */\n icon: IconSlot\n /** Accessible name, e.g. \"Follow us on LinkedIn\". */\n label: string\n}\n\n/**\n * Icon-only link to a social channel. Renders through `ButtonLink`, so it\n * picks up the framework link component from `LinkProvider` and the 44px touch\n * target. The label is supplied as `aria-label` — there is no visible text.\n */\nfunction FooterSocialLink({ className, icon, label, ...props }: FooterSocialLinkProps) {\n return (\n <ButtonLink\n data-slot='footer-social-link'\n {...props}\n aria-label={label}\n variant='ghost'\n size='icon'\n leadingVisual={icon}\n className={cn(footerSocialLinkClassName, className)}\n />\n )\n}\n\ntype FooterAcknowledgementProps = React.ComponentPropsWithoutRef<'div'> & {\n ref?: React.Ref<HTMLDivElement>\n}\n\n/**\n * Acknowledgement of Country. Renders the standard NSW Government wording\n * unless `children` are supplied — pass your own text when an agency has\n * agreed different wording with the relevant Traditional Custodians.\n */\nfunction FooterAcknowledgement({ className, children, ref, ...props }: FooterAcknowledgementProps) {\n return (\n <div\n data-slot='footer-acknowledgement'\n {...props}\n className={cn('flex flex-row items-center gap-5 py-4', className)}\n ref={ref}\n >\n <p className='text-base text-pretty text-(--footer-ink) max-lg:text-center lg:text-left'>\n {children ??\n 'We acknowledge the Traditional Custodians of the land on which we work and live, and pay our respects to Elders past, present and emerging.'}\n </p>\n </div>\n )\n}\n\ntype FooterLegalLinksProps = Omit<React.ComponentPropsWithoutRef<'nav'>, 'children'> & {\n legalLinks: FooterLegalLinkItem[]\n ref?: React.Ref<HTMLElement>\n}\n\n/**\n * Navigation landmark holding the footer's supporting/legal links. Renders\n * nothing when `legalLinks` is empty, so an empty landmark is never exposed to\n * assistive tech.\n */\nfunction FooterLegalLinks({\n className,\n legalLinks,\n 'aria-label': ariaLabel = 'Footer',\n ref,\n ...props\n}: FooterLegalLinksProps) {\n if (legalLinks.length === 0) {\n return null\n }\n\n return (\n <nav\n data-slot='footer-legal-links'\n {...props}\n aria-label={ariaLabel}\n className={cn(\n 'flex flex-wrap gap-x-4 gap-y-3 py-4 text-sm max-lg:justify-center lg:justify-start',\n className,\n )}\n ref={ref}\n >\n {legalLinks.map((item) => (\n // variant='unstyled' — the footer supplies its own link treatment,\n // derived from --footer-ink so it tracks the surface colour. Link's own\n // variants are pinned to the primary palette (and flip in dark mode),\n // which would break on a coloured footer.\n <Link key={item.name} variant='unstyled' href={item.href} className={footerLinkClassName}>\n <TouchTarget>{item.name}</TouchTarget>\n </Link>\n ))}\n </nav>\n )\n}\n\ntype FooterNavLinkProps = Omit<React.ComponentPropsWithoutRef<typeof Link>, 'variant'>\n\n/**\n * A single site-map link, carrying the same ink-derived treatment as the legal\n * row. Exposed so a bespoke column layout (a mobile accordion, say) can match\n * the built-in columns without copying class strings.\n */\nfunction FooterNavLink({ className, children, ...props }: FooterNavLinkProps) {\n return (\n <Link\n data-slot='footer-nav-link'\n variant='unstyled'\n {...props}\n className={cn(footerLinkClassName, className)}\n >\n <TouchTarget>{children}</TouchTarget>\n </Link>\n )\n}\n\ntype FooterNavProps = React.ComponentPropsWithoutRef<'nav'> & {\n ref?: React.Ref<HTMLElement>\n}\n\n/**\n * Navigation landmark wrapping the footer's site-map columns.\n *\n * One landmark for the whole site map rather than one per column: a large\n * footer would otherwise add five nav landmarks to the page, burying the ones\n * that matter when a screen-reader user lists them. Columns are headed lists\n * inside it. The default four-column grid is overridable — `cn` lets a\n * `lg:grid-cols-3` on `className` win.\n */\nfunction FooterNav({\n className,\n 'aria-label': ariaLabel = 'Site map',\n ref,\n ...props\n}: FooterNavProps) {\n return (\n <nav\n data-slot='footer-nav'\n {...props}\n aria-label={ariaLabel}\n className={cn('grid gap-8 py-4 sm:max-lg:grid-cols-2 lg:grid-cols-4', className)}\n ref={ref}\n />\n )\n}\n\ntype FooterNavColumnProps = Omit<React.ComponentPropsWithoutRef<'div'>, 'children'> & {\n heading: React.ReactNode\n links: FooterLinkItem[]\n /**\n * Heading level for the column title. Defaults to `2` — correct when the\n * footer sits at the top level of the document outline. Step it down if the\n * surrounding page nests the footer under another heading, so the outline\n * stays in order (WCAG 1.3.1).\n *\n * The two bounds are not symmetric. `6` is simply the deepest heading HTML\n * defines. `1` is excluded on purpose: a site-map column title is never the\n * page's own title, so an `h1` here would be the very outline error the prop\n * exists to avoid.\n */\n headingLevel?: 2 | 3 | 4 | 5 | 6\n ref?: React.Ref<HTMLDivElement>\n}\n\n/** A headed column of site-map links. Sits inside `FooterNav`. */\nfunction FooterNavColumn({\n className,\n heading,\n links,\n headingLevel = 2,\n ref,\n ...props\n}: FooterNavColumnProps) {\n const Heading = `h${headingLevel}` as const\n\n return (\n <div\n data-slot='footer-nav-column'\n {...props}\n className={cn('flex flex-col gap-3', className)}\n ref={ref}\n >\n <Heading className='text-sm font-bold text-(--footer-ink)'>{heading}</Heading>\n <ul className='flex list-none flex-col gap-2 text-sm'>\n {links.map((item) => (\n <li key={item.name}>\n <FooterNavLink href={item.href}>{item.name}</FooterNavLink>\n </li>\n ))}\n </ul>\n </div>\n )\n}\n\ntype FooterSmallPrintProps = React.ComponentPropsWithoutRef<'div'> & {\n /** Owning agency, e.g. \"Digital NSW, Department of Customer Service\". */\n department?: string\n socialLinks?: FooterSocialLinkItem[]\n /**\n * Copyright year. Defaults to the current year read at render time — which\n * on a server-rendered page is the *server's* year, so a request that\n * straddles new year (or a server in a different timezone to the audience)\n * can hydrate with a mismatch. Pass an explicit year to pin it.\n */\n year?: number\n ref?: React.Ref<HTMLDivElement>\n}\n\n/**\n * Copyright line and social channels. `children` replace the generated\n * copyright sentence when an agency needs different wording.\n */\nfunction FooterSmallPrint({\n className,\n department,\n socialLinks,\n year = new Date().getFullYear(),\n children,\n ref,\n ...props\n}: FooterSmallPrintProps) {\n return (\n <div\n data-slot='footer-small-print'\n {...props}\n className={cn(\n 'flex items-center justify-between gap-5 pt-4 max-sm:flex-col sm:flex-row',\n className,\n )}\n ref={ref}\n >\n <p className='text-sm text-(--footer-ink) max-lg:text-center lg:text-left'>\n {children ?? (\n <>\n © Copyright {year}\n {department ? ` ${department}` : ''}. All rights reserved.\n </>\n )}\n </p>\n {socialLinks && socialLinks.length > 0 && (\n <ul className='flex list-none gap-4 max-lg:justify-center lg:justify-end'>\n {socialLinks.map((item) => (\n <li key={item.name}>\n <FooterSocialLink\n href={item.href}\n icon={item.icon}\n label={item.label ?? `Follow us on ${item.name}`}\n />\n </li>\n ))}\n </ul>\n )}\n </div>\n )\n}\n\ntype FooterProps = React.ComponentPropsWithoutRef<'footer'> &\n VariantProps<typeof footerVariants> &\n VariantProps<typeof footerContainerVariants> & {\n /** Supporting/legal links — privacy, accessibility, copyright, etc. */\n legalLinks?: FooterLegalLinkItem[]\n /** Social channels rendered as icon-only links beside the copyright line. */\n socialLinks?: FooterSocialLinkItem[]\n /** Owning agency, named in the copyright line. */\n department?: string\n /**\n * Acknowledgement of Country. `true` (default) renders the standard\n * wording, `false` omits it, and a node replaces the wording.\n */\n acknowledgement?: boolean | React.ReactNode\n /**\n * Copyright line and social channels. Defaults to `true` — the copyright\n * line renders even with no `department` to name, since it is the footer's\n * core content.\n */\n smallPrint?: boolean\n /** Rule along the top edge of the footer content. Defaults to `true`. */\n topBorder?: boolean\n /** Copyright year. See `FooterSmallPrint` for the SSR caveat. */\n year?: number\n /** Classes applied to the inner width-constraining wrapper. */\n containerClassName?: string\n /**\n * Extra content rendered above the acknowledgement — a logo, contact\n * details, or link columns.\n */\n children?: React.ReactNode\n ref?: React.Ref<HTMLElement>\n }\n\n/**\n * End-of-page `contentinfo` landmark: acknowledgement of Country, supporting\n * links, ownership and social channels. Render it once in a shared layout so\n * the same content appears on every page.\n *\n * - `color` themes the surface and names its light-mode tone; dark mode deepens\n * it onto the same family's dark steps. Every option meets WCAG 2.2 AA in\n * light mode and AAA in dark (see `footerColors`). All link, border and hover\n * colours derive from the surface's ink, so they follow automatically in both\n * themes.\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 `--footer-max-width`\n * and `--footer-padding-x` custom properties.\n * - Each section is independently omissible: `acknowledgement={false}`,\n * `smallPrint={false}`, or simply pass no `legalLinks` (an empty nav\n * landmark is never rendered). The rule between the acknowledgement and the\n * link row appears only when there is content on both sides of it.\n *\n * For a layout this does not cover, compose `FooterAcknowledgement`,\n * `FooterLegalLinks`, `FooterSmallPrint` and `FooterSocialLink` directly\n * inside your own `<footer>` — they all read the same `--footer-*` tokens.\n */\nfunction Footer({\n className,\n color,\n container,\n containerClassName,\n legalLinks = [],\n socialLinks,\n department,\n acknowledgement = true,\n smallPrint = true,\n topBorder = true,\n year,\n children,\n ref,\n ...props\n}: FooterProps) {\n // Boolean() rather than `!== false`: an empty string or 0 reaching this prop\n // would otherwise render an empty acknowledgement block.\n const showAcknowledgement = Boolean(acknowledgement)\n const showLegalLinks = legalLinks.length > 0\n\n return (\n <footer\n data-slot='footer'\n data-color={color ?? DEFAULT_FOOTER_COLOR}\n {...props}\n className={cn(footerVariants({ color }), className)}\n ref={ref}\n >\n <div\n data-slot='footer-container'\n className={cn(footerContainerVariants({ container }), containerClassName)}\n >\n {topBorder && <Separator decorative className='mb-4 bg-(--footer-border)' />}\n {children}\n {showAcknowledgement && (\n <FooterAcknowledgement>\n {acknowledgement === true ? undefined : acknowledgement}\n </FooterAcknowledgement>\n )}\n {/* Only a divider — never a boundary between two empty regions. */}\n {showAcknowledgement && (showLegalLinks || smallPrint) && (\n <Separator decorative className='my-4 bg-(--footer-border)' />\n )}\n {showLegalLinks && <FooterLegalLinks legalLinks={legalLinks} />}\n {smallPrint && (\n <FooterSmallPrint department={department} socialLinks={socialLinks} year={year} />\n )}\n </div>\n </footer>\n )\n}\n\nexport {\n Footer,\n FooterAcknowledgement,\n footerColors,\n footerContainerVariants,\n FooterLegalLinks,\n footerLogoType,\n FooterNav,\n FooterNavColumn,\n FooterNavLink,\n FooterSmallPrint,\n FooterSocialLink,\n footerVariants,\n}\nexport type {\n FooterAcknowledgementProps,\n FooterColor,\n FooterLegalLinkItem,\n FooterLegalLinksProps,\n FooterLinkItem,\n FooterNavColumnProps,\n FooterNavLinkProps,\n FooterNavProps,\n FooterProps,\n FooterSmallPrintProps,\n FooterSocialLinkItem,\n FooterSocialLinkProps,\n}\n"]}
|
|
1
|
+
{"version":3,"sources":["../../src/components/footer.tsx"],"names":[],"mappings":";;;;;;;;AA0BA,MAAM,YAAA,GAAe;AAAA,EACnB,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,oBAAA,GAAoC,OAAA;AAE1C,MAAM,wBAAA,GAA2B,OAAA;AAOjC,MAAM,2CAA2B,IAAI,GAAA,CAAiB,CAAC,aAAA,EAAe,UAAA,EAAY,YAAY,CAAC,CAAA;AAO/F,MAAM,uCAAuB,IAAI,GAAA,CAAiB,CAAC,aAAA,EAAe,UAAA,EAAY,YAAY,CAAC,CAAA;AAU3F,SAAS,uBAAuB,KAAA,EAAoB;AAClD,EAAA,IAAI,OAAA,CAAQ,GAAA,CAAI,QAAA,KAAa,YAAA,EAAc;AACzC,IAAA;AAAA,EACF;AACA,EAAA,OAAA,CAAQ,IAAA;AAAA,IACN,4BAA4B,KAAK,CAAA,4PAAA;AAAA,GACnC;AACF;AAiCA,SAAS,eAAe,KAAA,EAAmE;AACzF,EAAA,MAAM,QAAA,GAAW,cAAA,CAAe,KAAA,EAAO,oBAAoB,CAAA;AAC3D,EAAA,IAAI,wBAAA,CAAyB,GAAA,CAAI,QAAQ,CAAA,EAAG;AAC1C,IAAA,OAAO,UAAA;AAAA,EACT;AACA,EAAA,IAAI,oBAAA,CAAqB,GAAA,CAAI,QAAQ,CAAA,EAAG;AACtC,IAAA,sBAAA,CAAuB,QAAQ,CAAA;AAC/B,IAAA,OAAO,YAAA;A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AA,CAAC,gBAAA,EAAA,EAAiB,UAAA,EAAwB,aAA0B,IAAA,EAAY;AAAA;AAAA;AAAA;AAEpF;AAAA,GACF;AAEJ","file":"footer.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\nimport { ButtonLink, type IconSlot, TouchTarget } from '../components/button.js'\nimport { Link } from '../components/link.js'\nimport { Separator } from '../components/separator.js'\n\n/**\n * Surface colours the footer can be themed with. Each one names its 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 * Every light pair clears WCAG 2.2 AA (1.4.3, 4.5:1) for the footer's smallest\n * text and 11 of the 13 also clear AAA (1.4.6, 7:1). The two AA-only pairs are\n * `primary-600` (4.57:1) and `accent-600` (5.18:1), both with white ink; prefer\n * the `-800` steps when a service is held to AAA. In dark mode all thirteen\n * clear AAA (worst 13.6:1).\n *\n * Unlike `Masthead` — which is restricted to verified AAA pairs because it is\n * legally-mandated identification — the footer carries supporting content, so\n * the full tonal range is offered here.\n */\nconst footerColors = [\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 FooterColor = (typeof footerColors)[number]\n\n// Shared by cva's defaultVariants, the `resolveVariant` call in `Footer` and\n// `footerLogoType`, so they can't drift apart.\nconst DEFAULT_FOOTER_COLOR: FooterColor = 'white'\n// Shared by cva's defaultVariants and the `resolveVariant` call in `Footer`.\nconst DEFAULT_FOOTER_CONTAINER = 'fluid'\n\n/**\n * Surfaces dark enough that the full-colour mark is illegible but the waratah\n * still reads — the `-800` steps. These take the masterbrand's \"full colour\n * reversed\" logo: white wordmark, red waratah.\n */\nconst footerReversedLogoColors = new Set<FooterColor>(['primary-800', 'grey-800', 'accent-800'])\n\n/**\n * Mid-tone surfaces — the `-600` steps — where NEITHER masterbrand colourway is\n * legible, so the restricted mono logo is the only option left. See\n * `footerLogoType` for the approval this carries.\n */\nconst footerMonoLogoColors = new Set<FooterColor>(['primary-600', 'grey-600', 'accent-600'])\n\n/**\n * Dev-only notice that a surface has forced the mark onto the mono logo. The\n * masterbrand guidelines class mono as RESTRICTED USE ONLY — \"only when a\n * design cannot accommodate for the full colour or reverse (red waratah)\n * logos\" — and require approval from the NSW Government Brand Team before it\n * is used. A design system cannot grant that approval, so it says so rather\n * than applying the treatment silently. No-op in production.\n */\nfunction warnIfMonoLogoRequired(color: FooterColor) {\n if (process.env.NODE_ENV === 'production') {\n return\n }\n console.warn(\n `[nswds/ui] Footer color=\"${color}\" leaves the NSW Government logo no legible masterbrand colourway, so the RESTRICTED mono logo is used. The guidelines require NSW Government Brand Team approval for mono. Prefer the \"-800\" step of this family, which takes the sanctioned reversed logo.`,\n )\n}\n\n/**\n * The `Logo` treatment the masterbrand guidelines call for on a given footer\n * surface.\n *\n * The brand mark does not inherit: its wordmark and waratah are painted from\n * fixed palette values under `logoType='default'`, so nothing in the footer's\n * ink chain reaches them and the treatment has to be chosen against the\n * surface. Getting it wrong is not subtle — `--primary-800` and\n * `--nsw-blue-800` are the same value, so `default` on a `primary-800` footer\n * paints the wordmark in exactly its own background at 1:1 contrast.\n *\n * The guidelines rank the colourways, and this follows that order:\n *\n * - **Full colour (`default`)** \"must be given preference over all other\n * versions\". Used on every light surface.\n * - **Full colour reversed (`reversed`)** is the sanctioned alternative \"where\n * the primary logo is illegible\" — the `-800` steps. Measured against those\n * three surfaces the white wordmark runs 13.6–15.1:1 and the waratah\n * 2.6–2.9:1, so both halves of the mark read.\n * - **Mono is RESTRICTED USE ONLY** and needs Brand Team approval. It is the\n * last resort here, not the default, and only the `-600` steps reach it:\n * against those the waratah measures 1.00, 1.13 and 1.59:1 — on\n * `accent-600` it is literally the same value as the surface\n * (`--accent-600` IS `--nsw-red-600`), so a reversed mark would lose its\n * flower exactly the way `default` lost its wordmark. That matches the\n * guidelines' own accessibility table, where the mid-tone row is crossed\n * for full colour AND for reversed.\n *\n * Light mode only, in every case: under `.dark` the mark's waratah flips to\n * white and every surface deepens, so all thirteen render an all-white logo.\n */\nfunction footerLogoType(color?: FooterColor | null): 'default' | 'reversed' | 'mono-white' {\n const resolved = resolveVariant(color, DEFAULT_FOOTER_COLOR)\n if (footerReversedLogoColors.has(resolved)) {\n return 'reversed'\n }\n if (footerMonoLogoColors.has(resolved)) {\n warnIfMonoLogoRequired(resolved)\n return 'mono-white'\n }\n return 'default'\n}\n\nconst footerVariants = cva(\n [\n 'w-full',\n // Every derived colour in the footer resolves from a single --footer-ink\n // token, so a colour variant only has to declare the surface utilities and\n // that one value. The derivations are written literally here (once) rather\n // than per-variant: Tailwind scans source text for class names, so a\n // template-built arbitrary property would never be emitted.\n //\n // Mirrors the color-mix derivation in link.tsx (--link-halo).\n '[--footer-border:color-mix(in_oklch,var(--footer-ink)_15%,transparent)]',\n '[--footer-halo:color-mix(in_oklch,var(--footer-ink)_10%,transparent)]',\n '[--footer-halo-active:color-mix(in_oklch,var(--footer-ink)_18%,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 // Note: a bracketed example in a comment here would itself be scanned by\n // Tailwind and emitted as a dead rule — keep such examples out of prose.\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 — so the\n // luminance ORDER within a family is preserved: the variant named for the\n // heaviest tone stays the heaviest. Ink goes white on all thirteen, and\n // every dark pair is WCAG 2.2 AAA (worst 13.6:1) — better than light\n // mode, where primary-600 and accent-600 are AA-only.\n color: {\n 'primary-800':\n 'bg-primary-800 text-white [--footer-ink:var(--color-white)] dark:bg-primary-950',\n 'primary-600':\n 'bg-primary-600 text-white [--footer-ink:var(--color-white)] dark:bg-primary-900',\n 'primary-400':\n 'bg-primary-400 text-primary-800 [--footer-ink:var(--primary-800)] dark:bg-primary-850 dark:text-white dark:[--footer-ink:var(--color-white)]',\n 'primary-200':\n 'bg-primary-200 text-primary-800 [--footer-ink:var(--primary-800)] dark:bg-primary-800 dark:text-white dark:[--footer-ink:var(--color-white)]',\n 'grey-800': 'bg-grey-800 text-white [--footer-ink:var(--color-white)] dark:bg-grey-950',\n 'grey-600': 'bg-grey-600 text-white [--footer-ink:var(--color-white)] dark:bg-grey-900',\n 'grey-400':\n 'bg-grey-400 text-grey-800 [--footer-ink:var(--grey-800)] dark:bg-grey-850 dark:text-white dark:[--footer-ink:var(--color-white)]',\n 'grey-200':\n 'bg-grey-200 text-grey-800 [--footer-ink:var(--grey-800)] dark:bg-grey-800 dark:text-white dark:[--footer-ink:var(--color-white)]',\n 'accent-800':\n 'bg-accent-800 text-white [--footer-ink:var(--color-white)] dark:bg-accent-950',\n 'accent-600':\n 'bg-accent-600 text-white [--footer-ink:var(--color-white)] dark:bg-accent-900',\n 'accent-400':\n 'bg-accent-400 text-accent-800 [--footer-ink:var(--accent-800)] dark:bg-accent-850 dark:text-white dark:[--footer-ink:var(--color-white)]',\n 'accent-200':\n 'bg-accent-200 text-accent-800 [--footer-ink:var(--accent-800)] dark:bg-accent-800 dark:text-white dark:[--footer-ink:var(--color-white)]',\n white:\n 'bg-white text-grey-800 [--footer-ink:var(--grey-800)] dark:bg-grey-900 dark:text-white dark:[--footer-ink:var(--color-white)]',\n },\n },\n defaultVariants: {\n color: DEFAULT_FOOTER_COLOR,\n },\n },\n)\n\nconst footerContainerVariants = cva(\n [\n 'mx-auto flex w-full flex-col max-sm:py-6 sm:py-8',\n // Lateral padding funnels through --footer-padding-x so an app can retune\n // it once (via the `style` prop or a utility class) without a new variant.\n // Same mechanism, and the same 16px → 24px → 48px rhythm, as the Masthead.\n 'px-(--footer-padding-x)',\n '[--footer-padding-x:--spacing(4)] sm:[--footer-padding-x:--spacing(6)] lg:[--footer-padding-x:--spacing(12)]',\n ],\n {\n variants: {\n container: {\n // Full-bleed (nswds-app parity). --footer-max-width is still read so a\n // shell app can constrain the inner wrapper without switching variants.\n fluid: 'max-w-[var(--footer-max-width,none)]',\n // Centred content column, legacy nsw-container parity (1200px).\n contained: 'max-w-[var(--footer-max-width,75rem)]',\n },\n },\n defaultVariants: {\n container: DEFAULT_FOOTER_CONTAINER,\n },\n },\n)\n\n/** A link rendered anywhere in the footer — legal row or site-map column. */\ntype FooterLinkItem = {\n /** Visible link text, e.g. \"Privacy\". */\n name: string\n href: string\n}\n\n/** Alias kept for the legal-links context, where the name reads better. */\ntype FooterLegalLinkItem = FooterLinkItem\n\n/** A social channel rendered as an icon-only link in the small print row. */\ntype FooterSocialLinkItem = {\n /** Channel name, e.g. \"LinkedIn\". Used to build the accessible name. */\n name: string\n href: string\n /**\n * Icon for the channel — the component (`IconLinkedIn`) or an element\n * (`<IconLinkedIn />`). Rendered through `ButtonLink`'s `leadingVisual` slot,\n * which sizes and colours it.\n *\n * Brand marks are not in the NSWDS icon set — which is Material Symbols — but\n * the six the NSW Government uses ship in the package's own `icons/brands`\n * subpath, already client-safe. (Registry consumers copy source, so they get\n * them from the `icon-brands` registry item instead; see the README.)\n *\n * `Footer` is server-compatible but `ButtonLink` is not, so a React Server\n * Component assembling `socialLinks` from its OWN plain icon modules must use\n * the element form — a bare function cannot cross the RSC boundary. The marks\n * above are client references, so either form works for them. See `IconSlot`.\n */\n icon: IconSlot\n /**\n * Accessible name for the link. Defaults to `Follow us on {name}`.\n */\n label?: string\n}\n\n// One link treatment for the whole footer — legal row and site-map columns\n// alike — so a consumer never has to reason about which kind they are styling.\nconst footerLinkClassName = [\n // Negative margin + padding keeps the hover/focus halo from shifting layout.\n '-m-1 rounded-sm p-1 text-(--footer-ink)',\n // relative + inline-flex position the TouchTarget expansion layer these links\n // render (see FooterNavLink / FooterLegalLinks). At text-sm the visible box is\n // 28px — 20px line box plus the 8px of padding above — which clears WCAG 2.2\n // AA 2.5.8 (24px) but sits well under the 44px floor DESIGN.md commits the\n // system to, and which the sibling FooterSocialLink already gets for free by\n // going through ButtonLink. Growing the box instead would have pushed a\n // mobile site map roughly 300px taller and broken the icon alignment in\n // FooterContact, so the hit area grows and the layout does not. inline-flex\n // (not inline) gives the absolutely-positioned layer a predictable box to\n // measure 100% against — an inline <a> that wraps has no single box.\n //\n // The list gaps are deliberately NOT widened to stop adjacent expansions\n // overlapping. In a site-map column the 28px boxes sit 8px apart, so 44px\n // layers overlap by 8px and each link's exclusive area is the 36px between\n // midpoints — still better than 28px boxes separated by 8px of dead gap,\n // and it leaves no unclickable band at all. Widening the gap under\n // `pointer:coarse` would also mean pairing a bare utility with a conditional\n // override of the same property, which check:cascade rejects, and guarding\n // it with `pointer:fine` instead would drop the gap to zero on `pointer:none`\n // devices.\n 'relative inline-flex items-center',\n 'underline decoration-current underline-offset-4',\n 'motion-safe:transition-colors',\n 'hover:bg-(--footer-halo) hover:decoration-2',\n 'active:bg-(--footer-halo-active) active:decoration-2',\n // outline-(--footer-ink) guarantees the indicator contrasts with the surface\n // on every colour variant (2.4.13 Focus Appearance).\n 'focus-visible:outline focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-(--footer-ink)',\n].join(' ')\n\n// Repoints ButtonLink's ghost-variant tokens at the footer's ink and halos so\n// the social buttons follow the surface colour instead of the button palette.\n// The `dark:` repeat is load-bearing, not redundant: `styles.colors` in\n// button.tsx gives each colour a `dark:[--btn-bg:…]` ink counterpart, which\n// would otherwise outrank the bare declaration here and repaint these glyphs in\n// the palette's ink. Restating it under the same variant makes the two\n// equal-specificity, and tailwind-merge keeps this one because the component's\n// className is merged last. `--footer-ink` already resolves per theme.\nconst footerSocialLinkClassName = [\n '[--btn-bg:var(--footer-ink)] dark:[--btn-bg:var(--footer-ink)]',\n '[--btn-icon:var(--footer-ink)]',\n '[--btn-transparent:transparent]',\n '[--btn-hover-overlay:var(--footer-halo)]',\n '[--btn-active-overlay:var(--footer-halo-active)]',\n].join(' ')\n\ntype FooterSocialLinkProps = Omit<\n React.ComponentPropsWithoutRef<typeof ButtonLink>,\n 'children' | 'color' | 'leadingVisual' | 'size' | 'variant'\n> & {\n /** Channel mark — component or element. See `IconSlot`. */\n icon: IconSlot\n /** Accessible name, e.g. \"Follow us on LinkedIn\". */\n label: string\n}\n\n/**\n * Icon-only link to a social channel. Renders through `ButtonLink`, so it\n * picks up the framework link component from `LinkProvider` and the 44px touch\n * target. The label is supplied as `aria-label` — there is no visible text.\n */\nfunction FooterSocialLink({ className, icon, label, ...props }: FooterSocialLinkProps) {\n return (\n <ButtonLink\n data-slot='footer-social-link'\n {...props}\n aria-label={label}\n variant='ghost'\n size='icon'\n leadingVisual={icon}\n className={cn(footerSocialLinkClassName, className)}\n />\n )\n}\n\ntype FooterAcknowledgementProps = React.ComponentPropsWithoutRef<'div'> & {\n ref?: React.Ref<HTMLDivElement>\n}\n\n/**\n * Acknowledgement of Country. Renders the standard NSW Government wording\n * unless `children` are supplied — pass your own text when an agency has\n * agreed different wording with the relevant Traditional Custodians.\n */\nfunction FooterAcknowledgement({ className, children, ref, ...props }: FooterAcknowledgementProps) {\n return (\n <div\n data-slot='footer-acknowledgement'\n {...props}\n className={cn('flex flex-row items-center gap-5 py-4', className)}\n ref={ref}\n >\n <p className='text-base text-pretty text-(--footer-ink) max-lg:text-center lg:text-left'>\n {children ??\n 'We acknowledge the Traditional Custodians of the land on which we work and live, and pay our respects to Elders past, present and emerging.'}\n </p>\n </div>\n )\n}\n\ntype FooterLegalLinksProps = Omit<React.ComponentPropsWithoutRef<'nav'>, 'children'> & {\n legalLinks: FooterLegalLinkItem[]\n ref?: React.Ref<HTMLElement>\n}\n\n/**\n * Navigation landmark holding the footer's supporting/legal links. Renders\n * nothing when `legalLinks` is empty, so an empty landmark is never exposed to\n * assistive tech.\n */\nfunction FooterLegalLinks({\n className,\n legalLinks,\n 'aria-label': ariaLabel = 'Footer',\n ref,\n ...props\n}: FooterLegalLinksProps) {\n if (legalLinks.length === 0) {\n return null\n }\n\n return (\n <nav\n data-slot='footer-legal-links'\n {...props}\n aria-label={ariaLabel}\n className={cn(\n 'flex flex-wrap gap-x-4 gap-y-3 py-4 text-sm max-lg:justify-center lg:justify-start',\n className,\n )}\n ref={ref}\n >\n {legalLinks.map((item) => (\n // variant='unstyled' — the footer supplies its own link treatment,\n // derived from --footer-ink so it tracks the surface colour. Link's own\n // variants are pinned to the primary palette (and flip in dark mode),\n // which would break on a coloured footer.\n <Link key={item.name} variant='unstyled' href={item.href} className={footerLinkClassName}>\n <TouchTarget>{item.name}</TouchTarget>\n </Link>\n ))}\n </nav>\n )\n}\n\ntype FooterNavLinkProps = Omit<React.ComponentPropsWithoutRef<typeof Link>, 'variant'>\n\n/**\n * A single site-map link, carrying the same ink-derived treatment as the legal\n * row. Exposed so a bespoke column layout (a mobile accordion, say) can match\n * the built-in columns without copying class strings.\n */\nfunction FooterNavLink({ className, children, ...props }: FooterNavLinkProps) {\n return (\n <Link\n data-slot='footer-nav-link'\n variant='unstyled'\n {...props}\n className={cn(footerLinkClassName, className)}\n >\n <TouchTarget>{children}</TouchTarget>\n </Link>\n )\n}\n\ntype FooterNavProps = React.ComponentPropsWithoutRef<'nav'> & {\n ref?: React.Ref<HTMLElement>\n}\n\n/**\n * Navigation landmark wrapping the footer's site-map columns.\n *\n * One landmark for the whole site map rather than one per column: a large\n * footer would otherwise add five nav landmarks to the page, burying the ones\n * that matter when a screen-reader user lists them. Columns are headed lists\n * inside it. The default four-column grid is overridable — `cn` lets a\n * `lg:grid-cols-3` on `className` win.\n */\nfunction FooterNav({\n className,\n 'aria-label': ariaLabel = 'Site map',\n ref,\n ...props\n}: FooterNavProps) {\n return (\n <nav\n data-slot='footer-nav'\n {...props}\n aria-label={ariaLabel}\n className={cn('grid gap-8 py-4 sm:max-lg:grid-cols-2 lg:grid-cols-4', className)}\n ref={ref}\n />\n )\n}\n\ntype FooterNavColumnProps = Omit<React.ComponentPropsWithoutRef<'div'>, 'children'> & {\n heading: React.ReactNode\n links: FooterLinkItem[]\n /**\n * Heading level for the column title. Defaults to `2` — correct when the\n * footer sits at the top level of the document outline. Step it down if the\n * surrounding page nests the footer under another heading, so the outline\n * stays in order (WCAG 1.3.1).\n *\n * The two bounds are not symmetric. `6` is simply the deepest heading HTML\n * defines. `1` is excluded on purpose: a site-map column title is never the\n * page's own title, so an `h1` here would be the very outline error the prop\n * exists to avoid.\n */\n headingLevel?: 2 | 3 | 4 | 5 | 6\n ref?: React.Ref<HTMLDivElement>\n}\n\n/** A headed column of site-map links. Sits inside `FooterNav`. */\nfunction FooterNavColumn({\n className,\n heading,\n links,\n headingLevel = 2,\n ref,\n ...props\n}: FooterNavColumnProps) {\n const Heading = `h${headingLevel}` as const\n\n return (\n <div\n data-slot='footer-nav-column'\n {...props}\n className={cn('flex flex-col gap-3', className)}\n ref={ref}\n >\n <Heading className='text-sm font-bold text-(--footer-ink)'>{heading}</Heading>\n <ul className='flex list-none flex-col gap-2 text-sm'>\n {links.map((item) => (\n <li key={item.name}>\n <FooterNavLink href={item.href}>{item.name}</FooterNavLink>\n </li>\n ))}\n </ul>\n </div>\n )\n}\n\ntype FooterSmallPrintProps = React.ComponentPropsWithoutRef<'div'> & {\n /** Owning agency, e.g. \"Digital NSW, Department of Customer Service\". */\n department?: string\n socialLinks?: FooterSocialLinkItem[]\n /**\n * Copyright year. Defaults to the current year read at render time — which\n * on a server-rendered page is the *server's* year, so a request that\n * straddles new year (or a server in a different timezone to the audience)\n * can hydrate with a mismatch. Pass an explicit year to pin it.\n */\n year?: number\n ref?: React.Ref<HTMLDivElement>\n}\n\n/**\n * Copyright line and social channels. `children` replace the generated\n * copyright sentence when an agency needs different wording.\n */\nfunction FooterSmallPrint({\n className,\n department,\n socialLinks,\n year = new Date().getFullYear(),\n children,\n ref,\n ...props\n}: FooterSmallPrintProps) {\n return (\n <div\n data-slot='footer-small-print'\n {...props}\n className={cn(\n 'flex items-center justify-between gap-5 pt-4 max-sm:flex-col sm:flex-row',\n className,\n )}\n ref={ref}\n >\n <p className='text-sm text-(--footer-ink) max-lg:text-center lg:text-left'>\n {children ?? (\n <>\n © Copyright {year}\n {department ? ` ${department}` : ''}. All rights reserved.\n </>\n )}\n </p>\n {socialLinks && socialLinks.length > 0 && (\n <ul className='flex list-none gap-4 max-lg:justify-center lg:justify-end'>\n {socialLinks.map((item) => (\n <li key={item.name}>\n <FooterSocialLink\n href={item.href}\n icon={item.icon}\n label={item.label ?? `Follow us on ${item.name}`}\n />\n </li>\n ))}\n </ul>\n )}\n </div>\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 FooterProps = Omit<React.ComponentPropsWithoutRef<'footer'>, 'color'> &\n VariantProps<typeof footerVariants> &\n VariantProps<typeof footerContainerVariants> & {\n /** Supporting/legal links — privacy, accessibility, copyright, etc. */\n legalLinks?: FooterLegalLinkItem[]\n /** Social channels rendered as icon-only links beside the copyright line. */\n socialLinks?: FooterSocialLinkItem[]\n /** Owning agency, named in the copyright line. */\n department?: string\n /**\n * Acknowledgement of Country. `true` (default) renders the standard\n * wording, `false` omits it, and a node replaces the wording.\n */\n acknowledgement?: boolean | React.ReactNode\n /**\n * Copyright line and social channels. Defaults to `true` — the copyright\n * line renders even with no `department` to name, since it is the footer's\n * core content.\n */\n smallPrint?: boolean\n /** Rule along the top edge of the footer content. Defaults to `true`. */\n topBorder?: boolean\n /** Copyright year. See `FooterSmallPrint` for the SSR caveat. */\n year?: number\n /** Classes applied to the inner width-constraining wrapper. */\n containerClassName?: string\n /**\n * Extra content rendered above the acknowledgement — a logo, contact\n * details, or link columns.\n */\n children?: React.ReactNode\n ref?: React.Ref<HTMLElement>\n }\n\n/**\n * End-of-page `contentinfo` landmark: acknowledgement of Country, supporting\n * links, ownership and social channels. Render it once in a shared layout so\n * the same content appears on every page.\n *\n * - `color` themes the surface and names its light-mode tone; dark mode deepens\n * it onto the same family's dark steps. Every option meets WCAG 2.2 AA in\n * light mode and AAA in dark (see `footerColors`). All link, border and hover\n * colours derive from the surface's ink, so they follow automatically in both\n * themes.\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 `--footer-max-width`\n * and `--footer-padding-x` custom properties.\n * - Each section is independently omissible: `acknowledgement={false}`,\n * `smallPrint={false}`, or simply pass no `legalLinks` (an empty nav\n * landmark is never rendered). The rule between the acknowledgement and the\n * link row appears only when there is content on both sides of it.\n *\n * For a layout this does not cover, compose `FooterAcknowledgement`,\n * `FooterLegalLinks`, `FooterSmallPrint` and `FooterSocialLink` directly\n * inside your own `<footer>` — they all read the same `--footer-*` tokens.\n */\nfunction Footer({\n className,\n color,\n container,\n containerClassName,\n legalLinks = [],\n socialLinks,\n department,\n acknowledgement = true,\n smallPrint = true,\n topBorder = true,\n year,\n children,\n ref,\n ...props\n}: FooterProps) {\n // Boolean() rather than `!== false`: an empty string or 0 reaching this prop\n // would otherwise render an empty acknowledgement block.\n const showAcknowledgement = Boolean(acknowledgement)\n const showLegalLinks = legalLinks.length > 0\n\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 // `--footer-max-width`, instead of dropping it.\n const colorway = resolveVariant(color, DEFAULT_FOOTER_COLOR)\n const containerway = resolveVariant(container, DEFAULT_FOOTER_CONTAINER)\n\n return (\n <footer\n data-slot='footer'\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(footerVariants({ color: colorway }), className)}\n ref={ref}\n >\n <div\n data-slot='footer-container'\n className={cn(footerContainerVariants({ container: containerway }), containerClassName)}\n >\n {topBorder && <Separator decorative className='mb-4 bg-(--footer-border)' />}\n {children}\n {showAcknowledgement && (\n <FooterAcknowledgement>\n {acknowledgement === true ? undefined : acknowledgement}\n </FooterAcknowledgement>\n )}\n {/* Only a divider — never a boundary between two empty regions. */}\n {showAcknowledgement && (showLegalLinks || smallPrint) && (\n <Separator decorative className='my-4 bg-(--footer-border)' />\n )}\n {showLegalLinks && <FooterLegalLinks legalLinks={legalLinks} />}\n {smallPrint && (\n <FooterSmallPrint department={department} socialLinks={socialLinks} year={year} />\n )}\n </div>\n </footer>\n )\n}\n\nexport {\n Footer,\n FooterAcknowledgement,\n footerColors,\n footerContainerVariants,\n FooterLegalLinks,\n footerLogoType,\n FooterNav,\n FooterNavColumn,\n FooterNavLink,\n FooterSmallPrint,\n FooterSocialLink,\n footerVariants,\n}\nexport type {\n FooterAcknowledgementProps,\n FooterColor,\n FooterLegalLinkItem,\n FooterLegalLinksProps,\n FooterLinkItem,\n FooterNavColumnProps,\n FooterNavLinkProps,\n FooterNavProps,\n FooterProps,\n FooterSmallPrintProps,\n FooterSocialLinkItem,\n FooterSocialLinkProps,\n}\n"]}
|
|
@@ -123,7 +123,7 @@ type HeaderActionsProps = React__default.ComponentPropsWithoutRef<'div'> & {
|
|
|
123
123
|
* navigation in your own `<nav>` inside `Header`.
|
|
124
124
|
*/
|
|
125
125
|
declare function HeaderActions({ className, ref, ...props }: HeaderActionsProps): React__default.JSX.Element;
|
|
126
|
-
type HeaderProps = React__default.ComponentPropsWithoutRef<'header'> & VariantProps<typeof headerVariants> & VariantProps<typeof headerContainerVariants> & {
|
|
126
|
+
type HeaderProps = Omit<React__default.ComponentPropsWithoutRef<'header'>, 'color'> & VariantProps<typeof headerVariants> & VariantProps<typeof headerContainerVariants> & {
|
|
127
127
|
/** Stick to the top of the viewport as the page scrolls. Defaults to `true`. */
|
|
128
128
|
sticky?: boolean;
|
|
129
129
|
/** Hairline rule along the bottom edge. Defaults to `true`. */
|
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
import { jsxs, jsx, Fragment } from 'react/jsx-runtime';
|
|
3
3
|
import { cva } from 'class-variance-authority';
|
|
4
4
|
import React from 'react';
|
|
5
|
+
import { resolveVariant } from '../lib/resolve-variant.js';
|
|
5
6
|
import { cn } from '../lib/utils.js';
|
|
6
7
|
import { Badge } from '../components/badge.js';
|
|
7
8
|
import { Link } from '../components/link.js';
|
|
@@ -19,6 +20,7 @@ const headerColors = {
|
|
|
19
20
|
grey: "bg-grey-800 text-white [--header-ink:var(--color-white)] dark:bg-grey-950"
|
|
20
21
|
};
|
|
21
22
|
const DEFAULT_HEADER_COLOR = "white";
|
|
23
|
+
const DEFAULT_HEADER_CONTAINER = "fluid";
|
|
22
24
|
const headerVariants = cva(
|
|
23
25
|
[
|
|
24
26
|
"w-full",
|
|
@@ -57,7 +59,7 @@ const headerContainerVariants = cva(
|
|
|
57
59
|
}
|
|
58
60
|
},
|
|
59
61
|
defaultVariants: {
|
|
60
|
-
container:
|
|
62
|
+
container: DEFAULT_HEADER_CONTAINER
|
|
61
63
|
}
|
|
62
64
|
}
|
|
63
65
|
);
|
|
@@ -229,16 +231,18 @@ function Header({
|
|
|
229
231
|
window.addEventListener("scroll", onScroll, { passive: true });
|
|
230
232
|
return () => window.removeEventListener("scroll", onScroll);
|
|
231
233
|
}, []);
|
|
234
|
+
const colorway = resolveVariant(color, DEFAULT_HEADER_COLOR);
|
|
235
|
+
const containerway = resolveVariant(container, DEFAULT_HEADER_CONTAINER);
|
|
232
236
|
return /* @__PURE__ */ jsx(
|
|
233
237
|
"header",
|
|
234
238
|
{
|
|
235
239
|
id: "nsw-header",
|
|
236
240
|
"data-slot": "header",
|
|
237
|
-
"data-color": color ?? DEFAULT_HEADER_COLOR,
|
|
238
241
|
"data-scrolled": isScrolled || void 0,
|
|
239
242
|
...props,
|
|
243
|
+
"data-color": colorway,
|
|
240
244
|
className: cn(
|
|
241
|
-
headerVariants({ color }),
|
|
245
|
+
headerVariants({ color: colorway }),
|
|
242
246
|
// z-40 sits below the z-50 SkipLinks: a sticky header at the same
|
|
243
247
|
// level comes later in the DOM and would paint over a focused skip
|
|
244
248
|
// link, hiding the page's bypass mechanism (WCAG 2.2, 2.4.1).
|
|
@@ -251,11 +255,11 @@ function Header({
|
|
|
251
255
|
className
|
|
252
256
|
),
|
|
253
257
|
ref,
|
|
254
|
-
children: /* @__PURE__ */ jsx(HeaderColorContext.Provider, { value:
|
|
258
|
+
children: /* @__PURE__ */ jsx(HeaderColorContext.Provider, { value: colorway, children: /* @__PURE__ */ jsx(
|
|
255
259
|
"div",
|
|
256
260
|
{
|
|
257
261
|
"data-slot": "header-container",
|
|
258
|
-
className: cn(headerContainerVariants({ container }), containerClassName),
|
|
262
|
+
className: cn(headerContainerVariants({ container: containerway }), containerClassName),
|
|
259
263
|
children
|
|
260
264
|
}
|
|
261
265
|
) })
|
|
@@ -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;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CAAA;AAExD,EAAA,KAAA,CAAM,UAAU,MAAM;AACpB,IAAA,SAAS,QAAA,GAAW;AAClB,MAAA,aAAA,CAAc,MAAA,CAAO,UAAU,CAAC,CAAA;AAAA,IAClC;AAGA,IAAA,QAAA,EAAS;AACT,IAAA,MAAA,CAAO,iBAAiB,QAAA,EAAU,QAAA,EAAU,EAAE,OAAA,EAAS,MAAM,CAAA;AAC7D,IAAA,OAAO,MAAM,MAAA,CAAO,mBAAA,CAAoB,QAAA,EAAU,QAAQ,CAAA;AAAA,EAC5D,CAAA,EAAG,EAAE,CAAA;AAEL,EAAA,uBACE,GAAA;AAAA,IAAC,QAAA;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
|
+
{"version":3,"sources":["../../src/components/header.tsx"],"names":[],"mappings":";;;;;;;;;AA6BA,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,wBAAA,GAA2B,OAAA;AAEjC,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,eA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AA,MAAA,CAAO,iBAAiB,QAAA,EAAU,QAAA,EAAU,EAAE,OAAA,EAAS,MAAM,CAAA;AAC7D,IAAA,OAAO,MAAM,MAAA,CAAO,mBAAA,CAAoB,QAAA,EAAU,QAAQ,CAAA;AAAA,EAC5D,CAAA,EAAG,EAAE,CAAA;AAML,EAAA,MAAM,QAAA,GAAW,cAAA,CAAe,KAAA,EAAO,oBAAoB,CAAA;AAC3D,EAAA,MAAM,YAAA,GAAe,cAAA,CAAe,SAAA,EAAW,wBAAwB,CAAA;AAEvE,EAAA,uBACE,GAAA;AAAA,IAAC,QAAA;AAAA,IAAA;AAAA,MACC,EAAA,EAAG,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" | "
|
|
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>;
|