@nswds/ui 5.1.2 → 5.2.0
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/README.md +36 -1
- package/dist/components/badge.d.ts +1 -1
- package/dist/components/button.d.ts +1 -1
- package/dist/components/callout.d.ts +60 -0
- package/dist/components/callout.js +65 -0
- package/dist/components/callout.js.map +1 -0
- package/dist/components/container.d.ts +36 -0
- package/dist/components/container.js +54 -0
- package/dist/components/container.js.map +1 -0
- package/dist/components/description-list.d.ts +72 -0
- package/dist/components/description-list.js +67 -0
- package/dist/components/description-list.js.map +1 -0
- package/dist/components/footer.d.ts +10 -6
- package/dist/components/footer.js.map +1 -1
- package/dist/components/header.d.ts +1 -1
- package/dist/components/link-card.d.ts +54 -0
- package/dist/components/link-card.js +82 -0
- package/dist/components/link-card.js.map +1 -0
- package/dist/components/masthead.d.ts +1 -1
- package/dist/components/on-this-page.d.ts +89 -0
- package/dist/components/on-this-page.js +127 -0
- package/dist/components/on-this-page.js.map +1 -0
- package/dist/components/section.d.ts +53 -0
- package/dist/components/section.js +44 -0
- package/dist/components/section.js.map +1 -0
- package/dist/components/skip-link.d.ts +1 -1
- package/dist/components/slider.d.ts +86 -0
- package/dist/components/slider.js +122 -0
- package/dist/components/slider.js.map +1 -0
- package/dist/hooks/use-chrome-height.d.ts +82 -0
- package/dist/hooks/use-chrome-height.js +45 -0
- package/dist/hooks/use-chrome-height.js.map +1 -0
- package/dist/icons/brands/index.d.ts +13 -0
- package/dist/icons/brands/index.js +56 -0
- package/dist/icons/brands/index.js.map +1 -0
- package/dist/icons/client.d.ts +1 -0
- package/dist/icons/client.js +2 -0
- package/dist/index.d.ts +9 -0
- package/dist/index.js +8 -0
- package/dist/styles.css +1 -1
- package/package.json +5 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/components/footer.tsx"],"names":[],"mappings":";;;;;;;AAyBA,MAAM,YAAA,GAAe;AAAA,EACnB,aAAA;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AAAA,MACpB,GAAG,KAAA;AAAA,MACJ,WAAW,EAAA,CAAG,cAAA,CAAe,EAAE,KAAA,EAAO,GAAG,SAAS,CAAA;AAAA,MAClD,GAAA;AAAA,MAEA,QAAA,kBAAA,IAAA;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,QAAA,EAAA;AAAA,YAAA,SAAA,oBAAa,GAAA,CAAC,SAAA,EAAA,EAAU,UAAA,EAAU,IAAA,EAAC,WAAU,2BAAA,EAA4B,CAAA;AAAA,YACzE,QAAA;AAAA,YACA,uCACC,GAAA,CAAC,qBAAA,EAAA,EACE,QAAA,EAAA,eAAA,KAAoB,IAAA,GAAO,SAAY,eAAA,EAC1C,CAAA;AAAA,YAGD,mBAAA,KAAwB,kBAAkB,UAAA,CAAA,oBACzC,GAAA,CAAC,aAAU,UAAA,EAAU,IAAA,EAAC,WAAU,2BAAA,EAA4B,CAAA;AAAA,YAE7D,cAAA,oBAAkB,GAAA,CAAC,gBAAA,EAAA,EAAiB,UAAA,EAAwB,CAAA;AAAA,YAC5D,UAAA,oBACC,GAAA,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 { 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 />`). Brand marks (LinkedIn, X, Facebook…) are not part of\n * the NSWDS icon set — which is Material Symbols — so the mark is supplied by\n * the consuming app. It is rendered through `ButtonLink`'s `leadingVisual`\n * slot, which sizes and colours it.\n *\n * `Footer` is server-compatible but `ButtonLink` is not, so a React Server\n * Component assembling `socialLinks` must use the element form; the component\n * form cannot cross the RSC boundary. 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":";;;;;;;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,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,KAAA;AAAA,QAAA;AAAA,UACC,WAAA,EAAU,kBAAA;AAAA,UACV,WAAW,EAAA,CAAG,uBAAA,CAAwB,EAAE,SAAA,EAAW,GAAG,kBAAkB,CAAA;AAAA,UAEvE,QAAA,EAAA;AAAA,YAAA,SAAA,oBAAa,GAAA,CAAC,SAAA,EAAA,EAAU,UAAA,EAAU,IAAA,EAAC,WAAU,2BAAA,EAA4B,CAAA;AAAA,YACzE,QAAA;AAAA,YACA,uCACC,GAAA,CAAC,qBAAA,EAAA,EACE,QAAA,EAAA,eAAA,KAAoB,IAAA,GAAO,SAAY,eAAA,EAC1C,CAAA;AAAA,YAGD,mBAAA,KAAwB,kBAAkB,UAAA,CAAA,oBACzC,GAAA,CAAC,aAAU,UAAA,EAAU,IAAA,EAAC,WAAU,2BAAA,EAA4B,CAAA;AAAA,YAE7D,cAAA,oBAAkB,GAAA,CAAC,gBAAA,EAAA,EAAiB,UAAA,EAAwB,CAAA;AAAA,YAC5D,UAAA,oBACC,GAAA,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 { 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"]}
|
|
@@ -30,7 +30,7 @@ declare const headerColors: {
|
|
|
30
30
|
};
|
|
31
31
|
type HeaderColor = keyof typeof headerColors;
|
|
32
32
|
declare const headerVariants: (props?: ({
|
|
33
|
-
color?: "
|
|
33
|
+
color?: "white" | "grey" | "light" | "dark" | null | undefined;
|
|
34
34
|
} & class_variance_authority_types.ClassProp) | undefined) => string;
|
|
35
35
|
declare const headerContainerVariants: (props?: ({
|
|
36
36
|
container?: "fluid" | "contained" | null | undefined;
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import { Link } from './link.js';
|
|
3
|
+
import 'class-variance-authority/types';
|
|
4
|
+
import 'class-variance-authority';
|
|
5
|
+
|
|
6
|
+
type LinkCardProps = Omit<React.ComponentPropsWithoutRef<'div'>, 'title'> & {
|
|
7
|
+
/** Destination. Routed through `Link`, so `LinkProvider` applies. */
|
|
8
|
+
href: React.ComponentPropsWithoutRef<typeof Link>['href'];
|
|
9
|
+
/** The card's heading, and its accessible name. */
|
|
10
|
+
title: React.ReactNode;
|
|
11
|
+
/** Optional short kicker above the title — a category, date or type. */
|
|
12
|
+
label?: React.ReactNode;
|
|
13
|
+
/** Supporting copy under the title. */
|
|
14
|
+
description?: React.ReactNode;
|
|
15
|
+
/**
|
|
16
|
+
* Render the link as an `ExternalLink` — adds the "opens in a new tab"
|
|
17
|
+
* treatment and its accessible-name suffix, and swaps the corner glyph for
|
|
18
|
+
* the outward arrow.
|
|
19
|
+
*/
|
|
20
|
+
external?: boolean;
|
|
21
|
+
ref?: React.Ref<HTMLDivElement>;
|
|
22
|
+
};
|
|
23
|
+
/**
|
|
24
|
+
* A card whose entire surface is one link.
|
|
25
|
+
*
|
|
26
|
+
* **Why this exists as a component rather than a documented recipe.** The
|
|
27
|
+
* obvious way to build a linked card — an anchor on the title, another on the
|
|
28
|
+
* description, a third on the arrow — gives one destination three tab stops
|
|
29
|
+
* and three competing accessible names, and it is what people reach for every
|
|
30
|
+
* time. This composes `Card` with a single anchor stretched over the card via
|
|
31
|
+
* `after:absolute after:inset-0`, so the whole surface is clickable while the
|
|
32
|
+
* accessibility tree sees exactly one link named by the title.
|
|
33
|
+
*
|
|
34
|
+
* Consequences of the stretched-link technique, all deliberate:
|
|
35
|
+
*
|
|
36
|
+
* - **The card is `relative` and the anchor's `::after` is its hit area.** Any
|
|
37
|
+
* other interactive element inside the card would be covered by it. A card
|
|
38
|
+
* with a second action is the wrong component — compose `Card` by hand.
|
|
39
|
+
* - **Text inside the card is no longer selectable by dragging**, because the
|
|
40
|
+
* overlay swallows the drag. That is inherent to the pattern and is why it
|
|
41
|
+
* suits short promo cards rather than cards containing copy worth quoting.
|
|
42
|
+
* - **Focus is styled on the card, not the anchor.** The anchor's own outline
|
|
43
|
+
* would draw around its text box, not the surface the user is actually
|
|
44
|
+
* targeting, so the anchor drops its outline and the card takes a
|
|
45
|
+
* `focus-within` ring instead. Removing a focus indicator is only safe
|
|
46
|
+
* because an equivalent one is restored on the ancestor (WCAG 2.2, 2.4.7).
|
|
47
|
+
*
|
|
48
|
+
* The corner glyph and the hover lift are `motion-safe:` only, so a reader who
|
|
49
|
+
* has asked for reduced motion gets the colour change without the movement
|
|
50
|
+
* (WCAG 2.2, 2.3.3).
|
|
51
|
+
*/
|
|
52
|
+
declare function LinkCard({ className, href, title, label, description, external, children, ref, ...props }: LinkCardProps): React.JSX.Element;
|
|
53
|
+
|
|
54
|
+
export { LinkCard, type LinkCardProps };
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
import { jsxs, jsx } from 'react/jsx-runtime';
|
|
2
|
+
import { cn } from '../lib/utils.js';
|
|
3
|
+
import { Card, CardHeader, CardTitle, CardContent, CardDescription } from '../components/card.js';
|
|
4
|
+
import { ExternalLink, Link } from '../components/link.js';
|
|
5
|
+
import { IconArrowForward } from '../icons/arrow-forward.js';
|
|
6
|
+
import { IconArrowOutward } from '../icons/arrow-outward.js';
|
|
7
|
+
|
|
8
|
+
function LinkCard({
|
|
9
|
+
className,
|
|
10
|
+
href,
|
|
11
|
+
title,
|
|
12
|
+
label,
|
|
13
|
+
description,
|
|
14
|
+
external = false,
|
|
15
|
+
children,
|
|
16
|
+
ref,
|
|
17
|
+
...props
|
|
18
|
+
}) {
|
|
19
|
+
const CornerIcon = external ? IconArrowOutward : IconArrowForward;
|
|
20
|
+
const anchorClassName = cn(
|
|
21
|
+
// The hit area: covers the whole card, sits above the content.
|
|
22
|
+
"after:absolute after:inset-0",
|
|
23
|
+
// See the component note — the ring moves to the card.
|
|
24
|
+
"focus-visible:outline-none",
|
|
25
|
+
"group-hover/link-card:text-primary motion-safe:transition-colors"
|
|
26
|
+
);
|
|
27
|
+
const anchor = external ? /* @__PURE__ */ jsx(
|
|
28
|
+
ExternalLink,
|
|
29
|
+
{
|
|
30
|
+
href,
|
|
31
|
+
variant: "unstyled",
|
|
32
|
+
icon: null,
|
|
33
|
+
className: anchorClassName,
|
|
34
|
+
children: title
|
|
35
|
+
}
|
|
36
|
+
) : /* @__PURE__ */ jsx(Link, { href, variant: "unstyled", className: anchorClassName, children: title });
|
|
37
|
+
return /* @__PURE__ */ jsxs(
|
|
38
|
+
Card,
|
|
39
|
+
{
|
|
40
|
+
ref,
|
|
41
|
+
"data-slot": "link-card",
|
|
42
|
+
className: cn(
|
|
43
|
+
"group/link-card relative h-full gap-3",
|
|
44
|
+
// The focus ring the stretched anchor gives up. `Card`'s own resting
|
|
45
|
+
// treatment is `ring-1 ring-foreground/10`, so this thickens and
|
|
46
|
+
// recolours the same ring rather than adding a second one.
|
|
47
|
+
"focus-within:ring-2 focus-within:ring-ring",
|
|
48
|
+
"hover:ring-2 hover:ring-primary",
|
|
49
|
+
"motion-safe:transition-all motion-safe:hover:-translate-y-0.5",
|
|
50
|
+
className
|
|
51
|
+
),
|
|
52
|
+
...props,
|
|
53
|
+
children: [
|
|
54
|
+
/* @__PURE__ */ jsxs(CardHeader, { children: [
|
|
55
|
+
label ? /* @__PURE__ */ jsx("p", { "data-slot": "link-card-label", className: "text-base/relaxed text-muted-foreground", children: label }) : null,
|
|
56
|
+
/* @__PURE__ */ jsx(CardTitle, { "data-slot": "link-card-title", className: "text-xl font-bold", children: anchor })
|
|
57
|
+
] }),
|
|
58
|
+
/* @__PURE__ */ jsxs(CardContent, { className: "flex flex-1 flex-col justify-between gap-6", children: [
|
|
59
|
+
description ? /* @__PURE__ */ jsx(CardDescription, { "data-slot": "link-card-description", children: description }) : null,
|
|
60
|
+
children,
|
|
61
|
+
/* @__PURE__ */ jsx(
|
|
62
|
+
CornerIcon,
|
|
63
|
+
{
|
|
64
|
+
"aria-hidden": "true",
|
|
65
|
+
"data-slot": "link-card-icon",
|
|
66
|
+
className: cn(
|
|
67
|
+
"size-6 text-muted-foreground",
|
|
68
|
+
"group-hover/link-card:text-primary",
|
|
69
|
+
"motion-safe:transition-transform motion-safe:group-hover/link-card:translate-x-0.5",
|
|
70
|
+
external && "motion-safe:group-hover/link-card:-translate-y-0.5"
|
|
71
|
+
)
|
|
72
|
+
}
|
|
73
|
+
)
|
|
74
|
+
] })
|
|
75
|
+
]
|
|
76
|
+
}
|
|
77
|
+
);
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
export { LinkCard };
|
|
81
|
+
//# sourceMappingURL=link-card.js.map
|
|
82
|
+
//# sourceMappingURL=link-card.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/components/link-card.tsx"],"names":[],"mappings":";;;;;;;AAwDA,SAAS,QAAA,CAAS;AAAA,EAChB,SAAA;AAAA,EACA,IAAA;AAAA,EACA,KAAA;AAAA,EACA,KAAA;AAAA,EACA,WAAA;AAAA,EACA,QAAA,GAAW,KAAA;AAAA,EACX,QAAA;AAAA,EACA,GAAA;AAAA,EACA,GAAG;AACL,CAAA,EAAkB;AAChB,EAAA,MAAM,UAAA,GAAa,WAAW,gBAAA,GAAmB,gBAAA;AAEjD,EAAA,MAAM,eAAA,GAAkB,EAAA;AAAA;AAAA,IAEtB,8BAAA;AAAA;AAAA,IAEA,4BAAA;AAAA,IACA;AAAA,GACF;AAKA,EAAA,MAAM,SAAS,QAAA,mBACb,GAAA;AAAA,IAAC,YAAA;AAAA,IAAA;AAAA,MACC,IAAA;AAAA,MACA,OAAA,EAAQ,UAAA;AAAA,MAOR,IAAA,EAAM,IAAA;AAAA,MACN,SAAA,EAAW,eAAA;AAAA,MAEV,QAAA,EAAA;AAAA;AAAA,GACH,uBAEC,IAAA,EAAA,EAAK,IAAA,EAAY,SAAQ,UAAA,EAAW,SAAA,EAAW,iBAC7C,QAAA,EAAA,KAAA,EACH,CAAA;AAGF,EAAA,uBACE,IAAA;AAAA,IAAC,IAAA;AAAA,IAAA;AAAA,MACC,GAAA;AAAA,MAMA,WAAA,EAAU,WAAA;AAAA,MACV,SAAA,EAAW,EAAA;AAAA,QACT,uCAAA;AAAA;AAAA;AAAA;AAAA,QAIA,4CAAA;AAAA,QACA,iCAAA;AAAA,QACA,+DAAA;AAAA,QACA;AAAA,OACF;AAAA,MACC,GAAG,KAAA;AAAA,MAEJ,QAAA,EAAA;AAAA,wBAAA,IAAA,CAAC,UAAA,EAAA,EACE,QAAA,EAAA;AAAA,UAAA,KAAA,uBACE,GAAA,EAAA,EAAE,WAAA,EAAU,mBAAkB,SAAA,EAAU,yCAAA,EACtC,iBACH,CAAA,GACE,IAAA;AAAA,8BACH,SAAA,EAAA,EAAU,WAAA,EAAU,iBAAA,EAAkB,SAAA,EAAU,qBAC9C,QAAA,EAAA,MAAA,EACH;AAAA,SAAA,EACF,CAAA;AAAA,wBAEA,IAAA,CAAC,WAAA,EAAA,EAAY,SAAA,EAAU,4CAAA,EACpB,QAAA,EAAA;AAAA,UAAA,WAAA,mBACC,GAAA,CAAC,eAAA,EAAA,EAAgB,WAAA,EAAU,uBAAA,EAAyB,uBAAY,CAAA,GAC9D,IAAA;AAAA,UACH,QAAA;AAAA,0BACD,GAAA;AAAA,YAAC,UAAA;AAAA,YAAA;AAAA,cACC,aAAA,EAAY,MAAA;AAAA,cACZ,WAAA,EAAU,gBAAA;AAAA,cACV,SAAA,EAAW,EAAA;AAAA,gBACT,8BAAA;AAAA,gBACA,oCAAA;AAAA,gBACA,oFAAA;AAAA,gBACA,QAAA,IAAY;AAAA;AACd;AAAA;AACF,SAAA,EACF;AAAA;AAAA;AAAA,GACF;AAEJ","file":"link-card.js","sourcesContent":["import type * as React from 'react'\n\nimport { cn } from '../lib/utils.js'\n\nimport { Card, CardContent, CardDescription, CardHeader, CardTitle } from '../components/card.js'\nimport { ExternalLink, Link } from '../components/link.js'\nimport { IconArrowForward } from '../icons/arrow-forward.js'\nimport { IconArrowOutward } from '../icons/arrow-outward.js'\n\ntype LinkCardProps = Omit<React.ComponentPropsWithoutRef<'div'>, 'title'> & {\n /** Destination. Routed through `Link`, so `LinkProvider` applies. */\n href: React.ComponentPropsWithoutRef<typeof Link>['href']\n /** The card's heading, and its accessible name. */\n title: React.ReactNode\n /** Optional short kicker above the title — a category, date or type. */\n label?: React.ReactNode\n /** Supporting copy under the title. */\n description?: React.ReactNode\n /**\n * Render the link as an `ExternalLink` — adds the \"opens in a new tab\"\n * treatment and its accessible-name suffix, and swaps the corner glyph for\n * the outward arrow.\n */\n external?: boolean\n ref?: React.Ref<HTMLDivElement>\n}\n\n/**\n * A card whose entire surface is one link.\n *\n * **Why this exists as a component rather than a documented recipe.** The\n * obvious way to build a linked card — an anchor on the title, another on the\n * description, a third on the arrow — gives one destination three tab stops\n * and three competing accessible names, and it is what people reach for every\n * time. This composes `Card` with a single anchor stretched over the card via\n * `after:absolute after:inset-0`, so the whole surface is clickable while the\n * accessibility tree sees exactly one link named by the title.\n *\n * Consequences of the stretched-link technique, all deliberate:\n *\n * - **The card is `relative` and the anchor's `::after` is its hit area.** Any\n * other interactive element inside the card would be covered by it. A card\n * with a second action is the wrong component — compose `Card` by hand.\n * - **Text inside the card is no longer selectable by dragging**, because the\n * overlay swallows the drag. That is inherent to the pattern and is why it\n * suits short promo cards rather than cards containing copy worth quoting.\n * - **Focus is styled on the card, not the anchor.** The anchor's own outline\n * would draw around its text box, not the surface the user is actually\n * targeting, so the anchor drops its outline and the card takes a\n * `focus-within` ring instead. Removing a focus indicator is only safe\n * because an equivalent one is restored on the ancestor (WCAG 2.2, 2.4.7).\n *\n * The corner glyph and the hover lift are `motion-safe:` only, so a reader who\n * has asked for reduced motion gets the colour change without the movement\n * (WCAG 2.2, 2.3.3).\n */\nfunction LinkCard({\n className,\n href,\n title,\n label,\n description,\n external = false,\n children,\n ref,\n ...props\n}: LinkCardProps) {\n const CornerIcon = external ? IconArrowOutward : IconArrowForward\n\n const anchorClassName = cn(\n // The hit area: covers the whole card, sits above the content.\n 'after:absolute after:inset-0',\n // See the component note — the ring moves to the card.\n 'focus-visible:outline-none',\n 'group-hover/link-card:text-primary motion-safe:transition-colors',\n )\n\n // Branched rather than `const Anchor = external ? ExternalLink : Link`: the\n // two components have different props (`icon` exists only on ExternalLink),\n // so a shared alias would type as their union and reject it.\n const anchor = external ? (\n <ExternalLink\n href={href}\n variant='unstyled'\n // `ExternalLink` renders its own trailing \"opens in a new tab\" glyph\n // inline after the title. The card already carries a corner glyph for\n // that job, and two marks for one link reads as two affordances — so the\n // inline one is suppressed and the corner icon changes shape instead.\n // The visually-hidden \"(opens in a new tab)\" suffix is untouched: the\n // announcement is the part a screen-reader user actually needs.\n icon={null}\n className={anchorClassName}\n >\n {title}\n </ExternalLink>\n ) : (\n <Link href={href} variant='unstyled' className={anchorClassName}>\n {title}\n </Link>\n )\n\n return (\n <Card\n ref={ref}\n // Deliberately replaces Card's own `data-slot=\"card\"` (props spread last\n // in card.tsx). `data-slot` names what a node IS, not what it is built\n // from, and nothing in the package selects `[data-slot=card]` — only\n // Card's own stories do. Card's `data-size` and `group/card` hooks are\n // untouched, so its internal padding selectors keep working.\n data-slot='link-card'\n className={cn(\n 'group/link-card relative h-full gap-3',\n // The focus ring the stretched anchor gives up. `Card`'s own resting\n // treatment is `ring-1 ring-foreground/10`, so this thickens and\n // recolours the same ring rather than adding a second one.\n 'focus-within:ring-2 focus-within:ring-ring',\n 'hover:ring-2 hover:ring-primary',\n 'motion-safe:transition-all motion-safe:hover:-translate-y-0.5',\n className,\n )}\n {...props}\n >\n <CardHeader>\n {label ? (\n <p data-slot='link-card-label' className='text-base/relaxed text-muted-foreground'>\n {label}\n </p>\n ) : null}\n <CardTitle data-slot='link-card-title' className='text-xl font-bold'>\n {anchor}\n </CardTitle>\n </CardHeader>\n\n <CardContent className='flex flex-1 flex-col justify-between gap-6'>\n {description ? (\n <CardDescription data-slot='link-card-description'>{description}</CardDescription>\n ) : null}\n {children}\n <CornerIcon\n aria-hidden='true'\n data-slot='link-card-icon'\n className={cn(\n 'size-6 text-muted-foreground',\n 'group-hover/link-card:text-primary',\n 'motion-safe:transition-transform motion-safe:group-hover/link-card:translate-x-0.5',\n external && 'motion-safe:group-hover/link-card:-translate-y-0.5',\n )}\n />\n </CardContent>\n </Card>\n )\n}\n\nexport { LinkCard }\nexport type { LinkCardProps }\n"]}
|
|
@@ -10,7 +10,7 @@ declare const mastheadColors: {
|
|
|
10
10
|
};
|
|
11
11
|
type MastheadColor = keyof typeof mastheadColors;
|
|
12
12
|
declare const mastheadVariants: (props?: ({
|
|
13
|
-
color?: "
|
|
13
|
+
color?: "white" | "grey" | "light" | "dark" | null | undefined;
|
|
14
14
|
} & class_variance_authority_types.ClassProp) | undefined) => string;
|
|
15
15
|
declare const mastheadContainerVariants: (props?: ({
|
|
16
16
|
container?: "fluid" | "contained" | null | undefined;
|
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
|
|
3
|
+
/** One in-page destination. `id` must match the `id` of an element on the page. */
|
|
4
|
+
type OnThisPageItem = {
|
|
5
|
+
/** `id` of the section this entry points at. */
|
|
6
|
+
id: string;
|
|
7
|
+
/** Visible link text. */
|
|
8
|
+
title: React.ReactNode;
|
|
9
|
+
};
|
|
10
|
+
type OnThisPageProps = Omit<React.ComponentPropsWithoutRef<'nav'>, 'children'> & {
|
|
11
|
+
/** In-page destinations, in document order. */
|
|
12
|
+
items: OnThisPageItem[];
|
|
13
|
+
/**
|
|
14
|
+
* `horizontal` is the sticky bar that docks under the site chrome;
|
|
15
|
+
* `vertical` is the left- or right-hand rail beside long-form content.
|
|
16
|
+
*
|
|
17
|
+
* @default 'horizontal'
|
|
18
|
+
*/
|
|
19
|
+
orientation?: 'horizontal' | 'vertical';
|
|
20
|
+
/**
|
|
21
|
+
* Y-coordinate, in CSS pixels from the top of the viewport, of the line a
|
|
22
|
+
* section must cross to count as the one being read. Set it to the height of
|
|
23
|
+
* whatever chrome overlays the top of the page (plus any slack you want),
|
|
24
|
+
* or sections scrolled to via their anchor register as active a fraction too
|
|
25
|
+
* late. `useChromeHeight` measures that number for you.
|
|
26
|
+
*
|
|
27
|
+
* @default 0
|
|
28
|
+
*/
|
|
29
|
+
offset?: number;
|
|
30
|
+
/**
|
|
31
|
+
* Active section (controlled). When set, the component reports what it
|
|
32
|
+
* observes through `onActiveChange` but never sets its own state — pick one
|
|
33
|
+
* mode per instance and stay in it, as with `ThemeSwitcher`.
|
|
34
|
+
*/
|
|
35
|
+
activeId?: string | null;
|
|
36
|
+
/** Fired whenever the observed section changes, in both modes. */
|
|
37
|
+
onActiveChange?: (id: string | null) => void;
|
|
38
|
+
/** Shown instead of the list when `items` is empty. `null` renders nothing. */
|
|
39
|
+
emptyMessage?: React.ReactNode;
|
|
40
|
+
ref?: React.Ref<HTMLElement>;
|
|
41
|
+
};
|
|
42
|
+
/**
|
|
43
|
+
* In-page navigation that tracks which section the reader has reached.
|
|
44
|
+
*
|
|
45
|
+
* **Not to be confused with the other three navigation components**, which
|
|
46
|
+
* this deliberately does not overlap:
|
|
47
|
+
*
|
|
48
|
+
* | Component | Moves you |
|
|
49
|
+
* | ---------------- | -------------------------------- |
|
|
50
|
+
* | `MainNav` | between sites/sections, mega menu |
|
|
51
|
+
* | `SideNav` | between pages, as a tree |
|
|
52
|
+
* | `StepNav` | through a multi-page journey |
|
|
53
|
+
* | `OnThisPage` | within the page you are on |
|
|
54
|
+
*
|
|
55
|
+
* It is named `OnThisPage` rather than the more obvious `SectionNav` because
|
|
56
|
+
* `SideNav` already announces itself as "Section navigation" by default, and
|
|
57
|
+
* two components with near-identical names and different jobs is the kind of
|
|
58
|
+
* ambiguity a design system exists to remove.
|
|
59
|
+
*
|
|
60
|
+
* **No Base UI primitive is involved, and none is missing.** The house rule is
|
|
61
|
+
* never to hand-roll ARIA, focus or keyboard behaviour — but these are plain
|
|
62
|
+
* anchors, which already have all three natively. What is added here is
|
|
63
|
+
* position tracking, which is not an interaction pattern.
|
|
64
|
+
*
|
|
65
|
+
* Accessibility contract:
|
|
66
|
+
*
|
|
67
|
+
* - The landmark is named (`aria-label`, default "On this page") so it is
|
|
68
|
+
* distinguishable from the page's other navigation landmarks (WCAG 2.2,
|
|
69
|
+
* 1.3.1).
|
|
70
|
+
* - The tracked entry is marked **`aria-current="location"`, not `"page"`**.
|
|
71
|
+
* The reader has not navigated anywhere — every entry points at the page
|
|
72
|
+
* they are already on — so `"page"` would announce every link as current.
|
|
73
|
+
* `"location"` is the value defined for "the closest ancestor in a set of
|
|
74
|
+
* related elements", which is exactly a position within a document.
|
|
75
|
+
* - `role="list"` is explicit on the `<ul>`: `list-style: none` strips list
|
|
76
|
+
* semantics in Safari/VoiceOver, the same reason `SideNav` and
|
|
77
|
+
* `StepIndicator` set it.
|
|
78
|
+
* - The active state changes colour **and** the marker rule, so it is not
|
|
79
|
+
* signalled by colour alone (WCAG 2.2, 1.4.1). The rule is always drawn, in
|
|
80
|
+
* `transparent` when idle, so becoming active never changes an element's
|
|
81
|
+
* size.
|
|
82
|
+
*
|
|
83
|
+
* Items are resolved by `document.getElementById` after mount. Sections that
|
|
84
|
+
* appear later (async content, a client-only region) are not picked up until
|
|
85
|
+
* `items` changes — pass a new array when the set of sections changes.
|
|
86
|
+
*/
|
|
87
|
+
declare function OnThisPage({ className, items, orientation, offset, activeId, onActiveChange, emptyMessage, 'aria-label': ariaLabel, ref, ...props }: OnThisPageProps): React.JSX.Element;
|
|
88
|
+
|
|
89
|
+
export { OnThisPage, type OnThisPageItem, type OnThisPageProps };
|
|
@@ -0,0 +1,127 @@
|
|
|
1
|
+
"use client"
|
|
2
|
+
import { jsx } from 'react/jsx-runtime';
|
|
3
|
+
import * as React from 'react';
|
|
4
|
+
import { cn } from '../lib/utils.js';
|
|
5
|
+
|
|
6
|
+
function OnThisPage({
|
|
7
|
+
className,
|
|
8
|
+
items,
|
|
9
|
+
orientation = "horizontal",
|
|
10
|
+
offset = 0,
|
|
11
|
+
activeId,
|
|
12
|
+
onActiveChange,
|
|
13
|
+
emptyMessage = null,
|
|
14
|
+
"aria-label": ariaLabel = "On this page",
|
|
15
|
+
ref,
|
|
16
|
+
...props
|
|
17
|
+
}) {
|
|
18
|
+
const isControlled = activeId !== void 0;
|
|
19
|
+
const [observed, setObserved] = React.useState(null);
|
|
20
|
+
const onActiveChangeRef = React.useRef(onActiveChange);
|
|
21
|
+
React.useEffect(() => {
|
|
22
|
+
onActiveChangeRef.current = onActiveChange;
|
|
23
|
+
}, [onActiveChange]);
|
|
24
|
+
const lastReported = React.useRef(null);
|
|
25
|
+
const ids = items.map((item) => item.id).join("\0");
|
|
26
|
+
React.useEffect(() => {
|
|
27
|
+
const sectionIds = ids ? ids.split("\0") : [];
|
|
28
|
+
const sections = sectionIds.map((id) => document.getElementById(id)).filter((element) => element !== null);
|
|
29
|
+
if (sections.length === 0) {
|
|
30
|
+
return;
|
|
31
|
+
}
|
|
32
|
+
let frame = 0;
|
|
33
|
+
function update() {
|
|
34
|
+
frame = 0;
|
|
35
|
+
const atBottom = window.innerHeight + window.scrollY >= document.documentElement.scrollHeight - 2;
|
|
36
|
+
const current = atBottom ? sections[sections.length - 1]?.id ?? null : sections.reduce(
|
|
37
|
+
(found, element) => element.getBoundingClientRect().top <= offset ? element.id : found,
|
|
38
|
+
null
|
|
39
|
+
);
|
|
40
|
+
if (current === lastReported.current) {
|
|
41
|
+
return;
|
|
42
|
+
}
|
|
43
|
+
lastReported.current = current;
|
|
44
|
+
if (!isControlled) {
|
|
45
|
+
setObserved(current);
|
|
46
|
+
}
|
|
47
|
+
onActiveChangeRef.current?.(current);
|
|
48
|
+
}
|
|
49
|
+
function onScroll() {
|
|
50
|
+
if (frame === 0) {
|
|
51
|
+
frame = requestAnimationFrame(update);
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
update();
|
|
55
|
+
window.addEventListener("scroll", onScroll, { passive: true });
|
|
56
|
+
window.addEventListener("resize", onScroll, { passive: true });
|
|
57
|
+
return () => {
|
|
58
|
+
if (frame !== 0) {
|
|
59
|
+
cancelAnimationFrame(frame);
|
|
60
|
+
}
|
|
61
|
+
window.removeEventListener("scroll", onScroll);
|
|
62
|
+
window.removeEventListener("resize", onScroll);
|
|
63
|
+
};
|
|
64
|
+
}, [ids, offset, isControlled]);
|
|
65
|
+
const active = isControlled ? activeId : observed;
|
|
66
|
+
return /* @__PURE__ */ jsx(
|
|
67
|
+
"nav",
|
|
68
|
+
{
|
|
69
|
+
ref,
|
|
70
|
+
"data-slot": "on-this-page",
|
|
71
|
+
"data-orientation": orientation,
|
|
72
|
+
"aria-label": ariaLabel,
|
|
73
|
+
className: cn(
|
|
74
|
+
"text-base",
|
|
75
|
+
// The scroll container for the horizontal bar — `min-w-max` on the list
|
|
76
|
+
// below only does anything with an overflowing parent. A visible
|
|
77
|
+
// scrollbar would sit on top of the links, so it is suppressed here, on
|
|
78
|
+
// the element that actually scrolls; the clipped final item is what
|
|
79
|
+
// signals there is more to the right. Scrolling itself is untouched, so
|
|
80
|
+
// pointer drag, shift-wheel and keyboard all still reach the overflow.
|
|
81
|
+
orientation === "horizontal" && "[scrollbar-width:none] overflow-x-auto [&::-webkit-scrollbar]:hidden",
|
|
82
|
+
className
|
|
83
|
+
),
|
|
84
|
+
...props,
|
|
85
|
+
children: items.length === 0 ? emptyMessage == null ? null : /* @__PURE__ */ jsx("p", { "data-slot": "on-this-page-empty", className: "text-muted-foreground", children: emptyMessage }) : /* @__PURE__ */ jsx(
|
|
86
|
+
"ul",
|
|
87
|
+
{
|
|
88
|
+
role: "list",
|
|
89
|
+
"data-slot": "on-this-page-list",
|
|
90
|
+
className: cn(
|
|
91
|
+
"flex",
|
|
92
|
+
orientation === "horizontal" ? "min-w-max items-center" : "flex-col border-s border-border"
|
|
93
|
+
),
|
|
94
|
+
children: items.map((item) => {
|
|
95
|
+
const isActive = active === item.id;
|
|
96
|
+
return /* @__PURE__ */ jsx("li", { children: /* @__PURE__ */ jsx(
|
|
97
|
+
"a",
|
|
98
|
+
{
|
|
99
|
+
href: `#${item.id}`,
|
|
100
|
+
"aria-current": isActive ? "location" : void 0,
|
|
101
|
+
"data-slot": "on-this-page-link",
|
|
102
|
+
"data-active": isActive ? "" : void 0,
|
|
103
|
+
className: cn(
|
|
104
|
+
"flex font-bold whitespace-nowrap",
|
|
105
|
+
"hover:bg-primary/10 hover:text-primary",
|
|
106
|
+
"focus-visible:outline-2 focus-visible:-outline-offset-2 focus-visible:outline-ring",
|
|
107
|
+
"motion-safe:transition-colors",
|
|
108
|
+
orientation === "horizontal" ? "items-center border-b-2 p-4" : "-ms-px items-baseline border-s-2 px-4 py-2",
|
|
109
|
+
// The idle ink lives in this branch rather than the base
|
|
110
|
+
// string: both colours are single-class selectors, so with
|
|
111
|
+
// them on the element at once the winner would come down to
|
|
112
|
+
// Tailwind's internal sort order.
|
|
113
|
+
isActive ? "border-primary text-primary" : "border-transparent text-foreground"
|
|
114
|
+
),
|
|
115
|
+
children: item.title
|
|
116
|
+
}
|
|
117
|
+
) }, item.id);
|
|
118
|
+
})
|
|
119
|
+
}
|
|
120
|
+
)
|
|
121
|
+
}
|
|
122
|
+
);
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
export { OnThisPage };
|
|
126
|
+
//# sourceMappingURL=on-this-page.js.map
|
|
127
|
+
//# sourceMappingURL=on-this-page.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/components/on-this-page.tsx"],"names":[],"mappings":";;;;AA4FA,SAAS,UAAA,CAAW;AAAA,EAClB,SAAA;AAAA,EACA,KAAA;AAAA,EACA,WAAA,GAAc,YAAA;AAAA,EACd,MAAA,GAAS,CAAA;AAAA,EACT,QAAA;AAAA,EACA,cAAA;AAAA,EACA,YAAA,GAAe,IAAA;AAAA,EACf,cAAc,SAAA,GAAY,cAAA;AAAA,EAC1B,GAAA;AAAA,EACA,GAAG;AACL,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AA,CAAK;AAAA;AAAA,aACR,EAAA,EAtBO,KAAK,EAuBd,CAAA;AAAA,UAEJ,CAAC;AAAA;AAAA;AACH;AAAA,GAEJ;AAEJ","file":"on-this-page.js","sourcesContent":["'use client'\n\nimport * as React from 'react'\n\nimport { cn } from '../lib/utils.js'\n\n/** One in-page destination. `id` must match the `id` of an element on the page. */\ntype OnThisPageItem = {\n /** `id` of the section this entry points at. */\n id: string\n /** Visible link text. */\n title: React.ReactNode\n}\n\ntype OnThisPageProps = Omit<React.ComponentPropsWithoutRef<'nav'>, 'children'> & {\n /** In-page destinations, in document order. */\n items: OnThisPageItem[]\n /**\n * `horizontal` is the sticky bar that docks under the site chrome;\n * `vertical` is the left- or right-hand rail beside long-form content.\n *\n * @default 'horizontal'\n */\n orientation?: 'horizontal' | 'vertical'\n /**\n * Y-coordinate, in CSS pixels from the top of the viewport, of the line a\n * section must cross to count as the one being read. Set it to the height of\n * whatever chrome overlays the top of the page (plus any slack you want),\n * or sections scrolled to via their anchor register as active a fraction too\n * late. `useChromeHeight` measures that number for you.\n *\n * @default 0\n */\n offset?: number\n /**\n * Active section (controlled). When set, the component reports what it\n * observes through `onActiveChange` but never sets its own state — pick one\n * mode per instance and stay in it, as with `ThemeSwitcher`.\n */\n activeId?: string | null\n /** Fired whenever the observed section changes, in both modes. */\n onActiveChange?: (id: string | null) => void\n /** Shown instead of the list when `items` is empty. `null` renders nothing. */\n emptyMessage?: React.ReactNode\n ref?: React.Ref<HTMLElement>\n}\n\n/**\n * In-page navigation that tracks which section the reader has reached.\n *\n * **Not to be confused with the other three navigation components**, which\n * this deliberately does not overlap:\n *\n * | Component | Moves you |\n * | ---------------- | -------------------------------- |\n * | `MainNav` | between sites/sections, mega menu |\n * | `SideNav` | between pages, as a tree |\n * | `StepNav` | through a multi-page journey |\n * | `OnThisPage` | within the page you are on |\n *\n * It is named `OnThisPage` rather than the more obvious `SectionNav` because\n * `SideNav` already announces itself as \"Section navigation\" by default, and\n * two components with near-identical names and different jobs is the kind of\n * ambiguity a design system exists to remove.\n *\n * **No Base UI primitive is involved, and none is missing.** The house rule is\n * never to hand-roll ARIA, focus or keyboard behaviour — but these are plain\n * anchors, which already have all three natively. What is added here is\n * position tracking, which is not an interaction pattern.\n *\n * Accessibility contract:\n *\n * - The landmark is named (`aria-label`, default \"On this page\") so it is\n * distinguishable from the page's other navigation landmarks (WCAG 2.2,\n * 1.3.1).\n * - The tracked entry is marked **`aria-current=\"location\"`, not `\"page\"`**.\n * The reader has not navigated anywhere — every entry points at the page\n * they are already on — so `\"page\"` would announce every link as current.\n * `\"location\"` is the value defined for \"the closest ancestor in a set of\n * related elements\", which is exactly a position within a document.\n * - `role=\"list\"` is explicit on the `<ul>`: `list-style: none` strips list\n * semantics in Safari/VoiceOver, the same reason `SideNav` and\n * `StepIndicator` set it.\n * - The active state changes colour **and** the marker rule, so it is not\n * signalled by colour alone (WCAG 2.2, 1.4.1). The rule is always drawn, in\n * `transparent` when idle, so becoming active never changes an element's\n * size.\n *\n * Items are resolved by `document.getElementById` after mount. Sections that\n * appear later (async content, a client-only region) are not picked up until\n * `items` changes — pass a new array when the set of sections changes.\n */\nfunction OnThisPage({\n className,\n items,\n orientation = 'horizontal',\n offset = 0,\n activeId,\n onActiveChange,\n emptyMessage = null,\n 'aria-label': ariaLabel = 'On this page',\n ref,\n ...props\n}: OnThisPageProps) {\n const isControlled = activeId !== undefined\n const [observed, setObserved] = React.useState<string | null>(null)\n\n // Kept in refs so the scroll effect never needs them in its dependency list:\n // re-subscribing scroll/resize listeners because a parent re-rendered with a\n // new inline callback would drop the current measurement on every keystroke\n // in an unrelated part of the page.\n const onActiveChangeRef = React.useRef(onActiveChange)\n React.useEffect(() => {\n onActiveChangeRef.current = onActiveChange\n }, [onActiveChange])\n\n const lastReported = React.useRef<string | null>(null)\n\n // `items` is an array, so a caller building it inline gives a new identity\n // every render. Depending on the ids alone keeps the effect stable for the\n // overwhelmingly common case of a constant list.\n const ids = items.map((item) => item.id).join('\u0000')\n\n React.useEffect(() => {\n const sectionIds = ids ? ids.split('\u0000') : []\n const sections = sectionIds\n .map((id) => document.getElementById(id))\n .filter((element): element is HTMLElement => element !== null)\n\n if (sections.length === 0) {\n return\n }\n\n let frame = 0\n\n function update() {\n frame = 0\n\n // The last section can be shorter than the remaining viewport, so it\n // would never cross the line on its own and could never become active.\n // At the bottom of the page it is unambiguously the one being read.\n const atBottom =\n window.innerHeight + window.scrollY >= document.documentElement.scrollHeight - 2\n\n const current = atBottom\n ? (sections[sections.length - 1]?.id ?? null)\n : sections.reduce<string | null>(\n (found, element) =>\n element.getBoundingClientRect().top <= offset ? element.id : found,\n null,\n )\n\n if (current === lastReported.current) {\n return\n }\n lastReported.current = current\n\n if (!isControlled) {\n setObserved(current)\n }\n onActiveChangeRef.current?.(current)\n }\n\n function onScroll() {\n // Coalesce to one measurement per frame — scroll fires far more often\n // than the page can paint, and each measurement forces layout.\n if (frame === 0) {\n frame = requestAnimationFrame(update)\n }\n }\n\n update()\n window.addEventListener('scroll', onScroll, { passive: true })\n window.addEventListener('resize', onScroll, { passive: true })\n\n return () => {\n if (frame !== 0) {\n cancelAnimationFrame(frame)\n }\n window.removeEventListener('scroll', onScroll)\n window.removeEventListener('resize', onScroll)\n }\n }, [ids, offset, isControlled])\n\n const active = isControlled ? activeId : observed\n\n return (\n <nav\n ref={ref}\n data-slot='on-this-page'\n data-orientation={orientation}\n aria-label={ariaLabel}\n className={cn(\n 'text-base',\n // The scroll container for the horizontal bar — `min-w-max` on the list\n // below only does anything with an overflowing parent. A visible\n // scrollbar would sit on top of the links, so it is suppressed here, on\n // the element that actually scrolls; the clipped final item is what\n // signals there is more to the right. Scrolling itself is untouched, so\n // pointer drag, shift-wheel and keyboard all still reach the overflow.\n orientation === 'horizontal' &&\n '[scrollbar-width:none] overflow-x-auto [&::-webkit-scrollbar]:hidden',\n className,\n )}\n {...props}\n >\n {items.length === 0 ? (\n emptyMessage == null ? null : (\n <p data-slot='on-this-page-empty' className='text-muted-foreground'>\n {emptyMessage}\n </p>\n )\n ) : (\n <ul\n role='list'\n data-slot='on-this-page-list'\n className={cn(\n 'flex',\n orientation === 'horizontal'\n ? 'min-w-max items-center'\n : 'flex-col border-s border-border',\n )}\n >\n {items.map((item) => {\n const isActive = active === item.id\n return (\n <li key={item.id}>\n <a\n href={`#${item.id}`}\n aria-current={isActive ? 'location' : undefined}\n data-slot='on-this-page-link'\n data-active={isActive ? '' : undefined}\n className={cn(\n 'flex font-bold whitespace-nowrap',\n 'hover:bg-primary/10 hover:text-primary',\n 'focus-visible:outline-2 focus-visible:-outline-offset-2 focus-visible:outline-ring',\n 'motion-safe:transition-colors',\n orientation === 'horizontal'\n ? 'items-center border-b-2 p-4'\n : '-ms-px items-baseline border-s-2 px-4 py-2',\n // The idle ink lives in this branch rather than the base\n // string: both colours are single-class selectors, so with\n // them on the element at once the winner would come down to\n // Tailwind's internal sort order.\n isActive ? 'border-primary text-primary' : 'border-transparent text-foreground',\n )}\n >\n {item.title}\n </a>\n </li>\n )\n })}\n </ul>\n )}\n </nav>\n )\n}\n\nexport { OnThisPage }\nexport type { OnThisPageItem, OnThisPageProps }\n"]}
|