Skip to content
This repository was archived by the owner on Mar 7, 2026. It is now read-only.

Commit dd21a47

Browse files
fix: update order of steps in tokens-check workflow (#7)
* feat(theme): complete design tokens documentation and add tokens-check script * docs: update project plan for task 1.5 * fix: update order of steps in tokens-check workflow * fix: update install dependencies command to not use frozen-lockfile
1 parent a097426 commit dd21a47

File tree

5 files changed

+123
-9
lines changed

5 files changed

+123
-9
lines changed

.github/workflows/tokens-check.yml

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
name: Design Tokens Check
2+
3+
on:
4+
push:
5+
branches: [main, develop]
6+
paths:
7+
- 'packages/ui-kit/src/theme/**'
8+
pull_request:
9+
branches: [main, develop]
10+
paths:
11+
- 'packages/ui-kit/src/theme/**'
12+
13+
jobs:
14+
tokens-check:
15+
name: Check Design Tokens Documentation
16+
runs-on: ubuntu-latest
17+
steps:
18+
- name: Checkout repository
19+
uses: actions/checkout@v4
20+
21+
- name: Install pnpm
22+
uses: pnpm/action-setup@v3
23+
with:
24+
version: 8
25+
run_install: false
26+
27+
- name: Setup Node.js
28+
uses: actions/setup-node@v4
29+
with:
30+
node-version: '20'
31+
cache: 'pnpm'
32+
33+
- name: Install dependencies
34+
run: pnpm install --no-frozen-lockfile
35+
36+
- name: Run tokens-check script
37+
working-directory: packages/ui-kit
38+
run: pnpm tokens-check

docs/project_plan.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,8 +33,8 @@ A pragmatic breakdown into **four one‑week sprints** plus a preparatory **Spri
3333
| 1.2b | Install and configure Storybook addon‑docs. | Documentation tab shows component documentation. ||
3434
| 1.2c | Configure and verify Storybook addon‑a11y. | axe‑a11y addon shows zero violations. ||
3535
| 1.3 | Add global theme bridging (`theme.css` ↔ DaisyUI). | Cypress visual diff (light/dark) matches golden images. ||
36-
| 1.4 | Create first **AuthShell** layout with logo slot. | Rendered via Storybook; Playwright snapshot approved. | PR |
37-
| 1.5 | Document design tokens (`DESIGN_TOKENS.md`). | File exists; CI step `tokens-check` verifies presence of each CSS var. | |
36+
| 1.4 | Create first **AuthShell** layout with logo slot. | Rendered via Storybook; Playwright snapshot approved. | |
37+
| 1.5 | Document design tokens (`DESIGN_TOKENS.md`). | File exists; CI step `tokens-check` verifies presence of each CSS var. | PR |
3838

3939
---
4040

packages/ui-kit/package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,8 @@
3030
"theme-screenshots": "cypress run --spec \"cypress/e2e/theme.cy.ts\"",
3131
"playwright:install": "playwright install",
3232
"playwright:test": "playwright test",
33-
"playwright:update-snapshots": "playwright test --update-snapshots"
33+
"playwright:update-snapshots": "playwright test --update-snapshots",
34+
"tokens-check": "node scripts/tokens-check.js"
3435
},
3536
"dependencies": {
3637
"@radix-ui/react-slot": "^1.0.2",
Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
#!/usr/bin/env node
2+
3+
/**
4+
* Design tokens consistency checker
5+
*
6+
* This script ensures that all CSS variables defined in theme.css
7+
* are properly documented in DESIGN_TOKENS.md
8+
*/
9+
10+
/* global console, process */
11+
12+
import fs from 'fs';
13+
import path from 'path';
14+
import { fileURLToPath } from 'url';
15+
16+
// Get current file and directory paths
17+
const __filename = fileURLToPath(import.meta.url);
18+
const __dirname = path.dirname(__filename);
19+
20+
// File paths
21+
const themeCssPath = path.join(__dirname, '../src/theme/theme.css');
22+
const tokensMdPath = path.join(__dirname, '../src/theme/DESIGN_TOKENS.md');
23+
24+
// Read the files
25+
const themeCss = fs.readFileSync(themeCssPath, 'utf8');
26+
const tokensMd = fs.readFileSync(tokensMdPath, 'utf8');
27+
28+
// Extract CSS variables from theme.css
29+
function extractCssVariables(css) {
30+
const regex = /--[\w-]+(?=:)/g;
31+
const matches = css.match(regex);
32+
33+
// Remove duplicates (variables can appear in both :root and .dark)
34+
return [...new Set(matches)];
35+
}
36+
37+
// Check if variables are documented in DESIGN_TOKENS.md
38+
function checkVariablesDocumented(variables, doc) {
39+
const undocumented = [];
40+
41+
for (const variable of variables) {
42+
const variableRegex = new RegExp(`\`${variable}\``, 'g');
43+
if (!variableRegex.test(doc)) {
44+
undocumented.push(variable);
45+
}
46+
}
47+
48+
return undocumented;
49+
}
50+
51+
// Main function
52+
function main() {
53+
console.log('🔍 Checking design tokens documentation...');
54+
55+
const cssVariables = extractCssVariables(themeCss);
56+
console.log(`Found ${cssVariables.length} CSS variables in theme.css`);
57+
58+
const undocumentedVariables = checkVariablesDocumented(cssVariables, tokensMd);
59+
60+
if (undocumentedVariables.length === 0) {
61+
console.log('✅ All CSS variables are properly documented in DESIGN_TOKENS.md');
62+
process.exit(0);
63+
} else {
64+
console.error('❌ The following CSS variables are not documented in DESIGN_TOKENS.md:');
65+
undocumentedVariables.forEach(v => console.error(` - ${v}`));
66+
console.error(`\nPlease add documentation for these ${undocumentedVariables.length} variables to maintain the design system consistency.`);
67+
process.exit(1);
68+
}
69+
}
70+
71+
main();

packages/ui-kit/src/theme/DESIGN_TOKENS.md

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -57,12 +57,16 @@ This document provides an overview of the design tokens used in the UI-Kit. Thes
5757

5858
### Shadows
5959

60-
| Token | Description |
61-
| ------------- | -------------- |
62-
| `--shadow-sm` | Small shadow |
63-
| `--shadow` | Default shadow |
64-
| `--shadow-md` | Medium shadow |
65-
| `--shadow-lg` | Large shadow |
60+
| Token | Value | Description |
61+
| ------------------- | -------------------- | ----------------------------------- |
62+
| `--shadow-color` | `220 3% 15%` (light) | Color used for shadow calculations |
63+
| | `220 40% 2%` (dark) | Darker in dark mode |
64+
| `--shadow-strength` | `1%` (light) | Opacity strength for shadow effects |
65+
| | `4%` (dark) | Stronger in dark mode |
66+
| `--shadow-sm` | Calculated value | Small shadow |
67+
| `--shadow` | Calculated value | Default shadow |
68+
| `--shadow-md` | Calculated value | Medium shadow |
69+
| `--shadow-lg` | Calculated value | Large shadow |
6670

6771
## Theme Switching
6872

0 commit comments

Comments
 (0)