@canonical/styles 0.29.0 → 0.31.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/package.json +5 -5
- package/src/controls.hover.shim.css +119 -0
- package/src/index.css +21 -0
- package/src/modifiers.criticality.shim.css +71 -0
- package/src/modifiers.density.css +166 -0
- package/src/modifiers.importance.shim.css +99 -0
- package/src/modifiers.states.shim.css +179 -0
- package/src/spacing.css +5 -4
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@canonical/styles",
|
|
3
3
|
"description": "Canonical Design System global stylesheet. Aggregates normalize, typography, and design tokens.",
|
|
4
|
-
"version": "0.
|
|
4
|
+
"version": "0.31.0",
|
|
5
5
|
"main": "src/index.css",
|
|
6
6
|
"exports": {
|
|
7
7
|
".": "./src/index.css",
|
|
@@ -30,11 +30,11 @@
|
|
|
30
30
|
},
|
|
31
31
|
"devDependencies": {
|
|
32
32
|
"@biomejs/biome": "2.4.9",
|
|
33
|
-
"@canonical/biome-config": "^0.
|
|
33
|
+
"@canonical/biome-config": "^0.31.0"
|
|
34
34
|
},
|
|
35
35
|
"dependencies": {
|
|
36
|
-
"@canonical/design-tokens": "
|
|
37
|
-
"@canonical/styles-typography": "^0.
|
|
36
|
+
"@canonical/design-tokens": "0.6.2-contrasted.0",
|
|
37
|
+
"@canonical/styles-typography": "^0.31.0",
|
|
38
38
|
"normalize.css": "^8.0.1"
|
|
39
39
|
},
|
|
40
40
|
"peerDependencies": {
|
|
@@ -45,5 +45,5 @@
|
|
|
45
45
|
"optional": true
|
|
46
46
|
}
|
|
47
47
|
},
|
|
48
|
-
"gitHead": "
|
|
48
|
+
"gitHead": "d4a67ebe42e62b8cf3de77f42f537309ca88d672"
|
|
49
49
|
}
|
|
@@ -0,0 +1,119 @@
|
|
|
1
|
+
/* @canonical/styles — Control selected-state SURFACE + HOVER SHIM (temporary)
|
|
2
|
+
*
|
|
3
|
+
* The generated design-tokens surface the control colours per nesting level
|
|
4
|
+
* (`.surface` → `.surface .surface` → `.contrasted` → `.modal`, in
|
|
5
|
+
* `@canonical/design-tokens/dist/modifiers.surfaces.css`) for the checkbox/radio
|
|
6
|
+
* UNSELECTED + checkmark and the switch knob — but NOT for any SELECTED state,
|
|
7
|
+
* nor the switch's unselected track. They also expose `--hover--color-foreground-*`
|
|
8
|
+
* (an OKLCH lightness-delta hover shade) only for those same unselected states.
|
|
9
|
+
*
|
|
10
|
+
* Consequences this shim fixes:
|
|
11
|
+
* 1. Selected controls were not surface-provided: a :checked box/dot/track kept
|
|
12
|
+
* the flat `--color-foreground-*-selected` on every surface, ignoring
|
|
13
|
+
* OnSurface stepping. (Ideal: selected states come through the surface layer
|
|
14
|
+
* like the unselected ones do.)
|
|
15
|
+
* 2. Hovered selected controls had no hover token, so components faked it with
|
|
16
|
+
* `filter: brightness()` on the whole <input> — which also dimmed the masked
|
|
17
|
+
* checkmark glyph / switch knob (Diana's review: "hover should not affect the
|
|
18
|
+
* checkmark/knob colour, just the fill/background").
|
|
19
|
+
*
|
|
20
|
+
* ── Part 1: surface-provided selected tokens ────────────────────────────────
|
|
21
|
+
* Mirror the surfaces.css selector structure so a control's SELECTED fill reads
|
|
22
|
+
* `--surface-color-foreground-*-selected`, resolved per surface. The design build
|
|
23
|
+
* has no `-selected-layer2/-layer3/-contrasted` PRIMITIVES yet, so every level
|
|
24
|
+
* currently aliases the flat base — but establishing the surface token means (a)
|
|
25
|
+
* components stop hard-coding the flat token, and (b) upstream can drop in real
|
|
26
|
+
* per-layer values later with zero component change. `switch-unselected` gets the
|
|
27
|
+
* same treatment (its surface token is also absent).
|
|
28
|
+
*
|
|
29
|
+
* ── Part 2: hover channels ──────────────────────────────────────────────────
|
|
30
|
+
* Same idiom as the generated `--hover--` tokens: shift the (now surface-aware)
|
|
31
|
+
* base lightness by the per-family `--delta-hover-*` step. Because Part 1 defines
|
|
32
|
+
* the surface tokens, these hovers are surface-correct too.
|
|
33
|
+
*
|
|
34
|
+
* Components read the CHANNELS, never re-derive the maths. Part 1 is zero-
|
|
35
|
+
* specificity (`:where()`) so it self-upgrades when upstream lands; Part 2 can be
|
|
36
|
+
* dropped once the `--hover--…-selected` tokens are generated. Imported into
|
|
37
|
+
* `ds.modifiers` after the generated tokens.
|
|
38
|
+
*/
|
|
39
|
+
|
|
40
|
+
@layer ds.modifiers {
|
|
41
|
+
/* Part 1 — surface-provided selected tokens, per surface level (mirrors
|
|
42
|
+
* modifiers.surfaces.css). No -selected-layerN primitives exist yet, so each
|
|
43
|
+
* level aliases the flat base.
|
|
44
|
+
*
|
|
45
|
+
* SELF-UPGRADING (no manual removal): the selectors are wrapped in `:where()`,
|
|
46
|
+
* so this block has ZERO specificity. The generated `modifiers.surfaces.css`
|
|
47
|
+
* rules use normal `.surface` selectors (specificity 0,1,0), so the moment
|
|
48
|
+
* upstream defines the real per-level `-selected` values they WIN over this
|
|
49
|
+
* fallback automatically — even though this shim is imported later in the same
|
|
50
|
+
* layer. The shim can stay indefinitely; it only ever supplies a value when
|
|
51
|
+
* upstream has none. (Removing it once upstream lands is still tidy, but no
|
|
52
|
+
* longer load-bearing.) */
|
|
53
|
+
:where(
|
|
54
|
+
.surface,
|
|
55
|
+
.surface .surface,
|
|
56
|
+
.surface .surface .surface,
|
|
57
|
+
.contrasted,
|
|
58
|
+
.modal
|
|
59
|
+
) {
|
|
60
|
+
--surface-color-foreground-checkbox-selected: var(
|
|
61
|
+
--color-foreground-checkbox-selected
|
|
62
|
+
);
|
|
63
|
+
--surface-color-foreground-radio-selected: var(
|
|
64
|
+
--color-foreground-radio-selected
|
|
65
|
+
);
|
|
66
|
+
--surface-color-foreground-switch-selected: var(
|
|
67
|
+
--color-foreground-switch-selected
|
|
68
|
+
);
|
|
69
|
+
--surface-color-foreground-switch-unselected: var(
|
|
70
|
+
--color-foreground-switch-unselected
|
|
71
|
+
);
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
/* Part 2 — hover channels, derived from the surface-aware base above. */
|
|
75
|
+
:root {
|
|
76
|
+
/* Checkbox — selected fill on :checked / :indeterminate hover. */
|
|
77
|
+
--hover--color-foreground-checkbox-selected: oklch(
|
|
78
|
+
from
|
|
79
|
+
var(
|
|
80
|
+
--surface-color-foreground-checkbox-selected,
|
|
81
|
+
var(--color-foreground-checkbox-selected)
|
|
82
|
+
)
|
|
83
|
+
calc(l + var(--delta-hover-color-foreground-checkbox-selected, -0.0391))
|
|
84
|
+
c h
|
|
85
|
+
);
|
|
86
|
+
|
|
87
|
+
/* Switch — selected track on :checked hover, and unselected track hover. */
|
|
88
|
+
--hover--color-foreground-switch-selected: oklch(
|
|
89
|
+
from
|
|
90
|
+
var(
|
|
91
|
+
--surface-color-foreground-switch-selected,
|
|
92
|
+
var(--color-foreground-switch-selected)
|
|
93
|
+
)
|
|
94
|
+
calc(l + var(--delta-hover-color-foreground-switch-selected, -0.0391)) c
|
|
95
|
+
h
|
|
96
|
+
);
|
|
97
|
+
|
|
98
|
+
--hover--color-foreground-switch-unselected: oklch(
|
|
99
|
+
from
|
|
100
|
+
var(
|
|
101
|
+
--surface-color-foreground-switch-unselected,
|
|
102
|
+
var(--color-foreground-switch-unselected)
|
|
103
|
+
)
|
|
104
|
+
calc(l + var(--delta-hover-color-foreground-switch-unselected, -0.0391))
|
|
105
|
+
c h
|
|
106
|
+
);
|
|
107
|
+
|
|
108
|
+
/* Radio — selected dot on :checked hover (parity with checkbox). */
|
|
109
|
+
--hover--color-foreground-radio-selected: oklch(
|
|
110
|
+
from
|
|
111
|
+
var(
|
|
112
|
+
--surface-color-foreground-radio-selected,
|
|
113
|
+
var(--color-foreground-radio-selected)
|
|
114
|
+
)
|
|
115
|
+
calc(l + var(--delta-hover-color-foreground-radio-selected, -0.0391)) c
|
|
116
|
+
h
|
|
117
|
+
);
|
|
118
|
+
}
|
|
119
|
+
}
|
package/src/index.css
CHANGED
|
@@ -21,6 +21,23 @@
|
|
|
21
21
|
@import url("@canonical/design-tokens/dist/modifiers.criticality.css");
|
|
22
22
|
@import url("@canonical/design-tokens/dist/modifiers.emphasis.css");
|
|
23
23
|
@import url("@canonical/design-tokens/dist/modifiers.importance.css");
|
|
24
|
+
/* TEMP shims (remove once generated upstream):
|
|
25
|
+
- states: writes the explicit per-state colour tokens into the modifier
|
|
26
|
+
channel (the generated modifiers only expose root), so hover/active/
|
|
27
|
+
disabled compose with anticipation. Imported after the anticipation/
|
|
28
|
+
emphasis modifiers so the anticipation-class overrides win.
|
|
29
|
+
- importance: maps the (currently empty) importance modifiers to channel
|
|
30
|
+
hints so importance-driven components can render their hierarchy.
|
|
31
|
+
- criticality: adds an icon channel (--modifier-icon) mapping each
|
|
32
|
+
criticality class to its glyph, so criticality components render the icon
|
|
33
|
+
from the modifier rather than hard-coding it.
|
|
34
|
+
- controls-hover: adds the missing selected-state (and switch unselected)
|
|
35
|
+
`--hover--color-foreground-*` shades so checkbox/radio/switch hover shifts
|
|
36
|
+
only the fill/track, not the masked glyph/knob. */
|
|
37
|
+
@import url("./modifiers.states.shim.css");
|
|
38
|
+
@import url("./modifiers.importance.shim.css");
|
|
39
|
+
@import url("./modifiers.criticality.shim.css");
|
|
40
|
+
@import url("./controls.hover.shim.css");
|
|
24
41
|
@import url("@canonical/design-tokens/dist/states.css");
|
|
25
42
|
|
|
26
43
|
/* Grid layout presets */
|
|
@@ -29,6 +46,10 @@
|
|
|
29
46
|
/* Spacing architecture tokens */
|
|
30
47
|
@import url("./spacing.css");
|
|
31
48
|
|
|
49
|
+
/* Density modifier family (context × density → control height + baseline).
|
|
50
|
+
* After spacing.css, which supplies the --baseline-height these primitives use. */
|
|
51
|
+
@import url("./modifiers.density.css");
|
|
52
|
+
|
|
32
53
|
/* Scroll overflow affordance tokens */
|
|
33
54
|
@import url("./overflow.css");
|
|
34
55
|
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
/* @canonical/styles — Criticality modifier SHIM (temporary)
|
|
2
|
+
*
|
|
3
|
+
* The generated `@canonical/design-tokens/dist/modifiers.criticality.css`
|
|
4
|
+
* exposes the colour channels for each criticality (`--modifier-color-icon`,
|
|
5
|
+
* `-text`, `-border`, `-foreground-secondary`) but is missing two channels this
|
|
6
|
+
* shim fills in, keyed off the criticality class. Remove each block once its
|
|
7
|
+
* channel is generated upstream in the criticality modifier tokens.
|
|
8
|
+
*
|
|
9
|
+
* Design contract — components listen to the CHANNEL, never to the class. A
|
|
10
|
+
* consumer must not key off `.information` / `.warning`; it reads the generic
|
|
11
|
+
* channel, so any criticality gets the right value for free.
|
|
12
|
+
*
|
|
13
|
+
* ── 1. Icon channel (--modifier-icon) ──────────────────────────────────────
|
|
14
|
+
* Nothing upstream says *which glyph* signals "information" vs "warning" etc.
|
|
15
|
+
* Criticality-driven components (Announcement, and future callouts) each
|
|
16
|
+
* hard-code that mapping in their own markup today. This adds a channel that
|
|
17
|
+
* carries the glyph as a CSS `mask-image` reference into the Canonical icon set
|
|
18
|
+
* (served at `/icons/<name>.svg`):
|
|
19
|
+
*
|
|
20
|
+
* --modifier-icon a `mask-image` value; a component masks a pseudo-element
|
|
21
|
+
* with it and fills it with `--modifier-color-icon`, so the
|
|
22
|
+
* glyph both matches the criticality AND takes its colour.
|
|
23
|
+
*
|
|
24
|
+
* This mirrors the mask technique used by Accordion's chevron and the form
|
|
25
|
+
* CheckboxInput's checkmark (mask-image + background-color so the glyph is
|
|
26
|
+
* recolourable, unlike a background-image SVG).
|
|
27
|
+
*
|
|
28
|
+
* ── 2. On-surface text channel (--modifier-color-text-onForegroundSecondary) ─
|
|
29
|
+
* The generated `--modifier-color-text` is the *standalone* criticality text
|
|
30
|
+
* colour (e.g. green text on the page background). Components that place text on
|
|
31
|
+
* the criticality's own coloured surface — Badge sits its label on
|
|
32
|
+
* `--modifier-color-foreground-secondary` — need the *on-surface* pairing
|
|
33
|
+
* instead, or they render same-hue-on-same-hue with failing contrast. The
|
|
34
|
+
* design-tokens build already defines `--color-text-onForegroundSecondary-*`
|
|
35
|
+
* per criticality; it just isn't wired into the modifier family. This exposes
|
|
36
|
+
* it as a channel so on-surface criticality components read it generically.
|
|
37
|
+
*
|
|
38
|
+
* Imported into the `ds.modifiers` layer after the generated criticality
|
|
39
|
+
* modifiers so these class rules compose at equal specificity, later source
|
|
40
|
+
* order.
|
|
41
|
+
*/
|
|
42
|
+
|
|
43
|
+
@layer ds.modifiers {
|
|
44
|
+
.information {
|
|
45
|
+
--modifier-icon: url("/icons/information.svg#information");
|
|
46
|
+
--modifier-color-text-onForegroundSecondary: var(
|
|
47
|
+
--color-text-onForegroundSecondary-information
|
|
48
|
+
);
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
.success {
|
|
52
|
+
--modifier-icon: url("/icons/success.svg#success");
|
|
53
|
+
--modifier-color-text-onForegroundSecondary: var(
|
|
54
|
+
--color-text-onForegroundSecondary-success
|
|
55
|
+
);
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
.warning {
|
|
59
|
+
--modifier-icon: url("/icons/warning.svg#warning");
|
|
60
|
+
--modifier-color-text-onForegroundSecondary: var(
|
|
61
|
+
--color-text-onForegroundSecondary-warning
|
|
62
|
+
);
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
.error {
|
|
66
|
+
--modifier-icon: url("/icons/error.svg#error");
|
|
67
|
+
--modifier-color-text-onForegroundSecondary: var(
|
|
68
|
+
--color-text-onForegroundSecondary-error
|
|
69
|
+
);
|
|
70
|
+
}
|
|
71
|
+
}
|
|
@@ -0,0 +1,166 @@
|
|
|
1
|
+
/* @canonical/styles — Density modifier family
|
|
2
|
+
*
|
|
3
|
+
* A composed 2×3 modifier family that sizes controls and seats their text on the
|
|
4
|
+
* 4px baseline grid, applied as classes on an ancestor (an app root, or a section):
|
|
5
|
+
*
|
|
6
|
+
* CONTEXT .app / .site / .docs — the surface. Sets the comfortable/dense
|
|
7
|
+
* PAIR for every density primitive. `.docs` shares `.site`'s values.
|
|
8
|
+
* DENSITY .comfortable / .dense — picks within the context pair.
|
|
9
|
+
*
|
|
10
|
+
* This is the LOWEST layer of the density system, and it lives in @canonical/styles
|
|
11
|
+
* so EVERY package can read it (ds-global, ds-global-form, and any future consumer)
|
|
12
|
+
* — the primitives were previously in ds-global-form, out of reach of ds-global.
|
|
13
|
+
*
|
|
14
|
+
* Design contract — components listen to the CHANNEL, never to the class. This
|
|
15
|
+
* file exposes only GENERIC, domain-neutral primitives; it knows nothing about
|
|
16
|
+
* forms, fields, buttons, accordions, or any component. A consumer reads the
|
|
17
|
+
* `--density-*` outputs and applies them to its own box/tokens (see the seating
|
|
18
|
+
* guides shipped by ds-global-form):
|
|
19
|
+
*
|
|
20
|
+
* --density-line-height the control-height / line unit for a cell
|
|
21
|
+
* --density-line-height-effective the same, with the full fallback chain
|
|
22
|
+
* --density-target-baseline-px the grid line a control's baseline lands on
|
|
23
|
+
* --density-padding-inline inline padding for a cell
|
|
24
|
+
* --density-space-sm / -md / -lg three vertical spacing rungs for a cell
|
|
25
|
+
*
|
|
26
|
+
* Every value is a WHOLE multiple of --baseline-height (from spacing.css), so
|
|
27
|
+
* vertical rhythm holds in all four cells. Sites/docs run one baseline looser than
|
|
28
|
+
* apps on the height (+4px) and on each rung, so the looser surface breathes.
|
|
29
|
+
*
|
|
30
|
+
* app site / docs
|
|
31
|
+
* comfy dense comfy dense
|
|
32
|
+
* line-height 32 (8) 24 (6) 36 (9) 28 (7)
|
|
33
|
+
* padding-inline 16 (4) 8 (2) 16 (4) 12 (3)
|
|
34
|
+
* space-lg 24 (6) 16 (4) 28 (7) 20 (5)
|
|
35
|
+
* space-md 16 (4) 8 (2) 20 (5) 12 (3)
|
|
36
|
+
* space-sm 8 (2) 4 (1) 8 (2) 8 (2)
|
|
37
|
+
* (parenthesised = baseline units; 1 bU = --baseline-height = 4px)
|
|
38
|
+
*/
|
|
39
|
+
|
|
40
|
+
/* ── Context family: the comfortable/dense PAIR per surface ──────────────────
|
|
41
|
+
* The internal pair-vars are namespaced `--density-*-comfy/-dense` — they ship on
|
|
42
|
+
* the global @canonical/styles surface, so a bare name like `--lh-comfy` would be
|
|
43
|
+
* an easy collision with an app-level variable. The pre-namespace names are kept
|
|
44
|
+
* as back-compat ALIASES (an app or an older ds-global-form that read `--lh-comfy`
|
|
45
|
+
* directly still resolves) — same computed values, no output change. Read the
|
|
46
|
+
* namespaced name in new code; the aliases exist only for the transition. */
|
|
47
|
+
.app {
|
|
48
|
+
--density-lh-comfy: calc(var(--baseline-height) * 8); /* 32px */
|
|
49
|
+
--density-lh-dense: calc(var(--baseline-height) * 6); /* 24px */
|
|
50
|
+
--density-pad-inline-comfy: calc(var(--baseline-height) * 4); /* 16px */
|
|
51
|
+
--density-pad-inline-dense: calc(var(--baseline-height) * 2); /* 8px */
|
|
52
|
+
--density-space-lg-comfy: calc(var(--baseline-height) * 6); /* 24px */
|
|
53
|
+
--density-space-lg-dense: calc(var(--baseline-height) * 4); /* 16px */
|
|
54
|
+
--density-space-md-comfy: calc(var(--baseline-height) * 4); /* 16px */
|
|
55
|
+
--density-space-md-dense: calc(var(--baseline-height) * 2); /* 8px */
|
|
56
|
+
--density-space-sm-comfy: calc(var(--baseline-height) * 2); /* 8px */
|
|
57
|
+
--density-space-sm-dense: calc(var(--baseline-height) * 1); /* 4px */
|
|
58
|
+
|
|
59
|
+
/* Back-compat aliases (pre-namespace names). Remove once no consumer reads them. */
|
|
60
|
+
--lh-comfy: var(--density-lh-comfy);
|
|
61
|
+
--lh-dense: var(--density-lh-dense);
|
|
62
|
+
--pad-inline-comfy: var(--density-pad-inline-comfy);
|
|
63
|
+
--pad-inline-dense: var(--density-pad-inline-dense);
|
|
64
|
+
--space-lg-comfy: var(--density-space-lg-comfy);
|
|
65
|
+
--space-lg-dense: var(--density-space-lg-dense);
|
|
66
|
+
--space-md-comfy: var(--density-space-md-comfy);
|
|
67
|
+
--space-md-dense: var(--density-space-md-dense);
|
|
68
|
+
--space-sm-comfy: var(--density-space-sm-comfy);
|
|
69
|
+
--space-sm-dense: var(--density-space-sm-dense);
|
|
70
|
+
}
|
|
71
|
+
.site,
|
|
72
|
+
.docs {
|
|
73
|
+
--density-lh-comfy: calc(var(--baseline-height) * 9); /* 36px */
|
|
74
|
+
--density-lh-dense: calc(var(--baseline-height) * 7); /* 28px */
|
|
75
|
+
--density-pad-inline-comfy: calc(var(--baseline-height) * 4); /* 16px */
|
|
76
|
+
--density-pad-inline-dense: calc(var(--baseline-height) * 3); /* 12px */
|
|
77
|
+
--density-space-lg-comfy: calc(var(--baseline-height) * 7); /* 28px */
|
|
78
|
+
--density-space-lg-dense: calc(var(--baseline-height) * 5); /* 20px */
|
|
79
|
+
--density-space-md-comfy: calc(var(--baseline-height) * 5); /* 20px */
|
|
80
|
+
--density-space-md-dense: calc(var(--baseline-height) * 3); /* 12px */
|
|
81
|
+
--density-space-sm-comfy: calc(var(--baseline-height) * 2); /* 8px */
|
|
82
|
+
--density-space-sm-dense: calc(var(--baseline-height) * 2); /* 8px */
|
|
83
|
+
|
|
84
|
+
/* Back-compat aliases (pre-namespace names). Remove once no consumer reads them. */
|
|
85
|
+
--lh-comfy: var(--density-lh-comfy);
|
|
86
|
+
--lh-dense: var(--density-lh-dense);
|
|
87
|
+
--pad-inline-comfy: var(--density-pad-inline-comfy);
|
|
88
|
+
--pad-inline-dense: var(--density-pad-inline-dense);
|
|
89
|
+
--space-lg-comfy: var(--density-space-lg-comfy);
|
|
90
|
+
--space-lg-dense: var(--density-space-lg-dense);
|
|
91
|
+
--space-md-comfy: var(--density-space-md-comfy);
|
|
92
|
+
--space-md-dense: var(--density-space-md-dense);
|
|
93
|
+
--space-sm-comfy: var(--density-space-sm-comfy);
|
|
94
|
+
--space-sm-dense: var(--density-space-sm-dense);
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
/* ── Density family: pick within the context pair ────────────────────────────
|
|
98
|
+
* Each density tier resolves every GENERIC primitive from the context's
|
|
99
|
+
* *-comfy / *-dense pair. Fallbacks cover the app-comfortable defaults when no
|
|
100
|
+
* context class is present (a plain `.comfortable` still works). */
|
|
101
|
+
.comfortable {
|
|
102
|
+
--density-line-height: var(
|
|
103
|
+
--density-lh-comfy,
|
|
104
|
+
calc(var(--baseline-height) * 8)
|
|
105
|
+
);
|
|
106
|
+
--density-padding-inline: var(
|
|
107
|
+
--density-pad-inline-comfy,
|
|
108
|
+
calc(var(--baseline-height) * 4)
|
|
109
|
+
);
|
|
110
|
+
--density-space-lg: var(
|
|
111
|
+
--density-space-lg-comfy,
|
|
112
|
+
calc(var(--baseline-height) * 6)
|
|
113
|
+
);
|
|
114
|
+
--density-space-md: var(
|
|
115
|
+
--density-space-md-comfy,
|
|
116
|
+
calc(var(--baseline-height) * 4)
|
|
117
|
+
);
|
|
118
|
+
--density-space-sm: var(
|
|
119
|
+
--density-space-sm-comfy,
|
|
120
|
+
calc(var(--baseline-height) * 2)
|
|
121
|
+
);
|
|
122
|
+
}
|
|
123
|
+
.dense {
|
|
124
|
+
--density-line-height: var(
|
|
125
|
+
--density-lh-dense,
|
|
126
|
+
calc(var(--baseline-height) * 6)
|
|
127
|
+
);
|
|
128
|
+
--density-padding-inline: var(
|
|
129
|
+
--density-pad-inline-dense,
|
|
130
|
+
calc(var(--baseline-height) * 2)
|
|
131
|
+
);
|
|
132
|
+
--density-space-lg: var(
|
|
133
|
+
--density-space-lg-dense,
|
|
134
|
+
calc(var(--baseline-height) * 4)
|
|
135
|
+
);
|
|
136
|
+
--density-space-md: var(
|
|
137
|
+
--density-space-md-dense,
|
|
138
|
+
calc(var(--baseline-height) * 2)
|
|
139
|
+
);
|
|
140
|
+
--density-space-sm: var(
|
|
141
|
+
--density-space-sm-dense,
|
|
142
|
+
calc(var(--baseline-height) * 1)
|
|
143
|
+
);
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
/* ── Target baseline = round(up, height × 2/3) ──────────────────────────────
|
|
147
|
+
* Snapped UP so fractional cases lift (apps-comfy 5.33→6) while exact multiples
|
|
148
|
+
* stay (apps-dense 4.0, sites-comfy 6.0). Matches: apps 32→6th/24→4th,
|
|
149
|
+
* sites 36→6th/28→5th. */
|
|
150
|
+
:where(.comfortable, .dense, .app, .site, .docs) {
|
|
151
|
+
/* Effective line-height with the SAME fallback chain a control box uses
|
|
152
|
+
(--density-line-height → context --density-lh-comfy → apps-comfy literal).
|
|
153
|
+
Without this fallback, a bare context class (.app/.site/.docs applied with no
|
|
154
|
+
density class — the documented "no class = comfortable" case) leaves
|
|
155
|
+
--density-line-height unset, the round(calc(var(--density-line-height)…))
|
|
156
|
+
becomes invalid, the target resolves to 0, and controls lose their seating. */
|
|
157
|
+
--density-line-height-effective: var(
|
|
158
|
+
--density-line-height,
|
|
159
|
+
var(--density-lh-comfy, calc(var(--baseline-height) * 8))
|
|
160
|
+
);
|
|
161
|
+
--density-target-baseline-px: round(
|
|
162
|
+
up,
|
|
163
|
+
calc(var(--density-line-height-effective) * 2 / 3),
|
|
164
|
+
var(--baseline-height)
|
|
165
|
+
);
|
|
166
|
+
}
|
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
/* @canonical/styles — Importance modifier SHIM (temporary)
|
|
2
|
+
*
|
|
3
|
+
* The generated `@canonical/design-tokens/dist/modifiers.importance.css` is
|
|
4
|
+
* currently EMPTY: the `primary` / `secondary` / `tertiary` importance
|
|
5
|
+
* modifiers have no token mapping yet. This hand-authored shim provides a
|
|
6
|
+
* plausible mapping so importance-driven components (notably Button) can render
|
|
7
|
+
* their hierarchy today. It is expected to be superseded by the generated file
|
|
8
|
+
* once the importance tokens are ratified upstream — keep it minimal and remove
|
|
9
|
+
* it when that lands.
|
|
10
|
+
*
|
|
11
|
+
* Design contract — components listen to the CHANNEL, never to the class:
|
|
12
|
+
* Importance decides HOW colour is applied, not which colour. It exposes two
|
|
13
|
+
* channel hints that a consuming component reads generically (it must not key
|
|
14
|
+
* off `.primary` / `.secondary` / `.tertiary` directly):
|
|
15
|
+
*
|
|
16
|
+
* --modifier-surface the foreground channel that fills the background
|
|
17
|
+
* (a filled importance points it at the primary
|
|
18
|
+
* foreground; a ghost importance at the ghost
|
|
19
|
+
* foreground).
|
|
20
|
+
* --modifier-outline 1 when the importance shows a border, 0 when it does
|
|
21
|
+
* not. A component multiplies its border width by this.
|
|
22
|
+
*
|
|
23
|
+
* For a FILLED importance the text/icon must read as contrast ON the fill, so
|
|
24
|
+
* `.primary` also overrides `--modifier-color-text` / `--modifier-color-icon`
|
|
25
|
+
* with the on-foreground contrast tokens. This shim is imported after the
|
|
26
|
+
* anticipation/emphasis modifiers in the same `ds.modifiers` layer, so on a
|
|
27
|
+
* `.primary.destructive` button the anticipation colour drives the fill while
|
|
28
|
+
* this contrast text wins (equal specificity, later source order).
|
|
29
|
+
* `.secondary` pins its text to the root text colour by the same mechanism —
|
|
30
|
+
* per design, the secondary label never takes the anticipation colour. Only
|
|
31
|
+
* `.tertiary` leaves the text channel untouched, so the anticipation colour
|
|
32
|
+
* lands on the text — exactly the Figma treatment.
|
|
33
|
+
*/
|
|
34
|
+
|
|
35
|
+
@layer ds.modifiers {
|
|
36
|
+
/* Primary — filled: the primary foreground fills the background, no border,
|
|
37
|
+
and the label reads as contrast on the fill. The surface state variants
|
|
38
|
+
point at the primary-foreground state deltas from states.css. */
|
|
39
|
+
.primary {
|
|
40
|
+
--modifier-surface: var(
|
|
41
|
+
--modifier-color-foreground-primary,
|
|
42
|
+
var(--color-foreground-primary)
|
|
43
|
+
);
|
|
44
|
+
--modifier-surface-hover: var(--modifier-color-foreground-primary-hover);
|
|
45
|
+
--modifier-surface-active: var(--modifier-color-foreground-primary-active);
|
|
46
|
+
--modifier-surface-disabled: var(
|
|
47
|
+
--modifier-color-foreground-primary-disabled
|
|
48
|
+
);
|
|
49
|
+
--modifier-outline: 0;
|
|
50
|
+
--modifier-color-text: var(--color-text-onForegroundPrimary);
|
|
51
|
+
--modifier-color-text-disabled: var(
|
|
52
|
+
--color-text-onForegroundPrimary-disabled
|
|
53
|
+
);
|
|
54
|
+
/* The `--color-icon-onForegroundPrimary[-disabled]` tokens are broken
|
|
55
|
+
upstream (they reference a non-existent `on-foreground-primary` token);
|
|
56
|
+
use the working camelCase on-fill text tokens — the on-fill icon and
|
|
57
|
+
text share the same contrast colour. Remove once the icon tokens are
|
|
58
|
+
fixed upstream. */
|
|
59
|
+
--modifier-color-icon: var(--color-text-onForegroundPrimary);
|
|
60
|
+
--modifier-color-icon-disabled: var(
|
|
61
|
+
--color-text-onForegroundPrimary-disabled
|
|
62
|
+
);
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
/* Secondary — outlined: a ghost background with a visible border; the icon
|
|
66
|
+
keeps the modifier colour, but the label is pinned to the root text colour
|
|
67
|
+
(the anticipation colour shows on the border/fill states, not the text). */
|
|
68
|
+
.secondary {
|
|
69
|
+
--modifier-surface: var(
|
|
70
|
+
--modifier-color-foreground-ghost,
|
|
71
|
+
var(--surface-color-foreground-ghost, var(--color-foreground-ghost))
|
|
72
|
+
);
|
|
73
|
+
--modifier-surface-hover: var(--modifier-color-foreground-ghost-hover);
|
|
74
|
+
--modifier-surface-active: var(--modifier-color-foreground-ghost-active);
|
|
75
|
+
--modifier-surface-disabled: var(
|
|
76
|
+
--modifier-color-foreground-ghost-disabled
|
|
77
|
+
);
|
|
78
|
+
--modifier-outline: 1;
|
|
79
|
+
/* `color/text/root` compiles to the bare `--color-text` var; re-point at a
|
|
80
|
+
dedicated `button.secondary` semantic token once ratified upstream. */
|
|
81
|
+
--modifier-color-text: var(--color-text);
|
|
82
|
+
--modifier-color-text-disabled: var(--color-text-disabled);
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
/* Tertiary — text: a ghost background, no border; text/icon keep the modifier
|
|
86
|
+
colour (this is where the anticipation colour shows). */
|
|
87
|
+
.tertiary {
|
|
88
|
+
--modifier-surface: var(
|
|
89
|
+
--modifier-color-foreground-ghost,
|
|
90
|
+
var(--surface-color-foreground-ghost, var(--color-foreground-ghost))
|
|
91
|
+
);
|
|
92
|
+
--modifier-surface-hover: var(--modifier-color-foreground-ghost-hover);
|
|
93
|
+
--modifier-surface-active: var(--modifier-color-foreground-ghost-active);
|
|
94
|
+
--modifier-surface-disabled: var(
|
|
95
|
+
--modifier-color-foreground-ghost-disabled
|
|
96
|
+
);
|
|
97
|
+
--modifier-outline: 0;
|
|
98
|
+
}
|
|
99
|
+
}
|
|
@@ -0,0 +1,179 @@
|
|
|
1
|
+
/* @canonical/styles — Modifier state-channel SHIM (temporary)
|
|
2
|
+
*
|
|
3
|
+
* The generated modifier files expose only the ROOT colour channel
|
|
4
|
+
* (`--modifier-color-foreground-primary`, `--modifier-color-foreground-ghost`);
|
|
5
|
+
* they do not expose per-STATE channels. The explicit state tokens exist
|
|
6
|
+
* (`--color-foreground-primary-hover`, `-active`, `-disabled`, and their
|
|
7
|
+
* anticipation-suffixed variants), but nothing wires them into the channel, so
|
|
8
|
+
* a component that wants a hover/active/disabled colour has nothing to read —
|
|
9
|
+
* hover and focus appear to do nothing.
|
|
10
|
+
*
|
|
11
|
+
* This shim writes those explicit state tokens into new channel vars:
|
|
12
|
+
*
|
|
13
|
+
* --modifier-color-foreground-primary-hover / -active / -disabled
|
|
14
|
+
* --modifier-color-foreground-ghost-hover / -active / -disabled
|
|
15
|
+
*
|
|
16
|
+
* so a consumer reads the channel uniformly and the states compose with the
|
|
17
|
+
* anticipation modifier (each anticipation class re-points the channel at its
|
|
18
|
+
* own `-{anticipation}-{state}` tokens). Neutral defaults live on `:root`; the
|
|
19
|
+
* anticipation classes override in the `ds.modifiers` layer, imported after the
|
|
20
|
+
* generated modifiers so they win.
|
|
21
|
+
*
|
|
22
|
+
* Remove once the generated modifiers expose state channels upstream.
|
|
23
|
+
*/
|
|
24
|
+
|
|
25
|
+
@layer ds.modifiers {
|
|
26
|
+
/* Missing upstream tokens: `caution` uses the `warning` ramp, but the
|
|
27
|
+
warning ghost tokens (root + states) are not generated. Define plausible
|
|
28
|
+
values here, mirroring the destructive/constructive ghost pattern (a very
|
|
29
|
+
light / very dark tint at the ramp's hue — warning hue ≈ 66.86). Remove
|
|
30
|
+
once the warning ghost tokens are generated upstream. */
|
|
31
|
+
:root {
|
|
32
|
+
--color-foreground-ghost-warning: light-dark(
|
|
33
|
+
var(--color-palette-white),
|
|
34
|
+
var(--color-palette-gray-990)
|
|
35
|
+
);
|
|
36
|
+
--color-foreground-ghost-warning-hover: light-dark(
|
|
37
|
+
oklch(96% 0.06 66.86),
|
|
38
|
+
oklch(20% 0.045 66.86)
|
|
39
|
+
);
|
|
40
|
+
--color-foreground-ghost-warning-active: light-dark(
|
|
41
|
+
oklch(93% 0.08 66.86),
|
|
42
|
+
oklch(24% 0.05 66.86)
|
|
43
|
+
);
|
|
44
|
+
--color-foreground-ghost-warning-disabled: light-dark(
|
|
45
|
+
var(--color-palette-white),
|
|
46
|
+
oklch(12% 0 0)
|
|
47
|
+
);
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
/* Neutral defaults — the plain (non-anticipation) state tokens. */
|
|
51
|
+
:root {
|
|
52
|
+
--modifier-color-foreground-primary-hover: var(
|
|
53
|
+
--color-foreground-primary-hover
|
|
54
|
+
);
|
|
55
|
+
--modifier-color-foreground-primary-active: var(
|
|
56
|
+
--color-foreground-primary-active
|
|
57
|
+
);
|
|
58
|
+
--modifier-color-foreground-primary-disabled: var(
|
|
59
|
+
--color-foreground-primary-disabled
|
|
60
|
+
);
|
|
61
|
+
--modifier-color-foreground-ghost-hover: var(
|
|
62
|
+
--color-foreground-ghost-hover
|
|
63
|
+
);
|
|
64
|
+
--modifier-color-foreground-ghost-active: var(
|
|
65
|
+
--color-foreground-ghost-active
|
|
66
|
+
);
|
|
67
|
+
--modifier-color-foreground-ghost-disabled: var(
|
|
68
|
+
--color-foreground-ghost-disabled
|
|
69
|
+
);
|
|
70
|
+
--modifier-color-text-disabled: var(--color-text-disabled);
|
|
71
|
+
--modifier-color-icon-disabled: var(--color-icon-disabled);
|
|
72
|
+
/* The disabled border tracks the highlighted ramp the enabled border uses
|
|
73
|
+
(it matches the disabled-text tone), not the much fainter plain
|
|
74
|
+
border-disabled ramp. */
|
|
75
|
+
--modifier-color-border-disabled: var(--color-border-highlighted-disabled);
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
.constructive {
|
|
79
|
+
--modifier-color-foreground-primary-hover: var(
|
|
80
|
+
--color-foreground-primary-constructive-hover
|
|
81
|
+
);
|
|
82
|
+
--modifier-color-foreground-primary-active: var(
|
|
83
|
+
--color-foreground-primary-constructive-active
|
|
84
|
+
);
|
|
85
|
+
--modifier-color-foreground-primary-disabled: var(
|
|
86
|
+
--color-foreground-primary-constructive-disabled
|
|
87
|
+
);
|
|
88
|
+
--modifier-color-foreground-ghost-hover: var(
|
|
89
|
+
--color-foreground-ghost-constructive-hover
|
|
90
|
+
);
|
|
91
|
+
--modifier-color-foreground-ghost-active: var(
|
|
92
|
+
--color-foreground-ghost-constructive-active
|
|
93
|
+
);
|
|
94
|
+
--modifier-color-foreground-ghost-disabled: var(
|
|
95
|
+
--color-foreground-ghost-constructive-disabled
|
|
96
|
+
);
|
|
97
|
+
--modifier-color-text-disabled: var(--color-text-constructive-disabled);
|
|
98
|
+
--modifier-color-icon-disabled: var(--color-icon-constructive-disabled);
|
|
99
|
+
--modifier-color-border-disabled: var(--color-border-constructive-disabled);
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
.destructive {
|
|
103
|
+
--modifier-color-foreground-primary-hover: var(
|
|
104
|
+
--color-foreground-primary-destructive-hover
|
|
105
|
+
);
|
|
106
|
+
--modifier-color-foreground-primary-active: var(
|
|
107
|
+
--color-foreground-primary-destructive-active
|
|
108
|
+
);
|
|
109
|
+
--modifier-color-foreground-primary-disabled: var(
|
|
110
|
+
--color-foreground-primary-destructive-disabled
|
|
111
|
+
);
|
|
112
|
+
--modifier-color-foreground-ghost-hover: var(
|
|
113
|
+
--color-foreground-ghost-destructive-hover
|
|
114
|
+
);
|
|
115
|
+
--modifier-color-foreground-ghost-active: var(
|
|
116
|
+
--color-foreground-ghost-destructive-active
|
|
117
|
+
);
|
|
118
|
+
--modifier-color-foreground-ghost-disabled: var(
|
|
119
|
+
--color-foreground-ghost-destructive-disabled
|
|
120
|
+
);
|
|
121
|
+
--modifier-color-text-disabled: var(--color-text-destructive-disabled);
|
|
122
|
+
--modifier-color-icon-disabled: var(--color-icon-destructive-disabled);
|
|
123
|
+
--modifier-color-border-disabled: var(--color-border-destructive-disabled);
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
/* `caution` uses the `warning` colour ramp. The ghost-warning state tokens do
|
|
127
|
+
not exist upstream, so those fall back to the root ghost-warning colour. */
|
|
128
|
+
.caution {
|
|
129
|
+
/* The generated `.caution` modifier omits the ghost root channel that
|
|
130
|
+
destructive/constructive set — add it so caution ghost importances have a
|
|
131
|
+
base fill to state from. */
|
|
132
|
+
--modifier-color-foreground-ghost: var(--color-foreground-ghost-warning);
|
|
133
|
+
--modifier-color-foreground-primary-hover: var(
|
|
134
|
+
--color-foreground-primary-warning-hover
|
|
135
|
+
);
|
|
136
|
+
--modifier-color-foreground-primary-active: var(
|
|
137
|
+
--color-foreground-primary-warning-active
|
|
138
|
+
);
|
|
139
|
+
--modifier-color-foreground-primary-disabled: var(
|
|
140
|
+
--color-foreground-primary-warning-disabled
|
|
141
|
+
);
|
|
142
|
+
--modifier-color-foreground-ghost-hover: var(
|
|
143
|
+
--color-foreground-ghost-warning-hover
|
|
144
|
+
);
|
|
145
|
+
--modifier-color-foreground-ghost-active: var(
|
|
146
|
+
--color-foreground-ghost-warning-active
|
|
147
|
+
);
|
|
148
|
+
--modifier-color-foreground-ghost-disabled: var(
|
|
149
|
+
--color-foreground-ghost-warning-disabled
|
|
150
|
+
);
|
|
151
|
+
--modifier-color-text-disabled: var(--color-text-warning-disabled);
|
|
152
|
+
--modifier-color-icon-disabled: var(--color-icon-warning-disabled);
|
|
153
|
+
--modifier-color-border-disabled: var(--color-border-warning-disabled);
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
.branded {
|
|
157
|
+
--modifier-color-foreground-primary-hover: var(
|
|
158
|
+
--color-foreground-primary-branded-hover
|
|
159
|
+
);
|
|
160
|
+
--modifier-color-foreground-primary-active: var(
|
|
161
|
+
--color-foreground-primary-branded-active
|
|
162
|
+
);
|
|
163
|
+
--modifier-color-foreground-primary-disabled: var(
|
|
164
|
+
--color-foreground-primary-branded-disabled
|
|
165
|
+
);
|
|
166
|
+
--modifier-color-foreground-ghost-hover: var(
|
|
167
|
+
--color-foreground-ghost-branded-hover
|
|
168
|
+
);
|
|
169
|
+
--modifier-color-foreground-ghost-active: var(
|
|
170
|
+
--color-foreground-ghost-branded-active
|
|
171
|
+
);
|
|
172
|
+
--modifier-color-foreground-ghost-disabled: var(
|
|
173
|
+
--color-foreground-ghost-branded-disabled
|
|
174
|
+
);
|
|
175
|
+
--modifier-color-text-disabled: var(--color-text-branded-disabled);
|
|
176
|
+
--modifier-color-icon-disabled: var(--color-icon-branded-disabled);
|
|
177
|
+
--modifier-color-border-disabled: var(--color-border-branded-disabled);
|
|
178
|
+
}
|
|
179
|
+
}
|
package/src/spacing.css
CHANGED
|
@@ -16,10 +16,11 @@
|
|
|
16
16
|
|
|
17
17
|
:root {
|
|
18
18
|
/* ── Baseline grid ──────────────────────────────────────────────── */
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
19
|
+
/* SPIKE: the baseline unit is 4px (down from 8px). Set here in styles, NOT in
|
|
20
|
+
the design token — the token (--dimension-size-height-baseline) is left at
|
|
21
|
+
8px and intentionally no longer consumed, so this is the single place the
|
|
22
|
+
4px grid lives until it is promoted into design-tokens via its own PR. */
|
|
23
|
+
--space-baseline: 0.25rem; /* 4px — bU (was the 8px --dimension-size-height-baseline token) */
|
|
23
24
|
--baseline-height: var(
|
|
24
25
|
--space-baseline
|
|
25
26
|
); /* alias consumed by typography engine */
|