@nswds/ui 9.1.3 → 9.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.
@@ -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":";;;;AAqBA,MAAM,UAAA,GAAa;AAAA;AAAA;AAAA,EAGjB,IAAA,EAAM;AAAA,IACJ,+CAAA;AAAA,IACA;AAAA,GACF,CAAE,KAAK,GAAG,CAAA;AAAA,EACV,KAAA,EAAO;AAAA,IACL,4DAAA;AAAA,IACA,mGAAA;AAAA,IACA;AAAA,GACF,CAAE,KAAK,GAAG,CAAA;AAAA,EACV,KAAA,EAAO;AAAA,IACL,yDAAA;AAAA,IACA,mGAAA;AAAA,IACA;AAAA,GACF,CAAE,KAAK,GAAG,CAAA;AAAA;AAAA;AAAA;AAAA,EAIV,IAAA,EAAM;AAAA,IACJ,kEAAA;AAAA,IACA,iGAAA;AAAA,IACA;AAAA,GACF,CAAE,KAAK,GAAG;AACZ;AAIA,MAAM,kBAAA,GAAgC,OAAA;AAEtC,MAAM,YAAA,GAAe,IAAI,qCAAA,EAAuC;AAAA,EAC9D,QAAA,EAAU;AAAA,IACR,KAAA,EAAO;AAAA,GACT;AAA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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"]}
package/dist/index.d.ts CHANGED
@@ -23,6 +23,7 @@ export { ExpandableSearch, ExpandableSearchButtonProps, ExpandableSearchField, E
23
23
  export { Field, FieldContent, FieldContentProps, FieldDescription, FieldDescriptionProps, FieldError, FieldErrorProps, FieldGroup, FieldGroupProps, FieldItem, FieldItemProps, FieldLabel, FieldLabelProps, FieldLegend, FieldLegendProps, FieldProps, FieldSeparator, FieldSeparatorProps, FieldSet, FieldSetProps, FieldTitle, FieldTitleProps } from './components/field.js';
24
24
  export { Footer, FooterAcknowledgement, FooterAcknowledgementProps, FooterColor, FooterLegalLinkItem, FooterLegalLinks, FooterLegalLinksProps, FooterLinkItem, FooterNav, FooterNavColumn, FooterNavColumnProps, FooterNavLink, FooterNavLinkProps, FooterNavProps, FooterProps, FooterSmallPrint, FooterSmallPrintProps, FooterSocialLink, FooterSocialLinkItem, FooterSocialLinkProps, footerColors, footerContainerVariants, footerLogoType, footerVariants } from './components/footer.js';
25
25
  export { Header, HeaderActions, HeaderActionsProps, HeaderBrand, HeaderBrandProps, HeaderColor, HeaderProps, headerColors, headerContainerVariants, headerVariants } from './components/header.js';
26
+ export { Hero, HeroActions, HeroActionsProps, HeroColor, HeroContent, HeroContentProps, HeroDescription, HeroDescriptionProps, HeroMedia, HeroMediaProps, HeroProps, HeroRule, HeroRuleProps, HeroTitle, HeroTitleProps, heroColors, heroInnerVariants, heroMediaVariants, heroVariants } from './components/hero.js';
26
27
  export { HoverCard, HoverCardContent, HoverCardTrigger } from './components/hover-card.js';
27
28
  export { InputGroup, InputGroupAction, InputGroupAddon, InputGroupButton, InputGroupInput, InputGroupText, InputGroupTextarea, inputGroupActionVariants } from './components/input-group.js';
28
29
  export { InputOTP, InputOTPGroup, InputOTPSeparator, InputOTPSlot } from './components/input-otp.js';
package/dist/index.js CHANGED
@@ -23,6 +23,7 @@ export * from './components/expandable-search.js';
23
23
  export * from './components/field.js';
24
24
  export * from './components/footer.js';
25
25
  export * from './components/header.js';
26
+ export * from './components/hero.js';
26
27
  export * from './components/hover-card.js';
27
28
  export * from './components/input-group.js';
28
29
  export * from './components/input-otp.js';