@nswds/ui 9.1.3 → 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.
- package/dist/components/badge.d.ts +1 -1
- package/dist/components/breadcrumb.d.ts +1 -1
- package/dist/components/button-group.d.ts +1 -1
- package/dist/components/button.d.ts +2 -2
- package/dist/components/hero.d.ts +153 -0
- package/dist/components/hero.js +227 -0
- package/dist/components/hero.js.map +1 -0
- package/dist/components/input-group.d.ts +1 -1
- package/dist/components/page-header.d.ts +138 -0
- package/dist/components/page-header.js +178 -0
- package/dist/components/page-header.js.map +1 -0
- package/dist/components/tag.d.ts +1 -1
- package/dist/index.d.ts +2 -0
- package/dist/index.js +2 -0
- package/dist/styles.css +1 -1
- package/package.json +5 -4
|
@@ -7,7 +7,7 @@ import '@base-ui/react/button';
|
|
|
7
7
|
import './link.js';
|
|
8
8
|
|
|
9
9
|
declare const badgeCva: (props?: ({
|
|
10
|
-
variant?: "
|
|
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" | "
|
|
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?: "
|
|
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?: "
|
|
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" | "
|
|
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;
|
|
@@ -0,0 +1,153 @@
|
|
|
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
|
+
* Surface colours a hero can be drawn on, in the Header's and Masthead's
|
|
7
|
+
* four-name vocabulary plus `tint`, the pale brand panel a landing page uses
|
|
8
|
+
* to mark its opening off from a white body.
|
|
9
|
+
*
|
|
10
|
+
* Each surface sets three inks the slots read: `--hero-heading` (the title),
|
|
11
|
+
* `--hero-ink` (body text and anything a consumer adds) and `--hero-muted`
|
|
12
|
+
* (the description). On the light surfaces the heading is the brand navy and
|
|
13
|
+
* the description the muted role token, both of which flip for dark mode on
|
|
14
|
+
* their own; on `dark` everything is white, because white on `primary-800` is
|
|
15
|
+
* the one pairing that clears WCAG 2.2 AAA (14.4:1) and a muted white would
|
|
16
|
+
* not. Dark mode deepens each surface onto its family's dark step, on the
|
|
17
|
+
* same ramp Header uses (`-800 → -950`, white → `grey-900`, `-100 → -850`), so
|
|
18
|
+
* a hero under a themed header never draws a seam.
|
|
19
|
+
*/
|
|
20
|
+
declare const heroColors: {
|
|
21
|
+
dark: string;
|
|
22
|
+
light: string;
|
|
23
|
+
white: string;
|
|
24
|
+
tint: string;
|
|
25
|
+
};
|
|
26
|
+
type HeroColor = keyof typeof heroColors;
|
|
27
|
+
declare const heroVariants: (props?: ({
|
|
28
|
+
color?: "white" | "light" | "dark" | "tint" | null | undefined;
|
|
29
|
+
} & class_variance_authority_types.ClassProp) | undefined) => string;
|
|
30
|
+
/**
|
|
31
|
+
* The inner column, carrying the same lateral rhythm as `Container` and the
|
|
32
|
+
* chrome components (16px → 24px → 48px, funnelled through
|
|
33
|
+
* `--hero-padding-x`), so a hero's text lines up with the header above it.
|
|
34
|
+
* The media slots read the same custom property to bleed back out to the
|
|
35
|
+
* edge, which is why it is a property and not a bare padding utility.
|
|
36
|
+
*
|
|
37
|
+
* Vertical rhythm lives on `HeroContent`, not here: a `bleed` image fills the
|
|
38
|
+
* full height of the band, so the band itself cannot carry padding.
|
|
39
|
+
*/
|
|
40
|
+
declare const heroInnerVariants: (props?: ({
|
|
41
|
+
layout?: "split" | "stack" | null | undefined;
|
|
42
|
+
container?: "fluid" | "contained" | null | undefined;
|
|
43
|
+
} & class_variance_authority_types.ClassProp) | undefined) => string;
|
|
44
|
+
type HeroProps = React.ComponentPropsWithoutRef<'section'> & VariantProps<typeof heroVariants> & VariantProps<typeof heroInnerVariants> & {
|
|
45
|
+
/**
|
|
46
|
+
* Where the text sits. `centre` centres the content column and its
|
|
47
|
+
* title, description and actions — the opener of a landing page.
|
|
48
|
+
* `start` is the default, for a hero that reads on from the header.
|
|
49
|
+
*/
|
|
50
|
+
align?: 'start' | 'centre';
|
|
51
|
+
/**
|
|
52
|
+
* `id` of the `HeroTitle`. Names the section so it is exposed as a
|
|
53
|
+
* `region` landmark; as with `Section`, no fallback name is invented.
|
|
54
|
+
*/
|
|
55
|
+
labelledBy?: string;
|
|
56
|
+
/** Classes applied to the inner column. */
|
|
57
|
+
innerClassName?: string;
|
|
58
|
+
ref?: React.Ref<HTMLElement>;
|
|
59
|
+
};
|
|
60
|
+
/**
|
|
61
|
+
* The opening band of a page: a title, a short description, up to two
|
|
62
|
+
* actions, and optionally one illustration.
|
|
63
|
+
*
|
|
64
|
+
* Compose it from its slots — `HeroContent` holding `HeroTitle`,
|
|
65
|
+
* `HeroDescription` and `HeroActions`, with an optional `HeroRule` above the
|
|
66
|
+
* title and an optional `HeroMedia` beside or beneath the content:
|
|
67
|
+
*
|
|
68
|
+
* ```tsx
|
|
69
|
+
* <Hero color='dark' layout='split' labelledBy='hero-title'>
|
|
70
|
+
* <HeroContent>
|
|
71
|
+
* <HeroTitle id='hero-title'>Made to send.</HeroTitle>
|
|
72
|
+
* <HeroDescription>Reusable components for NSW Government email.</HeroDescription>
|
|
73
|
+
* <HeroActions>
|
|
74
|
+
* <ButtonLink href='/start' color='white'>Get started</ButtonLink>
|
|
75
|
+
* </HeroActions>
|
|
76
|
+
* </HeroContent>
|
|
77
|
+
* <HeroMedia fit='bleed'>
|
|
78
|
+
* <img src='/illustration.png' alt='' />
|
|
79
|
+
* </HeroMedia>
|
|
80
|
+
* </Hero>
|
|
81
|
+
* ```
|
|
82
|
+
*
|
|
83
|
+
* The five registry blocks (`hero-split`, `hero-framed`, `hero-panel`,
|
|
84
|
+
* `hero-centred`, `hero-statement`) are worked examples of the combinations
|
|
85
|
+
* the NSW Design System recommends; copy one and adapt it.
|
|
86
|
+
*/
|
|
87
|
+
declare function Hero({ className, innerClassName, color, layout, container, align, labelledBy, ref, children, ...props }: HeroProps): React.JSX.Element;
|
|
88
|
+
type HeroContentProps = React.ComponentPropsWithoutRef<'div'> & {
|
|
89
|
+
ref?: React.Ref<HTMLDivElement>;
|
|
90
|
+
};
|
|
91
|
+
/**
|
|
92
|
+
* The text column: title, description and actions, vertically centred
|
|
93
|
+
* against the media beside it and carrying the hero's vertical rhythm.
|
|
94
|
+
*/
|
|
95
|
+
declare function HeroContent({ className, ref, ...props }: HeroContentProps): React.JSX.Element;
|
|
96
|
+
type HeroTitleProps = React.ComponentPropsWithoutRef<'h1'> & {
|
|
97
|
+
/**
|
|
98
|
+
* The heading element. `1` by default, because a hero opens the page and
|
|
99
|
+
* its title is the page's title; `2` for a hero that opens a section of a
|
|
100
|
+
* page whose `h1` sits elsewhere, so the outline stays in order (WCAG
|
|
101
|
+
* 1.3.1).
|
|
102
|
+
*/
|
|
103
|
+
headingLevel?: 1 | 2;
|
|
104
|
+
ref?: React.Ref<HTMLHeadingElement>;
|
|
105
|
+
};
|
|
106
|
+
/**
|
|
107
|
+
* The headline. Semibold rather than bold, at 60px from `lg:`, with the
|
|
108
|
+
* tracking the masterbrand's display setting asks for. Sentence case — the
|
|
109
|
+
* brand sets nothing in uppercase.
|
|
110
|
+
*/
|
|
111
|
+
declare function HeroTitle({ className, headingLevel, ref, ...props }: HeroTitleProps): React.JSX.Element;
|
|
112
|
+
type HeroDescriptionProps = React.ComponentPropsWithoutRef<'p'> & {
|
|
113
|
+
ref?: React.Ref<HTMLParagraphElement>;
|
|
114
|
+
};
|
|
115
|
+
/** One or two sentences under the title, at the reading measure. */
|
|
116
|
+
declare function HeroDescription({ className, ref, ...props }: HeroDescriptionProps): React.JSX.Element;
|
|
117
|
+
type HeroActionsProps = React.ComponentPropsWithoutRef<'div'> & {
|
|
118
|
+
ref?: React.Ref<HTMLDivElement>;
|
|
119
|
+
};
|
|
120
|
+
/**
|
|
121
|
+
* The row of actions. One or two `ButtonLink`s: the first solid, the second
|
|
122
|
+
* outline. On the `dark` surface give them `color='white'`; elsewhere
|
|
123
|
+
* `primary` (see the note on Button's `color`).
|
|
124
|
+
*/
|
|
125
|
+
declare function HeroActions({ className, ref, ...props }: HeroActionsProps): React.JSX.Element;
|
|
126
|
+
type HeroRuleProps = React.ComponentPropsWithoutRef<'div'> & {
|
|
127
|
+
ref?: React.Ref<HTMLDivElement>;
|
|
128
|
+
};
|
|
129
|
+
/**
|
|
130
|
+
* A short accent rule above the title, for a hero that carries no
|
|
131
|
+
* illustration and wants one mark of the brand colour. Decorative, so it is
|
|
132
|
+
* hidden from assistive technology.
|
|
133
|
+
*/
|
|
134
|
+
declare function HeroRule({ className, ref, ...props }: HeroRuleProps): React.JSX.Element;
|
|
135
|
+
/**
|
|
136
|
+
* How the illustration sits against the content. Every fit sizes the image
|
|
137
|
+
* it wraps to fill the slot and crop (`object-cover`), so a consumer passes a
|
|
138
|
+
* plain `<img>` or their framework's image component.
|
|
139
|
+
*/
|
|
140
|
+
declare const heroMediaVariants: (props?: ({
|
|
141
|
+
fit?: "band" | "bleed" | "framed" | "rise" | null | undefined;
|
|
142
|
+
} & class_variance_authority_types.ClassProp) | undefined) => string;
|
|
143
|
+
type HeroMediaProps = React.ComponentPropsWithoutRef<'div'> & VariantProps<typeof heroMediaVariants> & {
|
|
144
|
+
ref?: React.Ref<HTMLDivElement>;
|
|
145
|
+
};
|
|
146
|
+
/**
|
|
147
|
+
* The illustration slot. Wraps one image; the `fit` decides how it sits.
|
|
148
|
+
* The image's `alt` is the consumer's: empty when the picture decorates the
|
|
149
|
+
* title, descriptive when it carries meaning the text does not.
|
|
150
|
+
*/
|
|
151
|
+
declare function HeroMedia({ className, fit, ref, ...props }: HeroMediaProps): React.JSX.Element;
|
|
152
|
+
|
|
153
|
+
export { Hero, HeroActions, type HeroActionsProps, type HeroColor, HeroContent, type HeroContentProps, HeroDescription, type HeroDescriptionProps, HeroMedia, type HeroMediaProps, type HeroProps, HeroRule, type HeroRuleProps, HeroTitle, type HeroTitleProps, heroColors, heroInnerVariants, heroMediaVariants, heroVariants };
|
|
@@ -0,0 +1,227 @@
|
|
|
1
|
+
import { jsx } from 'react/jsx-runtime';
|
|
2
|
+
import { cva } from 'class-variance-authority';
|
|
3
|
+
import { cn } from '../lib/utils.js';
|
|
4
|
+
|
|
5
|
+
const heroColors = {
|
|
6
|
+
// The brand band, as Header's `dark`: primary-800 with white text,
|
|
7
|
+
// deepening to primary-950 in dark mode (AGENTS.md §3, recorded exception).
|
|
8
|
+
dark: [
|
|
9
|
+
"bg-primary-800 text-white dark:bg-primary-950",
|
|
10
|
+
"[--hero-ink:var(--color-white)] [--hero-heading:var(--color-white)] [--hero-muted:var(--color-white)]"
|
|
11
|
+
].join(" "),
|
|
12
|
+
light: [
|
|
13
|
+
"bg-grey-100 text-grey-800 dark:bg-grey-850 dark:text-white",
|
|
14
|
+
"[--hero-ink:var(--grey-800)] [--hero-heading:var(--primary-800)] [--hero-muted:var(--text-muted)]",
|
|
15
|
+
"dark:[--hero-ink:var(--color-white)] dark:[--hero-heading:var(--color-white)] dark:[--hero-muted:var(--color-white)]"
|
|
16
|
+
].join(" "),
|
|
17
|
+
white: [
|
|
18
|
+
"bg-white text-grey-800 dark:bg-grey-900 dark:text-white",
|
|
19
|
+
"[--hero-ink:var(--grey-800)] [--hero-heading:var(--primary-800)] [--hero-muted:var(--text-muted)]",
|
|
20
|
+
"dark:[--hero-ink:var(--color-white)] dark:[--hero-heading:var(--color-white)] dark:[--hero-muted:var(--color-white)]"
|
|
21
|
+
].join(" "),
|
|
22
|
+
// The pale brand panel. primary-200 is the masterbrand's light blue; in dark
|
|
23
|
+
// mode it deepens to primary-900, one step short of the `dark` surface's
|
|
24
|
+
// dark step so the two stay distinguishable when stacked.
|
|
25
|
+
tint: [
|
|
26
|
+
"bg-primary-200 text-grey-800 dark:bg-primary-900 dark:text-white",
|
|
27
|
+
"[--hero-ink:var(--grey-800)] [--hero-heading:var(--primary-800)] [--hero-muted:var(--grey-800)]",
|
|
28
|
+
"dark:[--hero-ink:var(--color-white)] dark:[--hero-heading:var(--color-white)] dark:[--hero-muted:var(--color-white)]"
|
|
29
|
+
].join(" ")
|
|
30
|
+
};
|
|
31
|
+
const DEFAULT_HERO_COLOR = "white";
|
|
32
|
+
const heroVariants = cva("group/hero w-full text-(--hero-ink)", {
|
|
33
|
+
variants: {
|
|
34
|
+
color: heroColors
|
|
35
|
+
},
|
|
36
|
+
defaultVariants: {
|
|
37
|
+
color: DEFAULT_HERO_COLOR
|
|
38
|
+
}
|
|
39
|
+
});
|
|
40
|
+
const heroInnerVariants = cva(
|
|
41
|
+
[
|
|
42
|
+
"mx-auto w-full",
|
|
43
|
+
"px-(--hero-padding-x)",
|
|
44
|
+
"[--hero-padding-x:--spacing(4)] sm:[--hero-padding-x:--spacing(6)] lg:[--hero-padding-x:--spacing(12)]"
|
|
45
|
+
],
|
|
46
|
+
{
|
|
47
|
+
variants: {
|
|
48
|
+
layout: {
|
|
49
|
+
// Content beside media from `lg:`, stacked (content first) below it.
|
|
50
|
+
split: "grid max-lg:grid-cols-1 lg:grid-cols-2 lg:items-stretch lg:gap-x-16",
|
|
51
|
+
// Content over media, each full width. Also the layout for a hero
|
|
52
|
+
// with no media at all.
|
|
53
|
+
stack: "flex flex-col"
|
|
54
|
+
},
|
|
55
|
+
container: {
|
|
56
|
+
// Full-bleed, matching the chrome's default. `--hero-max-width` is
|
|
57
|
+
// still read so a shell app can constrain the column without
|
|
58
|
+
// switching variants.
|
|
59
|
+
fluid: "max-w-[var(--hero-max-width,none)]",
|
|
60
|
+
// Centred content column, legacy nsw-container parity (1200px).
|
|
61
|
+
contained: "max-w-[var(--hero-max-width,75rem)]"
|
|
62
|
+
}
|
|
63
|
+
},
|
|
64
|
+
defaultVariants: {
|
|
65
|
+
layout: "split",
|
|
66
|
+
container: "fluid"
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
);
|
|
70
|
+
function Hero({
|
|
71
|
+
className,
|
|
72
|
+
innerClassName,
|
|
73
|
+
color,
|
|
74
|
+
layout,
|
|
75
|
+
container,
|
|
76
|
+
align = "start",
|
|
77
|
+
labelledBy,
|
|
78
|
+
ref,
|
|
79
|
+
children,
|
|
80
|
+
...props
|
|
81
|
+
}) {
|
|
82
|
+
return /* @__PURE__ */ jsx(
|
|
83
|
+
"section",
|
|
84
|
+
{
|
|
85
|
+
ref,
|
|
86
|
+
"data-slot": "hero",
|
|
87
|
+
"data-color": color ?? DEFAULT_HERO_COLOR,
|
|
88
|
+
"data-layout": layout ?? "split",
|
|
89
|
+
"data-align": align,
|
|
90
|
+
"aria-labelledby": labelledBy,
|
|
91
|
+
className: cn(heroVariants({ color, className })),
|
|
92
|
+
...props,
|
|
93
|
+
children: /* @__PURE__ */ jsx(
|
|
94
|
+
"div",
|
|
95
|
+
{
|
|
96
|
+
"data-slot": "hero-inner",
|
|
97
|
+
className: cn(heroInnerVariants({ layout, container }), innerClassName),
|
|
98
|
+
children
|
|
99
|
+
}
|
|
100
|
+
)
|
|
101
|
+
}
|
|
102
|
+
);
|
|
103
|
+
}
|
|
104
|
+
function HeroContent({ className, ref, ...props }) {
|
|
105
|
+
return /* @__PURE__ */ jsx(
|
|
106
|
+
"div",
|
|
107
|
+
{
|
|
108
|
+
ref,
|
|
109
|
+
"data-slot": "hero-content",
|
|
110
|
+
className: cn(
|
|
111
|
+
"flex flex-col justify-center gap-6",
|
|
112
|
+
// The band's vertical rhythm, one step tighter than Section's so a
|
|
113
|
+
// hero does not push the page's first content below the fold.
|
|
114
|
+
"max-sm:py-14 sm:max-lg:py-16 lg:py-24",
|
|
115
|
+
// Centred alignment, driven by the hero's data-align so a consumer
|
|
116
|
+
// sets it once.
|
|
117
|
+
"group-data-[align=centre]/hero:mx-auto group-data-[align=centre]/hero:max-w-4xl group-data-[align=centre]/hero:items-center group-data-[align=centre]/hero:text-center",
|
|
118
|
+
className
|
|
119
|
+
),
|
|
120
|
+
...props
|
|
121
|
+
}
|
|
122
|
+
);
|
|
123
|
+
}
|
|
124
|
+
function HeroTitle({ className, headingLevel = 1, ref, ...props }) {
|
|
125
|
+
const Heading = `h${headingLevel}`;
|
|
126
|
+
return /* @__PURE__ */ jsx(
|
|
127
|
+
Heading,
|
|
128
|
+
{
|
|
129
|
+
ref,
|
|
130
|
+
"data-slot": "hero-title",
|
|
131
|
+
className: cn(
|
|
132
|
+
"max-w-[20ch] font-semibold tracking-tight text-balance text-(--hero-heading)",
|
|
133
|
+
"max-sm:text-4xl sm:max-lg:text-5xl lg:text-6xl",
|
|
134
|
+
"max-sm:leading-tight sm:leading-none",
|
|
135
|
+
className
|
|
136
|
+
),
|
|
137
|
+
...props
|
|
138
|
+
}
|
|
139
|
+
);
|
|
140
|
+
}
|
|
141
|
+
function HeroDescription({ className, ref, ...props }) {
|
|
142
|
+
return /* @__PURE__ */ jsx(
|
|
143
|
+
"p",
|
|
144
|
+
{
|
|
145
|
+
ref,
|
|
146
|
+
"data-slot": "hero-description",
|
|
147
|
+
className: cn("max-w-prose text-lg leading-8 text-pretty text-(--hero-muted)", className),
|
|
148
|
+
...props
|
|
149
|
+
}
|
|
150
|
+
);
|
|
151
|
+
}
|
|
152
|
+
function HeroActions({ className, ref, ...props }) {
|
|
153
|
+
return /* @__PURE__ */ jsx(
|
|
154
|
+
"div",
|
|
155
|
+
{
|
|
156
|
+
ref,
|
|
157
|
+
"data-slot": "hero-actions",
|
|
158
|
+
className: cn(
|
|
159
|
+
"flex flex-wrap gap-3 pt-3",
|
|
160
|
+
"group-data-[align=centre]/hero:justify-center",
|
|
161
|
+
className
|
|
162
|
+
),
|
|
163
|
+
...props
|
|
164
|
+
}
|
|
165
|
+
);
|
|
166
|
+
}
|
|
167
|
+
function HeroRule({ className, ref, ...props }) {
|
|
168
|
+
return /* @__PURE__ */ jsx(
|
|
169
|
+
"div",
|
|
170
|
+
{
|
|
171
|
+
ref,
|
|
172
|
+
"aria-hidden": "true",
|
|
173
|
+
"data-slot": "hero-rule",
|
|
174
|
+
className: cn("h-1.5 w-16 rounded-sm bg-primary", className),
|
|
175
|
+
...props
|
|
176
|
+
}
|
|
177
|
+
);
|
|
178
|
+
}
|
|
179
|
+
const heroMediaVariants = cva(
|
|
180
|
+
"relative overflow-hidden *:size-full *:object-cover [&_img]:size-full [&_img]:object-cover",
|
|
181
|
+
{
|
|
182
|
+
variants: {
|
|
183
|
+
fit: {
|
|
184
|
+
/**
|
|
185
|
+
* Flush to the band's edge, filling its full height — the opener of
|
|
186
|
+
* email.digital.nsw.gov.au. Reads `--hero-padding-x` back out to the
|
|
187
|
+
* edge on the media side (and both sides when stacked on a phone).
|
|
188
|
+
* With `container='contained'` it reaches the column's edge, not the
|
|
189
|
+
* viewport's.
|
|
190
|
+
*/
|
|
191
|
+
bleed: "max-lg:-mx-(--hero-padding-x) max-lg:aspect-3/2 lg:-mr-(--hero-padding-x) lg:h-full",
|
|
192
|
+
/** A rounded picture beside the content, vertically centred. */
|
|
193
|
+
framed: "aspect-3/2 self-center rounded-md max-sm:mb-14 sm:max-lg:mb-16 lg:mb-0",
|
|
194
|
+
/**
|
|
195
|
+
* Rising from the bottom edge of the band with its top corners
|
|
196
|
+
* rounded, as though the page's first card had been pulled up into
|
|
197
|
+
* the hero. Pair with `color='tint'`.
|
|
198
|
+
*/
|
|
199
|
+
rise: "aspect-4/3 self-end rounded-t-md",
|
|
200
|
+
/**
|
|
201
|
+
* A shallow full-width strip beneath the content, for `layout='stack'`.
|
|
202
|
+
* Reads `--hero-padding-x` back out to the edge on both sides.
|
|
203
|
+
*/
|
|
204
|
+
band: "-mx-(--hero-padding-x) max-sm:h-48 sm:max-lg:h-64 lg:h-80"
|
|
205
|
+
}
|
|
206
|
+
},
|
|
207
|
+
defaultVariants: {
|
|
208
|
+
fit: "framed"
|
|
209
|
+
}
|
|
210
|
+
}
|
|
211
|
+
);
|
|
212
|
+
function HeroMedia({ className, fit, ref, ...props }) {
|
|
213
|
+
return /* @__PURE__ */ jsx(
|
|
214
|
+
"div",
|
|
215
|
+
{
|
|
216
|
+
ref,
|
|
217
|
+
"data-slot": "hero-media",
|
|
218
|
+
"data-fit": fit ?? "framed",
|
|
219
|
+
className: cn(heroMediaVariants({ fit, className })),
|
|
220
|
+
...props
|
|
221
|
+
}
|
|
222
|
+
);
|
|
223
|
+
}
|
|
224
|
+
|
|
225
|
+
export { Hero, HeroActions, HeroContent, HeroDescription, HeroMedia, HeroRule, HeroTitle, heroColors, heroInnerVariants, heroMediaVariants, heroVariants };
|
|
226
|
+
//# sourceMappingURL=hero.js.map
|
|
227
|
+
//# sourceMappingURL=hero.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/components/hero.tsx"],"names":[],"mappings":"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","file":"hero.js","sourcesContent":["import type * as React from 'react'\n\nimport { cva, type VariantProps } from 'class-variance-authority'\n\nimport { cn } from '../lib/utils.js'\n\n/**\n * Surface colours a hero can be drawn on, in the Header's and Masthead's\n * four-name vocabulary plus `tint`, the pale brand panel a landing page uses\n * to mark its opening off from a white body.\n *\n * Each surface sets three inks the slots read: `--hero-heading` (the title),\n * `--hero-ink` (body text and anything a consumer adds) and `--hero-muted`\n * (the description). On the light surfaces the heading is the brand navy and\n * the description the muted role token, both of which flip for dark mode on\n * their own; on `dark` everything is white, because white on `primary-800` is\n * the one pairing that clears WCAG 2.2 AAA (14.4:1) and a muted white would\n * not. Dark mode deepens each surface onto its family's dark step, on the\n * same ramp Header uses (`-800 → -950`, white → `grey-900`, `-100 → -850`), so\n * a hero under a themed header never draws a seam.\n */\nconst heroColors = {\n // The brand band, as Header's `dark`: primary-800 with white text,\n // deepening to primary-950 in dark mode (AGENTS.md §3, recorded exception).\n dark: [\n 'bg-primary-800 text-white dark:bg-primary-950',\n '[--hero-ink:var(--color-white)] [--hero-heading:var(--color-white)] [--hero-muted:var(--color-white)]',\n ].join(' '),\n light: [\n 'bg-grey-100 text-grey-800 dark:bg-grey-850 dark:text-white',\n '[--hero-ink:var(--grey-800)] [--hero-heading:var(--primary-800)] [--hero-muted:var(--text-muted)]',\n 'dark:[--hero-ink:var(--color-white)] dark:[--hero-heading:var(--color-white)] dark:[--hero-muted:var(--color-white)]',\n ].join(' '),\n white: [\n 'bg-white text-grey-800 dark:bg-grey-900 dark:text-white',\n '[--hero-ink:var(--grey-800)] [--hero-heading:var(--primary-800)] [--hero-muted:var(--text-muted)]',\n 'dark:[--hero-ink:var(--color-white)] dark:[--hero-heading:var(--color-white)] dark:[--hero-muted:var(--color-white)]',\n ].join(' '),\n // The pale brand panel. primary-200 is the masterbrand's light blue; in dark\n // mode it deepens to primary-900, one step short of the `dark` surface's\n // dark step so the two stay distinguishable when stacked.\n tint: [\n 'bg-primary-200 text-grey-800 dark:bg-primary-900 dark:text-white',\n '[--hero-ink:var(--grey-800)] [--hero-heading:var(--primary-800)] [--hero-muted:var(--grey-800)]',\n 'dark:[--hero-ink:var(--color-white)] dark:[--hero-heading:var(--color-white)] dark:[--hero-muted:var(--color-white)]',\n ].join(' '),\n}\n\ntype HeroColor = keyof typeof heroColors\n\nconst DEFAULT_HERO_COLOR: HeroColor = 'white'\n\nconst heroVariants = cva('group/hero w-full text-(--hero-ink)', {\n variants: {\n color: heroColors,\n },\n defaultVariants: {\n color: DEFAULT_HERO_COLOR,\n },\n})\n\n/**\n * The inner column, carrying the same lateral rhythm as `Container` and the\n * chrome components (16px → 24px → 48px, funnelled through\n * `--hero-padding-x`), so a hero's text lines up with the header above it.\n * The media slots read the same custom property to bleed back out to the\n * edge, which is why it is a property and not a bare padding utility.\n *\n * Vertical rhythm lives on `HeroContent`, not here: a `bleed` image fills the\n * full height of the band, so the band itself cannot carry padding.\n */\nconst heroInnerVariants = cva(\n [\n 'mx-auto w-full',\n 'px-(--hero-padding-x)',\n '[--hero-padding-x:--spacing(4)] sm:[--hero-padding-x:--spacing(6)] lg:[--hero-padding-x:--spacing(12)]',\n ],\n {\n variants: {\n layout: {\n // Content beside media from `lg:`, stacked (content first) below it.\n split: 'grid max-lg:grid-cols-1 lg:grid-cols-2 lg:items-stretch lg:gap-x-16',\n // Content over media, each full width. Also the layout for a hero\n // with no media at all.\n stack: 'flex flex-col',\n },\n container: {\n // Full-bleed, matching the chrome's default. `--hero-max-width` is\n // still read so a shell app can constrain the column without\n // switching variants.\n fluid: 'max-w-[var(--hero-max-width,none)]',\n // Centred content column, legacy nsw-container parity (1200px).\n contained: 'max-w-[var(--hero-max-width,75rem)]',\n },\n },\n defaultVariants: {\n layout: 'split',\n container: 'fluid',\n },\n },\n)\n\ntype HeroProps = React.ComponentPropsWithoutRef<'section'> &\n VariantProps<typeof heroVariants> &\n VariantProps<typeof heroInnerVariants> & {\n /**\n * Where the text sits. `centre` centres the content column and its\n * title, description and actions — the opener of a landing page.\n * `start` is the default, for a hero that reads on from the header.\n */\n align?: 'start' | 'centre'\n /**\n * `id` of the `HeroTitle`. Names the section so it is exposed as a\n * `region` landmark; as with `Section`, no fallback name is invented.\n */\n labelledBy?: string\n /** Classes applied to the inner column. */\n innerClassName?: string\n ref?: React.Ref<HTMLElement>\n }\n\n/**\n * The opening band of a page: a title, a short description, up to two\n * actions, and optionally one illustration.\n *\n * Compose it from its slots — `HeroContent` holding `HeroTitle`,\n * `HeroDescription` and `HeroActions`, with an optional `HeroRule` above the\n * title and an optional `HeroMedia` beside or beneath the content:\n *\n * ```tsx\n * <Hero color='dark' layout='split' labelledBy='hero-title'>\n * <HeroContent>\n * <HeroTitle id='hero-title'>Made to send.</HeroTitle>\n * <HeroDescription>Reusable components for NSW Government email.</HeroDescription>\n * <HeroActions>\n * <ButtonLink href='/start' color='white'>Get started</ButtonLink>\n * </HeroActions>\n * </HeroContent>\n * <HeroMedia fit='bleed'>\n * <img src='/illustration.png' alt='' />\n * </HeroMedia>\n * </Hero>\n * ```\n *\n * The five registry blocks (`hero-split`, `hero-framed`, `hero-panel`,\n * `hero-centred`, `hero-statement`) are worked examples of the combinations\n * the NSW Design System recommends; copy one and adapt it.\n */\nfunction Hero({\n className,\n innerClassName,\n color,\n layout,\n container,\n align = 'start',\n labelledBy,\n ref,\n children,\n ...props\n}: HeroProps) {\n return (\n <section\n ref={ref}\n data-slot='hero'\n data-color={color ?? DEFAULT_HERO_COLOR}\n data-layout={layout ?? 'split'}\n data-align={align}\n aria-labelledby={labelledBy}\n className={cn(heroVariants({ color, className }))}\n {...props}\n >\n <div\n data-slot='hero-inner'\n className={cn(heroInnerVariants({ layout, container }), innerClassName)}\n >\n {children}\n </div>\n </section>\n )\n}\n\ntype HeroContentProps = React.ComponentPropsWithoutRef<'div'> & {\n ref?: React.Ref<HTMLDivElement>\n}\n\n/**\n * The text column: title, description and actions, vertically centred\n * against the media beside it and carrying the hero's vertical rhythm.\n */\nfunction HeroContent({ className, ref, ...props }: HeroContentProps) {\n return (\n <div\n ref={ref}\n data-slot='hero-content'\n className={cn(\n 'flex flex-col justify-center gap-6',\n // The band's vertical rhythm, one step tighter than Section's so a\n // hero does not push the page's first content below the fold.\n 'max-sm:py-14 sm:max-lg:py-16 lg:py-24',\n // Centred alignment, driven by the hero's data-align so a consumer\n // sets it once.\n 'group-data-[align=centre]/hero:mx-auto group-data-[align=centre]/hero:max-w-4xl group-data-[align=centre]/hero:items-center group-data-[align=centre]/hero:text-center',\n className,\n )}\n {...props}\n />\n )\n}\n\ntype HeroTitleProps = React.ComponentPropsWithoutRef<'h1'> & {\n /**\n * The heading element. `1` by default, because a hero opens the page and\n * its title is the page's title; `2` for a hero that opens a section of a\n * page whose `h1` sits elsewhere, so the outline stays in order (WCAG\n * 1.3.1).\n */\n headingLevel?: 1 | 2\n ref?: React.Ref<HTMLHeadingElement>\n}\n\n/**\n * The headline. Semibold rather than bold, at 60px from `lg:`, with the\n * tracking the masterbrand's display setting asks for. Sentence case — the\n * brand sets nothing in uppercase.\n */\nfunction HeroTitle({ className, headingLevel = 1, ref, ...props }: HeroTitleProps) {\n const Heading = `h${headingLevel}` as const\n return (\n <Heading\n ref={ref}\n data-slot='hero-title'\n className={cn(\n 'max-w-[20ch] font-semibold tracking-tight text-balance text-(--hero-heading)',\n 'max-sm:text-4xl sm:max-lg:text-5xl lg:text-6xl',\n 'max-sm:leading-tight sm:leading-none',\n className,\n )}\n {...props}\n />\n )\n}\n\ntype HeroDescriptionProps = React.ComponentPropsWithoutRef<'p'> & {\n ref?: React.Ref<HTMLParagraphElement>\n}\n\n/** One or two sentences under the title, at the reading measure. */\nfunction HeroDescription({ className, ref, ...props }: HeroDescriptionProps) {\n return (\n <p\n ref={ref}\n data-slot='hero-description'\n className={cn('max-w-prose text-lg leading-8 text-pretty text-(--hero-muted)', className)}\n {...props}\n />\n )\n}\n\ntype HeroActionsProps = React.ComponentPropsWithoutRef<'div'> & {\n ref?: React.Ref<HTMLDivElement>\n}\n\n/**\n * The row of actions. One or two `ButtonLink`s: the first solid, the second\n * outline. On the `dark` surface give them `color='white'`; elsewhere\n * `primary` (see the note on Button's `color`).\n */\nfunction HeroActions({ className, ref, ...props }: HeroActionsProps) {\n return (\n <div\n ref={ref}\n data-slot='hero-actions'\n className={cn(\n 'flex flex-wrap gap-3 pt-3',\n 'group-data-[align=centre]/hero:justify-center',\n className,\n )}\n {...props}\n />\n )\n}\n\ntype HeroRuleProps = React.ComponentPropsWithoutRef<'div'> & {\n ref?: React.Ref<HTMLDivElement>\n}\n\n/**\n * A short accent rule above the title, for a hero that carries no\n * illustration and wants one mark of the brand colour. Decorative, so it is\n * hidden from assistive technology.\n */\nfunction HeroRule({ className, ref, ...props }: HeroRuleProps) {\n return (\n <div\n ref={ref}\n aria-hidden='true'\n data-slot='hero-rule'\n className={cn('h-1.5 w-16 rounded-sm bg-primary', className)}\n {...props}\n />\n )\n}\n\n/**\n * How the illustration sits against the content. Every fit sizes the image\n * it wraps to fill the slot and crop (`object-cover`), so a consumer passes a\n * plain `<img>` or their framework's image component.\n */\nconst heroMediaVariants = cva(\n 'relative overflow-hidden *:size-full *:object-cover [&_img]:size-full [&_img]:object-cover',\n {\n variants: {\n fit: {\n /**\n * Flush to the band's edge, filling its full height — the opener of\n * email.digital.nsw.gov.au. Reads `--hero-padding-x` back out to the\n * edge on the media side (and both sides when stacked on a phone).\n * With `container='contained'` it reaches the column's edge, not the\n * viewport's.\n */\n bleed:\n 'max-lg:-mx-(--hero-padding-x) max-lg:aspect-3/2 lg:-mr-(--hero-padding-x) lg:h-full',\n /** A rounded picture beside the content, vertically centred. */\n framed: 'aspect-3/2 self-center rounded-md max-sm:mb-14 sm:max-lg:mb-16 lg:mb-0',\n /**\n * Rising from the bottom edge of the band with its top corners\n * rounded, as though the page's first card had been pulled up into\n * the hero. Pair with `color='tint'`.\n */\n rise: 'aspect-4/3 self-end rounded-t-md',\n /**\n * A shallow full-width strip beneath the content, for `layout='stack'`.\n * Reads `--hero-padding-x` back out to the edge on both sides.\n */\n band: '-mx-(--hero-padding-x) max-sm:h-48 sm:max-lg:h-64 lg:h-80',\n },\n },\n defaultVariants: {\n fit: 'framed',\n },\n },\n)\n\ntype HeroMediaProps = React.ComponentPropsWithoutRef<'div'> &\n VariantProps<typeof heroMediaVariants> & {\n ref?: React.Ref<HTMLDivElement>\n }\n\n/**\n * The illustration slot. Wraps one image; the `fit` decides how it sits.\n * The image's `alt` is the consumer's: empty when the picture decorates the\n * title, descriptive when it carries meaning the text does not.\n */\nfunction HeroMedia({ className, fit, ref, ...props }: HeroMediaProps) {\n return (\n <div\n ref={ref}\n data-slot='hero-media'\n data-fit={fit ?? 'framed'}\n className={cn(heroMediaVariants({ fit, className }))}\n {...props}\n />\n )\n}\n\nexport {\n Hero,\n HeroActions,\n heroColors,\n HeroContent,\n HeroDescription,\n heroInnerVariants,\n HeroMedia,\n heroMediaVariants,\n HeroRule,\n HeroTitle,\n heroVariants,\n}\nexport type {\n HeroActionsProps,\n HeroColor,\n HeroContentProps,\n HeroDescriptionProps,\n HeroMediaProps,\n HeroProps,\n HeroRuleProps,\n HeroTitleProps,\n}\n"]}
|
|
@@ -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?: "
|
|
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 };
|