@canonical/react-ds-global-form 0.37.0 → 0.40.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 +40 -0
- package/dist/esm/density.css +320 -302
- package/dist/esm/docs/examples/density-examples.css +19 -14
- package/dist/esm/index.css +361 -335
- package/dist/esm/lib/_work_in_progress/DensityTestbed/baseline-system.css +71 -64
- package/dist/esm/lib/_work_in_progress/DensityTestbed/density.testbed.css +127 -123
- package/dist/esm/lib/common/Wrapper/ToggleWrapper.css +73 -54
- package/dist/esm/lib/common/Wrapper/styles.css +35 -31
- package/dist/esm/lib/component/ChoicesField/common/Option/Option.js +4 -1
- package/dist/esm/lib/component/ChoicesField/common/Option/Option.js.map +1 -1
- package/dist/esm/lib/component/ChoicesField/styles.css +195 -163
- package/dist/esm/lib/component/RangeField/common/RangeControl/styles.css +39 -35
- package/dist/esm/lib/component/RichChoicesField/styles.css +93 -89
- package/dist/esm/lib/subcomponent/CheckboxInput/styles.css +115 -111
- package/dist/esm/lib/subcomponent/ColorInput/styles.css +177 -173
- package/dist/esm/lib/subcomponent/ComboboxInput/SingleCombobox.js.map +1 -1
- package/dist/esm/lib/subcomponent/ComboboxInput/common/List/styles.css +33 -29
- package/dist/esm/lib/subcomponent/ComboboxInput/common/ResetButton/styles.css +21 -17
- package/dist/esm/lib/subcomponent/ComboboxInput/styles.css +59 -55
- package/dist/esm/lib/subcomponent/DateInput/styles.css +23 -19
- package/dist/esm/lib/subcomponent/DateTimeInput/styles.css +24 -20
- package/dist/esm/lib/subcomponent/Field/Description/styles.css +9 -5
- package/dist/esm/lib/subcomponent/Field/Error/styles.css +9 -5
- package/dist/esm/lib/subcomponent/Field/Label/Label.js +2 -2
- package/dist/esm/lib/subcomponent/Field/Label/Label.js.map +1 -1
- package/dist/esm/lib/subcomponent/Field/Label/styles.css +25 -21
- package/dist/esm/lib/subcomponent/FileUploadInput/styles.css +125 -119
- package/dist/esm/lib/subcomponent/NumberInput/styles.css +32 -28
- package/dist/esm/lib/subcomponent/PasswordInput/styles.css +58 -54
- package/dist/esm/lib/subcomponent/PhoneInput/styles.css +53 -49
- package/dist/esm/lib/subcomponent/RadioInput/styles.css +70 -66
- package/dist/esm/lib/subcomponent/RangeInput/styles.css +74 -70
- package/dist/esm/lib/subcomponent/RatingInput/styles.css +132 -128
- package/dist/esm/lib/subcomponent/SelectInput/styles.css +44 -40
- package/dist/esm/lib/subcomponent/SwitchInput/styles.css +90 -86
- package/dist/esm/lib/subcomponent/TextInput/styles.css +30 -26
- package/dist/esm/lib/subcomponent/TextareaInput/styles.css +14 -10
- package/dist/esm/lib/subcomponent/TimeInput/styles.css +19 -15
- package/dist/esm/lib/utils/middleware/addRESTValidation.js +1 -1
- package/dist/esm/lib/utils/middleware/addRESTValidation.js.map +1 -1
- package/dist/types/lib/component/ChoicesField/common/Option/Option.d.ts.map +1 -1
- package/dist/types/lib/subcomponent/ComboboxInput/SingleCombobox.d.ts.map +1 -1
- package/package.json +17 -16
|
@@ -5,77 +5,84 @@
|
|
|
5
5
|
* (imported by src/index.css), so real components consume it by default. This
|
|
6
6
|
* file keeps only the TESTBED-ONLY helpers: the size-agnostic `.baseline` proof
|
|
7
7
|
* class and the `.spike-baseline-boxed` prototype + their proof surfaces.
|
|
8
|
+
*
|
|
9
|
+
* Layer: ds.components.global (@canonical/styles README, "Cascade layers").
|
|
8
10
|
*/
|
|
9
11
|
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
.
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
--line-height
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
12
|
+
@layer ds.components.global {
|
|
13
|
+
/* ── DS.01 — .baseline: snap any element to the grid, whatever its size ──────
|
|
14
|
+
* Reads whatever --font-size / --line-height is present and computes the same
|
|
15
|
+
* cap-unit nudges the engine uses on h1..h6/p, without assigning a tier. The
|
|
16
|
+
* maths is font-relative, so it holds at any size. */
|
|
17
|
+
.baseline {
|
|
18
|
+
--bl-line-height-ratio: var(--line-height-ratio, 1.4);
|
|
19
|
+
--bl-computed-line-height: var(
|
|
20
|
+
--line-height,
|
|
21
|
+
round(up, calc(1em * var(--bl-line-height-ratio)), var(--baseline-height))
|
|
22
|
+
);
|
|
23
|
+
line-height: var(--bl-computed-line-height);
|
|
21
24
|
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
25
|
+
--bl-baseline-position: calc((var(--bl-computed-line-height) + 1cap) / 2);
|
|
26
|
+
--bl-start-nudge: calc(
|
|
27
|
+
var(--baseline-height) -
|
|
28
|
+
mod(var(--bl-baseline-position), var(--baseline-height))
|
|
29
|
+
);
|
|
30
|
+
--bl-end-nudge: calc(var(--baseline-height) - var(--bl-start-nudge));
|
|
28
31
|
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
}
|
|
32
|
+
padding-block-start: var(--bl-start-nudge);
|
|
33
|
+
padding-block-end: var(--bl-end-nudge);
|
|
34
|
+
margin-block: 0;
|
|
35
|
+
}
|
|
33
36
|
|
|
34
|
-
/* ── DS.02 — .spike-baseline-boxed: PROTOTYPE ONLY, NOT CORE API ─────────────
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
.spike-baseline-boxed {
|
|
39
|
-
--line-height: var(--density-line-height, calc(var(--baseline-height) * 6));
|
|
40
|
-
box-sizing: border-box;
|
|
41
|
-
block-size: var(--density-line-height, calc(var(--baseline-height) * 6));
|
|
42
|
-
}
|
|
43
|
-
@supports (block-size: calc-size(min-content, size)) {
|
|
37
|
+
/* ── DS.02 — .spike-baseline-boxed: PROTOTYPE ONLY, NOT CORE API ─────────────
|
|
38
|
+
* `.baseline` with a density-chosen line-height; the box height is snapped to the
|
|
39
|
+
* grid (intrinsic snap via calc-size where supported, fixed grid-multiple
|
|
40
|
+
* fallback). Testbed only; never export. */
|
|
44
41
|
.spike-baseline-boxed {
|
|
45
|
-
|
|
42
|
+
--line-height: var(--density-line-height, calc(var(--baseline-height) * 6));
|
|
43
|
+
box-sizing: border-box;
|
|
44
|
+
block-size: var(--density-line-height, calc(var(--baseline-height) * 6));
|
|
45
|
+
}
|
|
46
|
+
@supports (block-size: calc-size(min-content, size)) {
|
|
47
|
+
.spike-baseline-boxed {
|
|
48
|
+
block-size: calc-size(
|
|
49
|
+
min-content,
|
|
50
|
+
round(up, size, var(--baseline-height))
|
|
51
|
+
);
|
|
52
|
+
}
|
|
46
53
|
}
|
|
47
|
-
}
|
|
48
54
|
|
|
49
|
-
/* ── Proof surface for .baseline (DS.01) — off-scale sizes on one line ─────── */
|
|
50
|
-
.baseline-proof {
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
}
|
|
57
|
-
.baseline-proof > .baseline {
|
|
58
|
-
|
|
59
|
-
}
|
|
55
|
+
/* ── Proof surface for .baseline (DS.01) — off-scale sizes on one line ─────── */
|
|
56
|
+
.baseline-proof {
|
|
57
|
+
display: flex;
|
|
58
|
+
align-items: flex-start;
|
|
59
|
+
gap: calc(var(--baseline-height) * 4);
|
|
60
|
+
overflow-x: auto;
|
|
61
|
+
white-space: nowrap;
|
|
62
|
+
}
|
|
63
|
+
.baseline-proof > .baseline {
|
|
64
|
+
font-family: inherit;
|
|
65
|
+
}
|
|
60
66
|
|
|
61
|
-
/* ── Proof surface for .spike-baseline-boxed (DS.02) — mixed sizes, 2 densities ── */
|
|
62
|
-
.boxed-proof {
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
}
|
|
70
|
-
.boxed-proof > .spike-baseline-boxed {
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
}
|
|
76
|
-
.boxed-proof.is-dense {
|
|
77
|
-
|
|
78
|
-
}
|
|
79
|
-
.boxed-proof.is-comfortable {
|
|
80
|
-
|
|
67
|
+
/* ── Proof surface for .spike-baseline-boxed (DS.02) — mixed sizes, 2 densities ── */
|
|
68
|
+
.boxed-proof {
|
|
69
|
+
display: flex;
|
|
70
|
+
align-items: flex-start;
|
|
71
|
+
gap: calc(var(--baseline-height) * 3);
|
|
72
|
+
overflow-x: auto;
|
|
73
|
+
white-space: nowrap;
|
|
74
|
+
margin-block: calc(var(--baseline-height) * 2);
|
|
75
|
+
}
|
|
76
|
+
.boxed-proof > .spike-baseline-boxed {
|
|
77
|
+
border: 1px solid var(--color-border, #b3b3b3);
|
|
78
|
+
border-radius: var(--dimension-radius-100, 0.25rem);
|
|
79
|
+
padding-inline: calc(var(--baseline-height) * 2);
|
|
80
|
+
background: transparent; /* let the grid overlay show through */
|
|
81
|
+
}
|
|
82
|
+
.boxed-proof.is-dense {
|
|
83
|
+
--density-line-height: calc(var(--baseline-height) * 6); /* 24px */
|
|
84
|
+
}
|
|
85
|
+
.boxed-proof.is-comfortable {
|
|
86
|
+
--density-line-height: calc(var(--baseline-height) * 8); /* 32px */
|
|
87
|
+
}
|
|
81
88
|
}
|
|
@@ -14,140 +14,144 @@
|
|
|
14
14
|
* The baseline grid overlay comes from the styles-debug plugin (story
|
|
15
15
|
* `parameters.baseline`); the box seat uses the shipped engine model (the
|
|
16
16
|
* alternative top-align + external-margin model lives in SPIKE.md).
|
|
17
|
+
*
|
|
18
|
+
* Layer: ds.components.global (@canonical/styles README, "Cascade layers").
|
|
17
19
|
*/
|
|
18
20
|
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
21
|
+
@layer ds.components.global {
|
|
22
|
+
/* ── The testbed root ── */
|
|
23
|
+
.density-testbed {
|
|
24
|
+
/* --baseline-height is 4px. Source of truth, in order:
|
|
25
|
+
1. @canonical/styles-typography's baseline-shim.css registers it via
|
|
26
|
+
`@property … initial-value: 0.25rem`, so the engine ALWAYS has 4px even
|
|
27
|
+
if styles-main did not load (order-independent — learned from the
|
|
28
|
+
typography example, which loads an engine standalone). Then
|
|
29
|
+
2. @canonical/styles' spacing.css sets it explicitly to 0.25rem when present.
|
|
30
|
+
The literal fallback below is belt-and-suspenders; the @property makes it
|
|
31
|
+
redundant. Nothing to override here. */
|
|
32
|
+
padding: 0 var(--baseline-height, 0.25rem);
|
|
33
|
+
color: var(--color-text, #1a1a1a);
|
|
34
|
+
}
|
|
32
35
|
|
|
33
|
-
/* ───────────────────────────────────────────────────────────────────────────
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
.density-testbed__row {
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
}
|
|
48
|
-
.density-testbed__row > * {
|
|
49
|
-
|
|
50
|
-
}
|
|
51
|
-
.density-testbed__row > .p {
|
|
52
|
-
|
|
53
|
-
}
|
|
36
|
+
/* ───────────────────────────────────────────────────────────────────────────
|
|
37
|
+
* Bucket row — REGULAR component layout, no flattening or overrides
|
|
38
|
+
*
|
|
39
|
+
* A simple inline row: a short prose lead, then the components in their NORMAL
|
|
40
|
+
* structure laid inline. Controls are top-referenced density boxes (the density
|
|
41
|
+
* system seats each one's text on the grid INTERNALLY), so the row aligns the
|
|
42
|
+
* boxes by their TOPS. No block padding — the row must sit at the canvas origin
|
|
43
|
+
* so what we read is the density system's own grid registration, not a nudge. */
|
|
44
|
+
.density-testbed__row {
|
|
45
|
+
display: flex;
|
|
46
|
+
flex-wrap: nowrap; /* one horizontal line — overflow scrolls, never wraps */
|
|
47
|
+
align-items: flex-start;
|
|
48
|
+
gap: calc(var(--baseline-height) * 3); /* 12px */
|
|
49
|
+
overflow-x: auto;
|
|
50
|
+
}
|
|
51
|
+
.density-testbed__row > * {
|
|
52
|
+
flex: 0 0 auto; /* natural width, don't grow/shrink; the row scrolls instead */
|
|
53
|
+
}
|
|
54
|
+
.density-testbed__row > .p {
|
|
55
|
+
margin: 0;
|
|
56
|
+
}
|
|
54
57
|
|
|
55
|
-
/* Re-seat the reference LEAD to the density target (TESTBED ONLY) ──────────────
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
.density-testbed__row > .density-testbed__lead.p {
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
}
|
|
58
|
+
/* Re-seat the reference LEAD to the density target (TESTBED ONLY) ──────────────
|
|
59
|
+
* Prose is engine-seated now (Stage A), which lands it on the NEAREST grid line —
|
|
60
|
+
* one baseline off from the controls' density TARGET line. The lead only exists to
|
|
61
|
+
* be read against the controls, so here (and only here) we opt it back into the
|
|
62
|
+
* exact density seat the controls use: crush to line-height 1, then pad the top by
|
|
63
|
+
* the same `target − (1em+1cap)/2` the shipping controls use. This is calibration
|
|
64
|
+
* of a measuring stick, NOT a change to how prose ships. */
|
|
65
|
+
.density-testbed__row > .density-testbed__lead.p {
|
|
66
|
+
line-height: 1;
|
|
67
|
+
padding-block-start: max(
|
|
68
|
+
0px,
|
|
69
|
+
calc(var(--density-target-baseline-px, 0px) - calc((1em + 1cap) / 2))
|
|
70
|
+
);
|
|
71
|
+
padding-block-end: 0;
|
|
72
|
+
}
|
|
70
73
|
|
|
71
|
-
/* ───────────────────────────────────────────────────────────────────────────
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
.density-testbed .spike-box {
|
|
79
|
-
|
|
80
|
-
|
|
74
|
+
/* ───────────────────────────────────────────────────────────────────────────
|
|
75
|
+
* Boxed controls — the two alignment models
|
|
76
|
+
*
|
|
77
|
+
* `.spike-box` is a bordered box whose interior is a single line of `.p` text
|
|
78
|
+
* (button label, input value, nav item, table cell). Inline-block so it sits on
|
|
79
|
+
* the line. The text seat reads the engine's --start-nudge / --end-nudge.
|
|
80
|
+
* ─────────────────────────────────────────────────────────────────────────── */
|
|
81
|
+
.density-testbed .spike-box {
|
|
82
|
+
--box-border-width: 1px;
|
|
83
|
+
--box-padding-inline: var(--density-padding-inline, 0.75rem);
|
|
81
84
|
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
}
|
|
85
|
+
display: inline-flex;
|
|
86
|
+
align-items: stretch;
|
|
87
|
+
box-sizing: border-box;
|
|
88
|
+
vertical-align: baseline;
|
|
89
|
+
border: var(--box-border-width) solid var(--color-border, #b3b3b3);
|
|
90
|
+
border-radius: var(--dimension-radius-100, 0.25rem);
|
|
91
|
+
padding-inline: var(--box-padding-inline);
|
|
92
|
+
background: var(--color-background, #fff);
|
|
93
|
+
}
|
|
91
94
|
|
|
92
|
-
.density-testbed .spike-box > .seat {
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
}
|
|
95
|
+
.density-testbed .spike-box > .seat {
|
|
96
|
+
display: block;
|
|
97
|
+
white-space: nowrap;
|
|
98
|
+
}
|
|
96
99
|
|
|
97
|
-
/* Shared-border stack (list/table rows) — laid horizontally on the line here,
|
|
98
|
-
|
|
99
|
-
.density-testbed .spike-rows {
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
}
|
|
103
|
-
.density-testbed .spike-rows > .spike-box {
|
|
104
|
-
|
|
105
|
-
}
|
|
106
|
-
.density-testbed .spike-rows > .spike-box + .spike-box {
|
|
107
|
-
|
|
108
|
-
}
|
|
100
|
+
/* Shared-border stack (list/table rows) — laid horizontally on the line here,
|
|
101
|
+
each cell a box; the shared-border collapse is between inline siblings. */
|
|
102
|
+
.density-testbed .spike-rows {
|
|
103
|
+
display: inline-flex;
|
|
104
|
+
vertical-align: baseline;
|
|
105
|
+
}
|
|
106
|
+
.density-testbed .spike-rows > .spike-box {
|
|
107
|
+
border-radius: 0;
|
|
108
|
+
}
|
|
109
|
+
.density-testbed .spike-rows > .spike-box + .spike-box {
|
|
110
|
+
border-inline-start: none;
|
|
111
|
+
}
|
|
109
112
|
|
|
110
|
-
/* Box seat — the shipped engine model: engine's asymmetric nudges, both borders
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
.density-testbed .spike-box > .seat {
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
}
|
|
113
|
+
/* Box seat — the shipped engine model: engine's asymmetric nudges, both borders
|
|
114
|
+
* on the grid. (The current/proposed model toggle was removed; the alternative
|
|
115
|
+
* top-align + external-margin model is documented in SPIKE.md.) */
|
|
116
|
+
.density-testbed .spike-box > .seat {
|
|
117
|
+
padding-block-start: var(--start-nudge);
|
|
118
|
+
padding-block-end: var(--end-nudge);
|
|
119
|
+
}
|
|
117
120
|
|
|
118
|
-
/* ───────────────────────────────────────────────────────────────────────────
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
.density-testbed__type {
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
}
|
|
121
|
+
/* ───────────────────────────────────────────────────────────────────────────
|
|
122
|
+
* Typography bucket (TODO 5) — real paragraph text at several sizes on one line,
|
|
123
|
+
* to witness how the 4px baseline affects cap-based nudges (TODO 6). Inline so
|
|
124
|
+
* the sizes sit next to each other and can be read against the grid together.
|
|
125
|
+
* ─────────────────────────────────────────────────────────────────────────── */
|
|
126
|
+
.density-testbed__type {
|
|
127
|
+
display: flex;
|
|
128
|
+
align-items: flex-start;
|
|
129
|
+
gap: calc(var(--baseline-height) * 4);
|
|
130
|
+
overflow-x: auto;
|
|
131
|
+
white-space: nowrap;
|
|
132
|
+
padding-block: calc(var(--baseline-height) * 2);
|
|
133
|
+
}
|
|
131
134
|
|
|
132
|
-
/* Stacked full paragraphs of each tier, one after another, below the inline
|
|
133
|
-
|
|
134
|
-
.density-testbed__prose {
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
}
|
|
135
|
+
/* Stacked full paragraphs of each tier, one after another, below the inline
|
|
136
|
+
row — so a real prose BLOCK of each tier can be read against the grid. */
|
|
137
|
+
.density-testbed__prose {
|
|
138
|
+
max-width: 40rem;
|
|
139
|
+
margin-top: calc(var(--baseline-height) * 4);
|
|
140
|
+
}
|
|
138
141
|
|
|
139
|
-
/* Both sections use the package's own tags (h1..h6, p). The engine sizes each
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
.density-testbed__type > :where(h1, h2, h3, h4, h5, h6, p),
|
|
143
|
-
.density-testbed__prose > :where(h1, h2, h3, h4, h5, h6, p) {
|
|
144
|
-
|
|
145
|
-
}
|
|
142
|
+
/* Both sections use the package's own tags (h1..h6, p). The engine sizes each
|
|
143
|
+
tier; we only reset the demo margins so the grid reading is clean. No custom
|
|
144
|
+
size classes — each tag IS its tier. */
|
|
145
|
+
.density-testbed__type > :where(h1, h2, h3, h4, h5, h6, p),
|
|
146
|
+
.density-testbed__prose > :where(h1, h2, h3, h4, h5, h6, p) {
|
|
147
|
+
margin: 0;
|
|
148
|
+
}
|
|
146
149
|
|
|
147
|
-
/* ── Density inline lever (retained) ── */
|
|
148
|
-
.density-comfortable {
|
|
149
|
-
|
|
150
|
-
}
|
|
151
|
-
.density-dense {
|
|
152
|
-
|
|
150
|
+
/* ── Density inline lever (retained) ── */
|
|
151
|
+
.density-comfortable {
|
|
152
|
+
--density-padding-inline: 0.75rem;
|
|
153
|
+
}
|
|
154
|
+
.density-dense {
|
|
155
|
+
--density-padding-inline: 0.5rem;
|
|
156
|
+
}
|
|
153
157
|
}
|
|
@@ -1,64 +1,83 @@
|
|
|
1
|
-
/*
|
|
2
|
-
* the input sits inline with its label, then the description and any error. */
|
|
3
|
-
.ds.field.field-toggle {
|
|
4
|
-
display: flex;
|
|
5
|
-
flex-direction: column;
|
|
6
|
-
row-gap: var(--form-group-gap);
|
|
7
|
-
|
|
8
|
-
/* The heading is a mock label (a <legend>): reset the fieldset default so it
|
|
9
|
-
flows like the other block children. */
|
|
10
|
-
& > .field-toggle-heading {
|
|
11
|
-
padding: 0;
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
/* Control row: the control centres on the label's FIRST line, and a multi-line
|
|
15
|
-
(sentence) label wraps below — never centring the box on the whole paragraph
|
|
16
|
-
(AV-325). `align-items: start` tops the row so wrapped lines flow under the
|
|
17
|
-
first; the control is then nudged down half a line-box to sit centred on the
|
|
18
|
-
first line (see the control rule below). The first-line box is one density
|
|
19
|
-
line-height (`--density-line-height-effective`, set on the density scope;
|
|
20
|
-
falls back to `1lh` outside a density context). */
|
|
21
|
-
& > .field-toggle-control {
|
|
22
|
-
--toggle-control-line: var(--density-line-height-effective, 1lh);
|
|
1
|
+
/* Layer: ds.components.global (@canonical/styles README, "Cascade layers"). */
|
|
23
2
|
|
|
3
|
+
@layer ds.components.global {
|
|
4
|
+
/* Toggle field layout, top to bottom: an optional heading, a control row where
|
|
5
|
+
* the input sits inline with its label, then the description and any error. */
|
|
6
|
+
.ds.field.field-toggle {
|
|
24
7
|
display: flex;
|
|
25
|
-
flex-direction:
|
|
26
|
-
|
|
27
|
-
column-gap: var(--form-field-inline-gap);
|
|
8
|
+
flex-direction: column;
|
|
9
|
+
row-gap: var(--form-group-gap);
|
|
28
10
|
|
|
29
|
-
/*
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
keeps its intrinsic size — only its vertical offset changes, so the click
|
|
34
|
-
target is untouched. */
|
|
35
|
-
& > :not(.ds.field-label) {
|
|
36
|
-
--toggle-control-size: var(--dimension-200);
|
|
37
|
-
align-self: start;
|
|
38
|
-
margin-block-start: max(
|
|
39
|
-
0px,
|
|
40
|
-
calc((var(--toggle-control-line) - var(--toggle-control-size)) / 2)
|
|
41
|
-
);
|
|
11
|
+
/* The heading is a mock label (a <legend>): reset the fieldset default so it
|
|
12
|
+
flows like the other block children. */
|
|
13
|
+
& > .field-toggle-heading {
|
|
14
|
+
padding: 0;
|
|
42
15
|
}
|
|
43
16
|
|
|
44
|
-
/*
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
17
|
+
/* Control row: `align-items: center` centres the control on the row, and a
|
|
18
|
+
multi-line (sentence) label wraps below it (AV-325). Spacing belongs to
|
|
19
|
+
the FIELD, not the label or control: the row's column-gap separates
|
|
20
|
+
control and label, the field's row-gap separates the row from the
|
|
21
|
+
description/error, and neither label nor control carries any padding or
|
|
22
|
+
margin — so spacing changes never shift the control off-centre. */
|
|
23
|
+
& > .field-toggle-control {
|
|
24
|
+
--toggle-control-line: var(--density-line-height-effective, 1lh);
|
|
25
|
+
|
|
26
|
+
display: flex;
|
|
27
|
+
flex-direction: row;
|
|
28
|
+
align-items: center;
|
|
29
|
+
column-gap: var(--form-field-inline-gap);
|
|
30
|
+
|
|
31
|
+
/* Every direct child that ISN'T the label is the control (checkbox / switch
|
|
32
|
+
input): a fixed 16px-tall box (--dimension-200 — checkbox 16×16, switch
|
|
33
|
+
track 16 high). The row's `align-items: center` does the centring; the
|
|
34
|
+
control itself carries no offset, margin or padding, so its intrinsic
|
|
35
|
+
size and click target are unchanged. */
|
|
36
|
+
& > :not(.ds.field-label) {
|
|
37
|
+
--toggle-control-size: var(--dimension-200);
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
/* The control label is often a full clickable sentence, so it reads as
|
|
41
|
+
regular body prose (not the bold heading weight the field label uses by
|
|
42
|
+
default): normal weight, left-aligned, pointer cursor, and it takes the
|
|
43
|
+
remaining width so it wraps beside the control instead of pushing it.
|
|
44
|
+
`padding: 0` keeps the label flush with the control — spacing between
|
|
45
|
+
blocks is the field's row-gap, never label geometry. */
|
|
46
|
+
& > .ds.field-label {
|
|
47
|
+
flex: 1;
|
|
48
|
+
min-width: 0;
|
|
49
|
+
font-weight: var(--typography-text-primary-font-weight);
|
|
50
|
+
text-align: start;
|
|
51
|
+
cursor: pointer;
|
|
52
|
+
padding: 0;
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
/* Label BEFORE the control (switch convention): the DOM stays
|
|
56
|
+
control-then-label for accessibility, so `row-reverse` moves the control
|
|
57
|
+
to the trailing (right) edge and the label to the leading (left) edge.
|
|
58
|
+
Logical `row-reverse` mirrors correctly in RTL. */
|
|
59
|
+
&.label-before {
|
|
60
|
+
flex-direction: row-reverse;
|
|
61
|
+
}
|
|
54
62
|
}
|
|
55
63
|
|
|
56
|
-
/*
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
64
|
+
/* Disabled control: the row stops signalling clickable and the control
|
|
65
|
+
label takes the disabled text token (color.text.disabled) — color, not
|
|
66
|
+
an opacity dim of the whole row. State-driven via :has so no disabled
|
|
67
|
+
plumbing is needed on the wrapper (same idiom as the choices Option's
|
|
68
|
+
`.disabled` and RatingInput). */
|
|
69
|
+
&:has(> .field-toggle-control input:disabled) {
|
|
70
|
+
cursor: not-allowed;
|
|
71
|
+
|
|
72
|
+
& > .field-toggle-control > .ds.field-label {
|
|
73
|
+
color: var(--form-label-color-disabled, var(--color-text-disabled));
|
|
74
|
+
&[data-required]::after {
|
|
75
|
+
color: var(
|
|
76
|
+
--form-required-marker-color-disabled,
|
|
77
|
+
var(--form-label-color-disabled, var(--color-text-disabled))
|
|
78
|
+
);
|
|
79
|
+
}
|
|
80
|
+
}
|
|
62
81
|
}
|
|
63
82
|
}
|
|
64
83
|
}
|
|
@@ -1,37 +1,41 @@
|
|
|
1
|
-
|
|
2
|
-
display: grid;
|
|
3
|
-
grid-template-columns: subgrid;
|
|
4
|
-
grid-column: var(--form-field-columns, 1 / -1);
|
|
5
|
-
/* Vertical gap from the label row down to the payload row. Uses the block-axis
|
|
6
|
-
label-gap token — NOT --form-field-inline-gap (that is horizontal-only now).
|
|
7
|
-
Default is the label→control gap (--form-field-label-gap, 8px); when a
|
|
8
|
-
description LEADS the payload the row below tightens it to the label→
|
|
9
|
-
description gap (--form-field-label-description-gap, 4px), per the 15/07
|
|
10
|
-
review's field-spacing spec. */
|
|
11
|
-
row-gap: var(--form-field-label-gap);
|
|
12
|
-
align-items: baseline;
|
|
1
|
+
/* Layer: ds.components.global (@canonical/styles README, "Cascade layers"). */
|
|
13
2
|
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
row-gap: var(
|
|
17
|
-
--form-field-label-description-gap,
|
|
18
|
-
var(--form-field-label-gap)
|
|
19
|
-
);
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
& > .ds.field-label {
|
|
23
|
-
grid-column: var(--form-label-columns, 1 / -1);
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
& > .payload {
|
|
27
|
-
grid-column: var(--form-payload-columns, 1 / -1);
|
|
3
|
+
@layer ds.components.global {
|
|
4
|
+
.ds.field {
|
|
28
5
|
display: grid;
|
|
29
6
|
grid-template-columns: subgrid;
|
|
30
|
-
|
|
31
|
-
|
|
7
|
+
grid-column: var(--form-field-columns, 1 / -1);
|
|
8
|
+
/* Vertical gap from the label row down to the payload row. Uses the block-axis
|
|
9
|
+
label-gap token — NOT --form-field-inline-gap (that is horizontal-only now).
|
|
10
|
+
Default is the label→control gap (--form-field-label-gap, 8px); when a
|
|
11
|
+
description LEADS the payload the row below tightens it to the label→
|
|
12
|
+
description gap (--form-field-label-description-gap, 4px), per the 15/07
|
|
13
|
+
review's field-spacing spec. */
|
|
14
|
+
row-gap: var(--form-field-label-gap);
|
|
15
|
+
align-items: baseline;
|
|
16
|
+
|
|
17
|
+
/* Label sits closer to a leading description than to a bare control. */
|
|
18
|
+
&:has(> .payload > .ds.field-description:first-child) {
|
|
19
|
+
row-gap: var(
|
|
20
|
+
--form-field-label-description-gap,
|
|
21
|
+
var(--form-field-label-gap)
|
|
22
|
+
);
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
& > .ds.field-label {
|
|
26
|
+
grid-column: var(--form-label-columns, 1 / -1);
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
& > .payload {
|
|
30
|
+
grid-column: var(--form-payload-columns, 1 / -1);
|
|
31
|
+
display: grid;
|
|
32
|
+
grid-template-columns: subgrid;
|
|
33
|
+
row-gap: var(--form-group-gap);
|
|
34
|
+
}
|
|
32
35
|
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
+
/* Inputs that don't need columns span the full payload width */
|
|
37
|
+
& > .payload > * {
|
|
38
|
+
grid-column: 1 / -1;
|
|
39
|
+
}
|
|
36
40
|
}
|
|
37
41
|
}
|