@kabmo-labs/kabmo 0.19.0 → 0.21.1

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.
Files changed (50) hide show
  1. package/README.md +32 -5
  2. package/dist/client/index.html +3 -3
  3. package/dist/client/index.js +340 -340
  4. package/dist/client/static/js/{index-sxdw908m.css → index-0721wrkf.css} +1 -1
  5. package/dist/client/static/js/{index-fcee4c13.js → index-thwqf24c.js} +685 -685
  6. package/dist/client/static/{manifest-42r8wcmg.webmanifest → manifest-q6h8k9e0.webmanifest} +1 -1
  7. package/index.html +1 -1
  8. package/package.json +1 -1
  9. package/public/manifest.webmanifest +1 -1
  10. package/src/client/components/common/checkbox/style.test.ts +11 -8
  11. package/src/client/components/common/panel-mark/index.test.tsx +124 -0
  12. package/src/client/components/common/panel-mark/index.tsx +9 -1
  13. package/src/client/components/settings/categories/panel-plugins/GitFreshness.test.tsx +46 -0
  14. package/src/client/components/settings/categories/panel-plugins/GitFreshness.tsx +1 -1
  15. package/src/client/components/settings/categories/panel-plugins/InstalledList.tsx +7 -9
  16. package/src/client/components/settings/categories/panel-plugins/PluginCard.test.tsx +149 -0
  17. package/src/client/components/settings/categories/panel-plugins/PluginCard.tsx +33 -6
  18. package/src/client/components/settings/categories/panel-plugins/PluginMark.test.ts +15 -0
  19. package/src/client/components/settings/categories/panel-plugins/PluginMark.tsx +6 -2
  20. package/src/client/components/settings/categories/panel-plugins/Section.tsx +7 -1
  21. package/src/client/components/settings/categories/panel-plugins/Toolbar.tsx +35 -2
  22. package/src/client/glass-sticky.test.ts +46 -0
  23. package/src/client/glass.css +27 -17
  24. package/src/client/glass.test.ts +21 -61
  25. package/src/client/hooks/ui/stuck-header.test.ts +28 -3
  26. package/src/client/hooks/ui/stuck-header.ts +36 -5
  27. package/src/client/hooks/workspace/panel-registry.ts +8 -4
  28. package/src/server/lib/lifecycle/tls.test.ts +6 -1
  29. package/src/server/lib/panels/git-update.server.test.ts +20 -0
  30. package/src/server/lib/panels/git-update.server.ts +20 -4
  31. package/src/server/lib/panels/sync.server.ts +9 -1
  32. package/src/server/lib/panels/update.server.test.ts +193 -0
  33. package/src/server/lib/panels/update.server.ts +210 -0
  34. package/src/server/lib/plugins/server-half.server.ts +42 -0
  35. package/src/server/lib/terminal/attach-replay.test.ts +26 -8
  36. package/src/server/routes/panels/install-route.test.ts +238 -0
  37. package/src/server/routes/panels/install.ts +36 -64
  38. package/src/server/routes/panels/panel-routes.test-util.ts +6 -1
  39. package/src/server/routes/panels/routes.test.ts +1 -118
  40. package/src/shared/lib/icons/icon-paint-css.test.ts +104 -25
  41. package/src/shared/lib/icons/icon-paint-css.ts +60 -50
  42. package/src/shared/lib/icons/icon-paint-panel.ts +16 -7
  43. package/src/shared/lib/icons/icon-paint-weight.ts +123 -0
  44. package/src/shared/lib/icons/icon-tone.ts +166 -0
  45. package/src/shared/lib/icons/tint-hues.generated.ts +50 -3
  46. package/src/shared/lib/icons/tint.test.ts +75 -15
  47. package/src/shared/lib/icons/tint.ts +40 -11
  48. package/src/shared/lib/panels/update.test.ts +107 -0
  49. package/src/shared/lib/panels/update.ts +73 -0
  50. package/src/shared/lib/theme/color.ts +50 -0
@@ -28,6 +28,7 @@ import {
28
28
  import { BRAND_COLORS } from '@/shared/lib/models/provider/brand-color';
29
29
  import { FILE_BRAND_COLORS } from '@/shared/lib/icons/file-brand-color';
30
30
  import { ICON_HUE_ROWS, ICON_TINT_ROWS, ICON_TINT_TOKENS } from '@/shared/lib/icons/tint';
31
+ import { ICON_TONES } from '@/shared/lib/icons/tint-hues.generated';
31
32
 
32
33
  const css = iconPaintStyleSheet();
33
34
  const rules = css.split('\n').filter((line) => line.startsWith(':where('));
@@ -82,31 +83,43 @@ describe('the icon paint stylesheet', () => {
82
83
  expect(css).toContain('[data-tool-row] [data-plugin-mark] { --plugin-color: var(--theme-ink); }');
83
84
  });
84
85
 
85
- test('a muted ink icon takes its hue, muted toward the ink rather than faded out', () => {
86
+ test('a muted ink icon keeps its hue and only loses CHROMA', () => {
86
87
  // `text-ink/60` is a WEIGHT. It is (0,1,0) and the hue rules are (0,0,0), so
87
88
  // the mute won and every muted icon stayed ink in the colour mode — the
88
89
  // reported "icon di setting modal kenapa gk full color".
89
- expect(css).toContain('[data-icon-style="color"] svg.lucide:not(.project-accent-mark)[class*="text-ink/60"] { color: color-mix(in srgb,');
90
- expect(css).toContain('[data-icon-style="color"] svg.lucide:not(.project-accent-mark)[class~="text-ink"] { color: hsl(var(--icon-hue');
91
- // Mixed toward the INK, never toward transparency: a hue at 40% alpha is
92
- // 1.56:1 against its surface, worse than the `text-ink/40` it replaces.
90
+ //
91
+ // The weight multiplies CHROMA and leaves LIGHTNESS alone. Mixing toward the
92
+ // ink also darkens, which is the opposite of a mute: measured, a muted
93
+ // settings icon read 7.48:1 where the active one read 3.96:1 and the
94
+ // monochrome ink it replaced read 4.74:1 — darker than both, which is the
95
+ // "masih kusam di light mode" report.
96
+ // `[class~=…]`, never `[class*=…]`: a substring match also fires on the
97
+ // VARIANT token — `text-ink/50 group-hover:text-ink/80` matched both, so the
98
+ // resting icon was painted at its hover weight (measured on the composer's
99
+ // target picker, `Folder` computed the `/80` paint while not hovered).
100
+ expect(css).toContain('[data-icon-style="color"] svg.lucide:not(.project-accent-mark)[class~="text-ink/60"] { --icon-paint: oklch(from var(--icon-color) l calc(c * 0.6) h); }');
101
+ expect(css).toContain('[data-icon-style="color"] svg.lucide:not(.project-accent-mark)[class~="text-ink"] { --icon-paint: var(--icon-color); }');
102
+ expect(css).not.toContain('[class*="text-ink/');
103
+ // Never toward transparency: a hue at 40% alpha is 1.56:1 against its
104
+ // surface, worse than the `text-ink/40` it replaces.
93
105
  const muted = css.split('\n').find((line) => line.includes('text-ink/40"')) ?? '';
94
- expect(muted).toContain('var(--theme-ink)');
106
+ expect(muted).toContain('oklch(from');
95
107
  expect(muted).not.toContain('transparent');
108
+ expect(muted).not.toContain('var(--theme-ink)');
96
109
  });
97
110
 
98
111
  test('the project accent survives the dark ink weights', () => {
99
112
  // Each folder mark carries the user's OWN colour as `--project-accent`, and
100
113
  // the call sites also write `text-ink/70`. The dark weight selector is
101
- // `[data-icon-style="color"][data-theme-variant="dark"] svg.lucide[class*="text-ink/70"]`
114
+ // `[data-icon-style="color"][data-theme-variant="dark"] svg.lucide[class~="text-ink/70"]`
102
115
  // = (0,4,1) — one ELEMENT above
103
116
  // `:root[data-icon-style="color"] .project-accent-mark` = (0,4,0) — so on a
104
117
  // dark theme every folder icon came out the same hue and light looked fine.
105
118
  // "A weight does not apply to the user's own colour" is the fix; out-specifying
106
119
  // it would be a tie waiting for the next attribute.
107
- expect(css).toContain('[data-icon-style="color"] svg.lucide:not(.project-accent-mark)[class*="text-ink/70"]');
120
+ expect(css).toContain('[data-icon-style="color"] svg.lucide:not(.project-accent-mark)[class~="text-ink/70"]');
108
121
  expect(css).toContain(
109
- '[data-icon-style="color"][data-theme-variant="dark"] svg.lucide:not(.project-accent-mark)[class*="text-ink/70"]',
122
+ '[data-icon-style="color"][data-theme-variant="dark"] svg.lucide:not(.project-accent-mark)[class~="text-ink/70"]',
110
123
  );
111
124
  expect(css).toContain(':root[data-icon-style="color"] .project-accent-mark { color: var(--project-accent); }');
112
125
  // Every weight rule, not just the one probed by hand: a single step that
@@ -131,21 +144,25 @@ describe('the icon paint stylesheet', () => {
131
144
  }
132
145
  });
133
146
 
134
- test('the base hue rule paints a custom-property hsl(), per variant', () => {
135
- expect(css).toContain(':where(svg.lucide) { color: hsl(var(--icon-hue,');
136
- expect(css).toContain(':where([data-icon-style="color"][data-theme-variant="dark"]) :where(svg.lucide) { color: hsl(var(--icon-hue,');
147
+ test('the base hue rule states --icon-color, per variant, and one rule paints it', () => {
148
+ expect(css).toContain(':where(svg.lucide) { --icon-color: var(--icon-tone, hsl(var(--icon-hue,');
149
+ expect(css).toContain(':where([data-icon-style="color"][data-theme-variant="dark"]) :where(svg.lucide) { --icon-color: hsl(var(--icon-hue,');
150
+ // ONE `color:` statement, derived from the two custom properties. Stating it
151
+ // per source instead made the weight rules fight them on specificity, and a
152
+ // signal token could be overwritten by winning that race.
153
+ expect(css).toContain('[data-icon-style="color"] :is(svg.lucide, svg[data-provider], svg[data-file-brand]) { --icon-paint: var(--icon-color); color: var(--icon-paint); }');
137
154
  });
138
155
 
139
156
  test('one hue statement per generated row', () => {
140
157
  for (const { className, hue } of ICON_HUE_ROWS) {
141
- expect(css).toContain(`:where(svg.${className}) { --icon-hue: ${hue}; }`);
158
+ expect(css).toContain(`:where(svg.${className}) { --icon-hue: ${hue}; --icon-tone: ${ICON_TONES[hue]}; }`);
142
159
  }
143
160
  });
144
161
 
145
162
  test('every signal row paints its palette token, after the hue rows', () => {
146
163
  const hueIndex = css.indexOf('--icon-hue');
147
164
  for (const { className, role } of ICON_TINT_ROWS) {
148
- const needle = `:where(svg.${className}) { color: ${ICON_TINT_TOKENS[role]}; }`;
165
+ const needle = `:where(svg.${className}) { --icon-color: ${ICON_TINT_TOKENS[role]}; }`;
149
166
  expect(css).toContain(needle);
150
167
  expect(css.indexOf(needle), `${className} must follow the hue rules`).toBeGreaterThan(hueIndex);
151
168
  }
@@ -154,23 +171,23 @@ describe('the icon paint stylesheet', () => {
154
171
  test('every provider row paints both variants', () => {
155
172
  for (const [name, entry] of Object.entries(BRAND_COLORS)) {
156
173
  const selector = `svg[data-provider="${name}"]`;
157
- expect(css).toContain(`:where(${selector}) { color: ${entry.light}; }`);
158
- expect(css).toContain(`color: ${entry.dark ?? 'var(--theme-ink)'}; }`);
174
+ expect(css).toContain(`:where(${selector}) { --icon-color: ${entry.light}; }`);
175
+ expect(css).toContain(`--icon-color: ${entry.dark ?? 'var(--theme-ink)'}; }`);
159
176
  }
160
177
  });
161
178
 
162
179
  test('every file-brand row paints both variants', () => {
163
180
  for (const [name, entry] of Object.entries(FILE_BRAND_COLORS)) {
164
181
  const selector = `svg[data-file-brand="${name}"]`;
165
- expect(css).toContain(`:where(${selector}) { color: ${entry.light}; }`);
166
- expect(css).toContain(`color: ${entry.dark ?? 'var(--theme-ink)'}; }`);
182
+ expect(css).toContain(`:where(${selector}) { --icon-color: ${entry.light}; }`);
183
+ expect(css).toContain(`--icon-color: ${entry.dark ?? 'var(--theme-ink)'}; }`);
167
184
  }
168
185
  });
169
186
 
170
187
  test('a plugin mark takes a runtime hue through --plugin-color', () => {
171
188
  // The hue is `hashHue(name)`, which no build can enumerate: the component
172
189
  // sets `--icon-hue` inline and these rules turn it into paint.
173
- expect(css).toContain(':where([data-plugin-mark]) { --plugin-color: var(--plugin-declared-light, hsl(var(--icon-hue,');
190
+ expect(css).toContain(':where([data-plugin-mark]) { --plugin-color: var(--plugin-declared-light, var(--icon-tone, hsl(var(--icon-hue,');
174
191
  expect(css).toContain(':where([data-icon-style="color"][data-theme-variant="dark"]) :where([data-plugin-mark])');
175
192
  });
176
193
 
@@ -181,7 +198,7 @@ describe('the icon paint stylesheet', () => {
181
198
  // monochrome. These rules carry enough specificity to win, `:not(.bg-ink *)`
182
199
  // keeps an inverted chip on its own foreground, and `[data-idle]` replaces
183
200
  // the colour as the state instead of stacking a second one on top.
184
- expect(css).toContain(':root[data-icon-style="color"] [data-panel-mark]:not(.bg-ink *) svg.lucide { color: var(--panel-color-light, hsl(var(--panel-hue, var(--icon-hue,');
201
+ expect(css).toContain(':root[data-icon-style="color"] [data-panel-mark]:not(.bg-ink *) svg.lucide { color: var(--panel-color-light, var(--panel-tone, hsl(var(--panel-hue, var(--icon-hue,');
185
202
  expect(css).toContain(':root[data-icon-style="color"][data-theme-variant="dark"] [data-panel-mark]:not(.bg-ink *) svg.lucide');
186
203
  // A plugin's own mark states `--plugin-color` from its name; inside a panel
187
204
  // mark the panel's declared colour (or its assigned hue) is the authority.
@@ -191,7 +208,7 @@ describe('the icon paint stylesheet', () => {
191
208
  // measured 95 → 62 on a 64px glyph, which is the "kusem" report. A brightness
192
209
  // shift moves luminance only; the two variants shift opposite ways because
193
210
  // "recede" is darker on ink and lighter on paper.
194
- expect(css).toContain('[data-icon-style="color"] [data-panel-mark][data-idle]:not([data-declared]) { filter: brightness(1.25) saturate(1.05); }');
211
+ expect(css).toContain('[data-icon-style="color"] [data-panel-mark][data-idle]:not([data-declared]) { filter: brightness(1.08) saturate(1.1); }');
195
212
  expect(css).toContain(
196
213
  '[data-icon-style="color"][data-theme-variant="dark"] [data-panel-mark][data-idle]:not([data-declared]) { filter: brightness(0.62) saturate(1.4); }',
197
214
  );
@@ -212,19 +229,24 @@ describe('the icon paint stylesheet', () => {
212
229
  // mid-tone ink (`#586e75`, `#93a1a1`), where no hue at any lightness clears
213
230
  // 3:1. The surface already declares `text-canvas`/`text-paper`, and the
214
231
  // palette guarantees that pair, so the icon inherits it.
215
- expect(css).toContain(':where([data-icon-style="color"]) :where(.bg-ink) :where(svg.lucide) { color: currentColor; }');
232
+ // (0,2,1) with an explicit `color`, not `:where()`: it has to TIE with the
233
+ // paint rule and win on order, and it cannot feed `currentColor` back into
234
+ // `--icon-color` — that is a cycle on the property computing `color`.
235
+ expect(css).toContain('[data-icon-style="color"] .bg-ink svg.lucide { color: currentColor; }');
216
236
  expect(css).toContain(':where([data-icon-style="color"]) :where(.bg-ink) :where([data-plugin-mark]) { --plugin-color: currentColor; }');
217
237
  // Same zero specificity as the base rules, so it has to come AFTER them.
218
- expect(css.indexOf(':where(.bg-ink) :where(svg.lucide)')).toBeGreaterThan(css.indexOf(':where(svg.lucide) { color: hsl(var(--icon-hue'));
238
+ expect(css.indexOf('.bg-ink svg.lucide { color: currentColor; }')).toBeGreaterThan(
239
+ css.indexOf('[data-icon-style="color"] :is(svg.lucide, svg[data-provider]'),
240
+ );
219
241
  });
220
242
 
221
243
  test('a plugin manifest colour wins over the hashed hue', () => {
222
244
  // `--panel-declared`/`--panel-color` is the plugin's OWN brand, and the
223
245
  // hashed hue is only the fallback — the order inside the `var()` chain is the
224
246
  // contract, so it is pinned literally.
225
- expect(css).toContain('--plugin-color: var(--plugin-declared-light, hsl(var(--icon-hue');
247
+ expect(css).toContain('--plugin-color: var(--plugin-declared-light, var(--icon-tone, hsl(var(--icon-hue');
226
248
  expect(css).toContain('--plugin-color: var(--plugin-declared-dark, hsl(var(--icon-hue');
227
- expect(css).toContain('color: var(--panel-color-light, hsl(var(--panel-hue, var(--icon-hue,');
249
+ expect(css).toContain('color: var(--panel-color-light, var(--panel-tone, hsl(var(--panel-hue, var(--icon-hue,');
228
250
  expect(css).toContain('color: var(--panel-color-dark, hsl(var(--panel-hue, var(--icon-hue,');
229
251
  });
230
252
 
@@ -232,3 +254,60 @@ describe('the icon paint stylesheet', () => {
232
254
  expect(iconPaintStyleSheet()).toBe(css);
233
255
  });
234
256
  });
257
+
258
+ describe('the ink weight selectors', () => {
259
+ // Only the rules that read a WEIGHT: the paint rule also sets `--icon-paint`
260
+ // (from `--icon-color`, unconditionally), and it is not a weight.
261
+ const weightRules = css.split('\n').filter((line) => line.includes('--icon-paint:') && line.includes('text-ink'));
262
+
263
+ test('a weight matches one class TOKEN, never a substring', () => {
264
+ // `[class*=…]` also fires on the VARIANT token: `text-ink/50
265
+ // group-hover:text-ink/80` matched both `/50` and `/80`, so the resting icon
266
+ // was painted at its HOVER weight — measured on the composer's target
267
+ // picker, `Folder` computed the `/80` paint while the pointer was elsewhere.
268
+ expect(weightRules.length).toBeGreaterThan(0);
269
+ for (const rule of weightRules) {
270
+ expect(rule, rule.slice(0, 90)).toContain('[class~="');
271
+ expect(rule, rule.slice(0, 90)).not.toContain('[class*="text-ink');
272
+ }
273
+ });
274
+
275
+ test('a hover weight is stated as a pseudo-class, in the right DOM order', () => {
276
+ // Two independent failures live here. ORDER: `.group` is an ancestor while
277
+ // `[data-icon-style]` sits on `<html>`, so `.group:hover` has to come AFTER
278
+ // the mode gate — written before it, the selector demands a descendant that
279
+ // carries the attribute and never matches (measured: `group-hover` had no
280
+ // effect at all). SPECIFICITY: the variant must outrank the resting rule, so
281
+ // an icon that is muted at rest and bright on hover really does brighten.
282
+ const groupRule = weightRules.find((line) => line.includes('[class~="group-hover:text-ink/80"]')) ?? '';
283
+ expect(groupRule).toMatch(/^\[data-icon-style="color"\] \.group:hover svg\.lucide/);
284
+
285
+ const hoverRule = weightRules.find((line) => line.includes('[class~="hover:text-ink/70"]')) ?? '';
286
+ expect(hoverRule).toMatch(/^\[data-icon-style="color"\] svg\.lucide.*\]:hover \{/);
287
+
288
+ // The resting rule for the same class must exist too, or the selector is a
289
+ // hover-only paint and the icon changes colour the moment the pointer moves.
290
+ expect(weightRules.some((line) => line.includes('[class~="text-ink/50"]') && !line.includes('hover'))).toBe(true);
291
+ });
292
+
293
+ test('the weight scales chroma, and never mixes toward the ink', () => {
294
+ // Mixing toward `var(--theme-ink)` desaturates AND darkens, and darkening is
295
+ // the opposite of a mute: a muted settings icon measured 7.48:1 where the
296
+ // active one read 3.96:1. Multiplying chroma leaves the solved lightness —
297
+ // and therefore the legibility — alone.
298
+ const stepped = weightRules.filter((line) => /text-ink\/\d+"\]/.test(line));
299
+ expect(stepped.length).toBeGreaterThan(0);
300
+ for (const rule of stepped) {
301
+ expect(rule, rule.slice(0, 90)).toContain('oklch(from var(--icon-color) l calc(c *');
302
+ expect(rule, rule.slice(0, 90)).not.toContain('var(--theme-ink)');
303
+ expect(rule, rule.slice(0, 90)).not.toContain('color-mix(');
304
+ }
305
+ });
306
+
307
+ test('every weight is gated on the colour mode and skips the project accent', () => {
308
+ for (const rule of weightRules) {
309
+ expect(rule.startsWith('[data-icon-style="color"]'), rule.slice(0, 80)).toBe(true);
310
+ expect(rule, rule.slice(0, 80)).toContain(':not(.project-accent-mark)');
311
+ }
312
+ });
313
+ });
@@ -47,6 +47,7 @@
47
47
 
48
48
  import { BRAND_COLORS } from '@/shared/lib/models/provider/brand-color';
49
49
  import { panelMarkRules } from '@/shared/lib/icons/icon-paint-panel';
50
+ import { inkWeightRules } from '@/shared/lib/icons/icon-paint-weight';
50
51
  import { FILE_BRAND_COLORS } from '@/shared/lib/icons/file-brand-color';
51
52
  import {
52
53
  DEFAULT_ICON_HUE,
@@ -54,6 +55,7 @@ import {
54
55
  ICON_TINT_ROWS,
55
56
  ICON_TINT_TOKENS,
56
57
  iconHuePaint,
58
+ iconTone,
57
59
  } from '@/shared/lib/icons/tint';
58
60
 
59
61
  /** The `<style>` element's id: the SSR shell writes it, the client checks it. */
@@ -62,23 +64,64 @@ export const ICON_PAINT_STYLE_ELEMENT_ID = 'omp-icon-paint';
62
64
  /** Both rules for one brand, since a brand colour has two values. */
63
65
  function brandRules(selector: string, light: string, dark: string | null): string[] {
64
66
  return [
65
- `:where([data-icon-style="color"]) :where(${selector}) { color: ${light}; }`,
66
- `:where([data-icon-style="color"][data-theme-variant="dark"]) :where(${selector}) { color: ${dark ?? 'var(--theme-ink)'}; }`,
67
+ `:where([data-icon-style="color"]) :where(${selector}) { --icon-color: ${light}; }`,
68
+ `:where([data-icon-style="color"][data-theme-variant="dark"]) :where(${selector}) { --icon-color: ${dark ?? 'var(--theme-ink)'}; }`,
67
69
  ];
68
70
  }
69
71
 
70
72
  /** The hue a functional glyph is painted with, per variant. */
71
73
  function hueRules(): string[] {
72
74
  const rules = [
73
- `:where([data-icon-style="color"]) :where(svg.lucide) { color: ${iconHuePaint('light')}; }`,
74
- `:where([data-icon-style="color"][data-theme-variant="dark"]) :where(svg.lucide) { color: ${iconHuePaint('dark')}; }`,
75
+ // `--icon-paint`, not `color`: WHICH colour an icon is and HOW LOUD it is are
76
+ // two decisions, and stating them as one `color` makes them compete on
77
+ // specificity. The weight rules below multiply the chroma of whatever this
78
+ // resolves to, so they cannot overwrite a signal token by winning a cascade
79
+ // race (which is exactly what they did — see `inkWeightRules`).
80
+ `:where([data-icon-style="color"]) :where(svg.lucide) { --icon-color: ${iconHuePaint('light')}; }`,
81
+ `:where([data-icon-style="color"][data-theme-variant="dark"]) :where(svg.lucide) { --icon-color: ${iconHuePaint('dark')}; }`,
75
82
  ];
76
83
  for (const { className, hue } of ICON_HUE_ROWS) {
77
- rules.push(`:where([data-icon-style="color"]) :where(svg.${className}) { --icon-hue: ${hue}; }`);
84
+ rules.push(`:where([data-icon-style="color"]) :where(svg.${className}) { --icon-hue: ${hue}; --icon-tone: ${iconTone(hue)}; }`);
78
85
  }
79
86
  return rules;
80
87
  }
81
88
 
89
+ /**
90
+ * The paint itself. Stated ONCE, after the sources above, so every rule that
91
+ * decides a colour only has to set `--icon-color`.
92
+ *
93
+ * `color` rather than a second fallback inside each source: it is the one
94
+ * property a caller can also set (`text-ink/60`), and this block is gated, so an
95
+ * icon outside the colour mode keeps the author's class.
96
+ *
97
+ * **The selector covers all three icon families, not just `.lucide`.** Provider
98
+ * and file-type marks are their own `<svg>` and carry no `lucide` class, so a
99
+ * `.lucide`-only paint rule left them inheriting their parent's text colour —
100
+ * measured, a brand mark computed `oklab(0.523 -0.022 -0.018 / 0.8)` (its row's
101
+ * muted ink) while its `--icon-color` held the brand hex. `:is()` costs nothing:
102
+ * each argument is (0,1,1), so the whole selector stays (0,2,1) and still beats
103
+ * a single utility.
104
+ */
105
+ function paintRules(): string[] {
106
+ return [
107
+ // `--icon-paint` is derived from `--icon-color`, which every source above
108
+ // sets. The indirection is what lets a WEIGHT rule (see `inkWeightRules`)
109
+ // transform the colour without knowing which source produced it — a signal
110
+ // token, a solved tone, a brand hex or a panel's own colour all flow through
111
+ // the same two lines.
112
+ //
113
+ // NOT `:where()` on this one, unlike every other rule in the sheet. The
114
+ // subject is the `color` property, which the call sites also set — a utility
115
+ // like `text-ink/60` is (0,1,0) — so a zero-specificity statement lost the
116
+ // mode entirely and every muted icon stayed monochrome ink (measured in the
117
+ // settings modal: `--icon-paint` computed to the tone, and `color` still
118
+ // resolved to `oklab(… / 0.6)`). (0,2,1) beats a single utility, and the
119
+ // rules that must still override it — a panel mark, a tool card, an inverted
120
+ // surface, the project accent — are stated after this one with more weight.
121
+ `[data-icon-style="color"] :is(svg.lucide, svg[data-provider], svg[data-file-brand]) { --icon-paint: var(--icon-color); color: var(--icon-paint); }`,
122
+ ];
123
+ }
124
+
82
125
  /**
83
126
  * MONOCHROME: an icon takes the ink of the text beside it.
84
127
  *
@@ -182,7 +225,12 @@ function projectAccentRules(): string[] {
182
225
  */
183
226
  function invertedSurfaceRules(): string[] {
184
227
  return [
185
- ':where([data-icon-style="color"]) :where(.bg-ink) :where(svg.lucide) { color: currentColor; }',
228
+ // Stated at (0,2,1) to TIE with `paintRules` and win on order — `:where()`
229
+ // would be (0,0,0) and lose to it, which is the whole reason this rule
230
+ // exists. It sets `color` directly rather than `--icon-color`, because
231
+ // `currentColor` resolves FROM `color`: feeding it back into the property
232
+ // that computes `color` is a cycle the browser drops.
233
+ '[data-icon-style="color"] .bg-ink svg.lucide { color: currentColor; }',
186
234
  ':where([data-icon-style="color"]) :where(.bg-ink) :where([data-plugin-mark]) { --plugin-color: currentColor; }',
187
235
  ];
188
236
  }
@@ -202,52 +250,11 @@ function pluginMarkRules(): string[] {
202
250
  ];
203
251
  }
204
252
 
205
- /**
206
- * `text-ink/60` is a WEIGHT, not a colour choice.
207
- *
208
- * The settings sidebar, the composer toolbar and a few hundred other call sites
209
- * write `text-ink/40`-`/80` to mute an icon. That is "the ink, quieter" — the
210
- * caller did not pick a colour — but a utility class is (0,1,0) and the hue
211
- * rules are `:where()` (0,0,0), so the mute won and every muted icon stayed ink
212
- * in the colour mode ("icon di setting modal kenapa gk full color").
213
- *
214
- * The mute is reproduced by mixing toward the INK, not toward transparency. Two
215
- * reasons, both measured. Transparency is the wrong lever for a graphic: a hue at
216
- * 40% alpha is 1.56:1 (light) / 1.77:1 (dark) against its surface, while the
217
- * `text-ink/40` it replaces was already only 1.71 / 2.05 — so the colour mode
218
- * would have made every muted icon less legible than before. Mixing toward the
219
- * ink instead keeps the same "mostly ink, quieter" reading AND lands at 3.89:1
220
- * worst case across every palette (`hue 80% + ink 20%`), 4.65:1 at the muted end.
221
- *
222
- * Specificity `svg.lucide[class*=…]` (0,2,1) beats the utility (0,1,0) on its
223
- * own; the `!` is not needed and is not used anywhere in this sheet.
224
- */
225
- function inkWeightRules(): string[] {
226
- const steps = [25, 30, 35, 40, 45, 50, 55, 60, 65, 70, 75, 80, 85, 90];
227
- const rules: string[] = [];
228
- for (const variant of ['light', 'dark'] as const) {
229
- const gate = variant === 'dark'
230
- ? '[data-icon-style="color"][data-theme-variant="dark"]'
231
- : '[data-icon-style="color"]';
232
- const paint = iconHuePaint(variant);
233
- // The un-suffixed `text-ink` is the full-strength ink.
234
- rules.push(`${gate} svg.lucide:not(.project-accent-mark)[class~="text-ink"] { color: ${paint}; }`);
235
- for (const step of steps) {
236
- // `NN%` of hue over the ink: the caller's mute survives as "mostly ink",
237
- // and the hue is what the mode added.
238
- rules.push(
239
- `${gate} svg.lucide:not(.project-accent-mark)[class*="text-ink/${step}"] { color: color-mix(in srgb, ${paint} ${step}%, var(--theme-ink)); }`,
240
- );
241
- }
242
- }
243
- return rules;
244
- }
245
-
246
253
  /** The signal colours, which beat the hue because they are stated after it. */
247
254
  function signalRules(): string[] {
248
255
  return ICON_TINT_ROWS.map(
249
256
  ({ className, role }) =>
250
- `:where([data-icon-style="color"]) :where(svg.${className}) { color: ${ICON_TINT_TOKENS[role]}; }`,
257
+ `:where([data-icon-style="color"]) :where(svg.${className}) { --icon-color: ${ICON_TINT_TOKENS[role]}; }`,
251
258
  );
252
259
  }
253
260
 
@@ -262,10 +269,13 @@ export function iconPaintStyleSheet(): string {
262
269
  '@layer theme, base, components, utilities;',
263
270
  '@layer utilities {',
264
271
  ...hueRules(),
265
- ...inkWeightRules(),
266
- ...panelMarkRules(),
267
272
  ...signalRules(),
268
273
  ...pluginMarkRules(),
274
+ // Every `--icon-color` source is stated above this line; the paint and the
275
+ // weight that SCALES it are stated below, in that order.
276
+ ...paintRules(),
277
+ ...inkWeightRules(),
278
+ ...panelMarkRules(),
269
279
  // Last: same specificity as everything above, so order is what makes an
270
280
  // inverted surface win over the paper-tuned paint.
271
281
  ...invertedSurfaceRules(),
@@ -33,7 +33,12 @@ import { DEFAULT_ICON_HUE, ICON_HUE_PAINT } from '@/shared/lib/icons/tint';
33
33
  */
34
34
  function panelPaint(variant: 'light' | 'dark'): string {
35
35
  const { saturation, lightness } = ICON_HUE_PAINT[variant];
36
- return `var(--panel-color-${variant}, hsl(var(--panel-hue, var(--icon-hue, ${DEFAULT_ICON_HUE})) ${saturation}% ${lightness}%))`;
36
+ const hsl = `hsl(var(--panel-hue, var(--icon-hue, ${DEFAULT_ICON_HUE})) ${saturation}% ${lightness}%)`;
37
+ // Light reads `--panel-tone`, the same solved table the glyph rows use: a
38
+ // panel's hue is assigned at runtime, so the tone is stamped by `PanelMark`
39
+ // rather than generated per row. Dark keeps the single `hsl()` pair.
40
+ const toned = variant === 'light' ? `var(--panel-tone, ${hsl})` : hsl;
41
+ return `var(--panel-color-${variant}, ${toned})`;
37
42
  }
38
43
 
39
44
  export function panelMarkRules(): string[] {
@@ -78,11 +83,15 @@ export function panelMarkRules(): string[] {
78
83
  // colour restored.
79
84
  //
80
85
  // The two variants shift in opposite directions because "recede" does: on ink
81
- // an idle icon is DARKER, on paper it is LIGHTER. `1.25` in light, not more:
82
- // measured, brighter steps walk the icon up the chroma curve and out of the
83
- // rail's range (1.5 read 2.22:1 against 3.82:1 active — glare), while 1.25
84
- // reads 2.74:1 with chroma 121 against the active 95, i.e. quieter and MORE
85
- // coloured at once, which is the whole point of dimming by luminance.
86
+ // an idle icon is DARKER, on paper it is LIGHTER.
87
+ //
88
+ // Light's factor is `1.08 saturate(1.1)`, NOT the `1.25` the darker paint
89
+ // needed. The light tone is now a solved hex sitting AT the contrast floor
90
+ // (3.15 mean 3.30, `icon-tone.ts`), where the old pair had 6.11 of headroom to
91
+ // spend — so the old factor walked every idle mark down to 2.23:1 and the rail
92
+ // went dim rather than quiet. Re-measured over the shipped tones: `1.08/1.1`
93
+ // reads 2.79:1 mean, still a visible step down, and holds chroma at 111% of
94
+ // the active mark (the `saturate()` is what pays for the multiply).
86
95
  //
87
96
  // A DECLARED brand colour is NOT dimmed. The settings card draws the same
88
97
  // plugin at full strength, so dimming this copy made one brand two colours
@@ -94,7 +103,7 @@ export function panelMarkRules(): string[] {
94
103
  // `[data-declared]` is stamped from `panel.color` — a property, not a
95
104
  // class-name or inline-style guess, so this cannot drift when the mark
96
105
  // changes how it carries its colour.
97
- '[data-icon-style="color"] [data-panel-mark][data-idle]:not([data-declared]) { filter: brightness(1.25) saturate(1.05); }',
106
+ '[data-icon-style="color"] [data-panel-mark][data-idle]:not([data-declared]) { filter: brightness(1.08) saturate(1.1); }',
98
107
  '[data-icon-style="color"][data-theme-variant="dark"] [data-panel-mark][data-idle]:not([data-declared]) { filter: brightness(0.62) saturate(1.4); }',
99
108
  ];
100
109
  }
@@ -0,0 +1,123 @@
1
+ /**
2
+ * @license
3
+ * SPDX-License-Identifier: MIT
4
+ */
5
+
6
+ /**
7
+ * `text-ink/60` is a WEIGHT, not a colour choice — and a weight means LESS
8
+ * COLOUR, not a darker colour.
9
+ *
10
+ * Split out of `icon-paint-css.ts` so both files stay readable, not because the
11
+ * rules are independent: they are the family that sheet concatenates, and they
12
+ * are stated AFTER `paintRules` because they transform what it resolves.
13
+ *
14
+ * The settings sidebar, the composer toolbar and a few hundred other call sites
15
+ * write `text-ink/40`-`/80` to mute an icon. That is "the ink, quieter": the
16
+ * caller chose a weight, not a colour. A utility class is (0,1,0) and the hue
17
+ * rules are `:where()` (0,0,0), so the mute won and every muted icon stayed ink
18
+ * in the colour mode ("icon di setting modal kenapa gk full color").
19
+ *
20
+ * ## The bug this replaces
21
+ *
22
+ * The first answer mixed the hue toward `var(--theme-ink)`. That does two things
23
+ * at once — it desaturates AND darkens — and darkening is the opposite of what a
24
+ * mute means. Measured on the settings sidebar (hue 250, `#736aec` on `paper`'s
25
+ * `#faf8f3`): the pure tone reads **3.96:1**, `text-ink/60` monochrome reads
26
+ * **4.74:1**, and the old rule painted **7.48:1** — a muted icon DARKER than the
27
+ * active one beside it, and darker than the monochrome ink it replaced. That is
28
+ * the "icon di modal setting masih kusam di light mode" report: not a shortage of
29
+ * chroma but a colour pushed to a weight it was never meant to have. Over all 36
30
+ * hues and all 32 light palettes the old rule moved mean contrast 4.37 → 9.46 as
31
+ * the weight got quieter, while monochrome moved 9.17 → 1.60.
32
+ *
33
+ * ## The rule now
34
+ *
35
+ * Multiply the CHROMA by the weight and leave LIGHTNESS alone: `60%` of a hue's
36
+ * chroma is the same hue, quieter, at the legibility the tone was solved for.
37
+ * Measured over the same matrix: contrast holds at **3.87 mean / 3.07 min** from
38
+ * `text-ink/90` down to `/25` (the tone's own 3.91), while chroma falls 0.146 →
39
+ * 0.040 — the icon recedes by losing colour rather than by going dark. Dark
40
+ * behaves the same way (3.83 mean, 3.02 min), because the transform never reads
41
+ * the variant.
42
+ *
43
+ * ## Two facts about the SELECTOR, both measured
44
+ *
45
+ * **1. `[class~=…]`, never `[class*=…]`.** A substring match also fires on the
46
+ * VARIANT token: `text-ink/50 group-hover:text-ink/80` matched both `/50` and
47
+ * `/80`, so the resting icon was painted at its HOVER weight — measured in the
48
+ * composer's target picker, `Folder` computed `oklch(… 0.151 320)` (the `/80`
49
+ * paint) while it was not hovered. `~=` compares one whitespace-separated word,
50
+ * and `group-hover:text-ink/80` is not the word `text-ink/80`, so the base
51
+ * weight is the only one that applies at rest.
52
+ *
53
+ * **2. The variants are stated explicitly.** With the base weights matching
54
+ * exactly, `hover:text-ink/70` and `group-hover:text-ink/80` would otherwise be
55
+ * ignored entirely (the paint rule sets `color` on the `svg` itself, so
56
+ * inheritance from the hovered parent cannot reach it). Each variant is
57
+ * re-stated against its own pseudo-class, which also gives it the higher
58
+ * specificity the tie needs.
59
+ *
60
+ * ## And it no longer eats a signal
61
+ *
62
+ * The rule is stated against `--icon-color`, not against a hue formula, so a
63
+ * signal glyph (`--icon-color: var(--theme-warning)`) keeps its token and is
64
+ * merely quieted — measured, `Bell` under `text-ink/60` used to paint
65
+ * `rgb(26,53,80)`, the warning orange replaced by the hashed hue path. Now it
66
+ * paints warning at 60% chroma (`oklch(0.553 0.104 38.4)`).
67
+ *
68
+ * `oklch(from …)` is relative colour syntax: it reads the source in OKLCH and
69
+ * rewrites one channel, which is the only CSS way to say "same colour, less of
70
+ * it". Supported in every engine this app targets (Chromium 119+, Safari 16.4+,
71
+ * WebKitGTK 2.42+); an engine that lacks it IGNORES the declaration and keeps
72
+ * the full-strength paint, so the failure is an unmuted icon, never a missing
73
+ * one.
74
+ */
75
+
76
+ /** The steps call sites actually use, plus the neighbours a new one may reach for. */
77
+ const WEIGHT_STEPS = [20, 25, 30, 35, 40, 45, 50, 55, 60, 65, 70, 75, 80, 85, 90];
78
+
79
+ /** The weight at `step/100`, or the untouched colour. */
80
+ function paintAt(step: number | null): string {
81
+ return step === null ? 'var(--icon-color)' : `oklch(from var(--icon-color) l calc(c * ${step / 100}) h)`;
82
+ }
83
+
84
+ /** Every variant prefix that carries a `text-ink` weight somewhere in this app. */
85
+ const VARIANTS = ['hover', 'group-hover'] as const;
86
+
87
+ /**
88
+ * `selector` and the weight it paints. `prefix` is empty for the resting state.
89
+ *
90
+ * DOM order matters: `.group` is an ANCESTOR of the icon while
91
+ * `[data-icon-style]` sits on `<html>`, so the group has to come AFTER the mode
92
+ * gate. Stated the other way round (`group:hover [data-icon-style="color"] …`)
93
+ * the selector demands a descendant carrying the attribute and never matches —
94
+ * measured, `group-hover:text-ink/80` had no effect at all.
95
+ *
96
+ * The order this returns is the order the rules are emitted in, and it matters:
97
+ * a variant has strictly higher specificity than the base, so a hover weight
98
+ * always wins over the resting one, whatever order the two landed in the sheet.
99
+ */
100
+ function weightRule(variant: (typeof VARIANTS)[number] | null, step: number | null, dark: boolean): string {
101
+ const mode = dark ? '[data-icon-style="color"][data-theme-variant="dark"]' : '[data-icon-style="color"]';
102
+ const token = variant ? `${variant}:text-ink` : 'text-ink';
103
+ const suffix = step === null ? '' : `/${step}`;
104
+ // `.group:hover` for the shared-parent variant, `svg:hover` for the direct one.
105
+ const scope = variant === 'group-hover' ? '.group:hover ' : '';
106
+ const pseudo = variant === 'hover' ? ':hover' : '';
107
+ return `${mode} ${scope}svg.lucide:not(.project-accent-mark)[class~="${token}${suffix}"]${pseudo} { --icon-paint: ${paintAt(step)}; }`;
108
+ }
109
+
110
+ export function inkWeightRules(): string[] {
111
+ const rules: string[] = [];
112
+ for (const dark of [false, true]) {
113
+ // The un-suffixed `text-ink` is the full-strength ink, and its variants are
114
+ // "the caller wants full ink back" — the same paint, no step.
115
+ rules.push(weightRule(null, null, dark));
116
+ for (const variant of VARIANTS) rules.push(weightRule(variant, null, dark));
117
+ for (const step of WEIGHT_STEPS) rules.push(weightRule(null, step, dark));
118
+ for (const step of WEIGHT_STEPS) {
119
+ for (const variant of VARIANTS) rules.push(weightRule(variant, step, dark));
120
+ }
121
+ }
122
+ return rules;
123
+ }