@celestia-island/hikari 0.55.416 → 0.55.417

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,6 +1,6 @@
1
1
  {
2
2
  "name": "@celestia-island/hikari",
3
- "version": "0.55.416",
3
+ "version": "0.55.417",
4
4
  "private": false,
5
5
  "type": "module",
6
6
  "description": "Hikari UI library, Vue 3 runtime — one design system for Vue 3 and Rust/WASM applications",
@@ -128,6 +128,21 @@ function retiredHits(source: string): string[] {
128
128
  }
129
129
 
130
130
  describe("channel fallbacks mirror the static seed", () => {
131
+ it(".hk-text-* semantic trio uses one namespace (the components --hi-*-fg)", () => {
132
+ // base.scss ships inside the components bundle, where the fg tokens are
133
+ // --hi-{tone}-fg (emitted by css_variables()); the Vue --hi-color-*-fg
134
+ // tier only resolves in a host that also loads the Vue token sheets.
135
+ const base = read(resolve(stylesDir, "../../../theme/styles/base.scss"));
136
+ for (const tone of ["success", "warning", "danger"]) {
137
+ const re = new RegExp(`\\.hk-text-${tone}\\s*\\{[^}]*color:\\s*var\\((--hi-[a-z-]+)\\)`);
138
+ const m = base.match(re);
139
+ expect(m, `.hk-text-${tone} present in base.scss`).toBeTruthy();
140
+ expect(m![1], `.hk-text-${tone} uses the components fg namespace`).toMatch(
141
+ /^--hi-(success|warning|danger)-fg$/,
142
+ );
143
+ }
144
+ });
145
+
131
146
  const seedSource = read(resolve(packageDir, "src", "tokens.scss"));
132
147
  const seed = seedTriplets(seedSource);
133
148
 
@@ -225,11 +225,6 @@ export function getThemeTokens(
225
225
  return null;
226
226
  }
227
227
 
228
- function contrastColor({ r, g, b }: ThemeTokenRGB): ThemeTokenRGB {
229
- const luminance = (0.2126 * r + 0.7152 * g + 0.0722 * b) / 255;
230
- return luminance > 0.55 ? { r: 0, g: 0, b: 0 } : { r: 255, g: 255, b: 255 };
231
- }
232
-
233
228
  /**
234
229
  * The white-or-black ink for ONE solid fill. Deliberately NOT "whichever
235
230
  * side wins the WCAG ratio": on saturated fills the ratio winner is the
@@ -314,7 +309,7 @@ export function tokensToCSSVars(
314
309
  tokens: ThemeSchemeTokens,
315
310
  groupVars?: Record<string, string>,
316
311
  ): Record<string, string> {
317
- const onPrimary = contrastColor(tokens.primary);
312
+ const onPrimary = solidInk(tokens.primary);
318
313
  const textSecondary = mixToken(tokens.text, tokens.muted, 0.25);
319
314
  const textTertiary = mixToken(tokens.text, tokens.muted, 0.5);
320
315
  // Content colors for solid brand fills default to white (the historical
@@ -19,6 +19,7 @@ import { fileURLToPath } from "node:url";
19
19
  import { describe, expect, it } from "vitest";
20
20
 
21
21
  import { solidInk, themePresets, tokensToCSSVars } from "./presets";
22
+ import type { ThemeTokenRGB } from "./presets";
22
23
 
23
24
  const WHITE = "255 255 255";
24
25
  const BLACK = "0 0 0";
@@ -64,6 +65,17 @@ const MUST_STAY_WHITE: Array<["light" | "dark", "danger" | "success" | "warning"
64
65
  ];
65
66
 
66
67
  describe("solid-fill ink rule", () => {
68
+ it("uses the house 0.65 threshold (not the legacy 0.55)", () => {
69
+ // #A3A3A3 γlum = 0.6400: the 0.65 house rule says WHITE (≤0.65), while
70
+ // the rejected 0.55 rule would say BLACK (>0.55).
71
+ const fill: ThemeTokenRGB = { r: 0xa3, g: 0xa3, b: 0xa3 };
72
+ const ink = solidInk(fill);
73
+ expect(ink).toEqual({ r: 255, g: 255, b: 255 });
74
+ // #A6A6A6 γlum = 0.6587 > 0.65 → black.
75
+ const above: ThemeTokenRGB = { r: 0xa6, g: 0xa6, b: 0xa6 };
76
+ expect(solidInk(above)).toEqual({ r: 0, g: 0, b: 0 });
77
+ });
78
+
67
79
  it("inks each shipped fill by its own lightness", () => {
68
80
  const light = tokensToCSSVars(themePresets.default.light);
69
81
  const dark = tokensToCSSVars(themePresets.default.dark);