@canonical/react-ds-global-form 0.37.0 → 0.38.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
|
@@ -9,151 +9,155 @@
|
|
|
9
9
|
* `starred` glyph is layered over it (`.star::after`) and its width is clipped
|
|
10
10
|
* to 0%, 50% or 100% to show empty, half or full — so half-fill is one masked
|
|
11
11
|
* shape rather than a separate half-width star.
|
|
12
|
+
*
|
|
13
|
+
* Layer: ds.components.global (@canonical/styles README, "Cascade layers").
|
|
12
14
|
*/
|
|
13
15
|
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
--rating-color-empty: var(--color-text-muted, #b0b0b0);
|
|
19
|
-
--rating-color-filled: var(--color-foreground-primary-warning, #f5a623);
|
|
20
|
-
--rating-size: var(--rating-size-default, 1.5rem);
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
.ds.form-rating > .star {
|
|
24
|
-
position: relative;
|
|
25
|
-
display: inline-block;
|
|
26
|
-
width: var(--rating-size);
|
|
27
|
-
height: var(--rating-size);
|
|
28
|
-
cursor: pointer;
|
|
29
|
-
}
|
|
16
|
+
@layer ds.components.global {
|
|
17
|
+
.ds.form-rating {
|
|
18
|
+
display: inline-flex;
|
|
19
|
+
gap: var(--dimension-025, 0.125rem);
|
|
30
20
|
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
height: 100%;
|
|
36
|
-
background-color: var(--rating-color-empty);
|
|
37
|
-
mask: url("/icons/starred-off.svg#starred-off") no-repeat center / contain;
|
|
38
|
-
-webkit-mask:
|
|
39
|
-
url("/icons/starred-off.svg#starred-off") no-repeat center / contain;
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
/* Solid star (fill overlay), clipped to a fill amount that defaults to 0. */
|
|
43
|
-
.ds.form-rating > .star::after {
|
|
44
|
-
content: "";
|
|
45
|
-
position: absolute;
|
|
46
|
-
inset: 0;
|
|
47
|
-
width: var(--star-fill, 0%);
|
|
48
|
-
overflow: hidden;
|
|
49
|
-
background-color: var(--rating-color-filled);
|
|
50
|
-
mask: url("/icons/starred.svg#starred") no-repeat left center / auto 100%;
|
|
51
|
-
-webkit-mask:
|
|
52
|
-
url("/icons/starred.svg#starred") no-repeat left center / auto 100%;
|
|
53
|
-
/* The mask must stay the full star width so clipping the box reveals a left
|
|
54
|
-
slice of the star, not a squashed star. */
|
|
55
|
-
mask-size: var(--rating-size) 100%;
|
|
56
|
-
-webkit-mask-size: var(--rating-size) 100%;
|
|
57
|
-
pointer-events: none;
|
|
58
|
-
}
|
|
21
|
+
--rating-color-empty: var(--color-text-muted, #b0b0b0);
|
|
22
|
+
--rating-color-filled: var(--color-foreground-primary-warning, #f5a623);
|
|
23
|
+
--rating-size: var(--rating-size-default, 1.5rem);
|
|
24
|
+
}
|
|
59
25
|
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
border: 0;
|
|
68
|
-
clip-path: inset(50%);
|
|
69
|
-
overflow: hidden;
|
|
70
|
-
white-space: nowrap;
|
|
71
|
-
}
|
|
26
|
+
.ds.form-rating > .star {
|
|
27
|
+
position: relative;
|
|
28
|
+
display: inline-block;
|
|
29
|
+
width: var(--rating-size);
|
|
30
|
+
height: var(--rating-size);
|
|
31
|
+
cursor: pointer;
|
|
32
|
+
}
|
|
72
33
|
|
|
73
|
-
/*
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
}
|
|
83
|
-
.ds.form-rating.half > .star > .star-target.right {
|
|
84
|
-
left: 50%;
|
|
85
|
-
}
|
|
34
|
+
/* Outline star (empty base). */
|
|
35
|
+
.ds.form-rating > .star > .star-glyph {
|
|
36
|
+
display: block;
|
|
37
|
+
width: 100%;
|
|
38
|
+
height: 100%;
|
|
39
|
+
background-color: var(--rating-color-empty);
|
|
40
|
+
mask: url("/icons/starred-off.svg#starred-off") no-repeat center / contain;
|
|
41
|
+
-webkit-mask:
|
|
42
|
+
url("/icons/starred-off.svg#starred-off") no-repeat center / contain;
|
|
43
|
+
}
|
|
86
44
|
|
|
87
|
-
/*
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
45
|
+
/* Solid star (fill overlay), clipped to a fill amount that defaults to 0. */
|
|
46
|
+
.ds.form-rating > .star::after {
|
|
47
|
+
content: "";
|
|
48
|
+
position: absolute;
|
|
49
|
+
inset: 0;
|
|
50
|
+
width: var(--star-fill, 0%);
|
|
51
|
+
overflow: hidden;
|
|
52
|
+
background-color: var(--rating-color-filled);
|
|
53
|
+
mask: url("/icons/starred.svg#starred") no-repeat left center / auto 100%;
|
|
54
|
+
-webkit-mask:
|
|
55
|
+
url("/icons/starred.svg#starred") no-repeat left center / auto 100%;
|
|
56
|
+
/* The mask must stay the full star width so clipping the box reveals a left
|
|
57
|
+
slice of the star, not a squashed star. */
|
|
58
|
+
mask-size: var(--rating-size) 100%;
|
|
59
|
+
-webkit-mask-size: var(--rating-size) 100%;
|
|
60
|
+
pointer-events: none;
|
|
61
|
+
}
|
|
91
62
|
|
|
92
|
-
/*
|
|
93
|
-
.ds.form-rating
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
63
|
+
/* Radios are visually hidden but keep a11y semantics and keyboard focus. */
|
|
64
|
+
.ds.form-rating .star-input {
|
|
65
|
+
position: absolute;
|
|
66
|
+
width: 1px;
|
|
67
|
+
height: 1px;
|
|
68
|
+
margin: -1px;
|
|
69
|
+
padding: 0;
|
|
70
|
+
border: 0;
|
|
71
|
+
clip-path: inset(50%);
|
|
72
|
+
overflow: hidden;
|
|
73
|
+
white-space: nowrap;
|
|
74
|
+
}
|
|
100
75
|
|
|
101
|
-
/*
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
76
|
+
/* Click targets. Full mode: one target covering the star. Half mode: a left
|
|
77
|
+
half and a right half, each an absolutely-positioned 50%-wide hit area. */
|
|
78
|
+
.ds.form-rating > .star > .star-target {
|
|
79
|
+
position: absolute;
|
|
80
|
+
inset: 0;
|
|
81
|
+
z-index: 1;
|
|
82
|
+
}
|
|
83
|
+
.ds.form-rating.half > .star > .star-target.left {
|
|
84
|
+
right: 50%;
|
|
85
|
+
}
|
|
86
|
+
.ds.form-rating.half > .star > .star-target.right {
|
|
87
|
+
left: 50%;
|
|
88
|
+
}
|
|
105
89
|
|
|
106
|
-
/*
|
|
107
|
-
|
|
108
|
-
.
|
|
109
|
-
|
|
110
|
-
:has(~ .star .star-input:checked)
|
|
111
|
-
) {
|
|
112
|
-
--star-fill: 50%;
|
|
113
|
-
}
|
|
90
|
+
/* --- Fill amount -------------------------------------------------------------
|
|
91
|
+
A star is FULL when its full radio is checked, or when any later star has a
|
|
92
|
+
radio checked. It is HALF when its half radio is checked (and no later star
|
|
93
|
+
is). CSS custom property `--star-fill` drives the ::after width. */
|
|
114
94
|
|
|
115
|
-
/*
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
95
|
+
/* Full: this star's whole-number radio is checked. */
|
|
96
|
+
.ds.form-rating
|
|
97
|
+
> .star:has(
|
|
98
|
+
> .star-input[data-rating$="0"]:checked,
|
|
99
|
+
> .star-input:not([data-rating*="."]):checked
|
|
100
|
+
) {
|
|
101
|
+
--star-fill: 100%;
|
|
119
102
|
}
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
.ds.form-rating > .star:has(~ .star:
|
|
103
|
+
|
|
104
|
+
/* Full: any later star has a checked radio → this star is fully filled. */
|
|
105
|
+
.ds.form-rating > .star:has(~ .star .star-input:checked) {
|
|
123
106
|
--star-fill: 100%;
|
|
124
107
|
}
|
|
125
|
-
|
|
126
|
-
|
|
108
|
+
|
|
109
|
+
/* Half: this star's half radio (a `.5` value) is checked. Comes after the full
|
|
110
|
+
rules so, when both apply to different stars, each resolves independently. */
|
|
111
|
+
.ds.form-rating.half
|
|
112
|
+
> .star:has(> .star-input[data-rating$=".5"]:checked):not(
|
|
113
|
+
:has(~ .star .star-input:checked)
|
|
114
|
+
) {
|
|
127
115
|
--star-fill: 50%;
|
|
128
116
|
}
|
|
129
|
-
|
|
130
|
-
|
|
117
|
+
|
|
118
|
+
/* Hover preview overrides the checked fill until the pointer leaves. */
|
|
119
|
+
@media (hover: hover) {
|
|
120
|
+
.ds.form-rating:hover > .star {
|
|
121
|
+
--star-fill: 0%;
|
|
122
|
+
}
|
|
123
|
+
/* Hovering a right (or full) target fills that star and every earlier one. */
|
|
124
|
+
.ds.form-rating > .star:hover,
|
|
125
|
+
.ds.form-rating > .star:has(~ .star:hover) {
|
|
126
|
+
--star-fill: 100%;
|
|
127
|
+
}
|
|
128
|
+
/* Hovering a left half-target fills earlier stars fully and this one to 50%. */
|
|
129
|
+
.ds.form-rating.half > .star:has(> .star-target.left:hover) {
|
|
130
|
+
--star-fill: 50%;
|
|
131
|
+
}
|
|
132
|
+
.ds.form-rating.half > .star:has(~ .star > .star-target.left:hover) {
|
|
133
|
+
--star-fill: 100%;
|
|
134
|
+
}
|
|
131
135
|
}
|
|
132
|
-
}
|
|
133
136
|
|
|
134
|
-
/* Keyboard focus ring on the star whose radio is focused. */
|
|
135
|
-
.ds.form-rating > .star:has(> .star-input:focus-visible) {
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
}
|
|
137
|
+
/* Keyboard focus ring on the star whose radio is focused. */
|
|
138
|
+
.ds.form-rating > .star:has(> .star-input:focus-visible) {
|
|
139
|
+
outline: var(--focus-outline-width, 2px) solid
|
|
140
|
+
var(--color-focus-ring, currentColor);
|
|
141
|
+
outline-offset: 2px;
|
|
142
|
+
border-radius: var(--dimension-radius-small, 2px);
|
|
143
|
+
}
|
|
141
144
|
|
|
142
|
-
/* Disabled. */
|
|
143
|
-
.ds.form-rating:has(.star-input:disabled) > .star {
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
}
|
|
145
|
+
/* Disabled. */
|
|
146
|
+
.ds.form-rating:has(.star-input:disabled) > .star {
|
|
147
|
+
cursor: not-allowed;
|
|
148
|
+
opacity: 0.5;
|
|
149
|
+
}
|
|
147
150
|
|
|
148
|
-
/* Local visually-hidden helper for the per-target text label. */
|
|
149
|
-
.ds.form-rating .ds-visually-hidden {
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
151
|
+
/* Local visually-hidden helper for the per-target text label. */
|
|
152
|
+
.ds.form-rating .ds-visually-hidden {
|
|
153
|
+
position: absolute;
|
|
154
|
+
width: 1px;
|
|
155
|
+
height: 1px;
|
|
156
|
+
margin: -1px;
|
|
157
|
+
padding: 0;
|
|
158
|
+
border: 0;
|
|
159
|
+
clip-path: inset(50%);
|
|
160
|
+
overflow: hidden;
|
|
161
|
+
white-space: nowrap;
|
|
162
|
+
}
|
|
159
163
|
}
|
|
@@ -1,41 +1,45 @@
|
|
|
1
|
-
/*
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
1
|
+
/* Layer: ds.components.global (@canonical/styles README, "Cascade layers"). */
|
|
2
|
+
|
|
3
|
+
@layer ds.components.global {
|
|
4
|
+
/* Chevron indicator, painted with CSS gradients so it takes the theme colour.
|
|
5
|
+
* A `background-image` SVG cannot be recoloured by CSS (no inheritance into
|
|
6
|
+
* the image document), which left the caret black on dark themes — the same
|
|
7
|
+
* reason the checkbox/accordion glyphs are masks. A <select> is a replaced
|
|
8
|
+
* element with no ::before/::after to mask, so the chevron is drawn instead:
|
|
9
|
+
* two diagonally-striped gradient squares butted together form a down-chevron
|
|
10
|
+
* STROKE (transparent → colour → transparent along each diagonal), coloured by
|
|
11
|
+
* --color-icon like every other control glyph. */
|
|
12
|
+
.ds.input.select {
|
|
13
|
+
appearance: none;
|
|
14
|
+
--select-caret-color: var(--color-icon, currentColor);
|
|
15
|
+
--select-caret-half: 0.4em; /* each square; the chevron is two halves wide */
|
|
16
|
+
/* left half: rising stroke ╱ */
|
|
17
|
+
background-image:
|
|
18
|
+
linear-gradient(
|
|
19
|
+
45deg,
|
|
20
|
+
transparent 42%,
|
|
21
|
+
var(--select-caret-color) 42%,
|
|
22
|
+
var(--select-caret-color) 58%,
|
|
23
|
+
transparent 58%
|
|
24
|
+
),
|
|
25
|
+
/* right half: falling stroke ╲ */
|
|
26
|
+
linear-gradient(
|
|
27
|
+
135deg,
|
|
28
|
+
transparent 42%,
|
|
29
|
+
var(--select-caret-color) 42%,
|
|
30
|
+
var(--select-caret-color) 58%,
|
|
31
|
+
transparent 58%
|
|
32
|
+
);
|
|
33
|
+
background-repeat: no-repeat;
|
|
34
|
+
background-position:
|
|
35
|
+
right calc(var(--form-input-padding-inline) + var(--select-caret-half))
|
|
36
|
+
center,
|
|
37
|
+
right var(--form-input-padding-inline) center;
|
|
38
|
+
background-size: var(--select-caret-half) var(--select-caret-half);
|
|
39
|
+
/* This element IS the text-bearing leaf, so it carries the inline padding
|
|
40
|
+
* (`.ds.input.chrome` provides only the block padding). The end side leaves
|
|
41
|
+
* room for the chevron. */
|
|
42
|
+
padding-inline-start: var(--form-input-padding-inline);
|
|
43
|
+
padding-inline-end: calc(var(--form-input-padding-inline) * 2 + 1em);
|
|
44
|
+
}
|
|
41
45
|
}
|
|
@@ -1,105 +1,109 @@
|
|
|
1
|
-
/*
|
|
2
|
-
* The track is the <input> box; the knob is a `::before` pseudo-element that
|
|
3
|
-
* slides from left (off) to right (on). Colours come from the switch token
|
|
4
|
-
* channel; the geometry is in baseline multiples. */
|
|
5
|
-
.ds.form-switch {
|
|
6
|
-
/* Geometry, all derived from the track size and a 1px inset. Fixed element sizes
|
|
7
|
-
(32×16px), NOT baseline multiples — the 4px-baseline spike halved the old
|
|
8
|
-
`--space-baseline × 4 / × 2`. Stable dimension tokens decouple the switch size
|
|
9
|
-
from the baseline grid unit. */
|
|
10
|
-
--switch-track-width: var(--dimension-400); /* 32px */
|
|
11
|
-
--switch-track-height: var(--dimension-200); /* 16px */
|
|
12
|
-
--switch-knob-inset: 1px;
|
|
13
|
-
--switch-knob-size: calc(
|
|
14
|
-
var(--switch-track-height) -
|
|
15
|
-
(var(--switch-knob-inset) * 2)
|
|
16
|
-
);
|
|
1
|
+
/* Layer: ds.components.global (@canonical/styles README, "Cascade layers"). */
|
|
17
2
|
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
3
|
+
@layer ds.components.global {
|
|
4
|
+
/* A switch is a checkbox (role="switch") styled as a sliding pill toggle.
|
|
5
|
+
* The track is the <input> box; the knob is a `::before` pseudo-element that
|
|
6
|
+
* slides from left (off) to right (on). Colours come from the switch token
|
|
7
|
+
* channel; the geometry is in baseline multiples. */
|
|
8
|
+
.ds.form-switch {
|
|
9
|
+
/* Geometry, all derived from the track size and a 1px inset. Fixed element sizes
|
|
10
|
+
(32×16px), NOT baseline multiples — the 4px-baseline spike halved the old
|
|
11
|
+
`--space-baseline × 4 / × 2`. Stable dimension tokens decouple the switch size
|
|
12
|
+
from the baseline grid unit. */
|
|
13
|
+
--switch-track-width: var(--dimension-400); /* 32px */
|
|
14
|
+
--switch-track-height: var(--dimension-200); /* 16px */
|
|
15
|
+
--switch-knob-inset: 1px;
|
|
16
|
+
--switch-knob-size: calc(
|
|
17
|
+
var(--switch-track-height) -
|
|
18
|
+
(var(--switch-knob-inset) * 2)
|
|
19
|
+
);
|
|
21
20
|
|
|
22
|
-
|
|
23
|
-
|
|
21
|
+
appearance: none;
|
|
22
|
+
box-sizing: border-box;
|
|
23
|
+
position: relative;
|
|
24
24
|
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
border under `box-sizing: border-box` would shrink the padding box the knob
|
|
28
|
-
is anchored to, throwing off the inset and slide). */
|
|
29
|
-
width: var(--switch-track-width);
|
|
30
|
-
height: var(--switch-track-height);
|
|
31
|
-
border-radius: var(--dimension-radius-full);
|
|
32
|
-
background: var(
|
|
33
|
-
--surface-color-foreground-switch-unselected,
|
|
34
|
-
var(--color-foreground-switch-unselected)
|
|
35
|
-
);
|
|
36
|
-
cursor: pointer;
|
|
37
|
-
transition: background-color 150ms ease;
|
|
25
|
+
/* Align to the field edge like the label, not the input's inner padding. */
|
|
26
|
+
margin-inline: var(--form-label-padding-inline, 0);
|
|
38
27
|
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
width: var(--switch-knob-size);
|
|
46
|
-
height: var(--switch-knob-size);
|
|
28
|
+
/* Track: a 2:1 pill. No border, so the width/height are the exact track box
|
|
29
|
+
and the absolutely-positioned knob is measured against the same box (a
|
|
30
|
+
border under `box-sizing: border-box` would shrink the padding box the knob
|
|
31
|
+
is anchored to, throwing off the inset and slide). */
|
|
32
|
+
width: var(--switch-track-width);
|
|
33
|
+
height: var(--switch-track-height);
|
|
47
34
|
border-radius: var(--dimension-radius-full);
|
|
48
|
-
/* Knob reads its surface-provided token (flat fallback) for OnSurface. */
|
|
49
|
-
background: var(
|
|
50
|
-
--surface-color-foreground-switch-knob,
|
|
51
|
-
var(--color-foreground-switch-knob)
|
|
52
|
-
);
|
|
53
|
-
transition: translate 150ms ease;
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
&:checked {
|
|
57
|
-
/* Selected track reads the surface-provided token (flat fallback). */
|
|
58
35
|
background: var(
|
|
59
|
-
--surface-color-foreground-switch-
|
|
60
|
-
var(--color-foreground-switch-
|
|
36
|
+
--surface-color-foreground-switch-unselected,
|
|
37
|
+
var(--color-foreground-switch-unselected)
|
|
61
38
|
);
|
|
39
|
+
cursor: pointer;
|
|
40
|
+
transition: background-color var(--motion-duration-fast) ease;
|
|
62
41
|
|
|
42
|
+
/* Knob: a circle inset from the track edges, sliding on the inline axis. */
|
|
63
43
|
&::before {
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
44
|
+
content: "";
|
|
45
|
+
position: absolute;
|
|
46
|
+
inset-block: var(--switch-knob-inset);
|
|
47
|
+
inset-inline-start: var(--switch-knob-inset);
|
|
48
|
+
width: var(--switch-knob-size);
|
|
49
|
+
height: var(--switch-knob-size);
|
|
50
|
+
border-radius: var(--dimension-radius-full);
|
|
51
|
+
/* Knob reads its surface-provided token (flat fallback) for OnSurface. */
|
|
52
|
+
background: var(
|
|
53
|
+
--surface-color-foreground-switch-knob,
|
|
54
|
+
var(--color-foreground-switch-knob)
|
|
55
|
+
);
|
|
56
|
+
transition: translate var(--motion-duration-fast) ease;
|
|
72
57
|
}
|
|
73
|
-
}
|
|
74
58
|
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
background: var(--hover--color-foreground-switch-unselected);
|
|
82
|
-
}
|
|
59
|
+
&:checked {
|
|
60
|
+
/* Selected track reads the surface-provided token (flat fallback). */
|
|
61
|
+
background: var(
|
|
62
|
+
--surface-color-foreground-switch-selected,
|
|
63
|
+
var(--color-foreground-switch-selected)
|
|
64
|
+
);
|
|
83
65
|
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
66
|
+
&::before {
|
|
67
|
+
/* Slide to the far edge: the space left over after the knob and both
|
|
68
|
+
insets are removed from the track width. */
|
|
69
|
+
translate: calc(
|
|
70
|
+
var(--switch-track-width) -
|
|
71
|
+
var(--switch-knob-size) -
|
|
72
|
+
(var(--switch-knob-inset) * 2)
|
|
73
|
+
)
|
|
74
|
+
0;
|
|
75
|
+
}
|
|
76
|
+
}
|
|
87
77
|
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
78
|
+
/* Hover shifts ONLY the track background, not the knob (per design review):
|
|
79
|
+
* the track swaps to the hovered shade while the `::before` knob keeps its
|
|
80
|
+
* colour. Shades come from the `--hover--…` channels (criticality-style OKLCH
|
|
81
|
+
* delta shim), replacing the old whole-element `filter: brightness()` that
|
|
82
|
+
* also dimmed the knob. */
|
|
83
|
+
&:hover:not(:disabled):not(:checked) {
|
|
84
|
+
background: var(--hover--color-foreground-switch-unselected);
|
|
85
|
+
}
|
|
92
86
|
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
87
|
+
&:checked:hover:not(:disabled) {
|
|
88
|
+
background: var(--hover--color-foreground-switch-selected);
|
|
89
|
+
}
|
|
96
90
|
|
|
97
|
-
|
|
98
|
-
|
|
91
|
+
&:focus-visible {
|
|
92
|
+
outline: none;
|
|
93
|
+
box-shadow: 0 0 0 1px var(--color-focus-ring);
|
|
99
94
|
}
|
|
100
|
-
}
|
|
101
95
|
|
|
102
|
-
|
|
103
|
-
|
|
96
|
+
&:disabled {
|
|
97
|
+
cursor: not-allowed;
|
|
98
|
+
background: var(--color-foreground-switch-unselected-disabled);
|
|
99
|
+
|
|
100
|
+
&::before {
|
|
101
|
+
background: var(--color-foreground-switch-knob-disabled);
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
&:checked:disabled {
|
|
106
|
+
background: var(--color-foreground-switch-selected-disabled);
|
|
107
|
+
}
|
|
104
108
|
}
|
|
105
109
|
}
|
|
@@ -1,30 +1,34 @@
|
|
|
1
|
-
|
|
2
|
-
direction: inherit;
|
|
3
|
-
display: flex;
|
|
4
|
-
align-items: stretch;
|
|
5
|
-
position: relative;
|
|
6
|
-
padding: 0;
|
|
1
|
+
/* Layer: ds.components.global (@canonical/styles README, "Cascade layers"). */
|
|
7
2
|
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
border: none;
|
|
12
|
-
background: transparent;
|
|
13
|
-
color: inherit;
|
|
14
|
-
font-family: inherit;
|
|
15
|
-
outline: none;
|
|
16
|
-
/* Baseline engine provides font-size, line-height, padding-top,
|
|
17
|
-
padding-bottom via the .p class */
|
|
18
|
-
padding-inline: var(--form-input-padding-inline);
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
& > .prefix,
|
|
22
|
-
& > .suffix {
|
|
3
|
+
@layer ds.components.global {
|
|
4
|
+
.ds.input.text {
|
|
5
|
+
direction: inherit;
|
|
23
6
|
display: flex;
|
|
24
|
-
align-items:
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
7
|
+
align-items: stretch;
|
|
8
|
+
position: relative;
|
|
9
|
+
padding: 0;
|
|
10
|
+
|
|
11
|
+
& > input {
|
|
12
|
+
flex: 1;
|
|
13
|
+
min-width: 0;
|
|
14
|
+
border: none;
|
|
15
|
+
background: transparent;
|
|
16
|
+
color: inherit;
|
|
17
|
+
font-family: inherit;
|
|
18
|
+
outline: none;
|
|
19
|
+
/* Baseline engine provides font-size, line-height, padding-top,
|
|
20
|
+
padding-bottom via the .p class */
|
|
21
|
+
padding-inline: var(--form-input-padding-inline);
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
& > .prefix,
|
|
25
|
+
& > .suffix {
|
|
26
|
+
display: flex;
|
|
27
|
+
align-items: center;
|
|
28
|
+
padding-inline: var(--form-field-inline-gap);
|
|
29
|
+
color: var(--color-text-muted);
|
|
30
|
+
white-space: nowrap;
|
|
31
|
+
user-select: none;
|
|
32
|
+
}
|
|
29
33
|
}
|
|
30
34
|
}
|
|
@@ -1,12 +1,16 @@
|
|
|
1
|
-
|
|
2
|
-
/* This element IS the text-bearing leaf, so it carries the inline padding
|
|
3
|
-
* (`.ds.input.chrome` provides only the block padding). */
|
|
4
|
-
padding-inline: var(--form-input-padding-inline);
|
|
1
|
+
/* Layer: ds.components.global (@canonical/styles README, "Cascade layers"). */
|
|
5
2
|
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
3
|
+
@layer ds.components.global {
|
|
4
|
+
.ds.input.textarea {
|
|
5
|
+
/* This element IS the text-bearing leaf, so it carries the inline padding
|
|
6
|
+
* (`.ds.input.chrome` provides only the block padding). */
|
|
7
|
+
padding-inline: var(--form-input-padding-inline);
|
|
8
|
+
|
|
9
|
+
/* Block placement is supplied by density.css (baseline-grid seating of the
|
|
10
|
+
first line + grid-multiple line-height). The chrome contributes only its
|
|
11
|
+
block padding as the box's own inset; the baseline nudge lives in density. */
|
|
12
|
+
padding-block: var(--form-input-padding-block);
|
|
13
|
+
min-height: calc(5lh + var(--form-input-padding-block) * 2);
|
|
14
|
+
resize: vertical;
|
|
15
|
+
}
|
|
12
16
|
}
|