@juwel-development/design-system 3.0.0 → 3.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +31 -0
- package/dist/design-system.js +219 -128
- package/dist/index.css +1 -1
- package/dist/types/Arrangement/Cluster/Cluster.d.ts +50 -0
- package/dist/types/Arrangement/Stack/Stack.d.ts +51 -0
- package/dist/types/Display/Figure/Figure.d.ts +21 -4
- package/dist/types/Display/Rail/Rail.d.ts +6 -0
- package/dist/types/Display/Typography/H1/H1.d.ts +7 -1
- package/dist/types/Display/Typography/Note/Note.d.ts +35 -0
- package/dist/types/Interaction/Link/Link.d.ts +4 -4
- package/dist/types/Layout/Cover/Cover.d.ts +48 -0
- package/dist/types/Layout/Form/Form.d.ts +8 -4
- package/dist/types/Layout/Header/Header.d.ts +20 -1
- package/dist/types/Layout/Hero/Hero.d.ts +9 -7
- package/dist/types/Layout/Section/Section.d.ts +7 -0
- package/dist/types/Theme/Palette.d.ts +55 -6
- package/dist/types/index.d.ts +4 -0
- package/package.json +1 -1
- package/src/Arrangement/Cluster/Cluster.tsx +80 -0
- package/src/Arrangement/Stack/Stack.tsx +81 -0
- package/src/Display/Figure/Figure.tsx +48 -7
- package/src/Display/Rail/Rail.tsx +6 -0
- package/src/Display/Typography/H1/H1.tsx +17 -7
- package/src/Display/Typography/Note/Note.tsx +56 -0
- package/src/Interaction/Button/Button.tsx +4 -1
- package/src/Interaction/Input/Input.tsx +17 -6
- package/src/Interaction/Link/Link.tsx +9 -5
- package/src/Interaction/TextArea/TextArea.tsx +17 -6
- package/src/Layout/Cover/Cover.tsx +85 -0
- package/src/Layout/Form/Form.tsx +24 -8
- package/src/Layout/Header/Header.tsx +37 -4
- package/src/Layout/Hero/Hero.tsx +10 -6
- package/src/Layout/PageHead/PageHead.tsx +2 -0
- package/src/Layout/Section/Section.tsx +11 -0
- package/src/Theme/Palette.ts +63 -14
- package/src/Theme/renderTokens.ts +37 -7
- package/src/index.ts +4 -0
- package/src/tokens.css +29 -10
- package/src/tokens.dark.css +25 -6
- package/src/tokens.light.css +25 -6
|
@@ -38,14 +38,35 @@ export type PaletteTokens = {
|
|
|
38
38
|
* because a failed image renders its alt text on this plate and that text must stay legible. That
|
|
39
39
|
* keeps it near `surface` rather than a mid grey. */
|
|
40
40
|
backing: string;
|
|
41
|
-
/** The main call-to-action fill.
|
|
41
|
+
/** The main call-to-action fill. A filled control draws no border, so the fill is the only thing
|
|
42
|
+
* separating the control from the surface - what `controlBorder` is for an unfilled one.
|
|
43
|
+
* Constraint (WCAG 2.2 SC 1.4.11): at least 3:1 against `surface` in the same theme,
|
|
44
|
+
* `primaryHover` included, since a hovered control has to stay identifiable too. A second
|
|
45
|
+
* constraint governs this value and `primaryHover` from the other side, stated on
|
|
46
|
+
* `primaryForeground` - the ink they carry - rather than restated here. */
|
|
42
47
|
primary: string;
|
|
43
48
|
primaryHover: string;
|
|
44
|
-
/** Text and icons drawn on top of `primary`.
|
|
49
|
+
/** Text and icons drawn on top of `primary`. Constraint (WCAG 2.2 SC 1.4.3): at least 4.5:1
|
|
50
|
+
* against both `primary` and `primaryHover` in the same theme, hover included, since a hovered
|
|
51
|
+
* control has to stay readable too. Button text is normal-weight at the `body` role, so it takes
|
|
52
|
+
* the text threshold rather than the 3:1 large-text allowance. This is what makes the ink follow
|
|
53
|
+
* the theme where the fills' own roles do not: a fill light enough to clear 3:1 against a dark
|
|
54
|
+
* surface is too light to carry near-white text, so the ink sits at the *surface's* end of the
|
|
55
|
+
* neutral range in each theme. Not required against `disabled` or `disabledHover` - a disabled
|
|
56
|
+
* control is an inactive user interface component, which SC 1.4.3 exempts. */
|
|
45
57
|
primaryForeground: string;
|
|
46
|
-
/** The alternative action fill, for choices that sit beside a primary one.
|
|
58
|
+
/** The alternative action fill, for choices that sit beside a primary one. Filled like `primary`
|
|
59
|
+
* and so identified the same way. Constraint (WCAG 2.2 SC 1.4.11): at least 3:1 against
|
|
60
|
+
* `surface` in the same theme, `secondaryHover` included. A second constraint governs this value
|
|
61
|
+
* and `secondaryHover` from the other side, stated on `secondaryForeground`. */
|
|
47
62
|
secondary: string;
|
|
48
63
|
secondaryHover: string;
|
|
64
|
+
/** Text and icons drawn on top of `secondary`. Constraint (WCAG 2.2 SC 1.4.3): at least 4.5:1
|
|
65
|
+
* against both `secondary` and `secondaryHover` in the same theme, hover included, since a
|
|
66
|
+
* hovered control has to stay readable too. Not required against `disabled` or `disabledHover` -
|
|
67
|
+
* a disabled control is an inactive user interface component, which SC 1.4.3 exempts. Why the
|
|
68
|
+
* threshold is 4.5 and not 3, and why this makes the ink follow the theme: see
|
|
69
|
+
* `primaryForeground`, which carries the same rule for the other ramp. */
|
|
49
70
|
secondaryForeground: string;
|
|
50
71
|
/** The tone a control takes when it cannot be interacted with - its fill, or its border when
|
|
51
72
|
* the fill is transparent. */
|
|
@@ -68,11 +89,39 @@ export type PaletteTokens = {
|
|
|
68
89
|
error: string;
|
|
69
90
|
info: string;
|
|
70
91
|
};
|
|
92
|
+
/**
|
|
93
|
+
* The ink follows the theme, and that is what set the eight fill and ink values across both sets
|
|
94
|
+
* (issue #93). Solve the window a fill has to sit in - at least 3:1 against its surface (#78) and
|
|
95
|
+
* at least 4.5:1 against the ink drawn on it - and it comes out lopsided: a near-white ink is
|
|
96
|
+
* unbounded above in light and leaves a window just 1.26x wide in dark, and a near-black ink is the
|
|
97
|
+
* exact inverse. The reason is structural - in a dark theme a fill has to be light enough to
|
|
98
|
+
* separate from a near-black surface, and a light fill wants dark text - so pinning the ink
|
|
99
|
+
* near-white in both themes asks a dark fill to be both at once. That 1.26x has to hold two values,
|
|
100
|
+
* rest and hover, where what shipped before it stepped 1.35x and 1.23x here and 1.35x and 1.48x in
|
|
101
|
+
* dark. Letting the ink invert instead puts every value on a stock ramp step, with hover steps of
|
|
102
|
+
* 1.25x and 1.27x here and 1.56x and 1.48x in dark.
|
|
103
|
+
*
|
|
104
|
+
* Two routes were rejected, and they are what a reader arriving here is most likely to re-propose:
|
|
105
|
+
* - Keep one near-white ink in both themes and move the fills. It clears 4.5:1, but caps the dark
|
|
106
|
+
* hover at that same 1.26x - gutting the state #78 constrained hover in order to keep.
|
|
107
|
+
* - Give each ramp its own ink, the same in both themes. It clears 4.5:1 only against pure black:
|
|
108
|
+
* against `#0f172a`, the dark set's own `surface`, sky-600 lands at 4.36 and fails. It also buys
|
|
109
|
+
* a light theme with white text on one button and black on the one beside it.
|
|
110
|
+
*/
|
|
71
111
|
export declare const light: PaletteTokens;
|
|
72
112
|
/**
|
|
73
|
-
* Dark reverses the
|
|
74
|
-
*
|
|
113
|
+
* Dark reverses the direction the fills step: it sits higher up the ramp than light does and hovers
|
|
114
|
+
* *up* into lighter still, where light sits lower and hovers down. That is what the components' old
|
|
75
115
|
* `dark:bg-primary-600 dark:hover:bg-primary-500` pair encoded, moved here so it is stated once
|
|
76
|
-
* for the whole system instead of repeated per component.
|
|
116
|
+
* for the whole system instead of repeated per component. The two sets no longer share a step, since
|
|
117
|
+
* each theme's pair has to clear its own ink as well as its own surface (issue #93).
|
|
118
|
+
*
|
|
119
|
+
* The ink inverts with the ramp: slate-950 under these lighter fills, where light takes slate-50
|
|
120
|
+
* under its darker ones. The pair is the two ends of the one neutral ramp the rest of the palette is
|
|
121
|
+
* already built from - `#f8fafc` is slate-50, `surface` slate-900, `muted` slate-500 - rather than a
|
|
122
|
+
* new colour arriving for a single job. `#020617` is also the lightest slate step that still admits
|
|
123
|
+
* violet-500 and sky-600, which is what leaves this set's `secondary` pair unmoved: slate-900 draws
|
|
124
|
+
* 4.22 and 4.36 against them and fails. Why the ink follows the theme at all, and the two routes
|
|
125
|
+
* rejected in getting here: see the light set.
|
|
77
126
|
*/
|
|
78
127
|
export declare const dark: PaletteTokens;
|
package/dist/types/index.d.ts
CHANGED
|
@@ -1,4 +1,6 @@
|
|
|
1
1
|
import './styles.css';
|
|
2
|
+
export { Cluster } from 'Arrangement/Cluster/Cluster';
|
|
3
|
+
export { Stack } from 'Arrangement/Stack/Stack';
|
|
2
4
|
export { Brandmark } from 'Display/Brandmark/Brandmark';
|
|
3
5
|
export { Checklist } from 'Display/Checklist/Checklist';
|
|
4
6
|
export { DefinitionList } from 'Display/DefinitionList/DefinitionList';
|
|
@@ -12,12 +14,14 @@ export { H3 } from 'Display/Typography/H3/H3';
|
|
|
12
14
|
export { H4 } from 'Display/Typography/H4/H4';
|
|
13
15
|
export { H5 } from 'Display/Typography/H5/H5';
|
|
14
16
|
export { H6 } from 'Display/Typography/H6/H6';
|
|
17
|
+
export { Note } from 'Display/Typography/Note/Note';
|
|
15
18
|
export { P } from 'Display/Typography/P/P';
|
|
16
19
|
export { Prose } from 'Display/Typography/Prose/Prose';
|
|
17
20
|
export { Button } from 'Interaction/Button/Button';
|
|
18
21
|
export { Input } from 'Interaction/Input/Input';
|
|
19
22
|
export { Link } from 'Interaction/Link/Link';
|
|
20
23
|
export { TextArea } from 'Interaction/TextArea/TextArea';
|
|
24
|
+
export { Cover } from 'Layout/Cover/Cover';
|
|
21
25
|
export { Footer } from 'Layout/Footer/Footer';
|
|
22
26
|
export type { FormState } from 'Layout/Form/Form';
|
|
23
27
|
export { Form } from 'Layout/Form/Form';
|
package/package.json
CHANGED
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
import type { VariantProps } from 'class-variance-authority';
|
|
2
|
+
import { cva } from 'class-variance-authority';
|
|
3
|
+
import type { FunctionComponent, ReactNode } from 'react';
|
|
4
|
+
|
|
5
|
+
// One recipe on a plain <div>. The two axes are two positions and take different roles, so the base
|
|
6
|
+
// sets `gap-y` and the variant sets `gap-x` - a shorthand would hand the caller both. `gap` holds the
|
|
7
|
+
// two roles attested along a line and defaults to `region`, the wider one every clustered site uses;
|
|
8
|
+
// the wrapped-line gap and the baseline alignment have one answer each in the evidence, so the recipe
|
|
9
|
+
// fixes them and no prop reaches them (docs/adr/0008). Header hand-writes a near-identical row and
|
|
10
|
+
// cannot import this one (architecture standard, the import test); it deliberately differs on gap-y.
|
|
11
|
+
const cluster = cva(
|
|
12
|
+
'flex flex-wrap items-baseline gap-y-[var(--space-stack)]',
|
|
13
|
+
{
|
|
14
|
+
variants: {
|
|
15
|
+
gap: {
|
|
16
|
+
stack: 'gap-x-[var(--space-stack)]',
|
|
17
|
+
region: 'gap-x-[var(--space-region)]',
|
|
18
|
+
},
|
|
19
|
+
justify: {
|
|
20
|
+
start: '',
|
|
21
|
+
between: 'justify-between',
|
|
22
|
+
},
|
|
23
|
+
},
|
|
24
|
+
defaultVariants: { gap: 'region', justify: 'start' },
|
|
25
|
+
},
|
|
26
|
+
);
|
|
27
|
+
|
|
28
|
+
export interface IClusterProps extends VariantProps<typeof cluster> {
|
|
29
|
+
/** The clustered matter. Rendered unmodified: `Cluster` imposes no anatomy and wraps nothing in an
|
|
30
|
+
* item element. */
|
|
31
|
+
children?: ReactNode;
|
|
32
|
+
testId?: string;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
/**
|
|
36
|
+
* A horizontal arrangement that wraps: children in a row, aligned on their baselines, with a wider
|
|
37
|
+
* gap along a line than between wrapped lines. It owns one arrangement and nothing else - no
|
|
38
|
+
* landmark, no band, no join, no gutter, no fill - and takes no outer space, so whatever holds it
|
|
39
|
+
* owns the rhythm around it.
|
|
40
|
+
*
|
|
41
|
+
* @Guarantees — enforced on every render
|
|
42
|
+
* - It renders a `div` with no landmark role, no `nav` of its own and no margin.
|
|
43
|
+
* - Children wrap onto further lines rather than overflowing or shrinking, at every prop combination.
|
|
44
|
+
* - Children are always aligned on their baselines. These rows mix type at different roles — a nav
|
|
45
|
+
* link at the label role beside a credit line at the small role — and centring them makes the type
|
|
46
|
+
* look mis-set, so this is the arrangement rather than a default to override (docs/adr/0008).
|
|
47
|
+
* - `gap` selects which space role separates items **along a line**: `region` (the default), the gap
|
|
48
|
+
* between one group and the next, or `stack`, the sibling gap between items that belong together.
|
|
49
|
+
* Nothing else — neither the band role, which is vertical padding and never a gap, nor the gutter,
|
|
50
|
+
* which is measured against the screen where these roles are measured against the type.
|
|
51
|
+
* - The gap between **wrapped lines** is always `--space-stack` and no prop can change it: a wrapped
|
|
52
|
+
* line sitting as far from its neighbour as its items sit from each other stops reading as one group.
|
|
53
|
+
* - `justify="start"` (the default) runs the row from the start edge; `justify="between"` distributes
|
|
54
|
+
* it end to end, which is the row with a group at each end.
|
|
55
|
+
* - No literal length and no numbered spacing rung appears in the recipe: every value it emits is a
|
|
56
|
+
* role the token layer already names, so a second brand re-points all of them.
|
|
57
|
+
* - `children` render unmodified, and it needs no JavaScript.
|
|
58
|
+
*
|
|
59
|
+
* @CallerMustEnsure — the component cannot see these and does not check them
|
|
60
|
+
* - A cluster that navigates is wrapped in — or wraps — the caller's own `<nav aria-label="…">`.
|
|
61
|
+
* This component declares no landmark, exactly as `Footer`'s guidance already directs.
|
|
62
|
+
* - The gutter and the vertical band belong to whatever holds it — a `Section`, a `Footer` — and not
|
|
63
|
+
* to a prop here, or two components own one job.
|
|
64
|
+
*
|
|
65
|
+
* @UXGuidelines
|
|
66
|
+
* - `gap="stack"` is the row whose items belong together, as a form's actions do. `gap="region"`
|
|
67
|
+
* separates one group from the next; reach for it when the row's items are not a single set.
|
|
68
|
+
* - `justify="between"` needs two groups to distribute. A row of loose items pushed end to end reads
|
|
69
|
+
* as a gap in the middle rather than as a distribution.
|
|
70
|
+
*/
|
|
71
|
+
export const Cluster: FunctionComponent<IClusterProps> = ({
|
|
72
|
+
gap,
|
|
73
|
+
justify,
|
|
74
|
+
children,
|
|
75
|
+
testId,
|
|
76
|
+
}) => (
|
|
77
|
+
<div className={cluster({ gap, justify })} data-testid={testId}>
|
|
78
|
+
{children}
|
|
79
|
+
</div>
|
|
80
|
+
);
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
import type { VariantProps } from 'class-variance-authority';
|
|
2
|
+
import { cva } from 'class-variance-authority';
|
|
3
|
+
import type { FunctionComponent, ReactNode } from 'react';
|
|
4
|
+
|
|
5
|
+
// One recipe on a plain <div>. Six components hand-write this same utility set and their specs pin
|
|
6
|
+
// it as a set, not an order (architecture standard, the import test). `band` is vertical padding,
|
|
7
|
+
// never a gap; the bound holds exactly the two container roles docs/adr/0008's Amendments attest
|
|
8
|
+
// (#97), which argue the `w-full` pairing. `split` turns at `lg`, the Rail/DefinitionList threshold.
|
|
9
|
+
const stack = cva('flex', {
|
|
10
|
+
variants: {
|
|
11
|
+
gap: {
|
|
12
|
+
stack: 'gap-[var(--space-stack)]',
|
|
13
|
+
region: 'gap-[var(--space-region)]',
|
|
14
|
+
},
|
|
15
|
+
measure: {
|
|
16
|
+
true: 'max-w-[var(--measure)]',
|
|
17
|
+
false: '',
|
|
18
|
+
action: 'w-full max-w-[var(--measure-action)]',
|
|
19
|
+
},
|
|
20
|
+
direction: {
|
|
21
|
+
column: 'flex-col',
|
|
22
|
+
split: 'flex-col lg:flex-row lg:items-start',
|
|
23
|
+
},
|
|
24
|
+
},
|
|
25
|
+
defaultVariants: { gap: 'stack', measure: false, direction: 'column' },
|
|
26
|
+
});
|
|
27
|
+
|
|
28
|
+
export interface IStackProps extends VariantProps<typeof stack> {
|
|
29
|
+
/** The stacked matter. Rendered unmodified: `Stack` imposes no anatomy. */
|
|
30
|
+
children?: ReactNode;
|
|
31
|
+
testId?: string;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
/**
|
|
35
|
+
* A vertical arrangement: children in a column, separated by one named space role and optionally
|
|
36
|
+
* bounded by the reading measure or the action column. It owns one axis and one gap and nothing
|
|
37
|
+
* else - no landmark, no heading, no band, no join, no gutter, no fill - and takes no outer space,
|
|
38
|
+
* so whatever holds it owns the rhythm around it.
|
|
39
|
+
*
|
|
40
|
+
* @Guarantees — enforced on every render
|
|
41
|
+
* - It renders a `div` with no landmark role, no heading and no margin of its own.
|
|
42
|
+
* - `gap` selects which space role separates the children: `stack` (the default), the gap between
|
|
43
|
+
* siblings within one block, or `region`, the gap between groups of blocks. Nothing else — a
|
|
44
|
+
* spacing neither role expresses is a request for a measurement (docs/adr/0003, docs/adr/0004).
|
|
45
|
+
* - `measure` bounds the element to `--measure`, the reading column; omitted, the column is
|
|
46
|
+
* unbounded, which is right wherever the children are not running text. It sets no font-size, so
|
|
47
|
+
* a `ch`-counted measure keeps resolving against inherited body type.
|
|
48
|
+
* - `measure="action"` bounds the element to `--measure-action`, the action column - the width a
|
|
49
|
+
* stack of full-width controls fills, so they read as one unit and their labels align - and fills
|
|
50
|
+
* its slot up to that bound, so a centering frame cannot shrink it to its widest label. The two
|
|
51
|
+
* options answer different questions about what the column holds - text or controls - never how
|
|
52
|
+
* wide it should be (docs/adr/0008, Amendments).
|
|
53
|
+
* - `direction="column"` (the default) never changes axis. `direction="split"` is the same column
|
|
54
|
+
* turning into a row at and above 64rem, its children aligned to their start edge rather than
|
|
55
|
+
* stretched. It is the only viewport-dependent behaviour here, and it is named for the job: the
|
|
56
|
+
* breakpoint is an implementation detail and is not part of the vocabulary.
|
|
57
|
+
* - No literal length and no numbered spacing rung appears in the recipe: every value it emits is a
|
|
58
|
+
* role the token layer already names, so a second brand re-points all of them.
|
|
59
|
+
* - `children` render unmodified, and it needs no JavaScript.
|
|
60
|
+
*
|
|
61
|
+
* @CallerMustEnsure — the component cannot see these and does not check them
|
|
62
|
+
* - The gutter and the vertical band belong to the `Section` around it —
|
|
63
|
+
* `<Section><Stack>…</Stack></Section>` — and not to a prop here, or two components own one job.
|
|
64
|
+
* - A stack holding running text is a reading block: reach for `Prose` instead, which is this
|
|
65
|
+
* arrangement plus the contract that says the content is prose.
|
|
66
|
+
*
|
|
67
|
+
* @UXGuidelines
|
|
68
|
+
* - `gap="region"` separates groups of blocks, not blocks. A region-sized gap between two paragraphs
|
|
69
|
+
* reads as missing content — the argument `Section` makes for joining rather than gapping.
|
|
70
|
+
*/
|
|
71
|
+
export const Stack: FunctionComponent<IStackProps> = ({
|
|
72
|
+
gap,
|
|
73
|
+
measure,
|
|
74
|
+
direction,
|
|
75
|
+
children,
|
|
76
|
+
testId,
|
|
77
|
+
}) => (
|
|
78
|
+
<div className={stack({ gap, measure, direction })} data-testid={testId}>
|
|
79
|
+
{children}
|
|
80
|
+
</div>
|
|
81
|
+
);
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { VariantProps } from 'class-variance-authority';
|
|
2
2
|
import { cva } from 'class-variance-authority';
|
|
3
|
-
import type { FunctionComponent } from 'react';
|
|
3
|
+
import type { FunctionComponent, ReactNode } from 'react';
|
|
4
4
|
|
|
5
5
|
// One recipe, on the `img` - the only element that varies. The wrapper `figure` and the `figcaption`
|
|
6
6
|
// carry literal class strings in JSX (the Input pattern, not the compound namespace: there is nothing
|
|
@@ -42,6 +42,10 @@ export interface IFigureProps extends VariantProps<typeof figure> {
|
|
|
42
42
|
responsive?: { srcSet: string; sizes: string };
|
|
43
43
|
/** Names the image. Its presence is what makes this a `figure`. */
|
|
44
44
|
caption?: string;
|
|
45
|
+
/** A slot over the image frame - the consumer's own decoration, rendered unmodified as a sibling of
|
|
46
|
+
* the image inside a positioning context. Having something to render is what makes that context
|
|
47
|
+
* exist; where inside it the overlay sits is expressed on the consumer's own element. */
|
|
48
|
+
overlay?: ReactNode;
|
|
45
49
|
/** Whether this image is visible when the page first paints. Set it on a hero. */
|
|
46
50
|
priority?: boolean;
|
|
47
51
|
testId?: string;
|
|
@@ -50,7 +54,9 @@ export interface IFigureProps extends VariantProps<typeof figure> {
|
|
|
50
54
|
/**
|
|
51
55
|
* An aspect-locked image frame with a focal point and an optional caption. The caption decides the
|
|
52
56
|
* element: with one, the image is wrapped in a `figure` with a `figcaption`; without one, the image
|
|
53
|
-
* renders alone, making no self-contained claim a thumbnail or logo should not make.
|
|
57
|
+
* renders alone, making no self-contained claim a thumbnail or logo should not make. An `overlay`
|
|
58
|
+
* decides a second element the same way: with one, the image sits in a positioning context the
|
|
59
|
+
* overlay can be placed against; without one, there is no wrapper at all.
|
|
54
60
|
*
|
|
55
61
|
* @Guarantees — enforced on every render
|
|
56
62
|
* - Every image reserves its box before it loads: an intrinsic `width`/`height`, and a locked
|
|
@@ -59,14 +65,25 @@ export interface IFigureProps extends VariantProps<typeof figure> {
|
|
|
59
65
|
* `lazy` otherwise), so an above-the-fold hero is never deferred.
|
|
60
66
|
* - A `figure` element appears only where there is a caption.
|
|
61
67
|
* - `srcset` never ships without `sizes`: `responsive` bundles the two so one cannot go without the other.
|
|
68
|
+
* - An `overlay` renders unmodified: the component adds no class and no ARIA attribute to it, strips
|
|
69
|
+
* nothing from it, and paints nothing on the frame - the wrapper it renders carries the positioning
|
|
70
|
+
* context and no other property, so the image fills its container exactly as it does without one.
|
|
71
|
+
*
|
|
72
|
+
* @CallerMustEnsure — the component cannot see these and does not check them
|
|
73
|
+
* - A decorative overlay carries the consumer's own `aria-hidden="true"`. The library will not add it:
|
|
74
|
+
* a slot it modifies is no longer a slot.
|
|
62
75
|
*
|
|
63
76
|
* @UXGuidelines
|
|
64
77
|
* - Pass a `src` your build's image pipeline produced. One raw source measured 2 MB against 31.6 KB
|
|
65
78
|
* for the same crop, taking `load` from 0.95 s to 10.3 s. The component cannot check this.
|
|
66
79
|
* - Check a photograph's hue range before putting a brand colour beside it. One frame sat entirely
|
|
67
80
|
* between hue 14° and 40°, so an amber call-to-action muddied against a terracotta wall - the accent
|
|
68
|
-
* lives where the photo isn't.
|
|
69
|
-
* to a figure
|
|
81
|
+
* lives where the photo isn't. The component paints nothing over the frame itself, so this is about
|
|
82
|
+
* what a page puts next to a figure - and about what it puts in `overlay`, which is the consumer's
|
|
83
|
+
* own decoration and answers to the same hue range.
|
|
84
|
+
* - `overlay` is a place, not a treatment. The library provides somewhere legal for a rim, a ring or a
|
|
85
|
+
* plate to go, and provides none of them; positioning it inside the frame is the consumer's, expressed
|
|
86
|
+
* on their own absolutely-positioned element.
|
|
70
87
|
*/
|
|
71
88
|
export const Figure: FunctionComponent<IFigureProps> = ({
|
|
72
89
|
src,
|
|
@@ -77,9 +94,18 @@ export const Figure: FunctionComponent<IFigureProps> = ({
|
|
|
77
94
|
focus,
|
|
78
95
|
responsive,
|
|
79
96
|
caption,
|
|
97
|
+
overlay,
|
|
80
98
|
priority,
|
|
81
99
|
testId,
|
|
82
100
|
}) => {
|
|
101
|
+
// Absence, not falsiness, and not `undefined` alone: `overlay={showRing && <Ring />}` hands over
|
|
102
|
+
// `false` when the decoration is off, and that consumer asked for no overlay - wrapping anyway
|
|
103
|
+
// would put a `div` where their flex or grid item used to be, which is the one thing this slot
|
|
104
|
+
// promises never to do. Absence is React's own set of nothing-to-render nodes, so a bare
|
|
105
|
+
// truthiness test is wrong in the other direction: `0` renders as `"0"`.
|
|
106
|
+
const hasOverlay =
|
|
107
|
+
overlay !== undefined && overlay !== null && typeof overlay !== 'boolean';
|
|
108
|
+
|
|
83
109
|
const image = (
|
|
84
110
|
<img
|
|
85
111
|
src={src}
|
|
@@ -92,12 +118,27 @@ export const Figure: FunctionComponent<IFigureProps> = ({
|
|
|
92
118
|
loading={priority ? 'eager' : 'lazy'}
|
|
93
119
|
fetchPriority={priority ? 'high' : undefined}
|
|
94
120
|
decoding={'async'}
|
|
95
|
-
data-testid={caption === undefined ? testId : undefined}
|
|
121
|
+
data-testid={caption === undefined && !hasOverlay ? testId : undefined}
|
|
96
122
|
/>
|
|
97
123
|
);
|
|
98
124
|
|
|
125
|
+
// The positioning context exists only where there is something to position, so an overlay-less
|
|
126
|
+
// `Figure` renders exactly what it rendered before this slot existed - which matters most in the
|
|
127
|
+
// caption-less shape, where the image itself is the flex or grid item its container sees.
|
|
128
|
+
const frame = !hasOverlay ? (
|
|
129
|
+
image
|
|
130
|
+
) : (
|
|
131
|
+
<div
|
|
132
|
+
className={'relative'}
|
|
133
|
+
data-testid={caption === undefined ? testId : undefined}
|
|
134
|
+
>
|
|
135
|
+
{image}
|
|
136
|
+
{overlay}
|
|
137
|
+
</div>
|
|
138
|
+
);
|
|
139
|
+
|
|
99
140
|
if (caption === undefined) {
|
|
100
|
-
return
|
|
141
|
+
return frame;
|
|
101
142
|
}
|
|
102
143
|
|
|
103
144
|
return (
|
|
@@ -105,7 +146,7 @@ export const Figure: FunctionComponent<IFigureProps> = ({
|
|
|
105
146
|
className={'flex flex-col gap-[var(--space-stack)]'}
|
|
106
147
|
data-testid={testId}
|
|
107
148
|
>
|
|
108
|
-
{
|
|
149
|
+
{frame}
|
|
109
150
|
<figcaption
|
|
110
151
|
className={'font-secondary text-label tracking-label text-muted'}
|
|
111
152
|
>
|
|
@@ -84,6 +84,8 @@ const RailContent: FunctionComponent<IRailContentProps> = ({
|
|
|
84
84
|
* the label role. Colours are semantic tokens re-pointed by `.dark`, so no class carries a `dark:` prefix.
|
|
85
85
|
* - `number` is optional: omitted, the index renders the name alone and no empty numeral element.
|
|
86
86
|
* - `Content` renders its children unmodified and sets no measure cap - `Prose` owns the reading measure.
|
|
87
|
+
* - `Content` sets no spacing between those children either - a composed `Stack` owns the gap. The slot
|
|
88
|
+
* is opaque, so it cannot see the pieces whose rhythm it would set: the same reason it sets no measure.
|
|
87
89
|
* - No margin, max-width, fill, box or vertical rule; no `tabular-nums` or `font-variant-numeric`.
|
|
88
90
|
* - It needs no JavaScript: `position: sticky` is CSS.
|
|
89
91
|
*
|
|
@@ -94,6 +96,10 @@ const RailContent: FunctionComponent<IRailContentProps> = ({
|
|
|
94
96
|
* consumer that files a section only in the index leaves it without an accessible name.
|
|
95
97
|
*
|
|
96
98
|
* @UXGuidelines
|
|
99
|
+
* - The heading `Content` is required to carry and the section's matter beneath it are two pieces in one
|
|
100
|
+
* opaque slot, and the slot separates nothing. Compose the column inside it -
|
|
101
|
+
* `<Rail.Content><Stack gap="…"><H2>Work</H2>{matter}</Stack></Rail.Content>` - and take the space role
|
|
102
|
+
* from `Stack`'s own guidance: `Rail` holds no opinion on which of the two roles this position wants.
|
|
97
103
|
* - An index is an information layer, not a layout remedy. Measured on the page that prompted it, the
|
|
98
104
|
* filing numeral bought 0px of width across three fallback rungs, and the column it sits in closed only
|
|
99
105
|
* +224px of a 933px deficit - it widens a composition's span, not its content. If a page sags, the
|
|
@@ -6,13 +6,17 @@ import type { FunctionComponent, ReactNode } from 'react';
|
|
|
6
6
|
// (docs/adr/0005). Weight inherits - Tailwind's preflight resets h1-h6 to font-weight: inherit, so
|
|
7
7
|
// the sized levels carry no weight class. --tracking-optical is the large-type correction, carried by
|
|
8
8
|
// the title role and above (#57), so the biggest type on the page is the first to take it. Colour is a
|
|
9
|
-
// semantic token re-pointed by `.dark`, so no variant carries a `dark:` class.
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
9
|
+
// semantic token re-pointed by `.dark`, so no variant carries a `dark:` class. The measure is base and
|
|
10
|
+
// not a variant because the role fixes it and a caller picks nothing (docs/adr/0008, #87).
|
|
11
|
+
const h1 = cva(
|
|
12
|
+
'font-primary text-display leading-display tracking-optical max-w-[var(--measure-display)]',
|
|
13
|
+
{
|
|
14
|
+
variants: {
|
|
15
|
+
color: { foreground: 'text-foreground', muted: 'text-muted' },
|
|
16
|
+
},
|
|
17
|
+
defaultVariants: { color: 'foreground' },
|
|
13
18
|
},
|
|
14
|
-
|
|
15
|
-
});
|
|
19
|
+
);
|
|
16
20
|
|
|
17
21
|
interface IH1Props extends VariantProps<typeof h1> {
|
|
18
22
|
children: ReactNode;
|
|
@@ -26,11 +30,17 @@ interface IH1Props extends VariantProps<typeof h1> {
|
|
|
26
30
|
* - Renders an `h1`; its outline level and the display role are one choice, not two (docs/adr/0005).
|
|
27
31
|
* - Reads `--font-primary`, sized by `--text-display`, led by `--leading-display` and optically
|
|
28
32
|
* corrected by `--tracking-optical`, the large-type correction every role from title up carries.
|
|
33
|
+
* - Bounded at `--measure-display`, the display role's own measure — narrower than the reading column
|
|
34
|
+
* because bigger type wants fewer characters per line (docs/adr/0004). The bound is the recipe's,
|
|
35
|
+
* not a caller's: the level fixes the role and the role fixes the measure, so there is no `measure`
|
|
36
|
+
* prop to select between roles (docs/adr/0008). It holds under every `color`.
|
|
29
37
|
* - `color` selects the `foreground` or `muted` role; nothing else paints text.
|
|
30
38
|
*
|
|
31
39
|
* @CallerMustEnsure — the component cannot see these and does not check them
|
|
32
40
|
* - This is an ordinary page title, and it is also a hero's lead - `display` is the hero role, so a
|
|
33
|
-
* poster hero's `h1` is this one, placed inside a `Hero` (#17), which renders no heading of its own
|
|
41
|
+
* poster hero's `h1` is this one, placed inside a `Hero` (#17), which renders no heading of its own
|
|
42
|
+
* and leaves its slot uncapped — the display measure arrives with this heading rather than with the
|
|
43
|
+
* slot, which would cap the mark beside it too (#87).
|
|
34
44
|
* - A subpage head is the exception: `PageHead` renders its own `h1` at the `title` role, the one
|
|
35
45
|
* sanctioned escape valve from level-fixes-role (docs/adr/0005). Reach for it where it fits.
|
|
36
46
|
* - Heading levels descend without skipping — an `h1` is followed by an `h2`, never an `h3`.
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
import type { VariantProps } from 'class-variance-authority';
|
|
2
|
+
import { cva } from 'class-variance-authority';
|
|
3
|
+
import type { FunctionComponent, ReactNode } from 'react';
|
|
4
|
+
|
|
5
|
+
// The annotation device: the secondary family at the small role, because docs/adr/0004 fixes
|
|
6
|
+
// --font-secondary as the face labels are set in and an annotation labels rather than reads. It
|
|
7
|
+
// defaults to `foreground` where Eyebrow defaults to `muted`: Eyebrow inverts the ordinary default
|
|
8
|
+
// because its device is defined as muted, and an annotation is not - it is foreground *or* muted -
|
|
9
|
+
// so Note follows `P` and keeps the ordinary default. No tracking and no weight: those two
|
|
10
|
+
// are what make an Eyebrow. No measure and no margin: the annotation sits in no reading column, and
|
|
11
|
+
// the page owns the rhythm around it. Colour is re-pointed by `.dark`, so no variant carries `dark:`.
|
|
12
|
+
const note = cva('font-secondary text-small', {
|
|
13
|
+
variants: {
|
|
14
|
+
color: { foreground: 'text-foreground', muted: 'text-muted' },
|
|
15
|
+
},
|
|
16
|
+
defaultVariants: { color: 'foreground' },
|
|
17
|
+
});
|
|
18
|
+
|
|
19
|
+
export interface INoteProps extends VariantProps<typeof note> {
|
|
20
|
+
/** The annotation. A `ReactNode` rather than a string, because these lines carry inline links. */
|
|
21
|
+
children: ReactNode;
|
|
22
|
+
testId?: string;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
/**
|
|
26
|
+
* A short annotation at the small type role in the secondary family — a routing line above a submit
|
|
27
|
+
* button, a privacy line at the point of submission, a line beside a control. Not reading matter:
|
|
28
|
+
* it takes no measure and sits in no reading column, which is what separates it from `Prose.Tail`
|
|
29
|
+
* at the same size, and it carries neither the tracking nor the weight that make an `Eyebrow`.
|
|
30
|
+
*
|
|
31
|
+
* @Guarantees — enforced on every render
|
|
32
|
+
* - Renders a `p`, reading `--font-secondary` and sized by `--text-small`.
|
|
33
|
+
* - `color` selects the `foreground` (default) or `muted` role; nothing else paints text.
|
|
34
|
+
* - Emits no tracking, no font-weight, no measure and no margin under any prop.
|
|
35
|
+
* - Carries no ARIA role and no live region under any prop.
|
|
36
|
+
*
|
|
37
|
+
* @CallerMustEnsure — the component cannot see these and does not check them
|
|
38
|
+
* - The device has three carriers and this primitive is only one: use it for an annotation no other
|
|
39
|
+
* component owns. A form's own message belongs to `Form`'s `note` and a table's to its note cell,
|
|
40
|
+
* each painted by the component that owns it.
|
|
41
|
+
* - Do **not** put a `Note` in `Form`'s `note` slot: that nests a `p` in a `p` and paints the text
|
|
42
|
+
* twice. The slot takes a node, so pass the wording straight to `Form` and let the links ride
|
|
43
|
+
* inside it — inline content only, never a block. `Form` cannot delegate here either — the
|
|
44
|
+
* architecture standard's one-way dependency rule is why `Prose` restates `P`'s utilities.
|
|
45
|
+
* - Where the annotation is a form's status message, `Form` owns `role="status"`/`role="alert"` by
|
|
46
|
+
* state; a `Note` announces nothing.
|
|
47
|
+
*/
|
|
48
|
+
export const Note: FunctionComponent<INoteProps> = ({
|
|
49
|
+
children,
|
|
50
|
+
color,
|
|
51
|
+
testId,
|
|
52
|
+
}) => (
|
|
53
|
+
<p className={note({ color })} data-testid={testId}>
|
|
54
|
+
{children}
|
|
55
|
+
</p>
|
|
56
|
+
);
|
|
@@ -10,8 +10,11 @@ import type { Subject } from 'rxjs';
|
|
|
10
10
|
// base too: identical across variants, drawn with outline, colour at rest so it never fades in -
|
|
11
11
|
// see docs/adr/0002-focus-ring-token-contract.md. The corner is in the base as well, one radius
|
|
12
12
|
// token every variant shares, so none can disagree - see docs/adr/0003-radius-token-contract.md.
|
|
13
|
+
// The face is in the base for the same reason - see docs/adr/0004-typography-token-contract.md (#90).
|
|
14
|
+
// The size is in the base for the same reason, and here it is load-bearing: the recipe fixes
|
|
15
|
+
// vertical padding and sets no height, so the font-size is what drives it (docs/adr/0004, #92).
|
|
13
16
|
const button = cva(
|
|
14
|
-
'transition-colors duration-[var(--motion-duration-color)] rounded-[var(--radius-control)] py-2 sm:py-2 disabled:bg-disabled disabled:hover:bg-disabled-hover cursor-pointer disabled:cursor-not-allowed select-none text-nowrap inline-flex flex-row items-center justify-center gap-2 outline-focus-ring outline-offset-[var(--focus-ring-offset)] focus-visible:outline focus-visible:outline-[length:var(--focus-ring-width)]',
|
|
17
|
+
'font-primary text-body transition-colors duration-[var(--motion-duration-color)] rounded-[var(--radius-control)] py-2 sm:py-2 disabled:bg-disabled disabled:hover:bg-disabled-hover cursor-pointer disabled:cursor-not-allowed select-none text-nowrap inline-flex flex-row items-center justify-center gap-2 outline-focus-ring outline-offset-[var(--focus-ring-offset)] focus-visible:outline focus-visible:outline-[length:var(--focus-ring-width)]',
|
|
15
18
|
{
|
|
16
19
|
variants: {
|
|
17
20
|
variant: {
|
|
@@ -8,9 +8,11 @@ import type { Subject } from 'rxjs';
|
|
|
8
8
|
// `.dark`, so no variant carries a `dark:` class. The border is the only boundary of a transparent
|
|
9
9
|
// control, drawn in `controlBorder` (>=3:1 against surface) and turned `error` on both `:user-invalid`
|
|
10
10
|
// and `aria-invalid` so a server-rendered and a browser-validated invalid state paint identically.
|
|
11
|
-
// Focus adds only the shared ring - the border never changes on focus (docs/adr/0002).
|
|
11
|
+
// Focus adds only the shared ring - the border never changes on focus (docs/adr/0002). The
|
|
12
|
+
// control's face, and the placeholder that follows it, are docs/adr/0004's (#90); so is its size
|
|
13
|
+
// (#92) - `body` is the role clearing the 16px below which iOS Safari zooms a focused control.
|
|
12
14
|
const input = cva(
|
|
13
|
-
'block w-full rounded-[var(--radius-control)] border border-solid border-control-border bg-transparent px-3 py-2 text-foreground transition-colors duration-[var(--motion-duration-color)] outline-focus-ring outline-offset-[var(--focus-ring-offset)] focus-visible:outline focus-visible:outline-[length:var(--focus-ring-width)] [&:user-invalid]:border-error aria-[invalid=true]:border-error disabled:cursor-not-allowed disabled:border-disabled disabled:text-muted',
|
|
15
|
+
'block w-full rounded-[var(--radius-control)] border border-solid border-control-border bg-transparent px-3 py-2 font-primary text-body text-foreground transition-colors duration-[var(--motion-duration-color)] outline-focus-ring outline-offset-[var(--focus-ring-offset)] focus-visible:outline focus-visible:outline-[length:var(--focus-ring-width)] [&:user-invalid]:border-error aria-[invalid=true]:border-error disabled:cursor-not-allowed disabled:border-disabled disabled:text-muted',
|
|
14
16
|
{
|
|
15
17
|
variants: {
|
|
16
18
|
// text/email/url are visually identical; the axis only selects the control's `type`
|
|
@@ -91,7 +93,14 @@ export const Input: FunctionComponent<IInputProps> = ({
|
|
|
91
93
|
|
|
92
94
|
return (
|
|
93
95
|
<div className={'flex flex-col gap-[var(--space-stack)]'}>
|
|
94
|
-
|
|
96
|
+
{/* Each of these declares `font-secondary` on itself, never on the wrapper above - the
|
|
97
|
+
wrapper would hand the labelling face to the control too (docs/adr/0004, #90). The
|
|
98
|
+
label's size is declared here for the same reason, and it is `body`, the control's own
|
|
99
|
+
role, rather than `label` (docs/adr/0004, #92). */}
|
|
100
|
+
<label
|
|
101
|
+
htmlFor={controlId}
|
|
102
|
+
className={'font-secondary font-medium text-body text-foreground'}
|
|
103
|
+
>
|
|
95
104
|
{label}
|
|
96
105
|
</label>
|
|
97
106
|
<input
|
|
@@ -111,15 +120,17 @@ export const Input: FunctionComponent<IInputProps> = ({
|
|
|
111
120
|
onInput={(event) => onInput$?.next(event.currentTarget.value)}
|
|
112
121
|
/>
|
|
113
122
|
{!required && optionalLabel && (
|
|
114
|
-
<span className={'text-muted text-
|
|
123
|
+
<span className={'font-secondary text-muted text-small'}>
|
|
124
|
+
{optionalLabel}
|
|
125
|
+
</span>
|
|
115
126
|
)}
|
|
116
127
|
{hint && (
|
|
117
|
-
<p id={hintId} className={'text-muted text-
|
|
128
|
+
<p id={hintId} className={'font-secondary text-muted text-small'}>
|
|
118
129
|
{hint}
|
|
119
130
|
</p>
|
|
120
131
|
)}
|
|
121
132
|
{invalid && (
|
|
122
|
-
<p id={errorId} className={'text-error text-
|
|
133
|
+
<p id={errorId} className={'font-secondary text-error text-small'}>
|
|
123
134
|
{errorMessage}
|
|
124
135
|
</p>
|
|
125
136
|
)}
|
|
@@ -8,6 +8,10 @@ import type { FunctionComponent, ReactNode } from 'react';
|
|
|
8
8
|
// semantic tokens re-pointed by `.dark`, so no treatment carries a `dark:` class. Underlines read the
|
|
9
9
|
// library's --underline-* tokens and arrive instantly, off the transition allowlist (docs/adr/0001):
|
|
10
10
|
// prose thickens its on hover, quiet and label-link raise one at rest thickness, graphic has none.
|
|
11
|
+
// Only `quiet` declares a face; the other three decline one deliberately (docs/adr/0004, #90).
|
|
12
|
+
// No treatment declares a type role either, `quiet` included, and that silence is a decision, not
|
|
13
|
+
// the omission #92 closed elsewhere: a face is constant across placements, a size is not
|
|
14
|
+
// (docs/adr/0004, #92; docs/adr/0006 for label-link).
|
|
11
15
|
const link = cva(
|
|
12
16
|
'outline-focus-ring outline-offset-[var(--focus-ring-offset)] focus-visible:outline focus-visible:outline-[length:var(--focus-ring-width)]',
|
|
13
17
|
{
|
|
@@ -16,7 +20,7 @@ const link = cva(
|
|
|
16
20
|
prose:
|
|
17
21
|
'text-link underline decoration-[length:var(--underline-thickness)] underline-offset-[var(--underline-offset)] hover:decoration-[length:var(--underline-thickness-hover)]',
|
|
18
22
|
quiet:
|
|
19
|
-
'text-muted no-underline decoration-[length:var(--underline-thickness)] underline-offset-[var(--underline-offset)] transition-colors duration-[var(--motion-duration-color)] hover:text-foreground hover:underline',
|
|
23
|
+
'font-secondary text-muted no-underline decoration-[length:var(--underline-thickness)] underline-offset-[var(--underline-offset)] transition-colors duration-[var(--motion-duration-color)] hover:text-foreground hover:underline',
|
|
20
24
|
'label-link':
|
|
21
25
|
'text-inherit no-underline decoration-[length:var(--underline-thickness)] underline-offset-[var(--underline-offset)] hover:underline',
|
|
22
26
|
graphic: 'text-inherit no-underline',
|
|
@@ -42,10 +46,10 @@ interface ILinkProps extends VariantProps<typeof link> {
|
|
|
42
46
|
|
|
43
47
|
/**
|
|
44
48
|
* A link in one of four treatments. `prose` for running text (told apart by its underline, never by
|
|
45
|
-
* hue), `quiet` for standing navigation (muted, and foreground with an
|
|
46
|
-
* `label-link` for a link acting as a label (inherits its colour, underlines
|
|
47
|
-
* of its own), and `graphic` for an anchor whose child is not text (paints
|
|
48
|
-
* its own colour). It renders a plain `<a>`, so it works with no hydration.
|
|
49
|
+
* hue), `quiet` for standing navigation (muted, set in the labelling face, and foreground with an
|
|
50
|
+
* underline on hover), `label-link` for a link acting as a label (inherits its colour, underlines
|
|
51
|
+
* on hover, sets no type of its own), and `graphic` for an anchor whose child is not text (paints
|
|
52
|
+
* nothing, so a mark keeps its own colour). It renders a plain `<a>`, so it works with no hydration.
|
|
49
53
|
*/
|
|
50
54
|
export const Link: FunctionComponent<ILinkProps> = ({
|
|
51
55
|
href,
|