@phcdevworks/spectre-ui 0.2.2 → 0.4.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 +108 -14
- package/dist/components.css +228 -189
- package/dist/index.css +1068 -4
- package/dist/utilities.css +7 -7
- package/package.json +7 -4
package/README.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# @phcdevworks/spectre-ui
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
Cross-platform UI built on Spectre Tokens. A Tailwind-powered design system that turns the tokens into consistent CSS utilities, component classes and design recipes for WordPress blocks, Astro components, 11ty templates and other modern web apps.
|
|
4
4
|
|
|
5
5
|
> 🤝 **[Contributing Guide](CONTRIBUTING.md)** | 📝 **[Changelog](CHANGELOG.md)**
|
|
6
6
|
|
|
@@ -43,11 +43,14 @@ import "@phcdevworks/spectre-ui/index.css";
|
|
|
43
43
|
|
|
44
44
|
### 2. Tailwind integration
|
|
45
45
|
|
|
46
|
-
Spectre ships
|
|
46
|
+
Spectre ships utilities to create Tailwind presets that mirror the design tokens exactly.
|
|
47
47
|
|
|
48
48
|
```ts
|
|
49
49
|
// tailwind.config.ts
|
|
50
|
-
import {
|
|
50
|
+
import { createSpectreTailwindPreset } from "@phcdevworks/spectre-ui/tailwind";
|
|
51
|
+
import { spectreTokens } from "@phcdevworks/spectre-tokens";
|
|
52
|
+
|
|
53
|
+
const spectrePreset = createSpectreTailwindPreset({ tokens: spectreTokens });
|
|
51
54
|
|
|
52
55
|
export default {
|
|
53
56
|
content: ["./src/**/*.{js,ts,jsx,tsx,astro}"],
|
|
@@ -61,10 +64,8 @@ Works with Tailwind 3.x and 4.x through the classic config API.
|
|
|
61
64
|
|
|
62
65
|
```ts
|
|
63
66
|
// tailwind.config.ts
|
|
64
|
-
import {
|
|
65
|
-
|
|
66
|
-
spectreTokens,
|
|
67
|
-
} from "@phcdevworks/spectre-ui";
|
|
67
|
+
import { createSpectreTailwindPreset } from "@phcdevworks/spectre-ui/tailwind";
|
|
68
|
+
import { spectreTokens } from "@phcdevworks/spectre-tokens";
|
|
68
69
|
|
|
69
70
|
const customPreset = createSpectreTailwindPreset({
|
|
70
71
|
tokens: spectreTokens,
|
|
@@ -87,10 +88,8 @@ export default {
|
|
|
87
88
|
|
|
88
89
|
```ts
|
|
89
90
|
// tailwind.config.ts
|
|
90
|
-
import {
|
|
91
|
-
|
|
92
|
-
spectreTokens,
|
|
93
|
-
} from "@phcdevworks/spectre-ui";
|
|
91
|
+
import { createSpectreTailwindTheme } from "@phcdevworks/spectre-ui/tailwind";
|
|
92
|
+
import { spectreTokens } from "@phcdevworks/spectre-tokens";
|
|
94
93
|
|
|
95
94
|
const { theme } = createSpectreTailwindTheme({
|
|
96
95
|
tokens: spectreTokens,
|
|
@@ -317,16 +316,105 @@ import {
|
|
|
317
316
|
|
|
318
317
|
Designers update tokens in `@phcdevworks/spectre-tokens`. Engineering evolves recipes, presets, and CSS in this package.
|
|
319
318
|
|
|
319
|
+
## Testing
|
|
320
|
+
|
|
321
|
+
The package includes automated tests to ensure recipe correctness, CSS contract integrity, and token-first design compliance:
|
|
322
|
+
|
|
323
|
+
```bash
|
|
324
|
+
npm test
|
|
325
|
+
```
|
|
326
|
+
|
|
327
|
+
Tests validate recipe output, CSS selector coverage, and guard against token drift (undefined variables, fallback values, raw color literals). All tests run via Vitest.
|
|
328
|
+
|
|
320
329
|
## Build & Release
|
|
321
330
|
|
|
322
331
|
```bash
|
|
323
332
|
npm run build
|
|
324
333
|
```
|
|
325
334
|
|
|
326
|
-
|
|
335
|
+
The build process consists of two steps:
|
|
336
|
+
|
|
337
|
+
1. **TypeScript & CSS Copy (via tsup):**
|
|
338
|
+
|
|
339
|
+
- Compiles the TypeScript source to ESM, CJS, and type definitions in `dist/`.
|
|
340
|
+
- Copies raw CSS files (`base.css`, `components.css`, `utilities.css`) from `src/styles/` to `dist/`.
|
|
341
|
+
|
|
342
|
+
2. **CSS Bundling (via PostCSS):**
|
|
343
|
+
|
|
344
|
+
- Processes `src/styles/index.css` with PostCSS (including imports and plugins) and outputs the bundled CSS as `dist/index.css`.
|
|
345
|
+
|
|
346
|
+
The `npm run build` script runs both steps in sequence:
|
|
347
|
+
|
|
348
|
+
```bash
|
|
349
|
+
tsup --config tsup.config.ts && npm run build:css
|
|
350
|
+
```
|
|
351
|
+
|
|
352
|
+
This ensures all JavaScript, type definitions, and CSS bundles are up to date in `dist/` for publishing.
|
|
327
353
|
|
|
328
354
|
For release history and version notes, see the **[Changelog](CHANGELOG.md)**.
|
|
329
355
|
|
|
356
|
+
## Spectre Design Philosophy
|
|
357
|
+
|
|
358
|
+
Spectre is a **specification-driven design system** built on three strict layers:
|
|
359
|
+
|
|
360
|
+
### 1. @phcdevworks/spectre-tokens (Foundation)
|
|
361
|
+
|
|
362
|
+
**Purpose**: Single source of truth for design values (colors, surfaces, text roles, space, radii, shadows, etc.)
|
|
363
|
+
|
|
364
|
+
**Exports**: CSS variables (`--sp-*`), TypeScript token object, Tailwind-compatible theme mappings
|
|
365
|
+
|
|
366
|
+
**Rules**:
|
|
367
|
+
|
|
368
|
+
- Tokens define semantic meaning, not UI behavior
|
|
369
|
+
- UI must never invent new colors or values
|
|
370
|
+
- Designers own `tokens/*.json`; engineers maintain `src/` transforms
|
|
371
|
+
- Contrast targets and accessibility constraints are encoded at the token level
|
|
372
|
+
|
|
373
|
+
**Status**: v0.1.0 released with stable semantic roles (`surface.*`, `text.*`, `component.*`) and considered correct/locked
|
|
374
|
+
|
|
375
|
+
### 2. @phcdevworks/spectre-ui (Framework-Agnostic UI Layer)
|
|
376
|
+
|
|
377
|
+
**Purpose**: Converts tokens into real CSS and class recipes
|
|
378
|
+
|
|
379
|
+
**Ships**:
|
|
380
|
+
|
|
381
|
+
- `index.css` (canonical CSS bundle: tokens + base + components + utilities)
|
|
382
|
+
- `base.css` (resets + globals)
|
|
383
|
+
- `components.css` (`.sp-btn`, `.sp-card`, `.sp-input`, etc.)
|
|
384
|
+
- `utilities.css` (`.sp-stack`, `.sp-container`, etc.)
|
|
385
|
+
- Type-safe recipes: `getButtonClasses`, `getCardClasses`, `getInputClasses`
|
|
386
|
+
|
|
387
|
+
**Rules**:
|
|
388
|
+
|
|
389
|
+
- UI must consume tokens, not redefine design values
|
|
390
|
+
- Literal values in CSS are fallbacks only
|
|
391
|
+
- Every CSS selector has a matching recipe where applicable
|
|
392
|
+
- Tailwind preset is optional and non-authoritative
|
|
393
|
+
|
|
394
|
+
**Status**: v0.4.0 released with refactored component styles and enhanced CSS variable system
|
|
395
|
+
|
|
396
|
+
### 3. Framework Adapters (WordPress, Astro, 11ty)
|
|
397
|
+
|
|
398
|
+
**Purpose**: Thin adapter layer around spectre-ui; automatically syncs and enqueues the Spectre UI CSS bundle
|
|
399
|
+
|
|
400
|
+
**Rules**:
|
|
401
|
+
|
|
402
|
+
- Adapters never define styles, never duplicate CSS, never load tokens directly
|
|
403
|
+
- Adapters only synchronize and load CSS
|
|
404
|
+
- All design values come from tokens, all CSS comes from spectre-ui
|
|
405
|
+
|
|
406
|
+
**Status**: WordPress and Astro adapters at v0.1.0 with frontend and editor integration
|
|
407
|
+
|
|
408
|
+
### Golden Rule (Non-Negotiable)
|
|
409
|
+
|
|
410
|
+
**Tokens define meaning. UI defines structure. Adapters only translate.**
|
|
411
|
+
|
|
412
|
+
Frameworks never invent CSS or design values—they only load what spectre-ui provides.
|
|
413
|
+
|
|
414
|
+
- If it's a design token → belongs in `@phcdevworks/spectre-tokens`
|
|
415
|
+
- If it's a CSS class or style → belongs in `@phcdevworks/spectre-ui`
|
|
416
|
+
- If it's framework integration (hooks, blocks, components) → belongs in the adapter
|
|
417
|
+
|
|
330
418
|
## Design Principles
|
|
331
419
|
|
|
332
420
|
1. **Single source of truth** – All Spectre products consume these styles and recipes.
|
|
@@ -341,8 +429,6 @@ Type definitions are bundled automatically:
|
|
|
341
429
|
|
|
342
430
|
```ts
|
|
343
431
|
import type {
|
|
344
|
-
SpectreTokens,
|
|
345
|
-
SpectreTailwindTheme,
|
|
346
432
|
ButtonVariant,
|
|
347
433
|
ButtonSize,
|
|
348
434
|
InputState,
|
|
@@ -358,6 +444,14 @@ import type {
|
|
|
358
444
|
BadgeRecipeOptions,
|
|
359
445
|
IconBoxRecipeOptions,
|
|
360
446
|
} from "@phcdevworks/spectre-ui";
|
|
447
|
+
|
|
448
|
+
import type {
|
|
449
|
+
SpectreTailwindTheme,
|
|
450
|
+
CreateSpectreTailwindThemeOptions,
|
|
451
|
+
CreateSpectreTailwindPresetOptions,
|
|
452
|
+
} from "@phcdevworks/spectre-ui/tailwind";
|
|
453
|
+
|
|
454
|
+
import type { SpectreTokens } from "@phcdevworks/spectre-tokens";
|
|
361
455
|
```
|
|
362
456
|
|
|
363
457
|
## Part of the Spectre Suite
|