@cdx-ui/styles 0.0.1-alpha.34
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 +171 -0
- package/css/theme.css +613 -0
- package/css/utilities.css +99 -0
- package/css/vanilla.css +609 -0
- package/lib/commonjs/index.js +2 -0
- package/lib/commonjs/index.js.map +1 -0
- package/lib/commonjs/package.json +1 -0
- package/lib/module/index.js +2 -0
- package/lib/module/index.js.map +1 -0
- package/lib/typescript/index.d.ts +58 -0
- package/lib/typescript/index.d.ts.map +1 -0
- package/package.json +70 -0
- package/src/index.ts +67 -0
- package/tokens/presets/.manifest.json +5 -0
- package/tokens/presets/poise.json +3081 -0
- package/tokens/presets/prestige.json +1975 -0
- package/tokens/presets/pulse.json +1975 -0
package/README.md
ADDED
|
@@ -0,0 +1,171 @@
|
|
|
1
|
+
# @cdx-ui/styles
|
|
2
|
+
|
|
3
|
+
Design tokens and theme infrastructure for the Candescent Design System. Tokens flow from Figma Variables through a Style Dictionary pipeline into CSS custom properties, Tailwind v4 theme variables, and runtime theming artifacts — supporting three presets (Poise, Prestige, Pulse), light/dark modes, cross-platform fonts, and FI white-label overrides.
|
|
4
|
+
|
|
5
|
+
## Installation
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
pnpm add @cdx-ui/styles
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
## Usage
|
|
12
|
+
|
|
13
|
+
### CSS imports (Tailwind v4 + Uniwind)
|
|
14
|
+
|
|
15
|
+
Import `theme.css` and `utilities.css` in your global stylesheet, after Tailwind and Uniwind:
|
|
16
|
+
|
|
17
|
+
```css
|
|
18
|
+
@import 'tailwindcss';
|
|
19
|
+
@import 'uniwind';
|
|
20
|
+
|
|
21
|
+
@import '@cdx-ui/styles/theme.css';
|
|
22
|
+
@import '@cdx-ui/styles/utilities.css';
|
|
23
|
+
```
|
|
24
|
+
|
|
25
|
+
`theme.css` declares all token variables — primitives in `@theme static`, mode-dependent semantics in `@variant light/dark`, and platform fonts in `@variant ios/android/web`. `utilities.css` provides composite typography utilities (`heading-xl` through `body-xs`).
|
|
26
|
+
|
|
27
|
+
Components then use standard Tailwind utilities backed by theme variables:
|
|
28
|
+
|
|
29
|
+
```tsx
|
|
30
|
+
<View className="bg-surface-background p-4 rounded-lg">
|
|
31
|
+
<Text className="text-content-primary heading-md">Welcome</Text>
|
|
32
|
+
<Text className="text-content-secondary body-md">Get started below.</Text>
|
|
33
|
+
</View>
|
|
34
|
+
```
|
|
35
|
+
|
|
36
|
+
### CSS imports (non-Tailwind)
|
|
37
|
+
|
|
38
|
+
For consumers that do not use Tailwind, `vanilla.css` provides all variables as plain `:root` declarations with `@media (prefers-color-scheme: dark)` and class-based typography:
|
|
39
|
+
|
|
40
|
+
```css
|
|
41
|
+
@import '@cdx-ui/styles/vanilla.css';
|
|
42
|
+
```
|
|
43
|
+
|
|
44
|
+
### Preset JSON
|
|
45
|
+
|
|
46
|
+
All three preset theme objects are importable as JSON for runtime theming:
|
|
47
|
+
|
|
48
|
+
```typescript
|
|
49
|
+
import poise from '@cdx-ui/styles/presets/poise.json';
|
|
50
|
+
import prestige from '@cdx-ui/styles/presets/prestige.json';
|
|
51
|
+
import pulse from '@cdx-ui/styles/presets/pulse.json';
|
|
52
|
+
```
|
|
53
|
+
|
|
54
|
+
### TypeScript types
|
|
55
|
+
|
|
56
|
+
The package exports DTCG-compatible type definitions for theme objects, overrides, and related structures:
|
|
57
|
+
|
|
58
|
+
```typescript
|
|
59
|
+
import type {
|
|
60
|
+
ThemeObject,
|
|
61
|
+
ThemeOverride,
|
|
62
|
+
TokenGroup,
|
|
63
|
+
TokenValue,
|
|
64
|
+
Mode,
|
|
65
|
+
Platform,
|
|
66
|
+
} from '@cdx-ui/styles';
|
|
67
|
+
```
|
|
68
|
+
|
|
69
|
+
## Token pipeline
|
|
70
|
+
|
|
71
|
+
The pipeline has two stages — **fetch** and **build** — both run from package scripts.
|
|
72
|
+
|
|
73
|
+
### Fetching tokens from Figma
|
|
74
|
+
|
|
75
|
+
Tokens are pulled from Figma Variables via the [REST API](https://www.figma.com/developers/api) (`GET /v1/files/:file_key/variables/local`). This requires an Enterprise plan and a personal access token with `file_variables:read` scope.
|
|
76
|
+
|
|
77
|
+
```bash
|
|
78
|
+
FIGMA_ACCESS_TOKEN=your_token pnpm tokens:fetch
|
|
79
|
+
```
|
|
80
|
+
|
|
81
|
+
The script reads `figma.config.json` for the file key, preset list, and default FI mode, then assembles one [DTCG-compatible](https://www.designtokens.org/TR/2025.10/format/) theme object JSON per preset:
|
|
82
|
+
|
|
83
|
+
```
|
|
84
|
+
tokens/presets/
|
|
85
|
+
poise.json # Default build preset
|
|
86
|
+
prestige.json
|
|
87
|
+
pulse.json
|
|
88
|
+
```
|
|
89
|
+
|
|
90
|
+
Each file is assembled from four Figma collections: **Primitives** (shared), **FI Primitives** (Candescent mode — brand/accent/base colors), **Semantics ({Preset})** (Light + Dark modes), and **Platform** (Web/iOS/Android fonts). Alias references are preserved as DTCG `"{path.to.token}"` syntax.
|
|
91
|
+
|
|
92
|
+
#### Figma MCP alternative
|
|
93
|
+
|
|
94
|
+
If the [Figma MCP server](https://developers.figma.com/docs/figma-mcp-server/) is configured in Cursor, you can inspect variables interactively. Select a frame/layer and ask the agent for variable names and values. This is useful for ad-hoc inspection but does not replace the fetch script for full pipeline runs.
|
|
95
|
+
|
|
96
|
+
### Building tokens
|
|
97
|
+
|
|
98
|
+
Style Dictionary v4 reads the default preset JSON and produces all output artifacts:
|
|
99
|
+
|
|
100
|
+
```bash
|
|
101
|
+
pnpm tokens:build
|
|
102
|
+
```
|
|
103
|
+
|
|
104
|
+
**CSS outputs** (written to `css/`):
|
|
105
|
+
|
|
106
|
+
| File | Contents |
|
|
107
|
+
| --------------- | --------------------------------------------------------------------------------------------------- |
|
|
108
|
+
| `theme.css` | `@theme static` (primitives + semantic defaults), `@variant light/dark`, `@variant ios/android/web` |
|
|
109
|
+
| `utilities.css` | `@utility` blocks for composite typography (headings, body, labels) |
|
|
110
|
+
| `vanilla.css` | Non-Tailwind fallback — `:root` variables + `@media (prefers-color-scheme: dark)` + classes |
|
|
111
|
+
|
|
112
|
+
**Generated artifacts** (from the same build pass):
|
|
113
|
+
|
|
114
|
+
| Artifact | Ships to | Purpose |
|
|
115
|
+
| ------------------- | ----------------- | ------------------------------------------------------------------ |
|
|
116
|
+
| Runtime map | Package (JSON) | Theme object path → CSS custom property name for sparse flattening |
|
|
117
|
+
| Preset patches | Package (JSON) | Sparse diff from build default → each non-default preset |
|
|
118
|
+
| Validation manifest | API deploy bundle | Allow-listed paths and types for server-side override validation |
|
|
119
|
+
|
|
120
|
+
## Theme architecture
|
|
121
|
+
|
|
122
|
+
### Presets
|
|
123
|
+
|
|
124
|
+
Three presets ship with the package — **Poise** (default), **Prestige**, and **Pulse** — each a complete theme object with all primitives, semantic tokens (light + dark), platform fonts, and typography composites. Poise is compiled into CSS at build time. Apps using a different preset apply a build-generated sparse patch via `Uniwind.updateCSSVariables`.
|
|
125
|
+
|
|
126
|
+
### Modes and platforms
|
|
127
|
+
|
|
128
|
+
Light/dark mode switching is handled by Uniwind `@variant light/dark` blocks in `theme.css`. Platform-specific fonts (SF Pro on iOS, Roboto on Android, Inter on web) use `@variant ios/android/web` blocks. Both are activated automatically by Uniwind at runtime.
|
|
129
|
+
|
|
130
|
+
### FI overrides
|
|
131
|
+
|
|
132
|
+
Financial institution white-labelling uses sparse JSON overrides — only the token paths that differ from the base preset. Overrides are validated server-side against a generated validation manifest and applied at runtime via the runtime map + `Uniwind.updateCSSVariables`. See [Theme Definition](../../docs/internal/token-architecture/02-theme-definition.md) for the full override flow.
|
|
133
|
+
|
|
134
|
+
## Package structure
|
|
135
|
+
|
|
136
|
+
```
|
|
137
|
+
styles/
|
|
138
|
+
├── css/
|
|
139
|
+
│ ├── theme.css # Auto-generated — all token variable declarations
|
|
140
|
+
│ ├── utilities.css # Auto-generated — composite typography @utility blocks
|
|
141
|
+
│ └── vanilla.css # Auto-generated — non-Tailwind fallback
|
|
142
|
+
├── scripts/
|
|
143
|
+
│ ├── figma-fetch-variables.mjs # Figma Variables REST API fetch
|
|
144
|
+
│ └── build-tokens.mjs # Style Dictionary build + artifact generation
|
|
145
|
+
├── src/
|
|
146
|
+
│ └── index.ts # TypeScript type exports (ThemeObject, ThemeOverride, etc.)
|
|
147
|
+
├── tokens/
|
|
148
|
+
│ └── presets/
|
|
149
|
+
│ ├── poise.json # Poise theme object (build default)
|
|
150
|
+
│ ├── prestige.json # Prestige theme object
|
|
151
|
+
│ └── pulse.json # Pulse theme object
|
|
152
|
+
├── figma.config.json # File key, preset list, default preset/FI mode
|
|
153
|
+
├── sd.config.ts # Style Dictionary v4 configuration
|
|
154
|
+
├── package.json
|
|
155
|
+
├── tsconfig.json
|
|
156
|
+
└── tsconfig.build.json
|
|
157
|
+
```
|
|
158
|
+
|
|
159
|
+
`css/` files are auto-generated — do not edit directly.
|
|
160
|
+
|
|
161
|
+
## Building
|
|
162
|
+
|
|
163
|
+
```bash
|
|
164
|
+
pnpm --filter @cdx-ui/styles build
|
|
165
|
+
```
|
|
166
|
+
|
|
167
|
+
TypeScript sources are compiled by `react-native-builder-bob` to `lib/` with CommonJS, ESM, and declaration targets.
|
|
168
|
+
|
|
169
|
+
## Further reading
|
|
170
|
+
|
|
171
|
+
- [Token Architecture](../../docs/internal/token-architecture/README.md) — full pipeline documentation (Figma analysis, theme definition, output architecture, Style Dictionary config, expected CSS output, runtime theming guide)
|