@billabex/ui-tokens 0.0.0 → 0.1.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.
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Billabex
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,90 @@
1
+ # @billabex/ui-tokens
2
+
3
+ [![npm](https://img.shields.io/npm/v/@billabex/ui-tokens?color=d4a853)](https://www.npmjs.com/package/@billabex/ui-tokens)
4
+
5
+ Design tokens for the [Billabex](https://next.billabex.com) design system. Pure TypeScript, framework-agnostic, [Figma Token Studio](https://tokens.studio/) compatible.
6
+
7
+ Part of the [Lingot](https://github.com/billabex/lingot) monorepo.
8
+
9
+ ## Install
10
+
11
+ ```bash
12
+ pnpm add @billabex/ui-tokens
13
+ ```
14
+
15
+ ## Usage
16
+
17
+ Tokens are rich TypeScript objects with built-in conversion methods — not plain strings:
18
+
19
+ ```ts
20
+ import { bg, text, spacing, shadows } from '@billabex/ui-tokens'
21
+
22
+ // Colors
23
+ bg.default.hex // '#ffffff'
24
+ bg.default.rgb // { r: 255, g: 255, b: 255 }
25
+ bg.default.rgba(0.5) // 'rgba(255, 255, 255, 0.5)'
26
+ bg.default.hsl // { h: 0, s: 0, l: 100 }
27
+ `${bg.default}` // '#ffffff' (toString)
28
+
29
+ // Dimensions
30
+ spacing.md.value // 8
31
+ spacing.md.px // '8px'
32
+ spacing.md.rem // '0.5rem'
33
+
34
+ // Shadows
35
+ shadows.sm.css // '0px 2px 8px 0px rgba(28, 28, 26, 0.08)'
36
+ ```
37
+
38
+ ## Token Architecture
39
+
40
+ ```
41
+ Primitive → Semantic → Consumer
42
+ ```
43
+
44
+ - **Primitive tokens** define the raw palette: `colors.neutral[700]`, `spacing.md`, `radii.lg`
45
+ - **Semantic tokens** give purpose: `bg.default`, `text.primary`, `action.destructive`, `border.default`
46
+
47
+ Semantic tokens reference primitives, so palette changes propagate everywhere automatically.
48
+
49
+ ## Units (px vs rem)
50
+
51
+ Primitive dimension tokens are authored from **px** values (to match Figma handoff precisely), but each token exposes both:
52
+
53
+ - `.px` for pixel-precise usage
54
+ - `.rem` for scalable, accessibility-friendly usage
55
+
56
+ Recommended usage:
57
+
58
+ - Typography and layout spacing: prefer **`rem`**
59
+ - Borders/hairlines and pixel-critical details: use **`px`**
60
+
61
+ Example:
62
+
63
+ ```ts
64
+ import { spacing, typography } from '@billabex/ui-tokens'
65
+
66
+ // Preferred defaults in component CSS
67
+ spacing.md.rem // '0.5rem'
68
+ typography.body.fontSize.rem // e.g. '0.875rem'
69
+
70
+ // Pixel-precise cases
71
+ spacing.md.px // '8px'
72
+ ```
73
+
74
+ ## Available Token Categories
75
+
76
+ | Category | Primitives | Semantics |
77
+ |----------|-----------|-----------|
78
+ | Colors | `neutral`, `gold`, `terracotta`, `status` scales | `bg.*`, `text.*`, `action.*`, `status.*`, `border.*` |
79
+ | Spacing | `xs` through `5xl` (4px–64px) | — |
80
+ | Radii | `sm`, `md`, `lg`, `xl`, `full` | — |
81
+ | Shadows | `sm`, `md`, `lg` | — |
82
+ | Typography | `heading`, `body`, `label`, `caption` | — |
83
+
84
+ ## Figma Token Studio
85
+
86
+ Tokens are exported to `tokens.json` in [W3C DTCG](https://design-tokens.github.io/community-group/format/) format. Semantic tokens use references (`{global.color.neutral.700}`) so changes to the primitive palette propagate automatically in Token Studio.
87
+
88
+ ## License
89
+
90
+ [MIT](https://github.com/billabex/lingot/blob/main/LICENSE)
package/dist/index.js CHANGED
@@ -7,12 +7,12 @@ function m(r) {
7
7
  };
8
8
  }
9
9
  function S(r, o, s) {
10
- const l = r / 255, a = o / 255, c = s / 255, i = Math.max(l, a, c), u = Math.min(l, a, c), b = (i + u) / 2;
10
+ const c = r / 255, a = o / 255, l = s / 255, i = Math.max(c, a, l), u = Math.min(c, a, l), b = (i + u) / 2;
11
11
  if (i === u)
12
12
  return { h: 0, s: 0, l: Math.round(b * 100) };
13
13
  const f = i - u, p = b > 0.5 ? f / (2 - i - u) : f / (i + u);
14
14
  let g = 0;
15
- return i === l ? g = ((a - c) / f + (a < c ? 6 : 0)) / 6 : i === a ? g = ((c - l) / f + 2) / 6 : g = ((l - a) / f + 4) / 6, {
15
+ return i === c ? g = ((a - l) / f + (a < l ? 6 : 0)) / 6 : i === a ? g = ((l - c) / f + 2) / 6 : g = ((c - a) / f + 4) / 6, {
16
16
  h: Math.round(g * 360),
17
17
  s: Math.round(p * 100),
18
18
  l: Math.round(b * 100)
@@ -23,16 +23,16 @@ function $(r) {
23
23
  return o.length === 8 ? parseInt(o.slice(6, 8), 16) / 255 : 1;
24
24
  }
25
25
  function n(r) {
26
- const { r: o, g: s, b: l } = m(r), a = S(o, s, l);
26
+ const { r: o, g: s, b: c } = m(r), a = S(o, s, c);
27
27
  return Object.freeze({
28
28
  hex: r,
29
- rgb: Object.freeze({ r: o, g: s, b: l }),
29
+ rgb: Object.freeze({ r: o, g: s, b: c }),
30
30
  hsl: Object.freeze(a),
31
- rgba(c) {
32
- return `rgba(${o}, ${s}, ${l}, ${c})`;
31
+ rgba(l) {
32
+ return `rgba(${o}, ${s}, ${c}, ${l})`;
33
33
  },
34
- hsla(c) {
35
- return `hsla(${a.h}, ${a.s}%, ${a.l}%, ${c})`;
34
+ hsla(l) {
35
+ return `hsla(${a.h}, ${a.s}%, ${a.l}%, ${l})`;
36
36
  },
37
37
  toString() {
38
38
  return r;
@@ -49,13 +49,13 @@ function e(r) {
49
49
  }
50
50
  });
51
51
  }
52
- function h(r, o, s, l, a) {
53
- const c = $(a), i = `#${a.replace("#", "").slice(0, 6)}`, u = n(i), { r: b, g: f, b: p } = u.rgb, g = `${r}px ${o}px ${s}px ${l}px rgba(${b}, ${f}, ${p}, ${Number(c.toFixed(2))})`;
52
+ function h(r, o, s, c, a) {
53
+ const l = $(a), i = `#${a.replace("#", "").slice(0, 6)}`, u = n(i), { r: b, g: f, b: p } = u.rgb, g = `${r}px ${o}px ${s}px ${c}px rgba(${b}, ${f}, ${p}, ${Number(l.toFixed(2))})`;
54
54
  return Object.freeze({
55
55
  offsetX: r,
56
56
  offsetY: o,
57
57
  blur: s,
58
- spread: l,
58
+ spread: c,
59
59
  color: u,
60
60
  css: g,
61
61
  toString() {
@@ -88,6 +88,7 @@ const t = {
88
88
  },
89
89
  /** Terracotta / link color */
90
90
  terracotta: {
91
+ 300: n("#eee3de"),
91
92
  400: n("#b5634b"),
92
93
  500: n("#9c5340")
93
94
  },
@@ -124,7 +125,9 @@ const t = {
124
125
  /** 32px */
125
126
  "3xl": e(32),
126
127
  /** 48px */
127
- "4xl": e(48)
128
+ "4xl": e(48),
129
+ /** 64px */
130
+ "5xl": e(64)
128
131
  }, y = {
129
132
  card: e(16),
130
133
  page: e(24)
@@ -202,7 +205,7 @@ const t = {
202
205
  /** Brand-tinted background */
203
206
  brand: t.blue[50],
204
207
  /** Accent background (warm) */
205
- accent: t.neutral[200]
208
+ accent: t.terracotta[300]
206
209
  }, M = {
207
210
  /** Primary text — headings, body */
208
211
  primary: t.neutral[700],
@@ -24,6 +24,7 @@ export declare const colors: {
24
24
  };
25
25
  /** Terracotta / link color */
26
26
  readonly terracotta: {
27
+ readonly 300: ColorToken;
27
28
  readonly 400: ColorToken;
28
29
  readonly 500: ColorToken;
29
30
  };
@@ -62,6 +63,8 @@ export declare const spacing: {
62
63
  readonly "3xl": DimensionToken;
63
64
  /** 48px */
64
65
  readonly "4xl": DimensionToken;
66
+ /** 64px */
67
+ readonly "5xl": DimensionToken;
65
68
  };
66
69
  export declare const padding: {
67
70
  readonly card: DimensionToken;
@@ -1 +1 @@
1
- {"version":3,"file":"primitive.d.ts","sourceRoot":"","sources":["../../src/tokens/primitive.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EACV,UAAU,EACV,cAAc,EAEd,WAAW,EAEZ,MAAM,aAAa,CAAC;AAOrB,eAAO,MAAM,MAAM;IACjB,kBAAkB;;;;;IAMlB,oDAAoD;;;;;;;;;;;IAYpD,0BAA0B;;;;;;IAO1B,8BAA8B;;;;;IAM9B,oBAAoB;;;;;;;;;;;;;;;;;CAoBsE,CAAC;AAM7F,eAAO,MAAM,OAAO;IAClB,UAAU;;IAEV,UAAU;;IAEV,UAAU;;IAEV,WAAW;;IAEX,WAAW;;IAEX,WAAW;;IAEX,WAAW;;IAEX,WAAW;;CAEsC,CAAC;AAMpD,eAAO,MAAM,OAAO;;;CAG+B,CAAC;AAMpD,eAAO,MAAM,KAAK;;;;;;;CAO8B,CAAC;AAMjD,eAAO,MAAM,OAAO;;;;CAI4B,CAAC;AAQjD,eAAO,MAAM,UAAU;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CA2C6B,CAAC"}
1
+ {"version":3,"file":"primitive.d.ts","sourceRoot":"","sources":["../../src/tokens/primitive.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EACV,UAAU,EACV,cAAc,EAEd,WAAW,EAEZ,MAAM,aAAa,CAAC;AAOrB,eAAO,MAAM,MAAM;IACjB,kBAAkB;;;;;IAMlB,oDAAoD;;;;;;;;;;;IAYpD,0BAA0B;;;;;;IAO1B,8BAA8B;;;;;;IAO9B,oBAAoB;;;;;;;;;;;;;;;;;CAoBsE,CAAC;AAM7F,eAAO,MAAM,OAAO;IAClB,UAAU;;IAEV,UAAU;;IAEV,UAAU;;IAEV,WAAW;;IAEX,WAAW;;IAEX,WAAW;;IAEX,WAAW;;IAEX,WAAW;;IAEX,WAAW;;CAEsC,CAAC;AAMpD,eAAO,MAAM,OAAO;;;CAG+B,CAAC;AAMpD,eAAO,MAAM,KAAK;;;;;;;CAO8B,CAAC;AAMjD,eAAO,MAAM,OAAO;;;;CAI4B,CAAC;AAQjD,eAAO,MAAM,UAAU;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CA2C6B,CAAC"}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=primitive.spec.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"primitive.spec.d.ts","sourceRoot":"","sources":["../../src/tokens/primitive.spec.ts"],"names":[],"mappings":""}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=semantic.spec.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"semantic.spec.d.ts","sourceRoot":"","sources":["../../src/tokens/semantic.spec.ts"],"names":[],"mappings":""}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=utils.spec.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"utils.spec.d.ts","sourceRoot":"","sources":["../src/utils.spec.ts"],"names":[],"mappings":""}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@billabex/ui-tokens",
3
- "version": "0.0.0",
3
+ "version": "0.1.1",
4
4
  "description": "Design tokens for the Billabex design system — framework-agnostic, Figma Token Studio compatible",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",
@@ -19,15 +19,6 @@
19
19
  "dist",
20
20
  "tokens.json"
21
21
  ],
22
- "scripts": {
23
- "build": "vite build && tsc --emitDeclarationOnly",
24
- "build:figma": "tsx scripts/build-figma.ts",
25
- "test": "vitest run",
26
- "test:watch": "vitest",
27
- "clean": "rm -rf dist",
28
- "lint": "tsc --noEmit",
29
- "prepare": "pnpm build:figma"
30
- },
31
22
  "devDependencies": {
32
23
  "tsx": "^4.19.0",
33
24
  "vite": "^6.0.0",
@@ -43,5 +34,13 @@
43
34
  "url": "https://github.com/billabex/lingot.git",
44
35
  "directory": "packages/ui-tokens"
45
36
  },
46
- "sideEffects": false
47
- }
37
+ "sideEffects": false,
38
+ "scripts": {
39
+ "build": "vite build && tsc --emitDeclarationOnly",
40
+ "build:figma": "tsx scripts/build-figma.ts",
41
+ "test": "vitest run",
42
+ "test:watch": "vitest",
43
+ "clean": "rm -rf dist",
44
+ "lint": "tsc --noEmit"
45
+ }
46
+ }
@@ -1,2 +0,0 @@
1
- export {};
2
- //# sourceMappingURL=tokens.test.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"tokens.test.d.ts","sourceRoot":"","sources":["../src/tokens.test.ts"],"names":[],"mappings":""}