@canonical/styles 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 +357 -24
- package/package.json +23 -12
- package/src/controls.hover.shim.css +19 -9
- package/src/elements.css +80 -0
- package/src/fonts.css +49 -22
- package/src/grid.css +37 -1
- package/src/index.css +80 -5
- package/src/layers.css +45 -0
- package/src/layout.css +67 -0
- package/src/modifiers.criticality.shim.css +4 -3
- package/src/modifiers.density.css +159 -151
- package/src/modifiers.importance.shim.css +6 -0
- package/src/modifiers.states.shim.css +7 -0
- package/src/motion.css +42 -9
- package/src/normalize.css +221 -0
- package/src/overflow.css +19 -11
- package/src/reset.css +186 -0
- package/src/spacing.css +87 -89
- package/src/tokens.css +124 -0
package/src/overflow.css
CHANGED
|
@@ -13,19 +13,27 @@
|
|
|
13
13
|
*
|
|
14
14
|
* TODO: promote `--overflow-gradient-height` to a real semantic token in
|
|
15
15
|
* @canonical/design-tokens (currently hard-coded here, like the spacing scale).
|
|
16
|
+
*
|
|
17
|
+
* Layers: the root default is `ds.tokens`; the `.surface` rule joins the
|
|
18
|
+
* generated surface family in `ds.surfaces`, whose selectors it mirrors. Both
|
|
19
|
+
* declare custom properties only, which act where a rule reads them.
|
|
16
20
|
*/
|
|
17
21
|
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
22
|
+
@layer ds.tokens {
|
|
23
|
+
:root {
|
|
24
|
+
/* Height of the overflow fade. Defaults to 2rem. */
|
|
25
|
+
--overflow-gradient-height: 2rem;
|
|
26
|
+
}
|
|
21
27
|
}
|
|
22
28
|
|
|
23
|
-
.
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
29
|
+
@layer ds.surfaces {
|
|
30
|
+
.surface {
|
|
31
|
+
/* Fades from transparent to the current surface background, so it adapts to
|
|
32
|
+
whichever layer (.surface nesting) it paints over. */
|
|
33
|
+
--surface-overflow-gradient: linear-gradient(
|
|
34
|
+
to bottom,
|
|
35
|
+
transparent,
|
|
36
|
+
var(--surface-color-background)
|
|
37
|
+
);
|
|
38
|
+
}
|
|
31
39
|
}
|
package/src/reset.css
ADDED
|
@@ -0,0 +1,186 @@
|
|
|
1
|
+
/* @canonical/styles — The page's baseline
|
|
2
|
+
*
|
|
3
|
+
* The root of the page declares the design system's baseline: its font, its
|
|
4
|
+
* colour, its line height and weight, how text wraps, and how glyphs are
|
|
5
|
+
* smoothed. Everything else on the page inherits from there, which is what
|
|
6
|
+
* makes a component render the same whether it sits in a card, a table cell or
|
|
7
|
+
* a dialog.
|
|
8
|
+
*
|
|
9
|
+
* The property set is not a matter of taste. It is the set an embedded copy of
|
|
10
|
+
* this stylesheet has to declare for a region to render as the design system's
|
|
11
|
+
* own inside a page that also runs another CSS framework, and it is fixed by
|
|
12
|
+
* the computed-style fixtures in `@canonical/styles-vanilla-adapter`. The rules
|
|
13
|
+
* below are that list, and the comments on them say what each group is for; the
|
|
14
|
+
* set grows when a fixture finds a property a host page can push across the
|
|
15
|
+
* boundary. `font-size` is deliberately not declared here — the page follows the
|
|
16
|
+
* reader's own root font size, which is what a rem-based scale is for — and it
|
|
17
|
+
* is the one property the embedded copy adds, because an island root, unlike a
|
|
18
|
+
* document element, has an ancestor that can size its text.
|
|
19
|
+
*
|
|
20
|
+
* `:where()` appears where a zero specificity matters: these are defaults.
|
|
21
|
+
* Layers sort before specificity, so any layer above `ds.reset` beats these
|
|
22
|
+
* whatever its weight; the zero weight is for a rule written into `ds.reset`
|
|
23
|
+
* itself, which must win by coming later, never by outweighing a default.
|
|
24
|
+
*/
|
|
25
|
+
|
|
26
|
+
@layer ds.reset {
|
|
27
|
+
:where(html) {
|
|
28
|
+
/* The style longhand, not the `text-wrap` shorthand: the shorthand also
|
|
29
|
+
resets `text-wrap-mode`, which would overwrite the browser's own
|
|
30
|
+
`white-space: pre` on a `<select>` and let a long option wrap. How text
|
|
31
|
+
wraps is the rule below, which can exclude the elements whose wrapping is
|
|
32
|
+
part of what they mean. */
|
|
33
|
+
text-wrap-style: auto;
|
|
34
|
+
-webkit-font-smoothing: auto;
|
|
35
|
+
|
|
36
|
+
/* Inherited properties a host page can push across the boundary.
|
|
37
|
+
`revert` cannot undo inheritance — rolling a property back to the user
|
|
38
|
+
agent leaves an inherited one at its parent's value — so the root has to
|
|
39
|
+
declare. These are the typographic inherited properties Vanilla sets
|
|
40
|
+
anywhere in its build, enumerated from the compiled stylesheet, at the
|
|
41
|
+
values a page running pragma alone computes.
|
|
42
|
+
|
|
43
|
+
`font-size` is not among them here, and it is the one place the embedded
|
|
44
|
+
copy declares more than this file does: on the document root there is
|
|
45
|
+
nothing above to inherit from, and declaring a size would override the
|
|
46
|
+
reader's own. An island root does have an ancestor, so the copy pins it.
|
|
47
|
+
|
|
48
|
+
Four inherited properties are deliberately NOT declared, because a host
|
|
49
|
+
setting them is communicating something the island should obey rather
|
|
50
|
+
than styling it: `direction` (a page may be right-to-left), `visibility`
|
|
51
|
+
(a hidden container must stay hidden), `pointer-events` (an inert
|
|
52
|
+
container must stay inert) and `cursor` (a busy container). `color-scheme`
|
|
53
|
+
belongs to the theme bridge. `list-style-type` needs nothing here: on a
|
|
54
|
+
root that is itself a list the boundary's `all: revert` gives the user
|
|
55
|
+
agent's own value, and every list inside gets the same treatment. */
|
|
56
|
+
font-variant-caps: normal;
|
|
57
|
+
font-variant-numeric: normal;
|
|
58
|
+
letter-spacing: normal;
|
|
59
|
+
word-spacing: normal;
|
|
60
|
+
text-indent: 0;
|
|
61
|
+
text-transform: none;
|
|
62
|
+
text-shadow: none;
|
|
63
|
+
text-underline-offset: auto;
|
|
64
|
+
hyphens: manual;
|
|
65
|
+
tab-size: 8;
|
|
66
|
+
word-break: normal;
|
|
67
|
+
border-collapse: separate;
|
|
68
|
+
caption-side: top;
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
/* Five declarations for the properties the browser gives some elements an
|
|
72
|
+
absolute value of its own, each excluded on those elements. Their lists
|
|
73
|
+
come from the user agent's stylesheet rather than from `normalize`, which
|
|
74
|
+
is why they are rules of their own: the browser greys an `<hr>` and gives
|
|
75
|
+
a button its own label colour, bolds a `<th>`, italicises `<em>` and its
|
|
76
|
+
family, and centres a `<th>`, a `<caption>` and a button's label, the
|
|
77
|
+
button-typed inputs included, which also keep their own text selection. On
|
|
78
|
+
a document element every list is inert; on an island root, which can be any
|
|
79
|
+
element, they are not. */
|
|
80
|
+
:where(
|
|
81
|
+
html:not(hr, button, [type="button"], [type="submit"], [type="reset"])
|
|
82
|
+
) {
|
|
83
|
+
/* A `light-dark()` token, resolved against the root's own colour scheme
|
|
84
|
+
(see the theme modifiers), so this one declaration is correct in both. */
|
|
85
|
+
color: var(--color-text);
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
:where(html:not(b, strong, optgroup, th)) {
|
|
89
|
+
font-weight: normal;
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
:where(html:not(i, cite, em, var, address, dfn)) {
|
|
93
|
+
font-style: normal;
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
:where(
|
|
97
|
+
html:not(
|
|
98
|
+
th,
|
|
99
|
+
caption,
|
|
100
|
+
button,
|
|
101
|
+
center,
|
|
102
|
+
[type="button"],
|
|
103
|
+
[type="submit"],
|
|
104
|
+
[type="reset"]
|
|
105
|
+
)
|
|
106
|
+
) {
|
|
107
|
+
text-align: start;
|
|
108
|
+
user-select: auto;
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
/* Where the browser's own value is RELATIVE, excluding the element is not
|
|
112
|
+
enough: `b` and `strong` are `bolder` and `small` is `80%`, both resolved
|
|
113
|
+
against the parent, which on a mixed page is the host's. So those roots are
|
|
114
|
+
given the absolute value the browser would have computed for them on a page
|
|
115
|
+
of pragma's own, rather than left to the host. Measured: a `<b class="ds">`
|
|
116
|
+
inside a Vanilla `.p-heading--4` computed weight 400 against pragma's 700,
|
|
117
|
+
and inside `.p-muted-heading` 900. */
|
|
118
|
+
:where(html):is(b, strong, optgroup) {
|
|
119
|
+
font-weight: bold;
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
/* Two properties an element's own rule in `normalize` may also set, each on
|
|
123
|
+
a root that is not one of the elements whose rule sets it. `normalize` sits
|
|
124
|
+
BELOW this layer, so without the lists a `<pre class="ds">` would take the
|
|
125
|
+
baseline font rather than its own monospace, and a `<sub class="ds">` the
|
|
126
|
+
baseline size rather than 75%. The lists differ because the element rules
|
|
127
|
+
differ: `pre`, `code`, `kbd` and `samp` set a family, `sub` and `sup` a line
|
|
128
|
+
height, and the form controls both. A control keeps the baseline family and size on purpose: `normalize`
|
|
129
|
+
gives it `inherit` and `100%`, which on an island root would resolve against
|
|
130
|
+
the host page rather than pragma.
|
|
131
|
+
|
|
132
|
+
On a document element every list is inert, because a document element is
|
|
133
|
+
never a `<pre>` or a `<sub>`. They earn their keep in the embedded copy,
|
|
134
|
+
where the same rules land on an island root, which can be any element at
|
|
135
|
+
all. The `white-space` rule below carries a list of its own for the same
|
|
136
|
+
reason. */
|
|
137
|
+
:where(html:not(pre, code, kbd, samp)) {
|
|
138
|
+
/* The same token the typography element rules read for the base font, so
|
|
139
|
+
the root and the elements inside it cannot disagree. */
|
|
140
|
+
font-family: var(--typography-text-primary-font-family);
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
:where(html:not(sub, sup, button, input, optgroup, select, textarea)) {
|
|
144
|
+
line-height: normal;
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
/* Whether text wraps, which `text-wrap-style` above does not cover:
|
|
148
|
+
`white-space` is a shorthand for `white-space-collapse` and
|
|
149
|
+
`text-wrap-mode`, both inherited. Declaring it on the root gives the page a
|
|
150
|
+
known starting point instead of whichever value the browser or an embedding
|
|
151
|
+
document happened to hand down.
|
|
152
|
+
|
|
153
|
+
The exclusions are elements whose own white-space is part of what they are.
|
|
154
|
+
They are inert here, because the browser's rule for `pre` or `select` beats
|
|
155
|
+
an inherited value anyway; they are load-bearing in the adapter's embedded
|
|
156
|
+
copy, where this rule lands on a region root that may itself be one of
|
|
157
|
+
them, and they are kept identical so the two cannot drift. A short, fixed
|
|
158
|
+
list from HTML, not an inventory of another framework's rules. */
|
|
159
|
+
:where(
|
|
160
|
+
html:not(
|
|
161
|
+
pre,
|
|
162
|
+
textarea,
|
|
163
|
+
select,
|
|
164
|
+
[type="button"],
|
|
165
|
+
[type="submit"],
|
|
166
|
+
[type="reset"],
|
|
167
|
+
[type="file"],
|
|
168
|
+
[contenteditable]
|
|
169
|
+
)
|
|
170
|
+
) {
|
|
171
|
+
white-space: normal;
|
|
172
|
+
}
|
|
173
|
+
|
|
174
|
+
/* Border-box for everything, pseudo-elements included. The components are
|
|
175
|
+
authored against it: without it a padded control's width no longer includes
|
|
176
|
+
its padding and border, and every control's box grows. Not wrapped in
|
|
177
|
+
`:where()` — `*` carries no specificity and each pseudo-element one, less
|
|
178
|
+
than any class — and
|
|
179
|
+
kept as one rule because it is the only one in the package with universal
|
|
180
|
+
reach, where an extra matching pass is measurable on a large page. */
|
|
181
|
+
*,
|
|
182
|
+
::before,
|
|
183
|
+
::after {
|
|
184
|
+
box-sizing: border-box;
|
|
185
|
+
}
|
|
186
|
+
}
|
package/src/spacing.css
CHANGED
|
@@ -12,108 +12,106 @@
|
|
|
12
12
|
* Commented-out properties are valid extension points that consumers
|
|
13
13
|
* or themes may set; they are documented so the full API surface
|
|
14
14
|
* is visible in one place.
|
|
15
|
+
*
|
|
16
|
+
* Layers: everything here is `ds.tokens`. These are custom properties, which
|
|
17
|
+
* act only where a rule reads them, so this file styles nothing on its own —
|
|
18
|
+
* which is what lets the tokens entry carry it. The content-flow container,
|
|
19
|
+
* which used to sit at the end of this file, sets a real property on an element
|
|
20
|
+
* and now travels with the layout presets in grid.css for that reason.
|
|
15
21
|
*/
|
|
16
22
|
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
23
|
+
@layer ds.tokens {
|
|
24
|
+
:root {
|
|
25
|
+
/* ── Baseline grid ──────────────────────────────────────────────── */
|
|
26
|
+
/* SPIKE: the baseline unit is 4px (down from 8px). Set here in styles, NOT in
|
|
20
27
|
the design token — the token (--dimension-size-height-baseline) is left at
|
|
21
28
|
8px and intentionally no longer consumed, so this is the single place the
|
|
22
29
|
4px grid lives until it is promoted into design-tokens via its own PR. */
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
/* ── Spacing scale (semantic aliases) ───────────────────────────── */
|
|
29
|
-
--space-0: 0;
|
|
30
|
-
--space-025: var(--dimension-025); /* 0.125rem / 2px — micro */
|
|
31
|
-
--space-050: var(--dimension-050); /* 0.25rem / 4px — xxs */
|
|
32
|
-
--space-100: var(--dimension-100); /* 0.5rem / 8px — xs (1bU) */
|
|
33
|
-
--space-150: var(--dimension-150); /* 0.75rem / 12px — sm */
|
|
34
|
-
--space-200: var(--dimension-200); /* 1rem / 16px — md (2bU) */
|
|
35
|
-
--space-300: var(--dimension-300); /* 1.5rem / 24px — lg (3bU) */
|
|
36
|
-
--space-400: var(--dimension-400); /* 2rem / 32px — xl (4bU) */
|
|
37
|
-
--space-600: var(--dimension-600); /* 3rem / 48px — 2xl */
|
|
38
|
-
--space-800: var(--dimension-800); /* 4rem / 64px — 3xl */
|
|
30
|
+
--space-baseline: 0.25rem; /* 4px — bU (was the 8px --dimension-size-height-baseline token) */
|
|
31
|
+
--baseline-height: var(
|
|
32
|
+
--space-baseline
|
|
33
|
+
); /* alias consumed by typography engine */
|
|
39
34
|
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
/* h1, h2: --space-after: 2 (= 2 × 0.5rem = 1rem = 16px) */
|
|
52
|
-
/* h3-h6, p: --space-after: 1 (= 1 × 0.5rem = 0.5rem = 8px) */
|
|
53
|
-
/* */
|
|
54
|
-
/* The tokens below are for NON-typographic elements. */
|
|
55
|
-
/* When the spacing architecture is finalised, the typography */
|
|
56
|
-
/* mapper should read FROM these tokens instead of hardcoding. */
|
|
57
|
-
--spaceAfter-button: var(--space-200); /* 1rem / 16px — block-end margin */
|
|
58
|
-
/* --spaceAfter-figure: var(--space-300); */ /* block-end margin for figures */
|
|
59
|
-
/* --spaceAfter-list: var(--space-200); */ /* block-end margin for ul/ol */
|
|
60
|
-
/* --spaceAfter-table: var(--space-300); */ /* block-end margin for tables */
|
|
61
|
-
/* --spaceAfter-hr: var(--space-400); */ /* block-end margin for <hr> */
|
|
35
|
+
/* ── Spacing scale (semantic aliases) ───────────────────────────── */
|
|
36
|
+
--space-0: 0;
|
|
37
|
+
--space-025: var(--dimension-025); /* 0.125rem / 2px — micro */
|
|
38
|
+
--space-050: var(--dimension-050); /* 0.25rem / 4px — xxs */
|
|
39
|
+
--space-100: var(--dimension-100); /* 0.5rem / 8px — xs (1bU) */
|
|
40
|
+
--space-150: var(--dimension-150); /* 0.75rem / 12px — sm */
|
|
41
|
+
--space-200: var(--dimension-200); /* 1rem / 16px — md (2bU) */
|
|
42
|
+
--space-300: var(--dimension-300); /* 1.5rem / 24px — lg (3bU) */
|
|
43
|
+
--space-400: var(--dimension-400); /* 2rem / 32px — xl (4bU) */
|
|
44
|
+
--space-600: var(--dimension-600); /* 3rem / 48px — 2xl */
|
|
45
|
+
--space-800: var(--dimension-800); /* 4rem / 64px — 3xl */
|
|
62
46
|
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
47
|
+
/* ── Element-owned spacing (margin-block-end) ───────────────────── */
|
|
48
|
+
/* Direction: block-end (downward in horizontal writing modes). */
|
|
49
|
+
/* */
|
|
50
|
+
/* For typographic elements (h1-h6, p, .p), space-after is */
|
|
51
|
+
/* implemented in @canonical/styles-typography mapper.css as a */
|
|
52
|
+
/* unitless --space-after variable (in baseline-height units) */
|
|
53
|
+
/* consumed by the baseline engine: */
|
|
54
|
+
/* margin-bottom: calc(bottom-nudge + space-after × baseline-height) */
|
|
55
|
+
/* */
|
|
56
|
+
/* Default: --space-after: 0 on all elements (app UI contexts). */
|
|
57
|
+
/* Editorial/prose contexts opt in via the .editorial class: */
|
|
58
|
+
/* h1, h2: --space-after: 2 (= 2 × 0.5rem = 1rem = 16px) */
|
|
59
|
+
/* h3-h6, p: --space-after: 1 (= 1 × 0.5rem = 0.5rem = 8px) */
|
|
60
|
+
/* */
|
|
61
|
+
/* The tokens below are for NON-typographic elements. */
|
|
62
|
+
/* When the spacing architecture is finalised, the typography */
|
|
63
|
+
/* mapper should read FROM these tokens instead of hardcoding. */
|
|
64
|
+
--spaceAfter-button: var(--space-200); /* 1rem / 16px — block-end margin */
|
|
65
|
+
/* --spaceAfter-figure: var(--space-300); */ /* block-end margin for figures */
|
|
66
|
+
/* --spaceAfter-list: var(--space-200); */ /* block-end margin for ul/ol */
|
|
67
|
+
/* --spaceAfter-table: var(--space-300); */ /* block-end margin for tables */
|
|
68
|
+
/* --spaceAfter-hr: var(--space-400); */ /* block-end margin for <hr> */
|
|
71
69
|
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
70
|
+
/* ── Container-owned spacing (gap values) ───────────────────────── */
|
|
71
|
+
/* Used in application UI contexts: forms, dashboards, cards. */
|
|
72
|
+
/* These are axis-agnostic by default — containers apply them to */
|
|
73
|
+
/* whichever axis they need (block-direction gap for stacked forms, */
|
|
74
|
+
/* inline-direction gap for button rows, both for grids). */
|
|
75
|
+
--container-gap-tight: var(--space-050); /* 4px — dense key-value pairs */
|
|
76
|
+
--container-gap-default: var(
|
|
77
|
+
--space-200
|
|
78
|
+
); /* 16px — standard card/form gap */
|
|
79
|
+
--container-gap-loose: var(--space-300); /* 24px — sections, visual break */
|
|
75
80
|
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
--space-100
|
|
80
|
-
); /* 8px — block (vertical) padding */
|
|
81
|
-
--component-padding-inline: var(
|
|
82
|
-
--space-200
|
|
83
|
-
); /* 16px — inline (horizontal) padding */
|
|
81
|
+
/* Per-axis container gap overrides (set by consumers, not defined here): */
|
|
82
|
+
/* --container-gap-block: … ; */ /* block-direction gap override */
|
|
83
|
+
/* --container-gap-inline: … ; */ /* inline-direction gap override */
|
|
84
84
|
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
85
|
+
/* ── Intra-component spacing ────────────────────────────────────── */
|
|
86
|
+
/* Component-owned: internal padding regardless of context. */
|
|
87
|
+
--component-padding-block: var(
|
|
88
|
+
--space-100
|
|
89
|
+
); /* 8px — block (vertical) padding */
|
|
90
|
+
--component-padding-inline: var(
|
|
91
|
+
--space-200
|
|
92
|
+
); /* 16px — inline (horizontal) padding */
|
|
90
93
|
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
--
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
--space-400
|
|
97
|
-
); /* 32px / 2rem — outer page margin (inline-direction) */
|
|
94
|
+
/* Per-side component padding overrides (set by themes/consumers): */
|
|
95
|
+
/* --component-padding-block-start: … ; */ /* top padding override */
|
|
96
|
+
/* --component-padding-block-end: … ; */ /* bottom padding override */
|
|
97
|
+
/* --component-padding-inline-start: … ; */ /* left (LTR) padding */
|
|
98
|
+
/* --component-padding-inline-end: … ; */ /* right (LTR) padding */
|
|
98
99
|
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
/* --heading-padding-inline: … ; */ /* set by layout context, default 0 */
|
|
107
|
-
}
|
|
100
|
+
/* ── Layout grid ────────────────────────────────────────────────── */
|
|
101
|
+
--grid-gutter: var(
|
|
102
|
+
--space-200
|
|
103
|
+
); /* 16px / 1rem — column gutters (inline-direction) */
|
|
104
|
+
--grid-margin: var(
|
|
105
|
+
--space-400
|
|
106
|
+
); /* 32px / 2rem — outer page margin (inline-direction) */
|
|
108
107
|
|
|
109
|
-
/*
|
|
108
|
+
/* Grid gap axis overrides (consumed by grid.css): */
|
|
109
|
+
/* --grid-gap: … ; */ /* shorthand: sets both row-gap and column-gap */
|
|
110
|
+
/* --grid-row-gap: … ; */ /* block-direction gap between grid rows */
|
|
111
|
+
/* --grid-column-gap: … ; */ /* inline-direction gap between grid columns */
|
|
110
112
|
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
* to prevent double spacing at the container boundary.
|
|
115
|
-
*/
|
|
116
|
-
.content-flow > :last-child {
|
|
117
|
-
margin-bottom: 0;
|
|
113
|
+
/* ── Heading alignment ──────────────────────────────────────────── */
|
|
114
|
+
/* Inline padding for headings to align with padded blocks. */
|
|
115
|
+
/* --heading-padding-inline: … ; */ /* set by layout context, default 0 */
|
|
118
116
|
}
|
|
119
117
|
}
|
package/src/tokens.css
ADDED
|
@@ -0,0 +1,124 @@
|
|
|
1
|
+
/* @canonical/styles — the values
|
|
2
|
+
*
|
|
3
|
+
* Every custom property the design system declares, and not one rule that
|
|
4
|
+
* selects an element: the colour palette and the semantic colour tokens, the
|
|
5
|
+
* spacing and density scales, the motion and overflow tokens, the modifier
|
|
6
|
+
* families that re-point colour channels, and the typographic scale.
|
|
7
|
+
*
|
|
8
|
+
* One thing here is not a value, and it is worth knowing before you import this
|
|
9
|
+
* file. `@canonical/design-tokens`' theme sheet declares `color-scheme` — on
|
|
10
|
+
* `:root`, and on `.light` and `.dark` — alongside the colour tokens, and that
|
|
11
|
+
* property is not inert: it decides the colour of the canvas, the form controls,
|
|
12
|
+
* the scrollbars and the system colours, whether or not anything reads a token.
|
|
13
|
+
* On a page that also runs another CSS framework, an element of that framework's
|
|
14
|
+
* carrying `light` or `dark` picks it up too.
|
|
15
|
+
*
|
|
16
|
+
* It cannot be separated here: that sheet is generated, and the declarations sit
|
|
17
|
+
* in the same rules as the colour tokens they belong to. Splitting them is a
|
|
18
|
+
* change to the tokens package's emitter, tracked as PRA-149. Until then, an
|
|
19
|
+
* application that must not have it declares `color-scheme` itself, in a layer
|
|
20
|
+
* above `ds.modifiers` or unlayered.
|
|
21
|
+
*
|
|
22
|
+
* Everything else here does nothing until something reads it.
|
|
23
|
+
*
|
|
24
|
+
* One of four entry points. `index.css` is the whole stylesheet and is what an
|
|
25
|
+
* ordinary page imports; `tokens.css`, `elements.css` and `layout.css` are it
|
|
26
|
+
* in three parts, for a page that wants some of it and supplies the rest.
|
|
27
|
+
*
|
|
28
|
+
* Every entry imports `layers.css` first, and none of them imports another
|
|
29
|
+
* entry. Both of those matter. The order has to reach the browser before any
|
|
30
|
+
* rule of the page it orders, and it is declared in exactly one file so that
|
|
31
|
+
* two entries can never disagree — if they did, the same rules would arbitrate
|
|
32
|
+
* differently depending on which entry a consumer picked. Measured in Chromium:
|
|
33
|
+
* a statement read through an `@import` orders the importing sheet exactly as
|
|
34
|
+
* one written in place would. Entries stay independent of each other because an
|
|
35
|
+
* `@layer` statement inside a layer block would declare sublayers rather than
|
|
36
|
+
* top-level layers, so an entry composing another would nest the order instead
|
|
37
|
+
* of sharing it; independent, a page may load one, two or all three, in any
|
|
38
|
+
* order, and get the same result.
|
|
39
|
+
*/
|
|
40
|
+
|
|
41
|
+
/* Read from the bottom up, each position is an argument:
|
|
42
|
+
* normalize pragma's own reset
|
|
43
|
+
* ds.tokens primitive values, spacing, motion, overflow
|
|
44
|
+
* ds.reset the page's baseline: font, colour, box-sizing
|
|
45
|
+
* ds.typography the semantic mapper and the baseline engines
|
|
46
|
+
* ds.modifiers theme, the typographic scale, the channel families and
|
|
47
|
+
* their shims, the density and context classes
|
|
48
|
+
* ds.surfaces the surface families
|
|
49
|
+
* ds.states the derived hover / active / disabled channels
|
|
50
|
+
* ds.components the parent of the tier layers. Nothing is written directly
|
|
51
|
+
* into it, by rule: a declaration in a parent layer sits in
|
|
52
|
+
* that layer's implicit final sublayer, above every named
|
|
53
|
+
* sublayer, so it would outrank every tier
|
|
54
|
+
* ds.components.global the shared component packages, and this
|
|
55
|
+
* package's own layout presets
|
|
56
|
+
* ds.components.sites } the four second-level tiers of the design
|
|
57
|
+
* ds.components.documentation } system's tier tree. They never share a
|
|
58
|
+
* ds.components.stores } page, so their order among themselves is
|
|
59
|
+
* ds.components.apps } arbitrary — but it is fixed here so that
|
|
60
|
+
* it can never depend on which package a bundler emits first
|
|
61
|
+
*
|
|
62
|
+
* The component layers follow the tier tree of the design system: who owns a
|
|
63
|
+
* component decides which layer its rules go in, and a deeper tier wins.
|
|
64
|
+
*
|
|
65
|
+
* The second level is named here in full, and only the second level. A package
|
|
66
|
+
* below it — one application's own tier, say — declares its own layer as the
|
|
67
|
+
* first rule of its CSS entry, `@layer ds.components.apps-lxd;`, and wraps its
|
|
68
|
+
* sheets in it. Because this statement always comes first, that name is new
|
|
69
|
+
* when the browser meets it and is appended after the names above, inside
|
|
70
|
+
* `ds.components`, so it sorts above them. That is the tree's own rule — the
|
|
71
|
+
* more specific tier wins — and it means this stylesheet never has to know
|
|
72
|
+
* which applications exist.
|
|
73
|
+
*
|
|
74
|
+
* The names are tier ids from that tree, lowercased and hyphenated for a
|
|
75
|
+
* sub-tier (`apps-lxd`), not the context words a page puts on its root
|
|
76
|
+
* (`app`, `site`, `docs`). A tier says who owns a component; a context says
|
|
77
|
+
* what kind of page it is being shown on. */
|
|
78
|
+
@import url("./layers.css");
|
|
79
|
+
|
|
80
|
+
/* Design tokens — colour, spacing, surfaces, states.
|
|
81
|
+
* Each generated file opens its own `@layer` block, so none of these imports
|
|
82
|
+
* carries a `layer()` keyword: that would nest the file's layer inside another. */
|
|
83
|
+
@import url("@canonical/design-tokens/dist/sets.primitive.css");
|
|
84
|
+
@import url("@canonical/design-tokens/dist/modifiers.theme.css");
|
|
85
|
+
@import url("@canonical/design-tokens/dist/modifiers.surfaces.css");
|
|
86
|
+
@import url("@canonical/design-tokens/dist/modifiers.anticipation.css");
|
|
87
|
+
@import url("@canonical/design-tokens/dist/modifiers.criticality.css");
|
|
88
|
+
@import url("@canonical/design-tokens/dist/modifiers.emphasis.css");
|
|
89
|
+
@import url("@canonical/design-tokens/dist/modifiers.importance.css");
|
|
90
|
+
/* TEMP shims (remove once generated upstream):
|
|
91
|
+
- states: writes the explicit per-state colour tokens into the modifier
|
|
92
|
+
channel (the generated modifiers only expose root), so hover/active/
|
|
93
|
+
disabled compose with anticipation. Imported after the anticipation/
|
|
94
|
+
emphasis modifiers so the anticipation-class overrides win.
|
|
95
|
+
- importance: maps the (currently empty) importance modifiers to channel
|
|
96
|
+
hints so importance-driven components can render their hierarchy.
|
|
97
|
+
- criticality: adds an icon channel (--modifier-icon) mapping each
|
|
98
|
+
criticality class to its glyph, so criticality components render the icon
|
|
99
|
+
from the modifier rather than hard-coding it.
|
|
100
|
+
- controls-hover: adds the missing selected-state (and switch unselected)
|
|
101
|
+
`--hover--color-foreground-*` shades so checkbox/radio/switch hover shifts
|
|
102
|
+
only the fill/track, not the masked glyph/knob. */
|
|
103
|
+
@import url("./modifiers.states.shim.css");
|
|
104
|
+
@import url("./modifiers.importance.shim.css");
|
|
105
|
+
@import url("./modifiers.criticality.shim.css");
|
|
106
|
+
@import url("./controls.hover.shim.css");
|
|
107
|
+
@import url("@canonical/design-tokens/dist/states.css");
|
|
108
|
+
|
|
109
|
+
/* Spacing architecture tokens */
|
|
110
|
+
@import url("./spacing.css");
|
|
111
|
+
|
|
112
|
+
/* Density modifier family (context × density → control height + baseline).
|
|
113
|
+
* After spacing.css, which supplies the --baseline-height these primitives use. */
|
|
114
|
+
@import url("./modifiers.density.css");
|
|
115
|
+
|
|
116
|
+
/* Scroll overflow affordance tokens */
|
|
117
|
+
@import url("./overflow.css");
|
|
118
|
+
|
|
119
|
+
/* Motion tokens (placeholder durations/easings) */
|
|
120
|
+
@import url("./motion.css");
|
|
121
|
+
|
|
122
|
+
/* The typographic scale and the naming shims that bridge it. The rules that
|
|
123
|
+
* read these values are in elements.css, not here. */
|
|
124
|
+
@import url("@canonical/styles-typography/tokens.css");
|