@keystone-sites/marketing-design-system 1.0.19 → 1.0.21
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/AGENTS.md +2 -1
- package/grid/gates.cjs +1 -0
- package/icons.tsx +22 -0
- package/index.css +4 -0
- package/lib/phone.ts +294 -0
- package/package.json +10 -1
- package/primitives/business-picker.css +120 -0
- package/primitives/business-picker.tsx +234 -0
- package/primitives/buttons.css +16 -0
- package/primitives/buttons.tsx +11 -4
- package/primitives/chip.css +121 -0
- package/primitives/chip.tsx +45 -0
- package/primitives/field.css +54 -0
- package/primitives/field.tsx +111 -1
- package/primitives/glyph-toggle.css +62 -0
- package/primitives/glyph-toggle.tsx +42 -0
- package/primitives/grader.css +4 -0
- package/primitives/modal.css +41 -3
- package/primitives/modal.tsx +18 -5
- package/primitives/tooltip.css +56 -0
- package/primitives/tooltip.tsx +103 -0
- package/rules/grid-and-layout.md +1 -1
- package/sections/footer-signature.css +14 -0
- package/sections/footer-signature.tsx +19 -2
- package/tokens/semantic.css +4 -0
package/primitives/field.tsx
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/** Labeled text, textarea, select, and checkbox field primitives. */
|
|
1
|
+
/** Labeled text, textarea, select, phone, and checkbox field primitives. */
|
|
2
2
|
|
|
3
3
|
import type {
|
|
4
4
|
InputHTMLAttributes,
|
|
@@ -7,6 +7,14 @@ import type {
|
|
|
7
7
|
TextareaHTMLAttributes,
|
|
8
8
|
} from "react";
|
|
9
9
|
import { IconChevronDownSmall } from "../icons";
|
|
10
|
+
import {
|
|
11
|
+
COUNTRIES,
|
|
12
|
+
countryOf,
|
|
13
|
+
dialCode,
|
|
14
|
+
flagOf,
|
|
15
|
+
formatNational,
|
|
16
|
+
maskPlaceholder,
|
|
17
|
+
} from "../lib/phone";
|
|
10
18
|
|
|
11
19
|
interface FieldShellProps {
|
|
12
20
|
id: string;
|
|
@@ -17,6 +25,8 @@ interface FieldShellProps {
|
|
|
17
25
|
labelHidden?: boolean;
|
|
18
26
|
/** Compact control height for toolbars and dense forms. */
|
|
19
27
|
compact?: boolean;
|
|
28
|
+
/** The pill, for a sheet whose controls are all round; the box otherwise. */
|
|
29
|
+
shape?: "box" | "pill";
|
|
20
30
|
/** Error copy; also marks the control invalid. */
|
|
21
31
|
error?: string | null;
|
|
22
32
|
children: ReactNode;
|
|
@@ -29,6 +39,7 @@ function FieldShell({
|
|
|
29
39
|
helpText,
|
|
30
40
|
labelHidden,
|
|
31
41
|
compact,
|
|
42
|
+
shape,
|
|
32
43
|
error,
|
|
33
44
|
children,
|
|
34
45
|
}: FieldShellProps) {
|
|
@@ -37,6 +48,7 @@ function FieldShell({
|
|
|
37
48
|
<div
|
|
38
49
|
className="ks-field"
|
|
39
50
|
data-size={compact ? "sm" : undefined}
|
|
51
|
+
data-shape={shape === "pill" ? shape : undefined}
|
|
40
52
|
data-invalid={error ? "" : undefined}
|
|
41
53
|
>
|
|
42
54
|
<label
|
|
@@ -82,6 +94,7 @@ type TextInputProps = Omit<InputHTMLAttributes<HTMLInputElement>, "id" | "classN
|
|
|
82
94
|
id: string;
|
|
83
95
|
label: ReactNode;
|
|
84
96
|
helpText?: string | null;
|
|
97
|
+
shape?: FieldShellProps["shape"];
|
|
85
98
|
/** Renders the value in the mono face (identifiers, JSON). */
|
|
86
99
|
mono?: boolean;
|
|
87
100
|
};
|
|
@@ -93,6 +106,7 @@ export function FieldText({
|
|
|
93
106
|
required,
|
|
94
107
|
labelHidden,
|
|
95
108
|
compact,
|
|
109
|
+
shape,
|
|
96
110
|
error,
|
|
97
111
|
mono,
|
|
98
112
|
...input
|
|
@@ -105,6 +119,7 @@ export function FieldText({
|
|
|
105
119
|
helpText={helpText}
|
|
106
120
|
labelHidden={labelHidden}
|
|
107
121
|
compact={compact}
|
|
122
|
+
shape={shape}
|
|
108
123
|
error={error}
|
|
109
124
|
>
|
|
110
125
|
<div className="ks-field-control" data-mono={mono || undefined}>
|
|
@@ -213,6 +228,101 @@ export function FieldSelect({
|
|
|
213
228
|
);
|
|
214
229
|
}
|
|
215
230
|
|
|
231
|
+
interface FieldPhoneProps extends ShellOptions {
|
|
232
|
+
id: string;
|
|
233
|
+
label: ReactNode;
|
|
234
|
+
helpText?: string | null;
|
|
235
|
+
shape?: FieldShellProps["shape"];
|
|
236
|
+
/** ISO country code of the number's country. */
|
|
237
|
+
country: string;
|
|
238
|
+
onCountryChange: (code: string) => void;
|
|
239
|
+
/** The national number as the field shows it (lib/phone.ts formats it). */
|
|
240
|
+
value: string;
|
|
241
|
+
onChange: (value: string) => void;
|
|
242
|
+
/** The country control's accessible name. */
|
|
243
|
+
countryLabel?: string;
|
|
244
|
+
autoFocus?: boolean;
|
|
245
|
+
required?: boolean;
|
|
246
|
+
disabled?: boolean;
|
|
247
|
+
}
|
|
248
|
+
|
|
249
|
+
/** A phone number: the country's flag over a native select of every
|
|
250
|
+
* country, its calling code, then the national number grouped as that
|
|
251
|
+
* country writes it. Reformatting on a country change keeps the digits. */
|
|
252
|
+
export function FieldPhone({
|
|
253
|
+
id,
|
|
254
|
+
label,
|
|
255
|
+
helpText,
|
|
256
|
+
required,
|
|
257
|
+
labelHidden,
|
|
258
|
+
compact,
|
|
259
|
+
shape,
|
|
260
|
+
error,
|
|
261
|
+
country,
|
|
262
|
+
onCountryChange,
|
|
263
|
+
value,
|
|
264
|
+
onChange,
|
|
265
|
+
countryLabel = "Country",
|
|
266
|
+
autoFocus,
|
|
267
|
+
disabled,
|
|
268
|
+
}: FieldPhoneProps) {
|
|
269
|
+
const selected = countryOf(country);
|
|
270
|
+
return (
|
|
271
|
+
<FieldShell
|
|
272
|
+
id={id}
|
|
273
|
+
label={label}
|
|
274
|
+
required={required}
|
|
275
|
+
helpText={helpText}
|
|
276
|
+
labelHidden={labelHidden}
|
|
277
|
+
compact={compact}
|
|
278
|
+
shape={shape}
|
|
279
|
+
error={error}
|
|
280
|
+
>
|
|
281
|
+
<div className="ks-field-control" data-kind="phone">
|
|
282
|
+
<span className="ks-field-country">
|
|
283
|
+
<span className="ks-field-flag" aria-hidden="true">
|
|
284
|
+
{flagOf(country)}
|
|
285
|
+
</span>
|
|
286
|
+
<IconChevronDownSmall className="ks-field-tick" />
|
|
287
|
+
<select
|
|
288
|
+
className="ks-field-country-select"
|
|
289
|
+
aria-label={countryLabel}
|
|
290
|
+
value={country}
|
|
291
|
+
disabled={disabled}
|
|
292
|
+
onChange={(e) => {
|
|
293
|
+
onCountryChange(e.target.value);
|
|
294
|
+
onChange(formatNational(value, countryOf(e.target.value)));
|
|
295
|
+
}}
|
|
296
|
+
>
|
|
297
|
+
{COUNTRIES.map((c) => (
|
|
298
|
+
<option key={c.code} value={c.code}>
|
|
299
|
+
{c.name} ({dialCode(c)})
|
|
300
|
+
</option>
|
|
301
|
+
))}
|
|
302
|
+
</select>
|
|
303
|
+
</span>
|
|
304
|
+
<span className="ks-field-vr" aria-hidden="true" />
|
|
305
|
+
<span className="type type-fixed ks-field-dial">{dialCode(selected)}</span>
|
|
306
|
+
<input
|
|
307
|
+
className="type type-fixed"
|
|
308
|
+
id={id}
|
|
309
|
+
type="tel"
|
|
310
|
+
inputMode="numeric"
|
|
311
|
+
autoComplete="tel-national"
|
|
312
|
+
value={value}
|
|
313
|
+
onChange={(e) => onChange(formatNational(e.target.value, selected))}
|
|
314
|
+
placeholder={maskPlaceholder(selected)}
|
|
315
|
+
required={required}
|
|
316
|
+
disabled={disabled}
|
|
317
|
+
autoFocus={autoFocus}
|
|
318
|
+
aria-invalid={error ? true : undefined}
|
|
319
|
+
aria-describedby={describedBy(id, helpText, error)}
|
|
320
|
+
/>
|
|
321
|
+
</div>
|
|
322
|
+
</FieldShell>
|
|
323
|
+
);
|
|
324
|
+
}
|
|
325
|
+
|
|
216
326
|
interface FieldCheckboxProps {
|
|
217
327
|
id: string;
|
|
218
328
|
name: string;
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
/* GlyphToggle: a round control the height of a small button (the row it
|
|
2
|
+
stands in), on the small gray button's chrome when off and filled with
|
|
3
|
+
ink when on; the glyph, at the small button's icon size, is the only
|
|
4
|
+
content. */
|
|
5
|
+
|
|
6
|
+
:root {
|
|
7
|
+
--glyph-toggle-h: 36px;
|
|
8
|
+
--glyph-toggle-glyph: 16px;
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
.glyph-toggles {
|
|
12
|
+
display: inline-flex;
|
|
13
|
+
align-items: center;
|
|
14
|
+
gap: var(--space-xs);
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
.glyph-toggle {
|
|
18
|
+
appearance: none;
|
|
19
|
+
display: grid;
|
|
20
|
+
place-items: center;
|
|
21
|
+
flex: none;
|
|
22
|
+
width: var(--glyph-toggle-h);
|
|
23
|
+
height: var(--glyph-toggle-h);
|
|
24
|
+
padding: var(--space-none);
|
|
25
|
+
border: 0;
|
|
26
|
+
border-radius: var(--radius-full);
|
|
27
|
+
background: var(--color-bg-300);
|
|
28
|
+
color: var(--color-text-500);
|
|
29
|
+
cursor: pointer;
|
|
30
|
+
transition-property: background-color, color;
|
|
31
|
+
transition-duration: var(--motion-hover-duration);
|
|
32
|
+
transition-timing-function: var(--motion-hover-ease);
|
|
33
|
+
}
|
|
34
|
+
.glyph-toggle svg {
|
|
35
|
+
width: var(--glyph-toggle-glyph);
|
|
36
|
+
height: var(--glyph-toggle-glyph);
|
|
37
|
+
}
|
|
38
|
+
.glyph-toggle[aria-pressed="true"] {
|
|
39
|
+
background: var(--color-text-200);
|
|
40
|
+
color: var(--color-bg-100);
|
|
41
|
+
}
|
|
42
|
+
@media (hover: hover) {
|
|
43
|
+
.glyph-toggle:hover:not(:disabled) {
|
|
44
|
+
background: var(--color-bg-400);
|
|
45
|
+
color: var(--color-text-200);
|
|
46
|
+
}
|
|
47
|
+
.glyph-toggle[aria-pressed="true"]:hover:not(:disabled) {
|
|
48
|
+
background: var(--color-text-100);
|
|
49
|
+
color: var(--color-bg-000);
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
.glyph-toggle:focus-visible {
|
|
53
|
+
outline: none;
|
|
54
|
+
box-shadow: 0 0 0 var(--ring-w) var(--color-border-200);
|
|
55
|
+
}
|
|
56
|
+
.glyph-toggle:disabled {
|
|
57
|
+
cursor: wait;
|
|
58
|
+
color: var(--color-text-600);
|
|
59
|
+
}
|
|
60
|
+
.glyph-toggle[aria-pressed="true"]:disabled {
|
|
61
|
+
color: var(--color-bg-300);
|
|
62
|
+
}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
/** GlyphToggle: a small round control that is on or off, drawn as a glyph
|
|
2
|
+
* alone — the state spoken by `aria-pressed`, the meaning by `label`,
|
|
3
|
+
* which is also its tooltip. A row of them (`GlyphToggles`) sits where a
|
|
4
|
+
* line of text would. Styles in glyph-toggle.css. */
|
|
5
|
+
|
|
6
|
+
import type { ReactNode } from "react";
|
|
7
|
+
import { Tooltip } from "./tooltip";
|
|
8
|
+
|
|
9
|
+
interface GlyphToggleProps {
|
|
10
|
+
/** The glyph (an icons.tsx line glyph). */
|
|
11
|
+
children: ReactNode;
|
|
12
|
+
/** Spoken, and the tooltip: what being on means. */
|
|
13
|
+
label: string;
|
|
14
|
+
pressed: boolean;
|
|
15
|
+
disabled?: boolean;
|
|
16
|
+
onClick: () => void;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
export function GlyphToggle({ children, label, pressed, disabled, onClick }: GlyphToggleProps) {
|
|
20
|
+
return (
|
|
21
|
+
<Tooltip label={label}>
|
|
22
|
+
<button
|
|
23
|
+
type="button"
|
|
24
|
+
className="glyph-toggle"
|
|
25
|
+
aria-pressed={pressed}
|
|
26
|
+
aria-label={label}
|
|
27
|
+
disabled={disabled}
|
|
28
|
+
onClick={onClick}
|
|
29
|
+
>
|
|
30
|
+
{children}
|
|
31
|
+
</button>
|
|
32
|
+
</Tooltip>
|
|
33
|
+
);
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
export function GlyphToggles({ children, label }: { children: ReactNode; label: string }) {
|
|
37
|
+
return (
|
|
38
|
+
<span className="glyph-toggles" role="group" aria-label={label}>
|
|
39
|
+
{children}
|
|
40
|
+
</span>
|
|
41
|
+
);
|
|
42
|
+
}
|
package/primitives/grader.css
CHANGED
|
@@ -253,6 +253,10 @@
|
|
|
253
253
|
border: 1px solid var(--color-border-000);
|
|
254
254
|
border-radius: var(--radius-xl);
|
|
255
255
|
box-shadow: var(--shadow-hard-square-md);
|
|
256
|
+
/* A long result list scrolls inside the menu rather than running
|
|
257
|
+
past the viewport. */
|
|
258
|
+
max-height: min(22rem, 50dvh);
|
|
259
|
+
overflow-y: auto;
|
|
256
260
|
}
|
|
257
261
|
/* Large pills use a larger menu gap; small pills a smaller menu type. */
|
|
258
262
|
@container style(--grader-size: lg) {
|
package/primitives/modal.css
CHANGED
|
@@ -6,6 +6,7 @@
|
|
|
6
6
|
--z-portal: 9999;
|
|
7
7
|
--modal-close: 32px;
|
|
8
8
|
--modal-mark: 44px;
|
|
9
|
+
--modal-scrim-blur: 3px;
|
|
9
10
|
}
|
|
10
11
|
|
|
11
12
|
.modal {
|
|
@@ -31,13 +32,15 @@
|
|
|
31
32
|
animation: modal-dim var(--motion-rise-duration) var(--motion-drawer-ease) both;
|
|
32
33
|
}
|
|
33
34
|
.modal-sheet {
|
|
35
|
+
--_pad: var(--space-3xl);
|
|
34
36
|
position: relative;
|
|
37
|
+
display: flex;
|
|
38
|
+
flex-direction: column;
|
|
35
39
|
box-sizing: border-box;
|
|
36
40
|
width: 100%;
|
|
37
41
|
max-width: 28rem;
|
|
38
42
|
max-height: calc(100dvh - var(--space-2xl) * 2);
|
|
39
43
|
overflow-y: auto;
|
|
40
|
-
padding: var(--space-3xl);
|
|
41
44
|
border: 1px solid var(--color-border-050);
|
|
42
45
|
border-radius: var(--radius-3xl);
|
|
43
46
|
background: var(--color-bg-200);
|
|
@@ -46,18 +49,53 @@
|
|
|
46
49
|
outline: none;
|
|
47
50
|
animation: modal-pop var(--motion-rise-duration) var(--motion-drawer-ease) both;
|
|
48
51
|
}
|
|
52
|
+
.modal-body {
|
|
53
|
+
padding: var(--_pad);
|
|
54
|
+
}
|
|
55
|
+
.modal-sheet[data-size="xs"] {
|
|
56
|
+
max-width: 25rem;
|
|
57
|
+
--_pad: var(--space-4xl);
|
|
58
|
+
}
|
|
59
|
+
/* The small sheet's body sits a touch deeper above than below. */
|
|
60
|
+
.modal-sheet[data-size="xs"] .modal-body {
|
|
61
|
+
padding-block: calc(var(--space-4xl) + var(--space-xs)) calc(var(--space-3xl) + var(--space-xs));
|
|
62
|
+
}
|
|
49
63
|
.modal-sheet[data-size="md"] {
|
|
50
64
|
max-width: 36rem;
|
|
51
65
|
}
|
|
52
66
|
.modal-sheet[data-size="lg"] {
|
|
53
67
|
max-width: 64rem;
|
|
54
|
-
|
|
68
|
+
--_pad: var(--space-2xl);
|
|
55
69
|
}
|
|
56
70
|
@container (--rt) {
|
|
57
71
|
.modal-sheet[data-size="lg"] {
|
|
58
|
-
|
|
72
|
+
--_pad: var(--space-3xl);
|
|
59
73
|
}
|
|
60
74
|
}
|
|
75
|
+
|
|
76
|
+
/* The foot: ruled off, quieter, centred. */
|
|
77
|
+
.modal-foot {
|
|
78
|
+
display: flex;
|
|
79
|
+
flex-direction: column;
|
|
80
|
+
align-items: center;
|
|
81
|
+
gap: var(--space-md);
|
|
82
|
+
padding: var(--space-xl) var(--space-3xl);
|
|
83
|
+
border-top: 1px solid var(--color-border-000);
|
|
84
|
+
text-align: center;
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
/* Ink backdrop: the page dims and blurs; the sheet sits on the page
|
|
88
|
+
ground, tighter-cornered, under a long soft drop and no hairline. */
|
|
89
|
+
.modal[data-backdrop="ink"] .modal-backdrop {
|
|
90
|
+
background: var(--color-scrim);
|
|
91
|
+
backdrop-filter: blur(var(--modal-scrim-blur));
|
|
92
|
+
}
|
|
93
|
+
.modal[data-backdrop="ink"] .modal-sheet {
|
|
94
|
+
border: 0;
|
|
95
|
+
border-radius: var(--radius-2xl);
|
|
96
|
+
background: var(--color-bg-100);
|
|
97
|
+
box-shadow: var(--shadow-sheet);
|
|
98
|
+
}
|
|
61
99
|
.modal-close {
|
|
62
100
|
appearance: none;
|
|
63
101
|
position: absolute;
|
package/primitives/modal.tsx
CHANGED
|
@@ -15,12 +15,24 @@ interface ModalProps {
|
|
|
15
15
|
/** Names the dialog for assistive technology. */
|
|
16
16
|
label: string;
|
|
17
17
|
onClose: () => void;
|
|
18
|
-
/** Sheet width: sm for prompts, md for forms, lg for records. */
|
|
19
|
-
size?: "sm" | "md" | "lg";
|
|
18
|
+
/** Sheet width: xs for a sign-in, sm for prompts, md for forms, lg for records. */
|
|
19
|
+
size?: "xs" | "sm" | "md" | "lg";
|
|
20
|
+
/** The page behind: lightened to paper, or dimmed to ink and blurred
|
|
21
|
+
* under a sheet on the page ground with a long soft drop. */
|
|
22
|
+
backdrop?: "paper" | "ink";
|
|
23
|
+
/** A band under the body, ruled off from it: a seal, the small print. */
|
|
24
|
+
foot?: ReactNode;
|
|
20
25
|
children: ReactNode;
|
|
21
26
|
}
|
|
22
27
|
|
|
23
|
-
export function Modal({
|
|
28
|
+
export function Modal({
|
|
29
|
+
label,
|
|
30
|
+
onClose,
|
|
31
|
+
size = "sm",
|
|
32
|
+
backdrop = "paper",
|
|
33
|
+
foot,
|
|
34
|
+
children,
|
|
35
|
+
}: ModalProps) {
|
|
24
36
|
const sheetRef = useRef<HTMLDivElement>(null);
|
|
25
37
|
const openerRef = useRef<Element | null>(null);
|
|
26
38
|
|
|
@@ -50,7 +62,7 @@ export function Modal({ label, onClose, size = "sm", children }: ModalProps) {
|
|
|
50
62
|
}, [onClose]);
|
|
51
63
|
|
|
52
64
|
return createPortal(
|
|
53
|
-
<div className="modal">
|
|
65
|
+
<div className="modal" data-backdrop={backdrop === "ink" ? backdrop : undefined}>
|
|
54
66
|
<button type="button" className="modal-backdrop" aria-label="Close" onClick={onClose} />
|
|
55
67
|
<div
|
|
56
68
|
ref={sheetRef}
|
|
@@ -64,7 +76,8 @@ export function Modal({ label, onClose, size = "sm", children }: ModalProps) {
|
|
|
64
76
|
<button type="button" className="modal-close" aria-label="Close" onClick={onClose}>
|
|
65
77
|
<IconGalleryClose />
|
|
66
78
|
</button>
|
|
67
|
-
{children}
|
|
79
|
+
<div className="modal-body">{children}</div>
|
|
80
|
+
{foot ? <div className="modal-foot">{foot}</div> : null}
|
|
68
81
|
</div>
|
|
69
82
|
</div>,
|
|
70
83
|
document.body,
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
/* Tooltip: the platform's dark pill, 8px off the trigger. In, it fades and
|
|
2
|
+
grows from 0.85 over 140ms; out, it fades and shrinks back over 100ms.
|
|
3
|
+
Reduced motion snaps both. The anchor wraps the trigger and is the pill's
|
|
4
|
+
positioning root. */
|
|
5
|
+
|
|
6
|
+
:root {
|
|
7
|
+
--tooltip-offset: 8px;
|
|
8
|
+
--tooltip-in-duration: 140ms;
|
|
9
|
+
--tooltip-out-duration: 100ms;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
.tooltip-anchor {
|
|
13
|
+
position: relative;
|
|
14
|
+
display: inline-flex;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
.tooltip {
|
|
18
|
+
position: absolute;
|
|
19
|
+
left: 50%;
|
|
20
|
+
z-index: var(--z-raised);
|
|
21
|
+
padding: var(--space-xs) var(--space-md);
|
|
22
|
+
border-radius: var(--radius-md);
|
|
23
|
+
background: var(--color-text-100);
|
|
24
|
+
color: var(--color-bg-100);
|
|
25
|
+
white-space: nowrap;
|
|
26
|
+
pointer-events: none;
|
|
27
|
+
opacity: 0;
|
|
28
|
+
visibility: hidden;
|
|
29
|
+
translate: -50% 0;
|
|
30
|
+
scale: 0.85;
|
|
31
|
+
transition-property: opacity, scale, visibility;
|
|
32
|
+
transition-duration: var(--tooltip-out-duration), var(--tooltip-out-duration), 0s;
|
|
33
|
+
transition-delay: 0s, 0s, var(--tooltip-out-duration);
|
|
34
|
+
transition-timing-function: ease-out;
|
|
35
|
+
}
|
|
36
|
+
.tooltip[data-placement="top"] {
|
|
37
|
+
bottom: calc(100% + var(--tooltip-offset));
|
|
38
|
+
transform-origin: bottom center;
|
|
39
|
+
}
|
|
40
|
+
.tooltip[data-placement="bottom"] {
|
|
41
|
+
top: calc(100% + var(--tooltip-offset));
|
|
42
|
+
transform-origin: top center;
|
|
43
|
+
}
|
|
44
|
+
.tooltip[data-open] {
|
|
45
|
+
opacity: 1;
|
|
46
|
+
visibility: visible;
|
|
47
|
+
scale: 1;
|
|
48
|
+
transition-duration: var(--tooltip-in-duration), var(--tooltip-in-duration), 0s;
|
|
49
|
+
transition-delay: 0s;
|
|
50
|
+
}
|
|
51
|
+
@media (prefers-reduced-motion: reduce) {
|
|
52
|
+
.tooltip {
|
|
53
|
+
transition: none;
|
|
54
|
+
scale: 1;
|
|
55
|
+
}
|
|
56
|
+
}
|
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
|
|
3
|
+
/** Tooltip: the platform's dark pill (keystone-console's
|
|
4
|
+
* `keystone-design-system` Tooltip), ported without react-aria. A word on
|
|
5
|
+
* a control that shows on hover after a short delay and on keyboard
|
|
6
|
+
* focus, closes on leave, blur and Escape, and describes the trigger to
|
|
7
|
+
* assistive tech; an icon-only trigger still carries its own
|
|
8
|
+
* `aria-label`. Styles in tooltip.css. */
|
|
9
|
+
|
|
10
|
+
import {
|
|
11
|
+
type KeyboardEvent,
|
|
12
|
+
type PointerEvent,
|
|
13
|
+
type ReactElement,
|
|
14
|
+
type ReactNode,
|
|
15
|
+
cloneElement,
|
|
16
|
+
useEffect,
|
|
17
|
+
useId,
|
|
18
|
+
useRef,
|
|
19
|
+
useState,
|
|
20
|
+
} from "react";
|
|
21
|
+
|
|
22
|
+
export type TooltipPlacement = "top" | "bottom";
|
|
23
|
+
|
|
24
|
+
interface TooltipProps {
|
|
25
|
+
/** Tooltip text. */
|
|
26
|
+
label: ReactNode;
|
|
27
|
+
/** The trigger: one focusable element; it is given `aria-describedby`. */
|
|
28
|
+
children: ReactElement<{ "aria-describedby"?: string }>;
|
|
29
|
+
/** Which side of the trigger. */
|
|
30
|
+
placement?: TooltipPlacement;
|
|
31
|
+
/** Hover open delay in ms — the anti-flicker as a cursor passes through. */
|
|
32
|
+
delay?: number;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
/* The platform's: hover opens after 100ms, focus at once. */
|
|
36
|
+
const OPEN_DELAY_MS = 100;
|
|
37
|
+
|
|
38
|
+
export function Tooltip({
|
|
39
|
+
label,
|
|
40
|
+
children,
|
|
41
|
+
placement = "top",
|
|
42
|
+
delay = OPEN_DELAY_MS,
|
|
43
|
+
}: TooltipProps) {
|
|
44
|
+
const id = useId();
|
|
45
|
+
const [open, setOpen] = useState(false);
|
|
46
|
+
const timer = useRef<ReturnType<typeof setTimeout> | null>(null);
|
|
47
|
+
// A focus that a press brought is the press's, not the keyboard's.
|
|
48
|
+
const pressed = useRef(false);
|
|
49
|
+
|
|
50
|
+
const clear = () => {
|
|
51
|
+
if (timer.current !== null) clearTimeout(timer.current);
|
|
52
|
+
timer.current = null;
|
|
53
|
+
};
|
|
54
|
+
useEffect(() => clear, []);
|
|
55
|
+
|
|
56
|
+
const show = () => {
|
|
57
|
+
clear();
|
|
58
|
+
setOpen(true);
|
|
59
|
+
};
|
|
60
|
+
const hide = () => {
|
|
61
|
+
clear();
|
|
62
|
+
setOpen(false);
|
|
63
|
+
};
|
|
64
|
+
const onPointerEnter = (event: PointerEvent) => {
|
|
65
|
+
// A finger shows nothing: the label is the control's own.
|
|
66
|
+
if (event.pointerType !== "mouse") return;
|
|
67
|
+
clear();
|
|
68
|
+
timer.current = setTimeout(show, delay);
|
|
69
|
+
};
|
|
70
|
+
const onPointerDown = () => {
|
|
71
|
+
pressed.current = true;
|
|
72
|
+
};
|
|
73
|
+
const onFocus = () => {
|
|
74
|
+
if (!pressed.current) show();
|
|
75
|
+
pressed.current = false;
|
|
76
|
+
};
|
|
77
|
+
const onKeyDown = (event: KeyboardEvent) => {
|
|
78
|
+
if (event.key === "Escape") hide();
|
|
79
|
+
};
|
|
80
|
+
|
|
81
|
+
return (
|
|
82
|
+
<span
|
|
83
|
+
className="tooltip-anchor"
|
|
84
|
+
onPointerEnter={onPointerEnter}
|
|
85
|
+
onPointerLeave={hide}
|
|
86
|
+
onPointerDown={onPointerDown}
|
|
87
|
+
onFocus={onFocus}
|
|
88
|
+
onBlur={hide}
|
|
89
|
+
onKeyDown={onKeyDown}
|
|
90
|
+
>
|
|
91
|
+
{cloneElement(children, { "aria-describedby": id })}
|
|
92
|
+
<span
|
|
93
|
+
role="tooltip"
|
|
94
|
+
id={id}
|
|
95
|
+
className="type type-fixed ts-text-xs-medium tooltip"
|
|
96
|
+
data-placement={placement}
|
|
97
|
+
data-open={open || undefined}
|
|
98
|
+
>
|
|
99
|
+
{label}
|
|
100
|
+
</span>
|
|
101
|
+
</span>
|
|
102
|
+
);
|
|
103
|
+
}
|
package/rules/grid-and-layout.md
CHANGED
|
@@ -23,7 +23,7 @@ at the bands' geometric midpoints, gated by **container queries** on
|
|
|
23
23
|
|
|
24
24
|
Gates are always written by name — `(--rs)`, `(--rt)`, `(--rd1)`, `(--rd2)`,
|
|
25
25
|
and the closed forms `(--below-rs)`, `(--below-rt)`, `(--below-rd1)`,
|
|
26
|
-
`(--rt-only)` — and resolved by the PostCSS plugin `grid/gates.cjs`; a pixel
|
|
26
|
+
`(--rt-only)`, `(--rd1-only)` — and resolved by the PostCSS plugin `grid/gates.cjs`; a pixel
|
|
27
27
|
width never appears in a container query.
|
|
28
28
|
|
|
29
29
|
- The tick is the page container's width ÷ 12, capped at 112px. Base CSS is
|
|
@@ -207,3 +207,17 @@
|
|
|
207
207
|
gap: var(--space-5xl);
|
|
208
208
|
}
|
|
209
209
|
}
|
|
210
|
+
|
|
211
|
+
/* A credited legal row holds five links: eight ticks do not carry them on
|
|
212
|
+
one line at rd1, so it keeps the tablet's geometry there (the TSX keeps
|
|
213
|
+
the matching lattice). From rd2 the row is wide enough as designed. */
|
|
214
|
+
@container (--rd1-only) {
|
|
215
|
+
.fsig-credited .fsig-copy {
|
|
216
|
+
width: calc(var(--t) * 10 + 1px);
|
|
217
|
+
margin-left: var(--t);
|
|
218
|
+
padding-inline: var(--space-4xl);
|
|
219
|
+
}
|
|
220
|
+
.fsig-credited .fsig-legal-links {
|
|
221
|
+
gap: var(--space-2xl);
|
|
222
|
+
}
|
|
223
|
+
}
|
|
@@ -21,6 +21,13 @@ export interface FooterSignatureLinks {
|
|
|
21
21
|
accessibility: string;
|
|
22
22
|
}
|
|
23
23
|
|
|
24
|
+
/** A credit a licence asks the page to carry, drawn as the last legal
|
|
25
|
+
* link (for instance the IP geolocation data behind a search box). */
|
|
26
|
+
export interface FooterSignatureCredit {
|
|
27
|
+
label: string;
|
|
28
|
+
href: string;
|
|
29
|
+
}
|
|
30
|
+
|
|
24
31
|
interface R {
|
|
25
32
|
gx: number;
|
|
26
33
|
gy: number;
|
|
@@ -62,6 +69,9 @@ const FOOTER_MAP: Record<GridBand, R[]> = {
|
|
|
62
69
|
rd1: footerMap(false, 2),
|
|
63
70
|
rd2: footerMap(false, 2),
|
|
64
71
|
};
|
|
72
|
+
/* With a credit the legal row carries five links, more than eight ticks
|
|
73
|
+
hold on one line at rd1; it keeps the tablet's one-cell inset there. */
|
|
74
|
+
const CREDITED_FOOTER_MAP: Record<GridBand, R[]> = { ...FOOTER_MAP, rd1: footerMap(false, 1) };
|
|
65
75
|
|
|
66
76
|
function Overlay({ maps }: { maps: Record<GridBand, R[]> }) {
|
|
67
77
|
return (
|
|
@@ -76,13 +86,15 @@ function Overlay({ maps }: { maps: Record<GridBand, R[]> }) {
|
|
|
76
86
|
export function FooterSignature({
|
|
77
87
|
copy,
|
|
78
88
|
links,
|
|
89
|
+
credit,
|
|
79
90
|
}: {
|
|
80
91
|
copy: FooterSignatureCopy;
|
|
81
92
|
links: FooterSignatureLinks;
|
|
93
|
+
credit?: FooterSignatureCredit;
|
|
82
94
|
}) {
|
|
83
95
|
return (
|
|
84
|
-
<footer className="sec fsig">
|
|
85
|
-
<Overlay maps={FOOTER_MAP} />
|
|
96
|
+
<footer className={credit ? "sec fsig fsig-credited" : "sec fsig"}>
|
|
97
|
+
<Overlay maps={credit ? CREDITED_FOOTER_MAP : FOOTER_MAP} />
|
|
86
98
|
<div className="fsig-signature" data-landmark="signature">
|
|
87
99
|
<div className="fsig-statement">
|
|
88
100
|
<div className="fsig-lead">
|
|
@@ -103,6 +115,11 @@ export function FooterSignature({
|
|
|
103
115
|
<a href={links.privacy}>{copy.legal.privacy}</a>
|
|
104
116
|
<a href={links.accessibility}>{copy.legal.accessibility}</a>
|
|
105
117
|
<CookiePreferencesLink label={copy.legal.cookies} className="fsig-legal-preferences" />
|
|
118
|
+
{credit ? (
|
|
119
|
+
<a href={credit.href} rel="noopener">
|
|
120
|
+
{credit.label}
|
|
121
|
+
</a>
|
|
122
|
+
) : null}
|
|
106
123
|
</div>
|
|
107
124
|
</div>
|
|
108
125
|
</footer>
|
package/tokens/semantic.css
CHANGED
|
@@ -122,6 +122,10 @@
|
|
|
122
122
|
--shadow-hard-square-md-0: 0 0 0 0 var(--shadow-ink);
|
|
123
123
|
/* The web-swatch hairline uses palette ink, unlike hard shadows. */
|
|
124
124
|
--shadow-web-swatch: 0 1px 2px 0 rgba(108, 104, 96, 0.05);
|
|
125
|
+
/* A sheet lifted over a dimmed page (ks-Grader 254:15012): a long soft
|
|
126
|
+
drop in the same warm near-black; the scrim is that ink at 55%. */
|
|
127
|
+
--shadow-sheet: 0 28px 80px -20px rgba(42, 36, 29, 0.5);
|
|
128
|
+
--color-scrim: rgba(42, 36, 29, 0.55);
|
|
125
129
|
}
|
|
126
130
|
|
|
127
131
|
/* Constants shared by more than one file. Section-local constants live
|