@halftone-ds/tokens 1.3.1 → 1.3.2

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": "@halftone-ds/tokens",
3
- "version": "1.3.1",
3
+ "version": "1.3.2",
4
4
  "description": "Design tokens (W3C DTCG) to NativeWind, Tailwind 4 / shadcn, TypeScript, DESIGN.md and Figma, with a WCAG AA contrast gate. The token build behind Halftone.",
5
5
  "license": "MIT",
6
6
  "type": "module",
@@ -24,15 +24,19 @@ function componentsObject(components) {
24
24
  return COMPONENT_NAMES.map((name) => {
25
25
  const c = components[name];
26
26
  const text = { font: c.text.font, size: round(c.text.size), lineHeight: round(c.text.leading), tracking: c.text.tracking };
27
- // The font role is typed as a role, so code can branch on it (the object is `as const`).
28
- const json = JSON.stringify({ height: c.h, x: c.x, radius: c.radius, text }).replace(/"font":("\w+")/, `"font":$1 as 'heading' | 'body' | 'mono'`);
27
+ // The font role is typed as a role, so code can branch on it (the object is `as const`), and tracking as a
28
+ // number: a kit compares it with 0, which wouldn't typecheck against a system's literal 0.01.
29
+ const json = JSON.stringify({ height: c.h, x: c.x, radius: c.radius, text })
30
+ .replace(/"font":("\w+")/, `"font":$1 as 'heading' | 'body' | 'mono'`)
31
+ .replace(/"tracking":(-?[\d.e-]+)/, '"tracking":$1 as number');
29
32
  return ` ${name}: ${json},`;
30
33
  }).join('\n');
31
34
  }
32
35
 
33
36
  function textStylesObject(styles) {
34
37
  return Object.entries(styles)
35
- .map(([name, s]) => ` ${name}: ${JSON.stringify({ font: s.font, weight: s.weight, size: round(s.size), lineHeight: round(s.lineHeight), tracking: s.tracking })},`)
38
+ // Tracking as a number, as the components' (a kit compares it with 0).
39
+ .map(([name, s]) => ` ${name}: ${JSON.stringify({ font: s.font, weight: s.weight, size: round(s.size), lineHeight: round(s.lineHeight), tracking: s.tracking }).replace(/"tracking":(-?[\d.e-]+)/, '"tracking":$1 as number')},`)
36
40
  .join('\n');
37
41
  }
38
42