@canonical/styles 0.28.0 → 0.30.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/index.css +16 -0
- package/src/modifiers.criticality.shim.css +47 -0
- package/src/modifiers.importance.shim.css +92 -0
- package/src/modifiers.states.shim.css +171 -0
- package/src/motion.css +22 -0
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.30.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.30.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.30.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": "40fe86ac955473536ac14f074812a9821f5b65c0"
|
|
49
49
|
}
|
package/src/index.css
CHANGED
|
@@ -21,6 +21,19 @@
|
|
|
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
|
+
@import url("./modifiers.states.shim.css");
|
|
35
|
+
@import url("./modifiers.importance.shim.css");
|
|
36
|
+
@import url("./modifiers.criticality.shim.css");
|
|
24
37
|
@import url("@canonical/design-tokens/dist/states.css");
|
|
25
38
|
|
|
26
39
|
/* Grid layout presets */
|
|
@@ -31,3 +44,6 @@
|
|
|
31
44
|
|
|
32
45
|
/* Scroll overflow affordance tokens */
|
|
33
46
|
@import url("./overflow.css");
|
|
47
|
+
|
|
48
|
+
/* Motion tokens (placeholder durations/easings) */
|
|
49
|
+
@import url("./motion.css");
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
/* @canonical/styles — Criticality modifier ICON 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 NOT an icon channel: nothing
|
|
6
|
+
* says *which glyph* signals "information" vs "warning" etc. Criticality-driven
|
|
7
|
+
* components (Announcement, and future callouts) each hard-code that mapping in
|
|
8
|
+
* their own markup today.
|
|
9
|
+
*
|
|
10
|
+
* This hand-authored shim adds a single channel, keyed off the criticality
|
|
11
|
+
* class, that carries the glyph as a CSS `mask-image` reference into the
|
|
12
|
+
* Canonical icon set (served at `/icons/<name>.svg`):
|
|
13
|
+
*
|
|
14
|
+
* --modifier-icon a `mask-image` value; a component masks a pseudo-element
|
|
15
|
+
* with it and fills it with `--modifier-color-icon`, so the
|
|
16
|
+
* glyph both matches the criticality AND takes its colour.
|
|
17
|
+
*
|
|
18
|
+
* Design contract — components listen to the CHANNEL, never to the class. A
|
|
19
|
+
* consumer must not key off `.information` / `.warning`; it reads
|
|
20
|
+
* `--modifier-icon` generically, so any criticality gets the right glyph for
|
|
21
|
+
* free. This mirrors the mask technique used by Accordion's chevron and the
|
|
22
|
+
* form CheckboxInput's checkmark (mask-image + background-color so the glyph is
|
|
23
|
+
* recolourable, unlike a background-image SVG).
|
|
24
|
+
*
|
|
25
|
+
* Imported into the `ds.modifiers` layer after the generated criticality
|
|
26
|
+
* modifiers so these class rules compose at equal specificity, later source
|
|
27
|
+
* order. Remove once an icon channel is generated upstream in the criticality
|
|
28
|
+
* modifier tokens.
|
|
29
|
+
*/
|
|
30
|
+
|
|
31
|
+
@layer ds.modifiers {
|
|
32
|
+
.information {
|
|
33
|
+
--modifier-icon: url("/icons/information.svg#information");
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
.success {
|
|
37
|
+
--modifier-icon: url("/icons/success.svg#success");
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
.warning {
|
|
41
|
+
--modifier-icon: url("/icons/warning.svg#warning");
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
.error {
|
|
45
|
+
--modifier-icon: url("/icons/error.svg#error");
|
|
46
|
+
}
|
|
47
|
+
}
|
|
@@ -0,0 +1,92 @@
|
|
|
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). For ghost
|
|
29
|
+
* importances the text channel is left untouched, so the anticipation colour
|
|
30
|
+
* lands on the text — exactly the Figma treatment.
|
|
31
|
+
*/
|
|
32
|
+
|
|
33
|
+
@layer ds.modifiers {
|
|
34
|
+
/* Primary — filled: the primary foreground fills the background, no border,
|
|
35
|
+
and the label reads as contrast on the fill. The surface state variants
|
|
36
|
+
point at the primary-foreground state deltas from states.css. */
|
|
37
|
+
.primary {
|
|
38
|
+
--modifier-surface: var(
|
|
39
|
+
--modifier-color-foreground-primary,
|
|
40
|
+
var(--color-foreground-primary)
|
|
41
|
+
);
|
|
42
|
+
--modifier-surface-hover: var(--modifier-color-foreground-primary-hover);
|
|
43
|
+
--modifier-surface-active: var(--modifier-color-foreground-primary-active);
|
|
44
|
+
--modifier-surface-disabled: var(
|
|
45
|
+
--modifier-color-foreground-primary-disabled
|
|
46
|
+
);
|
|
47
|
+
--modifier-outline: 0;
|
|
48
|
+
--modifier-color-text: var(--color-text-onForegroundPrimary);
|
|
49
|
+
--modifier-color-text-disabled: var(
|
|
50
|
+
--color-text-onForegroundPrimary-disabled
|
|
51
|
+
);
|
|
52
|
+
/* The `--color-icon-onForegroundPrimary[-disabled]` tokens are broken
|
|
53
|
+
upstream (they reference a non-existent `on-foreground-primary` token);
|
|
54
|
+
use the working camelCase on-fill text tokens — the on-fill icon and
|
|
55
|
+
text share the same contrast colour. Remove once the icon tokens are
|
|
56
|
+
fixed upstream. */
|
|
57
|
+
--modifier-color-icon: var(--color-text-onForegroundPrimary);
|
|
58
|
+
--modifier-color-icon-disabled: var(
|
|
59
|
+
--color-text-onForegroundPrimary-disabled
|
|
60
|
+
);
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
/* Secondary — outlined: a ghost background with a visible border; text/icon
|
|
64
|
+
keep the modifier colour. */
|
|
65
|
+
.secondary {
|
|
66
|
+
--modifier-surface: var(
|
|
67
|
+
--modifier-color-foreground-ghost,
|
|
68
|
+
var(--surface-color-foreground-ghost, var(--color-foreground-ghost))
|
|
69
|
+
);
|
|
70
|
+
--modifier-surface-hover: var(--modifier-color-foreground-ghost-hover);
|
|
71
|
+
--modifier-surface-active: var(--modifier-color-foreground-ghost-active);
|
|
72
|
+
--modifier-surface-disabled: var(
|
|
73
|
+
--modifier-color-foreground-ghost-disabled
|
|
74
|
+
);
|
|
75
|
+
--modifier-outline: 1;
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
/* Tertiary — text: a ghost background, no border; text/icon keep the modifier
|
|
79
|
+
colour (this is where the anticipation colour shows). */
|
|
80
|
+
.tertiary {
|
|
81
|
+
--modifier-surface: var(
|
|
82
|
+
--modifier-color-foreground-ghost,
|
|
83
|
+
var(--surface-color-foreground-ghost, var(--color-foreground-ghost))
|
|
84
|
+
);
|
|
85
|
+
--modifier-surface-hover: var(--modifier-color-foreground-ghost-hover);
|
|
86
|
+
--modifier-surface-active: var(--modifier-color-foreground-ghost-active);
|
|
87
|
+
--modifier-surface-disabled: var(
|
|
88
|
+
--modifier-color-foreground-ghost-disabled
|
|
89
|
+
);
|
|
90
|
+
--modifier-outline: 0;
|
|
91
|
+
}
|
|
92
|
+
}
|
|
@@ -0,0 +1,171 @@
|
|
|
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
|
+
}
|
|
73
|
+
|
|
74
|
+
.constructive {
|
|
75
|
+
--modifier-color-foreground-primary-hover: var(
|
|
76
|
+
--color-foreground-primary-constructive-hover
|
|
77
|
+
);
|
|
78
|
+
--modifier-color-foreground-primary-active: var(
|
|
79
|
+
--color-foreground-primary-constructive-active
|
|
80
|
+
);
|
|
81
|
+
--modifier-color-foreground-primary-disabled: var(
|
|
82
|
+
--color-foreground-primary-constructive-disabled
|
|
83
|
+
);
|
|
84
|
+
--modifier-color-foreground-ghost-hover: var(
|
|
85
|
+
--color-foreground-ghost-constructive-hover
|
|
86
|
+
);
|
|
87
|
+
--modifier-color-foreground-ghost-active: var(
|
|
88
|
+
--color-foreground-ghost-constructive-active
|
|
89
|
+
);
|
|
90
|
+
--modifier-color-foreground-ghost-disabled: var(
|
|
91
|
+
--color-foreground-ghost-constructive-disabled
|
|
92
|
+
);
|
|
93
|
+
--modifier-color-text-disabled: var(--color-text-constructive-disabled);
|
|
94
|
+
--modifier-color-icon-disabled: var(--color-icon-constructive-disabled);
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
.destructive {
|
|
98
|
+
--modifier-color-foreground-primary-hover: var(
|
|
99
|
+
--color-foreground-primary-destructive-hover
|
|
100
|
+
);
|
|
101
|
+
--modifier-color-foreground-primary-active: var(
|
|
102
|
+
--color-foreground-primary-destructive-active
|
|
103
|
+
);
|
|
104
|
+
--modifier-color-foreground-primary-disabled: var(
|
|
105
|
+
--color-foreground-primary-destructive-disabled
|
|
106
|
+
);
|
|
107
|
+
--modifier-color-foreground-ghost-hover: var(
|
|
108
|
+
--color-foreground-ghost-destructive-hover
|
|
109
|
+
);
|
|
110
|
+
--modifier-color-foreground-ghost-active: var(
|
|
111
|
+
--color-foreground-ghost-destructive-active
|
|
112
|
+
);
|
|
113
|
+
--modifier-color-foreground-ghost-disabled: var(
|
|
114
|
+
--color-foreground-ghost-destructive-disabled
|
|
115
|
+
);
|
|
116
|
+
--modifier-color-text-disabled: var(--color-text-destructive-disabled);
|
|
117
|
+
--modifier-color-icon-disabled: var(--color-icon-destructive-disabled);
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
/* `caution` uses the `warning` colour ramp. The ghost-warning state tokens do
|
|
121
|
+
not exist upstream, so those fall back to the root ghost-warning colour. */
|
|
122
|
+
.caution {
|
|
123
|
+
/* The generated `.caution` modifier omits the ghost root channel that
|
|
124
|
+
destructive/constructive set — add it so caution ghost importances have a
|
|
125
|
+
base fill to state from. */
|
|
126
|
+
--modifier-color-foreground-ghost: var(--color-foreground-ghost-warning);
|
|
127
|
+
--modifier-color-foreground-primary-hover: var(
|
|
128
|
+
--color-foreground-primary-warning-hover
|
|
129
|
+
);
|
|
130
|
+
--modifier-color-foreground-primary-active: var(
|
|
131
|
+
--color-foreground-primary-warning-active
|
|
132
|
+
);
|
|
133
|
+
--modifier-color-foreground-primary-disabled: var(
|
|
134
|
+
--color-foreground-primary-warning-disabled
|
|
135
|
+
);
|
|
136
|
+
--modifier-color-foreground-ghost-hover: var(
|
|
137
|
+
--color-foreground-ghost-warning-hover
|
|
138
|
+
);
|
|
139
|
+
--modifier-color-foreground-ghost-active: var(
|
|
140
|
+
--color-foreground-ghost-warning-active
|
|
141
|
+
);
|
|
142
|
+
--modifier-color-foreground-ghost-disabled: var(
|
|
143
|
+
--color-foreground-ghost-warning-disabled
|
|
144
|
+
);
|
|
145
|
+
--modifier-color-text-disabled: var(--color-text-warning-disabled);
|
|
146
|
+
--modifier-color-icon-disabled: var(--color-icon-warning-disabled);
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
.branded {
|
|
150
|
+
--modifier-color-foreground-primary-hover: var(
|
|
151
|
+
--color-foreground-primary-branded-hover
|
|
152
|
+
);
|
|
153
|
+
--modifier-color-foreground-primary-active: var(
|
|
154
|
+
--color-foreground-primary-branded-active
|
|
155
|
+
);
|
|
156
|
+
--modifier-color-foreground-primary-disabled: var(
|
|
157
|
+
--color-foreground-primary-branded-disabled
|
|
158
|
+
);
|
|
159
|
+
--modifier-color-foreground-ghost-hover: var(
|
|
160
|
+
--color-foreground-ghost-branded-hover
|
|
161
|
+
);
|
|
162
|
+
--modifier-color-foreground-ghost-active: var(
|
|
163
|
+
--color-foreground-ghost-branded-active
|
|
164
|
+
);
|
|
165
|
+
--modifier-color-foreground-ghost-disabled: var(
|
|
166
|
+
--color-foreground-ghost-branded-disabled
|
|
167
|
+
);
|
|
168
|
+
--modifier-color-text-disabled: var(--color-text-branded-disabled);
|
|
169
|
+
--modifier-color-icon-disabled: var(--color-icon-branded-disabled);
|
|
170
|
+
}
|
|
171
|
+
}
|
package/src/motion.css
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
/* @canonical/styles — Motion tokens
|
|
2
|
+
*
|
|
3
|
+
* PLACEHOLDER durations and easings. These are provisional values chosen to be
|
|
4
|
+
* plausible defaults; they are NOT yet ratified by design and will migrate to
|
|
5
|
+
* @canonical/design-tokens once validated. Components should reference these
|
|
6
|
+
* tokens rather than hardcoding transition timings.
|
|
7
|
+
*
|
|
8
|
+
* Convention: ALL available custom properties are listed here so the full API
|
|
9
|
+
* surface is visible in one place.
|
|
10
|
+
*/
|
|
11
|
+
|
|
12
|
+
:root {
|
|
13
|
+
/* ── Durations ──────────────────────────────────────────────────── */
|
|
14
|
+
--motion-duration-fast: 0.165s; /* small state changes: chevrons, toggles */
|
|
15
|
+
--motion-duration-medium: 0.25s; /* panels, disclosures */
|
|
16
|
+
--motion-duration-slow: 0.4s; /* larger transitions, overlays */
|
|
17
|
+
|
|
18
|
+
/* ── Easings ────────────────────────────────────────────────────── */
|
|
19
|
+
--motion-easing-standard: ease-out; /* enter/exit default */
|
|
20
|
+
--motion-easing-decelerate: cubic-bezier(0, 0, 0.2, 1); /* entering */
|
|
21
|
+
--motion-easing-accelerate: cubic-bezier(0.4, 0, 1, 1); /* exiting */
|
|
22
|
+
}
|