@phcdevworks/spectre-tokens 0.0.4 → 0.2.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 +91 -7
- package/dist/index.cjs +378 -38
- package/dist/index.cjs.map +1 -1
- package/dist/index.css +86 -16
- package/dist/index.d.cts +81 -38
- package/dist/index.d.ts +81 -38
- package/dist/index.js +378 -38
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
- package/tokens/core.json +215 -13
package/README.md
CHANGED
|
@@ -6,7 +6,7 @@ Design-token source of truth that powers Spectre UI, Spectre Blocks, Spectre Ast
|
|
|
6
6
|
|
|
7
7
|
## Overview
|
|
8
8
|
|
|
9
|
-
`@phcdevworks/spectre-tokens` defines Spectre's visual language—colors, typography,
|
|
9
|
+
`@phcdevworks/spectre-tokens` defines Spectre's visual language—colors, typography, space, radii, shadows, breakpoints, z-index scales, transitions, and CRO-focused interaction states. The package turns the raw JSON tokens in `tokens/` into multiple consumption modes (JS, TS, Tailwind, CSS variables) so that teams can stay in sync regardless of framework. One token system runs the entire Spectre Suite; every other package simply consumes these values.
|
|
10
10
|
|
|
11
11
|
- ✅ Centralized token definitions and semantic naming
|
|
12
12
|
- ✅ JS/TS objects, Tailwind theme + preset, and CSS variable outputs
|
|
@@ -34,7 +34,7 @@ import tokens, {
|
|
|
34
34
|
console.log(tokens.colors.brand["500"]); // Brand palette swatches
|
|
35
35
|
```
|
|
36
36
|
|
|
37
|
-
- `tokens`: Raw structured tokens (colors,
|
|
37
|
+
- `tokens`: Raw structured tokens (colors, space, layout, radii, typography, shadows, z-index, transitions, buttons, forms, badges, accessibility, animations, opacity, fonts).
|
|
38
38
|
- `tailwindTheme`: Ready-to-use Tailwind theme object.
|
|
39
39
|
- `tailwindPreset`: Preset for Tailwind config (includes theme).
|
|
40
40
|
- `generateCssVariables()`: Generate custom `--sp-*` CSS variable strings with scoped selectors or prefixes.
|
|
@@ -160,6 +160,78 @@ tokens.opacity.disabled; // 0.38
|
|
|
160
160
|
tokens.opacity.overlay; // 0.5
|
|
161
161
|
```
|
|
162
162
|
|
|
163
|
+
### Typography scale
|
|
164
|
+
|
|
165
|
+
```ts
|
|
166
|
+
tokens.font.fontSize.xs; // 0.75rem
|
|
167
|
+
tokens.font.fontSize.sm; // 0.875rem
|
|
168
|
+
tokens.font.fontSize.base; // 1rem
|
|
169
|
+
tokens.font.fontSize.lg; // 1.25rem
|
|
170
|
+
tokens.font.fontSize.xl; // 1.5rem
|
|
171
|
+
|
|
172
|
+
tokens.font.lineHeight.xs; // 1rem
|
|
173
|
+
tokens.font.lineHeight.sm; // 1.25rem
|
|
174
|
+
tokens.font.lineHeight.base; // 1.5rem
|
|
175
|
+
tokens.font.lineHeight.lg; // 1.75rem
|
|
176
|
+
tokens.font.lineHeight.xl; // 2rem
|
|
177
|
+
|
|
178
|
+
tokens.font.weight.normal; // 400
|
|
179
|
+
tokens.font.weight.medium; // 500
|
|
180
|
+
tokens.font.weight.semibold; // 600
|
|
181
|
+
tokens.font.weight.bold; // 700
|
|
182
|
+
```
|
|
183
|
+
|
|
184
|
+
```css
|
|
185
|
+
.heading {
|
|
186
|
+
font-size: var(--sp-font-size-xl);
|
|
187
|
+
line-height: var(--sp-font-line-height-xl);
|
|
188
|
+
font-weight: var(--sp-font-weight-semibold);
|
|
189
|
+
}
|
|
190
|
+
|
|
191
|
+
.body-text {
|
|
192
|
+
font-size: var(--sp-font-size-base);
|
|
193
|
+
line-height: var(--sp-font-line-height-base);
|
|
194
|
+
font-weight: var(--sp-font-weight-normal);
|
|
195
|
+
}
|
|
196
|
+
```
|
|
197
|
+
|
|
198
|
+
### Badge tokens
|
|
199
|
+
|
|
200
|
+
```ts
|
|
201
|
+
tokens.component.badge.bg; // Background color
|
|
202
|
+
tokens.component.badge.text; // Text color
|
|
203
|
+
tokens.component.badge.border; // Border color
|
|
204
|
+
```
|
|
205
|
+
|
|
206
|
+
```css
|
|
207
|
+
.badge {
|
|
208
|
+
background: var(--sp-component-badge-bg);
|
|
209
|
+
color: var(--sp-component-badge-text);
|
|
210
|
+
border: 1px solid var(--sp-component-badge-border);
|
|
211
|
+
padding: 0.25rem 0.5rem;
|
|
212
|
+
border-radius: var(--sp-radius-sm);
|
|
213
|
+
font-size: var(--sp-font-size-xs);
|
|
214
|
+
font-weight: var(--sp-font-weight-medium);
|
|
215
|
+
}
|
|
216
|
+
```
|
|
217
|
+
|
|
218
|
+
### Meta text
|
|
219
|
+
|
|
220
|
+
For secondary/metadata text styling:
|
|
221
|
+
|
|
222
|
+
```ts
|
|
223
|
+
tokens.text.onPage.meta; // Metadata text on page backgrounds
|
|
224
|
+
tokens.text.onSurface.meta; // Metadata text on card/surface backgrounds
|
|
225
|
+
```
|
|
226
|
+
|
|
227
|
+
```css
|
|
228
|
+
.timestamp,
|
|
229
|
+
.byline {
|
|
230
|
+
color: var(--sp-text-on-page-meta);
|
|
231
|
+
font-size: var(--sp-font-size-sm);
|
|
232
|
+
}
|
|
233
|
+
```
|
|
234
|
+
|
|
163
235
|
### WCAG targets
|
|
164
236
|
|
|
165
237
|
- Brand 500 on white → ✅ AAA (4.8:1)
|
|
@@ -171,11 +243,21 @@ tokens.opacity.overlay; // 0.5
|
|
|
171
243
|
|
|
172
244
|
Always re-run final UI implementations through tools like [WebAIM Contrast Checker](https://webaim.org/resources/contrastchecker/).
|
|
173
245
|
|
|
246
|
+
## Spacing & Layout Tokens
|
|
247
|
+
|
|
248
|
+
- **8px grid**: `space.*` follows an 8px rhythm with a single 4px micro step for fine-grain alignment. Scale: 0, 4, 8, 12, 16, 20, 24, 32, 40, 48, 56, 64, 80, 96 (all in px, emitted as rem).
|
|
249
|
+
- **Semantic layout**: `layout.section.padding.{sm,md,lg}` → `space.24/32/48`; `layout.section.gap.{sm,md,lg}` → `space.16/24/32`; `layout.stack.gap.{sm,md,lg}` → `space.8/12/16`; `layout.container.paddingInline.{sm,md,lg}` → `space.16/24/32`.
|
|
250
|
+
- **Outputs**: CSS vars like `--sp-space-24` and `--sp-layout-section-padding-md`; Tailwind `theme.spacing` is sourced from `space.*`.
|
|
251
|
+
- **Usage**: Use `layout.*` for consistent gutters/padding rather than ad-hoc numbers. Example: `gap: var(--sp-layout-stack-gap-md);` or `padding-inline: var(--sp-layout-container-padding-inline-lg);`.
|
|
252
|
+
- **Responsiveness lives in Spectre UI**: apply breakpoint logic and component behavior in `@phcdevworks/spectre-ui` or consumers; keep tokens meaning-only.
|
|
253
|
+
|
|
174
254
|
## Surface & Typography Roles
|
|
175
255
|
|
|
176
256
|
- `surface.page`, `surface.card`, `surface.input`, `surface.overlay`: semantic backgrounds for the app canvas, containers/tiles, form fields, and modal/dropdown layers.
|
|
177
257
|
- `text.onPage.*` vs `text.onSurface.*`: use `onPage` for copy sitting directly on the page canvas; use `onSurface` for text inside cards, tiles, inputs, overlays, and other elevated surfaces.
|
|
178
|
-
- `
|
|
258
|
+
- `text.onPage.default`, `text.onPage.muted`, `text.onPage.subtle`, `text.onPage.meta`
|
|
259
|
+
- `text.onSurface.default`, `text.onSurface.muted`, `text.onSurface.subtle`, `text.onSurface.meta`
|
|
260
|
+
- `component.card.text`/`textMuted`, `component.input.text`/`placeholder`, `component.button.textDefault`/`textOnPrimary`, and `component.badge.*` alias the underlying semantic roles to keep component defaults aligned.
|
|
179
261
|
|
|
180
262
|
## Modes
|
|
181
263
|
|
|
@@ -195,15 +277,17 @@ Consumers can toggle themes by setting `data-spectre-theme="dark"` on `:root` or
|
|
|
195
277
|
|
|
196
278
|
These variables are the contract consumed by `@phcdevworks/spectre-ui`; removing or renaming them will break downstream UI packages.
|
|
197
279
|
|
|
198
|
-
- Surface
|
|
199
|
-
- Text
|
|
200
|
-
- Components
|
|
280
|
+
- **Surface**: `--sp-surface-page`, `--sp-surface-card`, `--sp-surface-input`, `--sp-surface-overlay`
|
|
281
|
+
- **Text**: `--sp-text-on-page-default`, `--sp-text-on-page-muted`, `--sp-text-on-page-meta`, `--sp-text-on-surface-default`, `--sp-text-on-surface-muted`, `--sp-text-on-surface-meta`
|
|
282
|
+
- **Components**: `--sp-component-card-text`, `--sp-component-card-text-muted`, `--sp-component-input-text`, `--sp-component-input-placeholder`, `--sp-component-badge-bg`, `--sp-component-badge-text`, `--sp-component-badge-border`
|
|
283
|
+
- **Buttons**: `--sp-button-primary-bg`, `--sp-button-primary-text`, `--sp-button-secondary-bg`, `--sp-button-secondary-text`, `--sp-button-ghost-bg`, `--sp-button-ghost-text`
|
|
284
|
+
- **Typography**: `--sp-font-size-{xs,sm,base,lg,xl}`, `--sp-font-line-height-{xs,sm,base,lg,xl}`, `--sp-font-weight-{normal,medium,semibold,bold}`
|
|
201
285
|
|
|
202
286
|
## Repository Layout
|
|
203
287
|
|
|
204
288
|
| Folder | Responsibility |
|
|
205
289
|
| ---------- | ------------------------------------------------------------------------------------------------------------- |
|
|
206
|
-
| `tokens/` | Raw JSON tokens owned by design. `core.json` holds colors,
|
|
290
|
+
| `tokens/` | Raw JSON tokens owned by design. `core.json` holds colors, space, radii, typography scales, shadows, and layout scales. |
|
|
207
291
|
| `src/` | TypeScript source that turns JSON into reusable formats (JS/TS exports, Tailwind theme, CSS helpers). |
|
|
208
292
|
| `scripts/` | Build utilities. `build-css.js` consumes the compiled library and writes `dist/index.css`. |
|
|
209
293
|
| `dist/` | Generated artifacts: `index.js`, `index.cjs`, `index.d.ts`, and `index.css`. Regenerated via `npm run build`. |
|