@canonical/styles 0.31.0 → 0.33.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 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.31.0",
4
+ "version": "0.33.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.31.0"
33
+ "@canonical/biome-config": "^0.33.0"
34
34
  },
35
35
  "dependencies": {
36
- "@canonical/design-tokens": "0.6.2-contrasted.0",
37
- "@canonical/styles-typography": "^0.31.0",
36
+ "@canonical/design-tokens": "0.8.1",
37
+ "@canonical/styles-typography": "^0.33.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": "d4a67ebe42e62b8cf3de77f42f537309ca88d672"
48
+ "gitHead": "fca2bc4440fff2d511fc8db6686f9b19222fdbc7"
49
49
  }
@@ -31,10 +31,16 @@
31
31
  * comfy dense comfy dense
32
32
  * line-height 32 (8) 24 (6) 36 (9) 28 (7)
33
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)
34
+ * space-lg 40 (10) 32 (8) 44 (11) 36 (9) ← between fields
35
+ * space-md 8 (2) 4 (1) 8 (2) 8 (2) ← label → control
36
+ * space-sm 8 (2) 4 (1) 8 (2) 8 (2) ← desc/error → input
37
+ * space-xs 4 (1) 4 (1) 4 (1) 4 (1) ← label → description
37
38
  * (parenthesised = baseline units; 1 bU = --baseline-height = 4px)
39
+ *
40
+ * NB the space-lg / space-md values were retuned from Diana's 15/07 review
41
+ * (label→input 8px, between-fields 40px), and space-xs (label→description 4px)
42
+ * added, replacing the earlier graded 16/24 rungs. The values stay whole
43
+ * baseline multiples, so vertical rhythm holds.
38
44
  */
39
45
 
40
46
  /* ── Context family: the comfortable/dense PAIR per surface ──────────────────
@@ -49,12 +55,14 @@
49
55
  --density-lh-dense: calc(var(--baseline-height) * 6); /* 24px */
50
56
  --density-pad-inline-comfy: calc(var(--baseline-height) * 4); /* 16px */
51
57
  --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 */
58
+ --density-space-lg-comfy: calc(var(--baseline-height) * 10); /* 40px */
59
+ --density-space-lg-dense: calc(var(--baseline-height) * 8); /* 32px */
60
+ --density-space-md-comfy: calc(var(--baseline-height) * 2); /* 8px */
61
+ --density-space-md-dense: calc(var(--baseline-height) * 1); /* 4px */
56
62
  --density-space-sm-comfy: calc(var(--baseline-height) * 2); /* 8px */
57
63
  --density-space-sm-dense: calc(var(--baseline-height) * 1); /* 4px */
64
+ --density-space-xs-comfy: calc(var(--baseline-height) * 1); /* 4px */
65
+ --density-space-xs-dense: calc(var(--baseline-height) * 1); /* 4px */
58
66
 
59
67
  /* Back-compat aliases (pre-namespace names). Remove once no consumer reads them. */
60
68
  --lh-comfy: var(--density-lh-comfy);
@@ -74,12 +82,14 @@
74
82
  --density-lh-dense: calc(var(--baseline-height) * 7); /* 28px */
75
83
  --density-pad-inline-comfy: calc(var(--baseline-height) * 4); /* 16px */
76
84
  --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 */
85
+ --density-space-lg-comfy: calc(var(--baseline-height) * 11); /* 44px */
86
+ --density-space-lg-dense: calc(var(--baseline-height) * 9); /* 36px */
87
+ --density-space-md-comfy: calc(var(--baseline-height) * 2); /* 8px */
88
+ --density-space-md-dense: calc(var(--baseline-height) * 2); /* 8px */
81
89
  --density-space-sm-comfy: calc(var(--baseline-height) * 2); /* 8px */
82
90
  --density-space-sm-dense: calc(var(--baseline-height) * 2); /* 8px */
91
+ --density-space-xs-comfy: calc(var(--baseline-height) * 1); /* 4px */
92
+ --density-space-xs-dense: calc(var(--baseline-height) * 1); /* 4px */
83
93
 
84
94
  /* Back-compat aliases (pre-namespace names). Remove once no consumer reads them. */
85
95
  --lh-comfy: var(--density-lh-comfy);
@@ -109,16 +119,20 @@
109
119
  );
110
120
  --density-space-lg: var(
111
121
  --density-space-lg-comfy,
112
- calc(var(--baseline-height) * 6)
122
+ calc(var(--baseline-height) * 10)
113
123
  );
114
124
  --density-space-md: var(
115
125
  --density-space-md-comfy,
116
- calc(var(--baseline-height) * 4)
126
+ calc(var(--baseline-height) * 2)
117
127
  );
118
128
  --density-space-sm: var(
119
129
  --density-space-sm-comfy,
120
130
  calc(var(--baseline-height) * 2)
121
131
  );
132
+ --density-space-xs: var(
133
+ --density-space-xs-comfy,
134
+ calc(var(--baseline-height) * 1)
135
+ );
122
136
  }
123
137
  .dense {
124
138
  --density-line-height: var(
@@ -131,22 +145,36 @@
131
145
  );
132
146
  --density-space-lg: var(
133
147
  --density-space-lg-dense,
134
- calc(var(--baseline-height) * 4)
148
+ calc(var(--baseline-height) * 8)
135
149
  );
136
150
  --density-space-md: var(
137
151
  --density-space-md-dense,
138
- calc(var(--baseline-height) * 2)
152
+ calc(var(--baseline-height) * 1)
139
153
  );
140
154
  --density-space-sm: var(
141
155
  --density-space-sm-dense,
142
156
  calc(var(--baseline-height) * 1)
143
157
  );
158
+ --density-space-xs: var(
159
+ --density-space-xs-dense,
160
+ calc(var(--baseline-height) * 1)
161
+ );
144
162
  }
145
163
 
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. */
164
+ /* ── Target baseline = round(nearest, height × 2/3) ─────────────────────────
165
+ * The control text seats where line-height × 2/3 lands on the grid — the optical
166
+ * centre of the box — snapped to the NEAREST grid line, not the next one up.
167
+ * Nearest (not up) because up over-lifts the one cell where lh × 2/3 is
168
+ * fractional: apps-comfortable is 32 × 2/3 = 21.33px, which round(up) forced a
169
+ * whole step onto the 24px line (6th), a baseline too low. round(nearest) seats
170
+ * it on the 20px line (5th) — Diana's F-O2 "move text 1 baseline up in
171
+ * apps/comfortable" (AV-323). The exact-multiple cells are unaffected:
172
+ * apps-comfy 21.33 → 20 (5th) ← the fix; was 24
173
+ * apps-dense 16.00 → 16 (4th) unchanged (exact)
174
+ * sites-comfy 24.00 → 24 (6th) unchanged (exact)
175
+ * sites-dense 18.67 → 20 (5th) unchanged (nearest == up here)
176
+ * So it's a self-correcting rule, not a per-cell offset: any future fractional
177
+ * cell snaps to its nearest line too. */
150
178
  :where(.comfortable, .dense, .app, .site, .docs) {
151
179
  /* Effective line-height with the SAME fallback chain a control box uses
152
180
  (--density-line-height → context --density-lh-comfy → apps-comfy literal).
@@ -159,8 +187,48 @@
159
187
  var(--density-lh-comfy, calc(var(--baseline-height) * 8))
160
188
  );
161
189
  --density-target-baseline-px: round(
162
- up,
190
+ nearest,
163
191
  calc(var(--density-line-height-effective) * 2 / 3),
164
192
  var(--baseline-height)
165
193
  );
194
+
195
+ /* ── Control seat (intrinsic) ──────────────────────────────────────────────
196
+ * ONE seat for every control (button, input chrome, accordion header, …):
197
+ * the text's own line box — the density cell minus one baseline of headroom
198
+ * per side (`--control-seat-line`) — IS the control interior. The height is
199
+ * INTRINSIC: no block-size; border + pads + line-height add up to the cell,
200
+ * and both outer edges land on grid lines.
201
+ *
202
+ * The shared layer exports the two BORDER-AGNOSTIC pieces. A var() inside a
203
+ * custom property is substituted where the property is DECLARED — here, the
204
+ * density scope — so a component's border can never be a formula input at
205
+ * this level; each component folds its own border in at the application site
206
+ * (single-line <input>/<select> also floor the line at the UA's `normal`
207
+ * minimum — see the form package's density.css):
208
+ *
209
+ * --seat-before: max(0px, calc(
210
+ * var(--control-seat-basis) - <border-width>));
211
+ * --seat-after: max(0px, calc(
212
+ * var(--density-line-height-effective) - var(--control-seat-line) -
213
+ * var(--seat-before) - 2 * <border-width>));
214
+ * line-height: var(--control-seat-line);
215
+ * padding-block: var(--seat-before) var(--seat-after);
216
+ *
217
+ * `1cap` below stays an unresolved token inside the custom property and only
218
+ * resolves where the seat is APPLIED — each component's own font — so
219
+ * components with different fonts still seat on the SAME grid index. The
220
+ * border must be the control's CONSTANT nominal width (transparent where no
221
+ * border shows), so bordered and borderless variants share one geometry. */
222
+ --control-seat-line: calc(
223
+ var(--density-line-height-effective) -
224
+ 2 *
225
+ var(--baseline-height)
226
+ );
227
+ /* Unclamped distance from just inside the box's top border down to the
228
+ target baseline, for a --control-seat-line line box. */
229
+ --control-seat-basis: calc(
230
+ var(--density-target-baseline-px) -
231
+ (var(--control-seat-line) + 1cap) /
232
+ 2
233
+ );
166
234
  }