Skip to content

v2.3.0 — Shared ThemeController, DTCG Tokens, CSS-in-JS Adapters & Modern CSS

Choose a tag to compare

@toozuuu toozuuu released this 11 Jul 04:02
· 4 commits to main since this release
6e6e343

TokiForge 2.3.0 introduces a shared headless ThemeController that all framework adapters now build on, W3C DTCG token format support, four new packages (Emotion, styled-components, CMS, design-tools), a modern OKLCH color engine — and a large batch of critical fixes across the core exporter, framework adapters, and the CLI.

✨ Highlights

  • ThemeController (core) — a headless controller that owns the full theming lifecycle: initial-theme resolution (persisted → option → config default), CSS injection, localStorage persistence, system-theme watching, and change subscriptions. The React, Next.js, Remix, Solid, Svelte, and SvelteKit adapters are now thin wrappers over it, so theming behaves identically in every framework.
  • W3C DTCG format support — $value / $type / $description token files parse transparently, and TokenParser.toDTCG() exports for Figma Variables, Tokens Studio, and Style Dictionary v4 interop. Both formats can be mixed in one file.
  • Composite tokens — typography objects flatten to per-part variables, shadow tokens compose to box-shadow strings (multi-shadow and inset supported), font stacks join into fallback lists, and cubicBezier becomes cubic-bezier().
  • Modern CSS output — TokenExporter.exportLightDarkCSS() emits a single stylesheet using the CSS light-dark() function + color-scheme for zero-JS light/dark switching, and controller.setThemeWithTransition() cross-fades theme switches via the View Transitions API with graceful fallback.
  • OKLCH color engine & APCA — ColorUtils.parseColor() (hex/rgb/hsl), OKLCH conversions, generateScale() for Tailwind-style 50–900 palettes, perceptual mix(), and AccessibilityUtils.calculateAPCA() implementing the WCAG 3 candidate contrast algorithm.
  • tokiforge docs — generates a self-contained static HTML styleguide (swatches, CSS variables, values, descriptions) from a token file.

📦 New packages

  • @tokiforge/emotion — Emotion adapter with ThemeProvider, useTheme, and styled re-export
  • @tokiforge/styled-components — styled-components v5+ adapter with the same API
  • @tokiforge/cms — headless CMS integrations for Contentful, Strapi, and Sanity (fetch & push)
  • @tokiforge/design-tools — Sketch and Adobe XD plugin API adapters

🐛 Critical fixes

  • Core: TokenExporter.flattenTokens dropped ancestor keys — color.primary emitted --hf-primary instead of the documented --hf-color-primary, colliding same-named leaves across groups. Full paths are now emitted everywhere.
  • Core: chained token references ({a} → {b} → value) now resolve fully, with circular-reference protection; shorthand 3/4-digit hex no longer produces NaN.
  • CLI: the published binary crashed on launch (require is not defined in ES module scope) — now built as ESM.
  • Next.js: the 'use client' directive was stripped from the built bundle, breaking App Router usage; the index and server entries now build sequentially with the directive preserved.
  • All adapters: initial theme application now respects the persisted / initialTheme / defaultTheme resolution order (previously React had empty initial tokens, Vue injected no CSS on load, and Next.js/Remix ignored the persisted theme).

🛠️ Infrastructure

  • Test suites added for the Next.js, Remix, Astro, Solid, SvelteKit, and Storybook adapters; the React suite is re-enabled — 400+ tests across the monorepo now run on every push across Linux, Windows, and macOS on Node 20 and 22.
  • New bundle-size CI guard fails the build when gzipped bundles exceed budget.
  • New Token Diff GitHub Action comments a design-token change summary on PRs that touch token files.

Full Changelog: 2.2.4...2.3.0