@nswds/ui 9.2.0 → 9.3.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.
@@ -7,7 +7,7 @@ import '@base-ui/react/button';
7
7
  import './link.js';
8
8
 
9
9
  declare const badgeCva: (props?: ({
10
- variant?: "solid" | "soft" | "surface" | "outline" | null | undefined;
10
+ variant?: "soft" | "solid" | "surface" | "outline" | null | undefined;
11
11
  size?: "default" | "sm" | "lg" | null | undefined;
12
12
  } & class_variance_authority_types.ClassProp) | undefined) => string;
13
13
  type BadgeVariantProps = NonNullable<Parameters<typeof badgeCva>[0]> & {
@@ -24,7 +24,7 @@ import * as React from 'react';
24
24
  * look lands on the 4px grid (40px tall, 48px with the ellipsis).
25
25
  */
26
26
  declare const breadcrumbVariants: (props?: ({
27
- variant?: "default" | "soft" | "band" | "rail" | null | undefined;
27
+ variant?: "default" | "rail" | "band" | "soft" | null | undefined;
28
28
  } & class_variance_authority_types.ClassProp) | undefined) => string;
29
29
  /**
30
30
  * The `sideOffset` to give a DropdownMenuContent opened from the ellipsis. The
@@ -45,7 +45,7 @@ import '@base-ui/react/separator';
45
45
  * group's segments.
46
46
  */
47
47
  declare const buttonGroupVariants: (props?: ({
48
- variant?: "solid" | "soft" | "surface" | "outline" | "ghost" | null | undefined;
48
+ variant?: "soft" | "solid" | "surface" | "outline" | "ghost" | null | undefined;
49
49
  orientation?: "horizontal" | "vertical" | null | undefined;
50
50
  } & class_variance_authority_types.ClassProp) | undefined) => string;
51
51
  /** The group variants a ButtonGroup can paint. `link` has no group form. */
@@ -5,9 +5,9 @@ import React__default from 'react';
5
5
  import { Link } from './link.js';
6
6
 
7
7
  declare const buttonCva: (props?: ({
8
- variant?: "link" | "solid" | "soft" | "surface" | "outline" | "ghost" | null | undefined;
8
+ variant?: "soft" | "link" | "solid" | "surface" | "outline" | "ghost" | null | undefined;
9
9
  color?: "primary" | "secondary" | "white" | "accent" | "tertiary" | "success" | "warning" | "grey" | "danger" | null | undefined;
10
- size?: "default" | "sm" | "lg" | "icon" | null | undefined;
10
+ size?: "default" | "icon" | "sm" | "lg" | null | undefined;
11
11
  iconOnly?: boolean | null | undefined;
12
12
  onTint?: boolean | null | undefined;
13
13
  } & class_variance_authority_types.ClassProp) | undefined) => string;
@@ -17,7 +17,7 @@ declare const inputGroupAddonVariants: (props?: ({
17
17
  } & class_variance_authority_types.ClassProp) | undefined) => string;
18
18
  declare function InputGroupAddon({ className, align, ...props }: React.ComponentProps<'div'> & VariantProps<typeof inputGroupAddonVariants>): React.JSX.Element;
19
19
  declare const inputGroupButtonVariants: (props?: ({
20
- size?: "sm" | "xs" | "icon-xs" | "icon-sm" | null | undefined;
20
+ size?: "xs" | "sm" | "icon-xs" | "icon-sm" | null | undefined;
21
21
  } & class_variance_authority_types.ClassProp) | undefined) => string;
22
22
  /**
23
23
  * The inline button inside an addon — a secondary action or an icon
@@ -0,0 +1,138 @@
1
+ import * as class_variance_authority_types from 'class-variance-authority/types';
2
+ import * as React from 'react';
3
+ import { VariantProps } from 'class-variance-authority';
4
+
5
+ /**
6
+ * The colourways a page header's title box can wear. Each sets two custom
7
+ * properties the slots read: `--page-header-box`, the flat band the title is
8
+ * painted on, and `--page-header-rule`, the colour of the short rule under
9
+ * the standfirst. A third, `--page-header-ink`, is the interactive ink
10
+ * (`primary-800` light / `primary-200` dark, the Role-Flip Rule) and is the
11
+ * same in every colourway: the meta row's hairline is drawn in it, and so is
12
+ * the rule everywhere except `red`, where the rule follows the box. The ink
13
+ * is not declared here: it aliases `--overlay-ink` from `overlayInk`
14
+ * (`src/lib/overlay.ts`), the one declaration Breadcrumb and the overlays
15
+ * share, so a retune of the ink stays one edit (AGENTS.md §3).
16
+ *
17
+ * The box fills are palette steps, not role tokens (AGENTS.md §3, recorded
18
+ * exception): `blue` is `primary-600`, the masterbrand's Blue 02 and the
19
+ * colour the Transport for NSW reference uses, which no semantic role
20
+ * carries — `--primary` is the interactive fill and flips to a brighter
21
+ * blue in dark mode, where a brand band should hold still. White on it
22
+ * measures 4.57:1 (the same step Footer and MainNav record), which clears
23
+ * the 4.5:1 normal-text bar of WCAG 2.2 AA 1.4.3 with almost no headroom;
24
+ * the title being large text (32px and up, semibold), where the bar is 3:1,
25
+ * is the safety net under a retuned palette, not what makes it pass. It is
26
+ * theme-invariant, as `red` (`accent-600`, the waratah red) is; `navy`
27
+ * (`primary-800`, the brand band) lifts one step in dark mode, to
28
+ * `primary-700`, so the box stays distinct from a Header `dark` band above
29
+ * it, which deepens to `primary-950`. That partial flip is deliberate and
30
+ * recorded against DESIGN.md's Whole-Set Flip Rule.
31
+ */
32
+ declare const pageHeaderColors: {
33
+ blue: string;
34
+ navy: string;
35
+ red: string;
36
+ };
37
+ type PageHeaderColor = keyof typeof pageHeaderColors;
38
+ declare const pageHeaderVariants: (props?: ({
39
+ color?: "blue" | "navy" | "red" | null | undefined;
40
+ } & class_variance_authority_types.ClassProp) | undefined) => string;
41
+ /**
42
+ * The inner column, carrying the same lateral rhythm as `Container`, `Hero`
43
+ * and the chrome components (16px → 24px → 48px, funnelled through
44
+ * `--page-header-padding-x`), so the title's text lines up with the Header
45
+ * and Breadcrumb above it. The title box hangs back into that padding by its
46
+ * own horizontal padding, which is why the inset is a property and not a bare
47
+ * utility: a consumer who retunes the column keeps the box on the margin.
48
+ */
49
+ declare const pageHeaderInnerVariants: (props?: ({
50
+ container?: "fluid" | "contained" | null | undefined;
51
+ } & class_variance_authority_types.ClassProp) | undefined) => string;
52
+ type PageHeaderProps = React.ComponentPropsWithoutRef<'section'> & VariantProps<typeof pageHeaderVariants> & VariantProps<typeof pageHeaderInnerVariants> & {
53
+ /**
54
+ * `id` of the `PageHeaderTitle`. Names the section so it is exposed as a
55
+ * `region` landmark; as with `Section` and `Hero`, no fallback name is
56
+ * invented.
57
+ */
58
+ labelledBy?: string;
59
+ /** Classes applied to the inner column. */
60
+ innerClassName?: string;
61
+ ref?: React.Ref<HTMLElement>;
62
+ };
63
+ /**
64
+ * The opening of a content page: the page title wearing its own flat colour
65
+ * band, one box per wrapped line, then a standfirst and optionally a short
66
+ * rule or a meta row. It sits under the site's Header and Breadcrumb, which
67
+ * are separate components — a page header renders no breadcrumb of its own.
68
+ * For the opening band of a landing page, with actions and an illustration,
69
+ * use `Hero`.
70
+ *
71
+ * Compose it from its slots:
72
+ *
73
+ * ```tsx
74
+ * <PageHeader labelledBy='page-title'>
75
+ * <PageHeaderTitle id='page-title'>Discovery Pass</PageHeaderTitle>
76
+ * <PageHeaderDescription>
77
+ * Get unlimited travel on NSW TrainLink Regional trains and coaches.
78
+ * </PageHeaderDescription>
79
+ * <PageHeaderRule />
80
+ * </PageHeader>
81
+ * ```
82
+ */
83
+ declare function PageHeader({ className, innerClassName, color, container, labelledBy, ref, children, ...props }: PageHeaderProps): React.JSX.Element;
84
+ type PageHeaderTitleProps = React.ComponentPropsWithoutRef<'h1'> & {
85
+ /**
86
+ * The heading element. `1` by default, because a page header opens the
87
+ * page and its title is the page's title; `2` for a header that opens a
88
+ * section of a page whose `h1` sits elsewhere, so the outline stays in
89
+ * order (WCAG 1.3.1).
90
+ */
91
+ headingLevel?: 1 | 2;
92
+ ref?: React.Ref<HTMLHeadingElement>;
93
+ };
94
+ /**
95
+ * The page title on its band. The heading is inline, so the band is drawn
96
+ * per line (`box-decoration-break: clone`) and each box fits its own line's
97
+ * words: a short title is one box, a long one a stack of boxes that touch.
98
+ * Semibold at 48px from `sm:` and 32px below, with the tracking the
99
+ * masterbrand's display setting asks for, and sentence case — the brand sets
100
+ * nothing in uppercase.
101
+ *
102
+ * The box hangs back into the margin by its own horizontal padding, so the
103
+ * TEXT sits on the column, lined up with the breadcrumb above and the body
104
+ * below, and the colour reaches out past it. A block wrapper gives the title
105
+ * its measure (40rem, retuned through `--page-header-title-max-width` like
106
+ * the column's own `--page-header-max-width`), holds the air between it and
107
+ * the breadcrumb above (24px, 16px on a phone), and puts the slots after it
108
+ * on a new line.
109
+ */
110
+ declare function PageHeaderTitle({ className, headingLevel, ref, ...props }: PageHeaderTitleProps): React.JSX.Element;
111
+ type PageHeaderDescriptionProps = React.ComponentPropsWithoutRef<'p'> & {
112
+ ref?: React.Ref<HTMLParagraphElement>;
113
+ };
114
+ /**
115
+ * The standfirst: one or two light sentences under the title, 20/30 at a
116
+ * 62ch measure, stepping to 18px on a phone.
117
+ */
118
+ declare function PageHeaderDescription({ className, ref, ...props }: PageHeaderDescriptionProps): React.JSX.Element;
119
+ type PageHeaderRuleProps = React.ComponentPropsWithoutRef<'div'> & {
120
+ ref?: React.Ref<HTMLDivElement>;
121
+ };
122
+ /**
123
+ * A short rule closing the header, 48×4px in the ink — or, in the `red`
124
+ * colourway, in the box's red. Square-cornered: the brand is flat. Decorative,
125
+ * so it is hidden from assistive technology.
126
+ */
127
+ declare function PageHeaderRule({ className, ref, ...props }: PageHeaderRuleProps): React.JSX.Element;
128
+ type PageHeaderMetaProps = React.ComponentPropsWithoutRef<'div'> & {
129
+ ref?: React.Ref<HTMLDivElement>;
130
+ };
131
+ /**
132
+ * An optional row of facts about the page under a hairline in the ink — when
133
+ * it was last updated, which site it belongs to. Its children are the
134
+ * consumer's `span`s, spread to the row's two ends and stacked on a phone.
135
+ */
136
+ declare function PageHeaderMeta({ className, ref, ...props }: PageHeaderMetaProps): React.JSX.Element;
137
+
138
+ export { PageHeader, type PageHeaderColor, PageHeaderDescription, type PageHeaderDescriptionProps, PageHeaderMeta, type PageHeaderMetaProps, type PageHeaderProps, PageHeaderRule, type PageHeaderRuleProps, PageHeaderTitle, type PageHeaderTitleProps, pageHeaderColors, pageHeaderInnerVariants, pageHeaderVariants };
@@ -0,0 +1,178 @@
1
+ import { jsx } from 'react/jsx-runtime';
2
+ import { cva } from 'class-variance-authority';
3
+ import { overlayInk } from '../lib/overlay.js';
4
+ import { cn } from '../lib/utils.js';
5
+
6
+ const pageHeaderColors = {
7
+ blue: "[--page-header-box:var(--primary-600)] [--page-header-rule:var(--page-header-ink)]",
8
+ navy: [
9
+ "[--page-header-box:var(--primary-800)] dark:[--page-header-box:var(--primary-700)]",
10
+ "[--page-header-rule:var(--page-header-ink)]"
11
+ ].join(" "),
12
+ red: "[--page-header-box:var(--accent-600)] [--page-header-rule:var(--accent-600)]"
13
+ };
14
+ const DEFAULT_PAGE_HEADER_COLOR = "blue";
15
+ const pageHeaderVariants = cva(
16
+ [
17
+ "w-full text-foreground",
18
+ // The interactive ink, flipping for dark mode (DESIGN.md, The Role-Flip
19
+ // Rule), read from the shared declaration rather than restated. The
20
+ // hairline and, outside `red`, the rule read the alias.
21
+ overlayInk,
22
+ "[--page-header-ink:var(--overlay-ink)]"
23
+ ],
24
+ {
25
+ variants: {
26
+ color: pageHeaderColors
27
+ },
28
+ defaultVariants: {
29
+ color: DEFAULT_PAGE_HEADER_COLOR
30
+ }
31
+ }
32
+ );
33
+ const pageHeaderInnerVariants = cva(
34
+ [
35
+ "mx-auto w-full",
36
+ "px-(--page-header-padding-x)",
37
+ "[--page-header-padding-x:--spacing(4)] sm:[--page-header-padding-x:--spacing(6)] lg:[--page-header-padding-x:--spacing(12)]",
38
+ // Vertical rhythm, on the 4px grid: a little air under the breadcrumb,
39
+ // and a full step before the page's first body heading.
40
+ "pt-2 pb-10"
41
+ ],
42
+ {
43
+ variants: {
44
+ container: {
45
+ // Full-bleed, matching the chrome's default. `--page-header-max-width`
46
+ // is still read so a shell app can constrain the column without
47
+ // switching variants.
48
+ fluid: "max-w-[var(--page-header-max-width,none)]",
49
+ // Centred content column, legacy nsw-container parity (1200px).
50
+ contained: "max-w-[var(--page-header-max-width,75rem)]"
51
+ }
52
+ },
53
+ defaultVariants: {
54
+ container: "fluid"
55
+ }
56
+ }
57
+ );
58
+ function PageHeader({
59
+ className,
60
+ innerClassName,
61
+ color,
62
+ container,
63
+ labelledBy,
64
+ ref,
65
+ children,
66
+ ...props
67
+ }) {
68
+ const colorway = color ?? DEFAULT_PAGE_HEADER_COLOR;
69
+ return /* @__PURE__ */ jsx(
70
+ "section",
71
+ {
72
+ ref,
73
+ "data-slot": "page-header",
74
+ "data-color": colorway,
75
+ "aria-labelledby": labelledBy,
76
+ className: cn(pageHeaderVariants({ color: colorway, className })),
77
+ ...props,
78
+ children: /* @__PURE__ */ jsx(
79
+ "div",
80
+ {
81
+ "data-slot": "page-header-inner",
82
+ className: cn(pageHeaderInnerVariants({ container }), innerClassName),
83
+ children
84
+ }
85
+ )
86
+ }
87
+ );
88
+ }
89
+ function PageHeaderTitle({ className, headingLevel = 1, ref, ...props }) {
90
+ const Heading = `h${headingLevel}`;
91
+ return /* @__PURE__ */ jsx(
92
+ "div",
93
+ {
94
+ "data-slot": "page-header-title-row",
95
+ className: "max-w-[var(--page-header-title-max-width,40rem)] text-balance wrap-break-word max-sm:mt-4 sm:mt-6",
96
+ children: /* @__PURE__ */ jsx(
97
+ Heading,
98
+ {
99
+ ref,
100
+ "data-slot": "page-header-title",
101
+ className: cn(
102
+ // The box colour falls back to `blue`'s step so a title rendered
103
+ // outside a PageHeader (or copied without it) still paints. It is a
104
+ // literal because Tailwind only emits complete class strings; keep
105
+ // it in step with `pageHeaderColors.blue`.
106
+ "inline bg-[var(--page-header-box,var(--primary-600))] box-decoration-clone font-semibold tracking-tight text-white",
107
+ // 1.46 is the line-height at which the boxes of a wrapped title
108
+ // touch with neither a gap nor an overlap — the box is the line box
109
+ // plus the vertical padding, so the two are tuned together for
110
+ // Public Sans' ascent and descent; another `--font-sans` shows a
111
+ // seam or an overlap of a pixel or two between lines.
112
+ "max-sm:text-[2rem]/[1.46] sm:text-5xl/[1.46]",
113
+ "max-sm:px-3 max-sm:py-1 sm:px-4 sm:py-1.5",
114
+ // The hang is capped at the column inset, so a shell app that
115
+ // retunes --page-header-padding-x to 0 gets a box on the column
116
+ // rather than one poking out of the section.
117
+ "max-sm:-ms-[min(--spacing(3),var(--page-header-padding-x))] sm:-ms-[min(--spacing(4),var(--page-header-padding-x))]",
118
+ className
119
+ ),
120
+ ...props
121
+ }
122
+ )
123
+ }
124
+ );
125
+ }
126
+ function PageHeaderDescription({ className, ref, ...props }) {
127
+ return /* @__PURE__ */ jsx(
128
+ "p",
129
+ {
130
+ ref,
131
+ "data-slot": "page-header-description",
132
+ className: cn(
133
+ "max-w-[62ch] font-light text-pretty",
134
+ "max-sm:mt-4 max-sm:text-lg/[1.5] sm:mt-5 sm:text-xl/[1.5]",
135
+ className
136
+ ),
137
+ ...props
138
+ }
139
+ );
140
+ }
141
+ function PageHeaderRule({ className, ref, ...props }) {
142
+ return /* @__PURE__ */ jsx(
143
+ "div",
144
+ {
145
+ ref,
146
+ "aria-hidden": "true",
147
+ "data-slot": "page-header-rule",
148
+ className: cn(
149
+ // Outside a PageHeader the rule takes the text colour, which is
150
+ // theme-correct on its own, rather than a restated ink.
151
+ "h-1 w-12 bg-[var(--page-header-rule,currentColor)] max-sm:mt-6 sm:mt-7",
152
+ className
153
+ ),
154
+ ...props
155
+ }
156
+ );
157
+ }
158
+ function PageHeaderMeta({ className, ref, ...props }) {
159
+ return /* @__PURE__ */ jsx(
160
+ "div",
161
+ {
162
+ ref,
163
+ "data-slot": "page-header-meta",
164
+ className: cn(
165
+ // The hairline falls back to the row's own (muted) text colour when
166
+ // there is no PageHeader ink above it.
167
+ "flex border-t border-[var(--page-header-ink,currentColor)] pt-3 text-muted-foreground",
168
+ "max-sm:mt-6 max-sm:flex-col max-sm:gap-1 sm:mt-9 sm:flex-wrap sm:justify-between sm:gap-4",
169
+ className
170
+ ),
171
+ ...props
172
+ }
173
+ );
174
+ }
175
+
176
+ export { PageHeader, PageHeaderDescription, PageHeaderMeta, PageHeaderRule, PageHeaderTitle, pageHeaderColors, pageHeaderInnerVariants, pageHeaderVariants };
177
+ //# sourceMappingURL=page-header.js.map
178
+ //# sourceMappingURL=page-header.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/components/page-header.tsx"],"names":[],"mappings":";;;;;AAkCA,MAAM,gBAAA,GAAmB;AAAA,EACvB,IAAA,EAAM,oFAAA;AAAA,EACN,IAAA,EAA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GAAA;AAAA,IAAC,KAAA;AAAA,IAAA;AAAA,MACC,GAAA;AAAA,MACA,aAAA,EAAY,MAAA;AAAA,MACZ,WAAA,EAAU,kBAAA;AAAA,MACV,SAAA,EAAW,EAAA;AAAA;AAAA;AAAA,QAGT,wEAAA;AAAA,QACA;AAAA,OACF;AAAA,MACC,GAAG;AAAA;AAAA,GACN;AAEJ;AAWA,SAAS,eAAe,EAAE,SAAA,EAAW,GAAA,EAAK,GAAG,OAAM,EAAwB;AACzE,EAAA,uBACE,GAAA;AAAA,IAAC,KAAA;AAAA,IAAA;AAAA,MACC,GAAA;AAAA,MACA,WAAA,EAAU,kBAAA;AAAA,MACV,SAAA,EAAW,EAAA;AAAA;AAAA;AAAA,QAGT,uFAAA;AAAA,QACA,2FAAA;AAAA,QACA;AAAA,OACF;AAAA,MACC,GAAG;AAAA;AAAA,GACN;AAEJ","file":"page-header.js","sourcesContent":["import type * as React from 'react'\n\nimport { cva, type VariantProps } from 'class-variance-authority'\n\nimport { overlayInk } from '../lib/overlay.js'\nimport { cn } from '../lib/utils.js'\n\n/**\n * The colourways a page header's title box can wear. Each sets two custom\n * properties the slots read: `--page-header-box`, the flat band the title is\n * painted on, and `--page-header-rule`, the colour of the short rule under\n * the standfirst. A third, `--page-header-ink`, is the interactive ink\n * (`primary-800` light / `primary-200` dark, the Role-Flip Rule) and is the\n * same in every colourway: the meta row's hairline is drawn in it, and so is\n * the rule everywhere except `red`, where the rule follows the box. The ink\n * is not declared here: it aliases `--overlay-ink` from `overlayInk`\n * (`src/lib/overlay.ts`), the one declaration Breadcrumb and the overlays\n * share, so a retune of the ink stays one edit (AGENTS.md §3).\n *\n * The box fills are palette steps, not role tokens (AGENTS.md §3, recorded\n * exception): `blue` is `primary-600`, the masterbrand's Blue 02 and the\n * colour the Transport for NSW reference uses, which no semantic role\n * carries — `--primary` is the interactive fill and flips to a brighter\n * blue in dark mode, where a brand band should hold still. White on it\n * measures 4.57:1 (the same step Footer and MainNav record), which clears\n * the 4.5:1 normal-text bar of WCAG 2.2 AA 1.4.3 with almost no headroom;\n * the title being large text (32px and up, semibold), where the bar is 3:1,\n * is the safety net under a retuned palette, not what makes it pass. It is\n * theme-invariant, as `red` (`accent-600`, the waratah red) is; `navy`\n * (`primary-800`, the brand band) lifts one step in dark mode, to\n * `primary-700`, so the box stays distinct from a Header `dark` band above\n * it, which deepens to `primary-950`. That partial flip is deliberate and\n * recorded against DESIGN.md's Whole-Set Flip Rule.\n */\nconst pageHeaderColors = {\n blue: '[--page-header-box:var(--primary-600)] [--page-header-rule:var(--page-header-ink)]',\n navy: [\n '[--page-header-box:var(--primary-800)] dark:[--page-header-box:var(--primary-700)]',\n '[--page-header-rule:var(--page-header-ink)]',\n ].join(' '),\n red: '[--page-header-box:var(--accent-600)] [--page-header-rule:var(--accent-600)]',\n}\n\ntype PageHeaderColor = keyof typeof pageHeaderColors\n\nconst DEFAULT_PAGE_HEADER_COLOR: PageHeaderColor = 'blue'\n\nconst pageHeaderVariants = cva(\n [\n 'w-full text-foreground',\n // The interactive ink, flipping for dark mode (DESIGN.md, The Role-Flip\n // Rule), read from the shared declaration rather than restated. The\n // hairline and, outside `red`, the rule read the alias.\n overlayInk,\n '[--page-header-ink:var(--overlay-ink)]',\n ],\n {\n variants: {\n color: pageHeaderColors,\n },\n defaultVariants: {\n color: DEFAULT_PAGE_HEADER_COLOR,\n },\n },\n)\n\n/**\n * The inner column, carrying the same lateral rhythm as `Container`, `Hero`\n * and the chrome components (16px → 24px → 48px, funnelled through\n * `--page-header-padding-x`), so the title's text lines up with the Header\n * and Breadcrumb above it. The title box hangs back into that padding by its\n * own horizontal padding, which is why the inset is a property and not a bare\n * utility: a consumer who retunes the column keeps the box on the margin.\n */\nconst pageHeaderInnerVariants = cva(\n [\n 'mx-auto w-full',\n 'px-(--page-header-padding-x)',\n '[--page-header-padding-x:--spacing(4)] sm:[--page-header-padding-x:--spacing(6)] lg:[--page-header-padding-x:--spacing(12)]',\n // Vertical rhythm, on the 4px grid: a little air under the breadcrumb,\n // and a full step before the page's first body heading.\n 'pt-2 pb-10',\n ],\n {\n variants: {\n container: {\n // Full-bleed, matching the chrome's default. `--page-header-max-width`\n // is still read so a shell app can constrain the column without\n // switching variants.\n fluid: 'max-w-[var(--page-header-max-width,none)]',\n // Centred content column, legacy nsw-container parity (1200px).\n contained: 'max-w-[var(--page-header-max-width,75rem)]',\n },\n },\n defaultVariants: {\n container: 'fluid',\n },\n },\n)\n\ntype PageHeaderProps = React.ComponentPropsWithoutRef<'section'> &\n VariantProps<typeof pageHeaderVariants> &\n VariantProps<typeof pageHeaderInnerVariants> & {\n /**\n * `id` of the `PageHeaderTitle`. Names the section so it is exposed as a\n * `region` landmark; as with `Section` and `Hero`, no fallback name is\n * invented.\n */\n labelledBy?: string\n /** Classes applied to the inner column. */\n innerClassName?: string\n ref?: React.Ref<HTMLElement>\n }\n\n/**\n * The opening of a content page: the page title wearing its own flat colour\n * band, one box per wrapped line, then a standfirst and optionally a short\n * rule or a meta row. It sits under the site's Header and Breadcrumb, which\n * are separate components — a page header renders no breadcrumb of its own.\n * For the opening band of a landing page, with actions and an illustration,\n * use `Hero`.\n *\n * Compose it from its slots:\n *\n * ```tsx\n * <PageHeader labelledBy='page-title'>\n * <PageHeaderTitle id='page-title'>Discovery Pass</PageHeaderTitle>\n * <PageHeaderDescription>\n * Get unlimited travel on NSW TrainLink Regional trains and coaches.\n * </PageHeaderDescription>\n * <PageHeaderRule />\n * </PageHeader>\n * ```\n */\nfunction PageHeader({\n className,\n innerClassName,\n color,\n container,\n labelledBy,\n ref,\n children,\n ...props\n}: PageHeaderProps) {\n // Normalised once: cva treats an explicit `null` as \"no colourway\" where\n // `undefined` takes the default, so the classes and `data-color` would\n // otherwise disagree for `color={null}`.\n const colorway = color ?? DEFAULT_PAGE_HEADER_COLOR\n return (\n <section\n ref={ref}\n data-slot='page-header'\n data-color={colorway}\n aria-labelledby={labelledBy}\n className={cn(pageHeaderVariants({ color: colorway, className }))}\n {...props}\n >\n <div\n data-slot='page-header-inner'\n className={cn(pageHeaderInnerVariants({ container }), innerClassName)}\n >\n {children}\n </div>\n </section>\n )\n}\n\ntype PageHeaderTitleProps = React.ComponentPropsWithoutRef<'h1'> & {\n /**\n * The heading element. `1` by default, because a page header opens the\n * page and its title is the page's title; `2` for a header that opens a\n * section of a page whose `h1` sits elsewhere, so the outline stays in\n * order (WCAG 1.3.1).\n */\n headingLevel?: 1 | 2\n ref?: React.Ref<HTMLHeadingElement>\n}\n\n/**\n * The page title on its band. The heading is inline, so the band is drawn\n * per line (`box-decoration-break: clone`) and each box fits its own line's\n * words: a short title is one box, a long one a stack of boxes that touch.\n * Semibold at 48px from `sm:` and 32px below, with the tracking the\n * masterbrand's display setting asks for, and sentence case — the brand sets\n * nothing in uppercase.\n *\n * The box hangs back into the margin by its own horizontal padding, so the\n * TEXT sits on the column, lined up with the breadcrumb above and the body\n * below, and the colour reaches out past it. A block wrapper gives the title\n * its measure (40rem, retuned through `--page-header-title-max-width` like\n * the column's own `--page-header-max-width`), holds the air between it and\n * the breadcrumb above (24px, 16px on a phone), and puts the slots after it\n * on a new line.\n */\nfunction PageHeaderTitle({ className, headingLevel = 1, ref, ...props }: PageHeaderTitleProps) {\n const Heading = `h${headingLevel}` as const\n return (\n <div\n data-slot='page-header-title-row'\n // wrap-break-word so one unbreakable token (a URL, an acronym) wraps\n // inside a 320px viewport instead of pushing past it (WCAG 1.4.10).\n // text-balance lives here, not on the heading: balancing is a property\n // of the block container, and on the inline heading it does nothing.\n className='max-w-[var(--page-header-title-max-width,40rem)] text-balance wrap-break-word max-sm:mt-4 sm:mt-6'\n >\n <Heading\n ref={ref}\n data-slot='page-header-title'\n className={cn(\n // The box colour falls back to `blue`'s step so a title rendered\n // outside a PageHeader (or copied without it) still paints. It is a\n // literal because Tailwind only emits complete class strings; keep\n // it in step with `pageHeaderColors.blue`.\n 'inline bg-[var(--page-header-box,var(--primary-600))] box-decoration-clone font-semibold tracking-tight text-white',\n // 1.46 is the line-height at which the boxes of a wrapped title\n // touch with neither a gap nor an overlap — the box is the line box\n // plus the vertical padding, so the two are tuned together for\n // Public Sans' ascent and descent; another `--font-sans` shows a\n // seam or an overlap of a pixel or two between lines.\n 'max-sm:text-[2rem]/[1.46] sm:text-5xl/[1.46]',\n 'max-sm:px-3 max-sm:py-1 sm:px-4 sm:py-1.5',\n // The hang is capped at the column inset, so a shell app that\n // retunes --page-header-padding-x to 0 gets a box on the column\n // rather than one poking out of the section.\n 'max-sm:-ms-[min(--spacing(3),var(--page-header-padding-x))] sm:-ms-[min(--spacing(4),var(--page-header-padding-x))]',\n className,\n )}\n {...props}\n />\n </div>\n )\n}\n\ntype PageHeaderDescriptionProps = React.ComponentPropsWithoutRef<'p'> & {\n ref?: React.Ref<HTMLParagraphElement>\n}\n\n/**\n * The standfirst: one or two light sentences under the title, 20/30 at a\n * 62ch measure, stepping to 18px on a phone.\n */\nfunction PageHeaderDescription({ className, ref, ...props }: PageHeaderDescriptionProps) {\n return (\n <p\n ref={ref}\n data-slot='page-header-description'\n className={cn(\n 'max-w-[62ch] font-light text-pretty',\n 'max-sm:mt-4 max-sm:text-lg/[1.5] sm:mt-5 sm:text-xl/[1.5]',\n className,\n )}\n {...props}\n />\n )\n}\n\ntype PageHeaderRuleProps = React.ComponentPropsWithoutRef<'div'> & {\n ref?: React.Ref<HTMLDivElement>\n}\n\n/**\n * A short rule closing the header, 48×4px in the ink — or, in the `red`\n * colourway, in the box's red. Square-cornered: the brand is flat. Decorative,\n * so it is hidden from assistive technology.\n */\nfunction PageHeaderRule({ className, ref, ...props }: PageHeaderRuleProps) {\n return (\n <div\n ref={ref}\n aria-hidden='true'\n data-slot='page-header-rule'\n className={cn(\n // Outside a PageHeader the rule takes the text colour, which is\n // theme-correct on its own, rather than a restated ink.\n 'h-1 w-12 bg-[var(--page-header-rule,currentColor)] max-sm:mt-6 sm:mt-7',\n className,\n )}\n {...props}\n />\n )\n}\n\ntype PageHeaderMetaProps = React.ComponentPropsWithoutRef<'div'> & {\n ref?: React.Ref<HTMLDivElement>\n}\n\n/**\n * An optional row of facts about the page under a hairline in the ink — when\n * it was last updated, which site it belongs to. Its children are the\n * consumer's `span`s, spread to the row's two ends and stacked on a phone.\n */\nfunction PageHeaderMeta({ className, ref, ...props }: PageHeaderMetaProps) {\n return (\n <div\n ref={ref}\n data-slot='page-header-meta'\n className={cn(\n // The hairline falls back to the row's own (muted) text colour when\n // there is no PageHeader ink above it.\n 'flex border-t border-[var(--page-header-ink,currentColor)] pt-3 text-muted-foreground',\n 'max-sm:mt-6 max-sm:flex-col max-sm:gap-1 sm:mt-9 sm:flex-wrap sm:justify-between sm:gap-4',\n className,\n )}\n {...props}\n />\n )\n}\n\nexport {\n PageHeader,\n pageHeaderColors,\n PageHeaderDescription,\n pageHeaderInnerVariants,\n PageHeaderMeta,\n PageHeaderRule,\n PageHeaderTitle,\n pageHeaderVariants,\n}\nexport type {\n PageHeaderColor,\n PageHeaderDescriptionProps,\n PageHeaderMetaProps,\n PageHeaderProps,\n PageHeaderRuleProps,\n PageHeaderTitleProps,\n}\n"]}
@@ -8,7 +8,7 @@ import { Link } from './link.js';
8
8
  import './button.js';
9
9
 
10
10
  declare const tagCva: (props?: ({
11
- variant?: "solid" | "soft" | "surface" | "outline" | null | undefined;
11
+ variant?: "soft" | "solid" | "surface" | "outline" | null | undefined;
12
12
  size?: "default" | "sm" | "lg" | null | undefined;
13
13
  interactive?: boolean | null | undefined;
14
14
  } & class_variance_authority_types.ClassProp) | undefined) => string;
package/dist/index.d.ts CHANGED
@@ -38,6 +38,7 @@ export { MainNav, MainNavColor, MainNavItem, MainNavLinkItem, MainNavProps, main
38
38
  export { Masthead, MastheadColor, MastheadProps, mastheadContainerVariants, mastheadVariants } from './components/masthead.js';
39
39
  export { NativeSelect, NativeSelectOptGroup, NativeSelectOption, nativeSelectVariants } from './components/native-select.js';
40
40
  export { OnThisPage, OnThisPageItem, OnThisPageProps } from './components/on-this-page.js';
41
+ export { PageHeader, PageHeaderColor, PageHeaderDescription, PageHeaderDescriptionProps, PageHeaderMeta, PageHeaderMetaProps, PageHeaderProps, PageHeaderRule, PageHeaderRuleProps, PageHeaderTitle, PageHeaderTitleProps, pageHeaderColors, pageHeaderInnerVariants, pageHeaderVariants } from './components/page-header.js';
41
42
  export { Pagination, PaginationContent, PaginationEllipsis, PaginationItem, PaginationLink, PaginationNext, PaginationPrevious } from './components/pagination.js';
42
43
  export { Popover, PopoverContent, PopoverDescription, PopoverHeader, PopoverTitle, PopoverTrigger } from './components/popover.js';
43
44
  export { Progress, ProgressIndicator, ProgressLabel, ProgressTrack, ProgressValue } from './components/progress.js';
package/dist/index.js CHANGED
@@ -38,6 +38,7 @@ export * from './components/main-nav.js';
38
38
  export * from './components/masthead.js';
39
39
  export * from './components/native-select.js';
40
40
  export * from './components/on-this-page.js';
41
+ export * from './components/page-header.js';
41
42
  export * from './components/pagination.js';
42
43
  export * from './components/popover.js';
43
44
  export * from './components/progress.js';