@phcdevworks/spectre-ui 0.3.0 → 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 CHANGED
@@ -1,6 +1,6 @@
1
1
  # @phcdevworks/spectre-ui
2
2
 
3
- Framework-agnostic styling layer that powers Spectre Blocks, Spectre Astro, Spectre 11ty, and every Spectre integration.
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 an opinionated Tailwind preset that mirrors the design tokens exactly.
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 { spectrePreset } from "@phcdevworks/spectre-ui";
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
- createSpectreTailwindPreset,
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
- createSpectreTailwindTheme,
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,6 +316,16 @@ 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
@@ -344,6 +353,68 @@ This ensures all JavaScript, type definitions, and CSS bundles are up to date in
344
353
 
345
354
  For release history and version notes, see the **[Changelog](CHANGELOG.md)**.
346
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
+
347
418
  ## Design Principles
348
419
 
349
420
  1. **Single source of truth** – All Spectre products consume these styles and recipes.
@@ -358,8 +429,6 @@ Type definitions are bundled automatically:
358
429
 
359
430
  ```ts
360
431
  import type {
361
- SpectreTokens,
362
- SpectreTailwindTheme,
363
432
  ButtonVariant,
364
433
  ButtonSize,
365
434
  InputState,
@@ -375,6 +444,14 @@ import type {
375
444
  BadgeRecipeOptions,
376
445
  IconBoxRecipeOptions,
377
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";
378
455
  ```
379
456
 
380
457
  ## Part of the Spectre Suite