@economic/taco-tokens 4.0.0-alpha-rules.0 → 4.1.0-EC-08912-test-tanstack-virtual.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/README.md CHANGED
@@ -37,14 +37,17 @@ import { primaryColors, borderRadius, spacing } from '@economic/taco-tokens';
37
37
  ```
38
38
  packages/taco-tokens/
39
39
  ├── scripts/
40
- │ ├── fetch-tokens.ts # Fetches tokens from Figma API (omitted)
41
- │ └── build-tokens.ts # Converts JSON to CSS/TS/JS (omitted)
40
+ │ ├── fetch-tokens.ts # Fetches tokens from Figma API (omitted)
41
+ │ ├── fetch-tokens.test.ts # Unit tests for the Export page extraction — `npm test` (omitted)
42
+ │ ├── build-tokens.ts # Converts JSON to CSS/TS/JS (omitted)
43
+ │ ├── references.ts # Tier and reference validation/resolution, used by build-tokens (omitted)
44
+ │ └── references.test.ts # Unit tests for references.ts — `npm test` (omitted)
42
45
  ├── tokens/
43
- │ ├── tokens.json # Source data (omitted)
44
- │ ├── tokens.css # CSS variables (generated & committed)
45
- │ ├── tokens.ts # TypeScript constants (generated & committed)
46
- │ └── tokens.js # Same constants as plain JS (generated & committed)
47
- ├── .env.example # Required: FIGMA_API_TOKEN, FIGMA_FILE_ID
46
+ │ ├── tokens.json # Source data (omitted)
47
+ │ ├── tokens.css # CSS variables (generated & committed)
48
+ │ ├── tokens.ts # TypeScript constants (generated & committed)
49
+ │ └── tokens.js # Same constants as plain JS (generated & committed)
50
+ ├── .env.example # Required: FIGMA_API_TOKEN, FIGMA_FILE_ID
48
51
  └── package.json
49
52
  ```
50
53
 
@@ -91,9 +94,10 @@ npm run fetch-tokens
91
94
 
92
95
  - Reads Figma file via API (you'll need access to a token and the file)
93
96
  - Extracts token values from TEXT nodes or fills
94
- - Groups by frame name (e.g., "Primary Colors", "Spacing")
97
+ - Groups by frame name (e.g., "primitive primary colors", "semantic text colors")
95
98
  - Sorts by category order (see `CATEGORY_ORDER` in script)
96
- - Outputs: `tokens/tokens.json`
99
+ - Fails without writing `tokens.json` when tokens would otherwise be dropped without a trace: a `CATEGORY_ORDER` category with no frame (renamed, or moved into a parent frame or Section), a frame without tokens, a token that isn't a group, or a group without a value. Containers on the page that aren't frames (e.g. Sections), and frames missing from `CATEGORY_ORDER`, are reported as warnings. Text and shapes are ignored, so the page can be annotated freely.
100
+ - Outputs: `tokens/tokens.json` (git-ignored). Besides `tokens`, it holds `swatches`: the swatch color of every reference token, keyed by token. Only the fetch can see Figma, so this is how the build gets what Figma renders to verify references against. Swatches never end up in the generated CSS/TS/JS.
97
101
 
98
102
  **Build only:**
99
103
 
@@ -106,7 +110,10 @@ npm run build-tokens
106
110
  - `tokens/tokens.css` - CSS custom properties
107
111
  - `tokens/tokens.ts` - TypeScript constants with type safety
108
112
  - `tokens/tokens.js` - the same constants as plain JS, loaded at runtime (Node can't strip types from `.ts` under `node_modules`)
113
+ - Formats the outputs with prettier, as the pre-commit hook would, so a sync only shows real token changes
114
+ - Every Export page frame name starts with its tier: `primitive …` or `semantic …`. The tier is dropped from output names (`primitive primary colors` → `primaryColors`), so it only shows in Figma. Primitives hold values and can't reference anything; semantic tokens may only reference primitives. The build fails on a frame without a tier, or on two frames that only differ by tier.
109
115
  - Typography size tokens keep Figma source values in `tokens.json` (`px`), but `text-*` and `heading-*` are converted to `rem` in generated CSS/TS/JS outputs (base `16px`).
116
+ - A token can reference another token: a group whose text layer reads `{gray-100}` or `{neutral-black} 70%`. Every output keeps the link, so a change to a primitive visibly flows into the tokens built on it: CSS uses `var(--taco-gray-100)` (or `color-mix(in srgb, var(--taco-neutral-black) 70%, transparent)` with an opacity), TS/JS point at the target constant (`primaryColors.tacoGray100`, or `` `${neutralColors.tacoNeutralBlack}b3` ``). Constants must be declared before use, so a reference must point to a category that comes earlier in `CATEGORY_ORDER`. Color references also need a swatch in the group — bind its fill to the Figma variable — and the build fails if the swatch (from `swatches` in `tokens.json`) doesn't match what the reference resolves to. The reference is typed by hand while the bound swatch follows the variable, so e.g. re-pointing a variable in Figma without updating its `{…}` label fails the build instead of shipping a stale reference. The build also fails on unknown or chained references and on a key appearing in two categories.
110
117
 
111
118
  ---
112
119
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@economic/taco-tokens",
3
- "version": "4.0.0-alpha-rules.0",
3
+ "version": "4.1.0-EC-08912-test-tanstack-virtual.0",
4
4
  "private": false,
5
5
  "license": "MIT",
6
6
  "type": "module",
@@ -24,16 +24,19 @@
24
24
  ],
25
25
  "scripts": {
26
26
  "fetch-tokens": "node scripts/fetch-tokens.ts",
27
- "build-tokens": "node scripts/build-tokens.ts",
27
+ "build-tokens": "node scripts/build-tokens.ts && prettier --write --log-level warn tokens/tokens.css tokens/tokens.ts tokens/tokens.js",
28
28
  "sync-tokens": "npm run fetch-tokens && npm run build-tokens",
29
- "typecheck": "tsc --noEmit"
29
+ "typecheck": "tsc --noEmit",
30
+ "test": "vitest run --globals",
31
+ "test:watch": "vitest watch --globals"
30
32
  },
31
33
  "dependencies": {
32
34
  "dotenv": "^16.6.1"
33
35
  },
34
36
  "devDependencies": {
35
- "@types/node": "^22.20.5",
36
- "typescript": "^6.0.3"
37
+ "@types/node": "^22.20.7",
38
+ "typescript": "^6.0.3",
39
+ "vitest": "^5.1.2"
37
40
  },
38
- "gitHead": "3adc1536780c2ab75a6464e9abfe0b1a8dbc8ecf"
41
+ "gitHead": "4f7b34227dcc1c795ae34e159a2aa0bb80e006d9"
39
42
  }
package/tokens/tokens.css CHANGED
@@ -28,13 +28,13 @@
28
28
  --taco-red-500: #a23e35;
29
29
  --taco-red-700: #682e28;
30
30
  --taco-red-900: #3c2825;
31
- --taco-yellow-50: #fdefba;
32
- --taco-yellow-100: #f6e191;
33
- --taco-yellow-200: #ddbc28;
34
- --taco-yellow-300: #ba9c14;
35
- --taco-yellow-500: #756208;
36
- --taco-yellow-700: #4f4100;
37
- --taco-yellow-900: #362d07;
31
+ --taco-yellow-50: #feedcd;
32
+ --taco-yellow-100: #fddda0;
33
+ --taco-yellow-200: #e3b65c;
34
+ --taco-yellow-300: #c89513;
35
+ --taco-yellow-500: #7f5d08;
36
+ --taco-yellow-700: #563e01;
37
+ --taco-yellow-900: #3c2a02;
38
38
  --taco-green-50: #d9f7eb;
39
39
  --taco-green-100: #c5ecdd;
40
40
  --taco-green-200: #90cdb7;
@@ -105,4 +105,26 @@
105
105
  --taco-border-width-2: 2px;
106
106
  --taco-border-width-1: 1px;
107
107
  --taco-border-width-0: 0px;
108
+
109
+ /* Border Colors */
110
+ --taco-color-border-focus: var(--taco-blue-500);
111
+ --taco-color-border-emphasis: var(--taco-gray-500);
112
+ --taco-color-border-default: var(--taco-gray-100);
113
+
114
+ /* Background Colors */
115
+ --taco-color-background-surface-modal-backdrop: color-mix(in srgb, var(--taco-neutral-black) 70%, transparent);
116
+ --taco-color-background-surface-canvas: var(--taco-gray-50);
117
+ --taco-color-background-page-default: var(--taco-neutral-white);
118
+ --taco-color-background-surface-default: var(--taco-neutral-white);
119
+
120
+ /* Icon Colors */
121
+ --taco-color-icon-inverted: var(--taco-neutral-white);
122
+ --taco-color-icon-subtle: var(--taco-gray-500);
123
+ --taco-color-icon-default: var(--taco-neutral-black);
124
+
125
+ /* Text Colors */
126
+ --taco-color-text-inverted: var(--taco-neutral-white);
127
+ --taco-color-text-link: var(--taco-blue-700);
128
+ --taco-color-text-subtle: var(--taco-gray-500);
129
+ --taco-color-text-default: var(--taco-neutral-black);
108
130
  }
package/tokens/tokens.js CHANGED
@@ -30,13 +30,13 @@ export const secondaryColors = {
30
30
  tacoRed500: '#a23e35',
31
31
  tacoRed700: '#682e28',
32
32
  tacoRed900: '#3c2825',
33
- tacoYellow50: '#fdefba',
34
- tacoYellow100: '#f6e191',
35
- tacoYellow200: '#ddbc28',
36
- tacoYellow300: '#ba9c14',
37
- tacoYellow500: '#756208',
38
- tacoYellow700: '#4f4100',
39
- tacoYellow900: '#362d07',
33
+ tacoYellow50: '#feedcd',
34
+ tacoYellow100: '#fddda0',
35
+ tacoYellow200: '#e3b65c',
36
+ tacoYellow300: '#c89513',
37
+ tacoYellow500: '#7f5d08',
38
+ tacoYellow700: '#563e01',
39
+ tacoYellow900: '#3c2a02',
40
40
  tacoGreen50: '#d9f7eb',
41
41
  tacoGreen100: '#c5ecdd',
42
42
  tacoGreen200: '#90cdb7',
@@ -123,6 +123,36 @@ export const borderWidth = {
123
123
  tacoBorderWidth0: '0px',
124
124
  };
125
125
 
126
+ /* Border Colors */
127
+ export const borderColors = {
128
+ tacoColorBorderFocus: primaryColors.tacoBlue500,
129
+ tacoColorBorderEmphasis: primaryColors.tacoGray500,
130
+ tacoColorBorderDefault: primaryColors.tacoGray100,
131
+ };
132
+
133
+ /* Background Colors */
134
+ export const backgroundColors = {
135
+ tacoColorBackgroundSurfaceModalBackdrop: `${neutralColors.tacoNeutralBlack}b3`,
136
+ tacoColorBackgroundSurfaceCanvas: primaryColors.tacoGray50,
137
+ tacoColorBackgroundPageDefault: neutralColors.tacoNeutralWhite,
138
+ tacoColorBackgroundSurfaceDefault: neutralColors.tacoNeutralWhite,
139
+ };
140
+
141
+ /* Icon Colors */
142
+ export const iconColors = {
143
+ tacoColorIconInverted: neutralColors.tacoNeutralWhite,
144
+ tacoColorIconSubtle: primaryColors.tacoGray500,
145
+ tacoColorIconDefault: neutralColors.tacoNeutralBlack,
146
+ };
147
+
148
+ /* Text Colors */
149
+ export const textColors = {
150
+ tacoColorTextInverted: neutralColors.tacoNeutralWhite,
151
+ tacoColorTextLink: primaryColors.tacoBlue700,
152
+ tacoColorTextSubtle: primaryColors.tacoGray500,
153
+ tacoColorTextDefault: neutralColors.tacoNeutralBlack,
154
+ };
155
+
126
156
  /* All tokens combined */
127
157
  export const tokens = {
128
158
  primaryColors,
@@ -134,4 +164,8 @@ export const tokens = {
134
164
  typography,
135
165
  borderRadius,
136
166
  borderWidth,
167
+ borderColors,
168
+ backgroundColors,
169
+ iconColors,
170
+ textColors,
137
171
  };
package/tokens/tokens.ts CHANGED
@@ -30,13 +30,13 @@ export const secondaryColors = {
30
30
  tacoRed500: '#a23e35',
31
31
  tacoRed700: '#682e28',
32
32
  tacoRed900: '#3c2825',
33
- tacoYellow50: '#fdefba',
34
- tacoYellow100: '#f6e191',
35
- tacoYellow200: '#ddbc28',
36
- tacoYellow300: '#ba9c14',
37
- tacoYellow500: '#756208',
38
- tacoYellow700: '#4f4100',
39
- tacoYellow900: '#362d07',
33
+ tacoYellow50: '#feedcd',
34
+ tacoYellow100: '#fddda0',
35
+ tacoYellow200: '#e3b65c',
36
+ tacoYellow300: '#c89513',
37
+ tacoYellow500: '#7f5d08',
38
+ tacoYellow700: '#563e01',
39
+ tacoYellow900: '#3c2a02',
40
40
  tacoGreen50: '#d9f7eb',
41
41
  tacoGreen100: '#c5ecdd',
42
42
  tacoGreen200: '#90cdb7',
@@ -123,6 +123,36 @@ export const borderWidth = {
123
123
  tacoBorderWidth0: '0px',
124
124
  } as const;
125
125
 
126
+ /* Border Colors */
127
+ export const borderColors = {
128
+ tacoColorBorderFocus: primaryColors.tacoBlue500,
129
+ tacoColorBorderEmphasis: primaryColors.tacoGray500,
130
+ tacoColorBorderDefault: primaryColors.tacoGray100,
131
+ } as const;
132
+
133
+ /* Background Colors */
134
+ export const backgroundColors = {
135
+ tacoColorBackgroundSurfaceModalBackdrop: `${neutralColors.tacoNeutralBlack}b3`,
136
+ tacoColorBackgroundSurfaceCanvas: primaryColors.tacoGray50,
137
+ tacoColorBackgroundPageDefault: neutralColors.tacoNeutralWhite,
138
+ tacoColorBackgroundSurfaceDefault: neutralColors.tacoNeutralWhite,
139
+ } as const;
140
+
141
+ /* Icon Colors */
142
+ export const iconColors = {
143
+ tacoColorIconInverted: neutralColors.tacoNeutralWhite,
144
+ tacoColorIconSubtle: primaryColors.tacoGray500,
145
+ tacoColorIconDefault: neutralColors.tacoNeutralBlack,
146
+ } as const;
147
+
148
+ /* Text Colors */
149
+ export const textColors = {
150
+ tacoColorTextInverted: neutralColors.tacoNeutralWhite,
151
+ tacoColorTextLink: primaryColors.tacoBlue700,
152
+ tacoColorTextSubtle: primaryColors.tacoGray500,
153
+ tacoColorTextDefault: neutralColors.tacoNeutralBlack,
154
+ } as const;
155
+
126
156
  /* All tokens combined */
127
157
  export const tokens = {
128
158
  primaryColors,
@@ -134,6 +164,10 @@ export const tokens = {
134
164
  typography,
135
165
  borderRadius,
136
166
  borderWidth,
167
+ borderColors,
168
+ backgroundColors,
169
+ iconColors,
170
+ textColors,
137
171
  } as const;
138
172
 
139
173
  /* Types */