ui-foundations 0.1.1 → 0.3.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 +68 -227
- package/dist/core/index.css +7 -7
- package/dist/main.css +462 -289
- package/dist/react/index.js +1 -0
- package/dist/react/switch.js +45 -0
- package/dist/tokens/css/{color.dark.tokens.css → appearance-(modes).tokens.mode-dark.css} +2 -2
- package/dist/tokens/css/{color.light.tokens.css → appearance-(modes).tokens.mode-light.css} +3 -3
- package/dist/tokens/css/{component.tokens.css → components-(ui).tokens.css} +70 -54
- package/dist/tokens/css/{primitives.tokens.css → core-(primitives).tokens.css} +21 -21
- package/dist/tokens/css/{semantic.tokens.css → semantics-(roles).tokens.css} +7 -6
- package/dist/tokens/css/{brand-a.tokens.css → themes-(brands).tokens.brand-a.css} +11 -11
- package/dist/tokens/css/{brand-b.tokens.css → themes-(brands).tokens.brand-b.css} +10 -10
- package/dist/tokens/json/appearance-(modes).tokens.mode-dark.json +182 -0
- package/dist/tokens/json/appearance-(modes).tokens.mode-light.json +182 -0
- package/dist/tokens/json/components-(ui).tokens.json +739 -0
- package/dist/tokens/json/{primitives.tokens.json → core-(primitives).tokens.json} +766 -772
- package/dist/tokens/json/semantics-(roles).tokens.json +203 -0
- package/dist/tokens/json/themes-(brands).tokens.brand-a.json +115 -0
- package/dist/tokens/json/themes-(brands).tokens.brand-b.json +115 -0
- package/dist/tokens/tokens.yaml +1068 -847
- package/dist/tokens/ts/{color.dark.tokens.ts → appearance-(modes).tokens.mode-dark.ts} +3 -3
- package/dist/tokens/ts/{color.light.tokens.ts → appearance-(modes).tokens.mode-light.ts} +4 -4
- package/dist/tokens/ts/{component.tokens.ts → components-(ui).tokens.ts} +71 -55
- package/dist/tokens/ts/{primitives.tokens.ts → core-(primitives).tokens.ts} +22 -22
- package/dist/tokens/ts/{semantic.tokens.ts → semantics-(roles).tokens.ts} +7 -6
- package/dist/tokens/ts/{brand-a.tokens.ts → themes-(brands).tokens.brand-a.ts} +13 -13
- package/dist/tokens/ts/{brand-b.tokens.ts → themes-(brands).tokens.brand-b.ts} +12 -12
- package/dist/ui/index.css +1 -0
- package/dist/ui/patterns/button.css +1 -0
- package/dist/ui/patterns/switch.css +155 -0
- package/docs/agentic/assistant-behavior-rules.md +16 -0
- package/docs/agentic/skills/README.md +51 -0
- package/docs/agentic/skills/design-ops-specialist/SKILL.md +60 -0
- package/docs/agentic/skills/design-system-architect/SKILL.md +106 -0
- package/docs/agentic/team-ai-playbook.md +226 -0
- package/docs/foundations/foundation-010-implementation-and-pipeline-workflow.md +82 -0
- package/docs/foundations/foundation-011-branching-and-release-governance.md +42 -0
- package/docs/foundations/foundation-012-minimal-markup-and-composition.md +42 -0
- package/package.json +24 -12
- package/dist/tokens/json/brand-a.tokens.json +0 -192
- package/dist/tokens/json/brand-b.tokens.json +0 -192
- package/dist/tokens/json/color.dark.tokens.json +0 -364
- package/dist/tokens/json/color.light.tokens.json +0 -364
- package/dist/tokens/json/component.tokens.json +0 -1101
- package/dist/tokens/json/semantic.tokens.json +0 -206
package/README.md
CHANGED
|
@@ -1,259 +1,100 @@
|
|
|
1
1
|
# UI Foundations
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
A token-first design system that uses Figma as the single source of truth and automatically generates CSS, JSON, and TypeScript tokens.
|
|
4
4
|
|
|
5
|
-
|
|
6
|
-
- Component token APIs (variants, parts, properties, states)
|
|
7
|
-
- Foundational architecture rules for long-term consistency
|
|
8
|
-
- Docs/playground generated with Eleventy
|
|
5
|
+
## Pipeline
|
|
9
6
|
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
- A **multi-brand** and **multi-mode** ready architecture
|
|
14
|
-
- A place to document foundational rules that must remain stable over time
|
|
15
|
-
|
|
16
|
-
## What this is not (yet)
|
|
17
|
-
|
|
18
|
-
- A full “product design system” with all patterns, usage guidelines, and governance
|
|
19
|
-
- Product-specific application rules (these live downstream in product repositories)
|
|
20
|
-
|
|
21
|
-
## Architecture (4 layers)
|
|
22
|
-
|
|
23
|
-
1. **Core (Primitives)**
|
|
24
|
-
Raw physical values: spacing, radii, borders, typography primitives, layout constants.
|
|
25
|
-
|
|
26
|
-
2. **Color Modes (Light/Dark)**
|
|
27
|
-
Theme palettes: brand colors, neutrals, overlays. No semantic meaning.
|
|
28
|
-
|
|
29
|
-
3. **Semantics (Roles)**
|
|
30
|
-
Meaning-based roles: `Color.Text.*`, `Color.Fill.*`, `Color.Border.*`, `Typography.*`, `Corner.*`.
|
|
31
|
-
Supports brand modes (e.g. TUI, ROBINSON, LTUR).
|
|
32
|
-
|
|
33
|
-
4. **Components (APIs)**
|
|
34
|
-
Component-level API rules: variants, parts, properties, states.
|
|
35
|
-
Components reference semantic roles—**never raw values**.
|
|
36
|
-
|
|
37
|
-
## Naming conventions
|
|
38
|
-
|
|
39
|
-
Component tokens use a **variant-first** grouping:
|
|
40
|
-
|
|
41
|
-
`Component.variant.part.property.state`
|
|
42
|
-
|
|
43
|
-
Example:
|
|
44
|
-
|
|
45
|
-
- `Button.solid.container.background.default`
|
|
46
|
-
- `Button.outline.container.border-color.hover`
|
|
47
|
-
|
|
48
|
-
Rules:
|
|
49
|
-
|
|
50
|
-
- **Typography never includes color** (color lives in `Color.Text.*`)
|
|
51
|
-
- **Components never introduce new colors** (they reference semantic roles)
|
|
52
|
-
- Layout primitives (breakpoints, container sizes, z-index) live in **Core**
|
|
53
|
-
|
|
54
|
-
## Repository structure
|
|
55
|
-
|
|
56
|
-
- `figma/exports/` — token source exports from Figma
|
|
57
|
-
- `dist/tokens/` — generated token artifacts (CSS/JSON/TS)
|
|
58
|
-
- `src/` — package source layers (Core/UI/React)
|
|
59
|
-
- `site/` — Eleventy preview/docs site (templates + docs-specific CSS)
|
|
60
|
-
- `docs/foundations/` — foundational architecture and token rules (source of truth)
|
|
61
|
-
- `docs/agentic/` — assistant behavior rules and AI collaboration playbooks
|
|
62
|
-
- `figma/` — Figma exports, mappings, Code Connect notes
|
|
63
|
-
- `AGENTS.md` — entrypoint for AI coding agents
|
|
64
|
-
|
|
65
|
-
Docs structure (`site/`):
|
|
66
|
-
- `_includes/layouts/` — shared Nunjucks layouts
|
|
67
|
-
- `tokens/*.md` — token docs pages (Eleventy collection)
|
|
68
|
-
- `components/*.md` — component docs pages (Eleventy collection)
|
|
69
|
-
- `assets/docs.css` — docs-only styling
|
|
7
|
+
```
|
|
8
|
+
Figma Variables → Plugin Export → figma/exports/*.tokens.json → extract-tokens.js → dist/ (CSS, JSON, TS, YAML)
|
|
9
|
+
```
|
|
70
10
|
|
|
71
|
-
|
|
72
|
-
- `AGENTS.md` — quick entrypoint and baseline checks for agents
|
|
73
|
-
- `docs/agentic/assistant-behavior-rules.md` — assistant-specific guardrails
|
|
74
|
-
- `docs/agentic/team-ai-playbook.md` — standard AI-assisted workflows for component incubation and token roundtrips
|
|
11
|
+
## Features
|
|
75
12
|
|
|
76
|
-
|
|
13
|
+
- 5 variable collections: Core Primitives, Themes (Brands), Appearance (Modes), Semantics (Roles), Components (UI)
|
|
14
|
+
- Multi-brand support (Brand A/B) via `data-brand` selectors
|
|
15
|
+
- Dark/light mode via `data-mode` selectors
|
|
16
|
+
- Content-based scope detection (independent of filenames)
|
|
17
|
+
- Figma plugin with Validate + Export tabs (see `figma/plugin/README.md`)
|
|
18
|
+
- CI pipeline: lint, unit tests, build, smoke check, docs build
|
|
19
|
+
- Docs site with Eleventy, auto-generated from token data
|
|
77
20
|
|
|
78
|
-
|
|
79
|
-
Figma
|
|
80
|
-
├─ 0) Run boundary + utility check
|
|
81
|
-
│ ├─ Is this a standalone component or composition of an existing one?
|
|
82
|
-
│ └─ Snowflake check: one-off local case vs shared cross-context utility
|
|
83
|
-
├─ 1) Create/update component tokens
|
|
84
|
-
│ └─ figma/exports/Component.tokens.json
|
|
85
|
-
├─ 2) (Optional) Add/update Code Connect mapping
|
|
86
|
-
│ └─ figma/connections/web-<component>.figma.ts
|
|
87
|
-
└─ 3) Regenerate generated artifacts
|
|
88
|
-
└─ npm run build:all
|
|
89
|
-
├─ dist/tokens/*
|
|
90
|
-
├─ dist/ui/*
|
|
91
|
-
├─ dist/react/*
|
|
92
|
-
└─ dist/main.css
|
|
21
|
+
## Tech Stack
|
|
93
22
|
|
|
94
|
-
|
|
95
|
-
├─ 4) Add CSS pattern
|
|
96
|
-
│ └─ src/ui/patterns/<component>.css
|
|
97
|
-
├─ 5) Export pattern in UI bundle
|
|
98
|
-
│ └─ src/ui/index.css
|
|
99
|
-
├─ 6) Add React wrapper (if needed)
|
|
100
|
-
│ ├─ src/react/<component>.js
|
|
101
|
-
│ └─ src/react/index.js
|
|
102
|
-
└─ 7) Add assets (if needed)
|
|
103
|
-
└─ src/assets/*
|
|
23
|
+
Vanilla CSS (Custom Properties, Layers), Node.js scripts, Eleventy, Figma Plugin API, MCP.
|
|
104
24
|
|
|
105
|
-
|
|
106
|
-
├─ 8) Add component docs page
|
|
107
|
-
│ └─ site/components/<component>.md
|
|
108
|
-
├─ 9) Add playground page
|
|
109
|
-
│ └─ site/components/<component>-playground.md
|
|
110
|
-
├─ 10) Extend macros (if needed)
|
|
111
|
-
│ └─ site/_includes/macros/{ui.njk,playground.njk}
|
|
112
|
-
└─ 11) Extend playground runtime (only for new behavior)
|
|
113
|
-
└─ site/assets/playground/{renderers.js,state.js,code.js,shared.js}
|
|
25
|
+
## Install
|
|
114
26
|
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
├─ npm run build:all
|
|
118
|
-
├─ npm run docs:site
|
|
119
|
-
└─ npm run ci:check
|
|
27
|
+
```bash
|
|
28
|
+
npm install ui-foundations
|
|
120
29
|
```
|
|
121
30
|
|
|
122
|
-
##
|
|
123
|
-
|
|
124
|
-
This project is designed for a collaborative build loop between design and implementation, not only for one-way token export.
|
|
31
|
+
## Usage
|
|
125
32
|
|
|
126
|
-
```
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
│ ├─ standalone component or composition inside an existing component family
|
|
130
|
-
│ └─ Snowflake check: solves one local case or reusable across contexts
|
|
131
|
-
├─ 1) Ask the assistant for a proposed component setup
|
|
132
|
-
│ ├─ component structure (HTML/CSS/React)
|
|
133
|
-
│ ├─ token naming proposal
|
|
134
|
-
│ └─ docs/playground example
|
|
135
|
-
├─ 2) Review and adapt the proposal
|
|
136
|
-
│ └─ align names and states with your design language
|
|
137
|
-
├─ 3) Create/import the proposed tokens in Figma
|
|
138
|
-
│ └─ refine values and variants in design
|
|
139
|
-
├─ 4) Export from Figma back into this repository
|
|
140
|
-
│ └─ figma/exports/*.tokens.json
|
|
141
|
-
├─ 5) Let the assistant integrate and align implementation
|
|
142
|
-
│ ├─ src/ui/patterns/<component>.css
|
|
143
|
-
│ ├─ src/react/<component>.js
|
|
144
|
-
│ ├─ site/components/<component>.md
|
|
145
|
-
│ ├─ site/components/<component>-playground.md
|
|
146
|
-
│ └─ figma/connections/web-<component>.figma.ts (if needed)
|
|
147
|
-
└─ 6) Validate and iterate
|
|
148
|
-
├─ npm run ci:check
|
|
149
|
-
└─ repeat loop for naming, states, a11y, and behavior refinements
|
|
33
|
+
```js
|
|
34
|
+
import "ui-foundations/core.css";
|
|
35
|
+
import "ui-foundations/ui.css";
|
|
150
36
|
```
|
|
151
37
|
|
|
152
|
-
|
|
153
|
-
- It closes the gap between design intent and production implementation.
|
|
154
|
-
- It keeps token naming and component APIs consistent across Figma and code.
|
|
155
|
-
- It makes component incubation faster while staying auditable in Git.
|
|
156
|
-
|
|
157
|
-
## Script locations
|
|
158
|
-
|
|
159
|
-
- `scripts/` — build, token extraction, validation, lint and smoke-check automation for local/CI usage
|
|
160
|
-
- `site/assets/playground/` — browser runtime modules for docs playground (shared helpers, state, code formatting, renderers)
|
|
161
|
-
- `tests/` — unit tests for extraction helpers and edge-case behavior
|
|
162
|
-
|
|
163
|
-
## CSS variable naming
|
|
164
|
-
|
|
165
|
-
CSS custom property names are derived from `com.figma.codeSyntax.WEB`.
|
|
166
|
-
If a token is missing `codeSyntax.WEB`, a warning is logged and the build
|
|
167
|
-
falls back to an auto-derived token name.
|
|
168
|
-
|
|
169
|
-
Scopes are derived from export filenames:
|
|
170
|
-
|
|
171
|
-
- `Brand X.tokens.json` -> `:root[data-brand="x"]`
|
|
172
|
-
- `Mode Light.tokens.json` -> `:root`
|
|
173
|
-
- `Mode Dark.tokens.json` -> `:root[data-mode="dark"]`
|
|
38
|
+
Runtime scope switching:
|
|
174
39
|
|
|
175
|
-
|
|
40
|
+
```js
|
|
41
|
+
const root = document.documentElement;
|
|
42
|
+
root.dataset.brand = "a"; // "a" | "b"
|
|
43
|
+
root.dataset.mode = "light"; // "light" | "dark"
|
|
44
|
+
```
|
|
176
45
|
|
|
177
|
-
|
|
46
|
+
## Local Development
|
|
178
47
|
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
- Optional: include Figma metadata sidecars with `npm run tokens:generate -- --include-figma-metadata` (writes `*.figma.json`)
|
|
48
|
+
```bash
|
|
49
|
+
npm run build:all # generate tokens + build CSS
|
|
50
|
+
npm run docs:dev # build + serve docs site
|
|
51
|
+
```
|
|
184
52
|
|
|
185
|
-
|
|
53
|
+
Figma sync workflow:
|
|
186
54
|
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
55
|
+
```bash
|
|
56
|
+
# 1. Export tokens via Figma plugin (📦 Export tab)
|
|
57
|
+
# 2. Place JSON files in figma/exports/
|
|
58
|
+
# 3. Build
|
|
59
|
+
npm run build:all
|
|
60
|
+
```
|
|
190
61
|
|
|
191
|
-
|
|
62
|
+
Validation:
|
|
192
63
|
|
|
193
|
-
|
|
64
|
+
```bash
|
|
65
|
+
npm run lint
|
|
66
|
+
npm run test:unit
|
|
67
|
+
npm run ci:check
|
|
68
|
+
```
|
|
194
69
|
|
|
195
|
-
|
|
196
|
-
Scaffold and implement a new UI component named <component-name> in this repository.
|
|
70
|
+
## MCP Integration
|
|
197
71
|
|
|
198
|
-
|
|
199
|
-
- docs/agentic/team-ai-playbook.md
|
|
200
|
-
- docs/agentic/assistant-behavior-rules.md
|
|
201
|
-
- docs/foundations/*
|
|
72
|
+
This repo supports Figma integration via MCP (Model Context Protocol). Two servers are used:
|
|
202
73
|
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
2) Keep scope small, incremental, and reviewable in Git.
|
|
206
|
-
3) Implement token-first and reuse existing patterns:
|
|
207
|
-
- src/ui/patterns/<component>.css
|
|
208
|
-
- src/react/<component>.js and src/react/index.js (if needed)
|
|
209
|
-
- site/components/<component>.md
|
|
210
|
-
- site/components/<component>-playground.md
|
|
211
|
-
- figma/connections/web-<component>.figma.ts (only if a publishable top-level Figma component/component-set exists)
|
|
212
|
-
4) Validate before handoff:
|
|
213
|
-
- npm run lint
|
|
214
|
-
- npm run test:unit
|
|
215
|
-
- npm run ci:check
|
|
74
|
+
- `figma-developer-mcp` — REST API read access (requires `FIGMA_TOKEN` in `.env`)
|
|
75
|
+
- Figma Desktop MCP — local server via Figma Desktop app (enable in Dev Mode inspect panel)
|
|
216
76
|
|
|
217
|
-
|
|
218
|
-
- Start with: Tasks completion: 0/4
|
|
219
|
-
- Update after each phase: 1/4, 2/4, 3/4, 4/4
|
|
77
|
+
Configure these in your agent's MCP config. Example for the REST API server:
|
|
220
78
|
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
-
|
|
225
|
-
|
|
79
|
+
```json
|
|
80
|
+
{
|
|
81
|
+
"command": "npx",
|
|
82
|
+
"args": ["-y", "figma-developer-mcp", "--figma-api-key=YOUR_TOKEN", "--stdio"]
|
|
83
|
+
}
|
|
226
84
|
```
|
|
227
85
|
|
|
228
|
-
##
|
|
229
|
-
|
|
230
|
-
1. Optional syntax lint for JS files: `npm run lint`
|
|
231
|
-
2. Optional unit tests for extractor helpers: `npm run test:unit`
|
|
232
|
-
3. Generate token outputs (after Figma export updates): `npm run tokens:generate`
|
|
233
|
-
4. Build CSS bundles from already generated tokens: `npm run build:css`
|
|
234
|
-
5. Full refresh in one command (tokens + CSS): `npm run build:all`
|
|
235
|
-
6. Run smoke checks for generated artifacts: `npm run smoke:check`
|
|
236
|
-
7. Build docs: `npm run docs:site`
|
|
237
|
-
8. Run CI-equivalent checks locally: `npm run ci:check`
|
|
86
|
+
## Documentation
|
|
238
87
|
|
|
239
|
-
|
|
88
|
+
- Foundations: `docs/foundations/`
|
|
89
|
+
- AI playbook: `docs/agentic/team-ai-playbook.md`
|
|
90
|
+
- Figma plugin (Token Foundry): `figma/plugin/README.md`
|
|
91
|
+
- Docs site: `site/`
|
|
92
|
+
- Vanilla starter: `site/examples/vanilla-starter.md`
|
|
240
93
|
|
|
241
|
-
##
|
|
94
|
+
## Release
|
|
242
95
|
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
- `scripts/extract-tokens.value.js` — token grouping + output value formatting
|
|
249
|
-
- `scripts/extract-tokens.scope.js` — scope parsing and selector/output-base normalization
|
|
250
|
-
|
|
251
|
-
Data flow:
|
|
252
|
-
1. Read `figma/exports/*.tokens.json` (JSON/JSONC supported)
|
|
253
|
-
2. Flatten tokens + resolve aliases across the combined lookup
|
|
254
|
-
3. Assign CSS variable names from `com.figma.codeSyntax.WEB`
|
|
255
|
-
4. Emit `dist/tokens/{css,json,ts}` and `dist/tokens/tokens.yaml`
|
|
256
|
-
|
|
257
|
-
Fallback behavior:
|
|
258
|
-
- Missing or invalid `com.figma.codeSyntax.WEB` values fall back to auto-derived CSS variable names and are reported in the extract summary.
|
|
259
|
-
- Missing alias targets and alias cycles fall back to literal values and are reported.
|
|
96
|
+
```bash
|
|
97
|
+
npm run release:patch # or release:minor / release:major
|
|
98
|
+
npm run release:push
|
|
99
|
+
npm run release:publish
|
|
100
|
+
```
|
package/dist/core/index.css
CHANGED
|
@@ -2,11 +2,11 @@
|
|
|
2
2
|
@import url("./base/fonts.css") layer(base);
|
|
3
3
|
@import url("./base/base.css") layer(base);
|
|
4
4
|
@import url("./base/typography.css") layer(base);
|
|
5
|
-
@import url("../tokens/css/
|
|
6
|
-
@import url("../tokens/css/
|
|
7
|
-
@import url("../tokens/css/
|
|
8
|
-
@import url("../tokens/css/
|
|
9
|
-
@import url("../tokens/css/
|
|
10
|
-
@import url("../tokens/css/
|
|
11
|
-
@import url("../tokens/css/
|
|
5
|
+
@import url("../tokens/css/semantics-(roles).tokens.css") layer(tokens);
|
|
6
|
+
@import url("../tokens/css/components-(ui).tokens.css") layer(tokens);
|
|
7
|
+
@import url("../tokens/css/appearance-(modes).tokens.mode-dark.css") layer(tokens);
|
|
8
|
+
@import url("../tokens/css/appearance-(modes).tokens.mode-light.css") layer(tokens);
|
|
9
|
+
@import url("../tokens/css/core-(primitives).tokens.css") layer(tokens);
|
|
10
|
+
@import url("../tokens/css/themes-(brands).tokens.brand-a.css") layer(tokens);
|
|
11
|
+
@import url("../tokens/css/themes-(brands).tokens.brand-b.css") layer(tokens);
|
|
12
12
|
@import url("./themes/mode.css") layer(themes);
|