Skip to content

fix: keep the palette to the theme's own colours, each with a value - #11

Merged
ogorzalka merged 3 commits into
mainfrom
fix/semantic-palette
Sep 28, 2026
Merged

ogorzalka merged 3 commits into
mainfrom
fix/semantic-palette

Conversation

@ogorzalka

Copy link
Copy Markdown
Member

Problem

  • The editor offered some 290 colours (red-50 to stone-950), 13 font sizes and 8 radii, all Tailwind defaults nobody chose.
  • The 10 semantic colours (primary, accent, surface…) resolved to nothing: a block coloured "Primary" was transparent, on the page and in the editor.
  • Changing --text-lg or --radius-lg in app.css changed the page, never the editor.

Causes

  1. @import "tailwindcss" theme(static) emitted Tailwind's whole default theme, which wordpressThemeJson copies into theme.json.
  2. A copy-theme-json Vite step copied the built theme.json over the base one. The base wins on a duplicate slug, so the palette, sizes and radii froze.
  3. The semantic tokens were var(--wp--preset--color--<slug>, <fallback>), copied as is: a preset defined as itself, a cycle CSS discards.

Changes

  • Plain @import "tailwindcss"; @theme static declares the theme's colours, type scale (xs–5xl), radii (xs–2xl) and fonts (sans, mono) with concrete values. Tailwind's values are kept, so nothing changes on the page.
  • An @layer base :root rule points the colour utilities at the WordPress presets, so a palette edited in the Site Editor still reaches the theme.
  • The copy step is removed; the base theme.json holds no palette, sizes, fonts or radii.
  • Readable labels for sizes, radii and fonts in the editor.
  • The last scale colours in use move to tokens: rating stars yellow-400 → accent, grey texts → foreground / muted.
  • README: where the tokens live, and how to keep a value out of Tailwind (a slug in theme.json, or a disableTailwind* option).
  • editor.spec.ts: the test.fail marker on the semantic colours is removed; the palette test now also checks that red-500 is absent.

Checked on pollora-test

  • Built palette: 21 colours; font sizes, radii and fonts as declared; the login screen still resolves its colours, radii and font.
  • Apiary specs (Chromium): 7 passed, 1 skipped (apiary/ci-dynamic not scaffolded), 1 failed: "simple product", because the local copy lacks Walk the shop and the editor in a browser #8, not related.

Documentation: Pollora/documentation and theme-default follow the same model (linked PRs).

The palette offered authors some 290 Tailwind colours, and its semantic
colours resolved to nothing.

- `theme(static)` made Tailwind emit its whole default scale, which the
  theme.json plugin copies into the palette. It is gone; the @theme block is
  `static` instead, so every token of the theme reaches the palette.
- A build step copied the generated theme.json over the base one. The base
  wins over @theme on the next build, so the palette froze: edits to app.css
  never reached it. The step is removed and the base holds no palette.
- The semantic colours were var(--wp--preset--color--<slug>, <fallback>),
  copied as is: a preset defined as itself, a cycle CSS drops. @theme holds
  concrete colours now, and a :root rule points the utilities at the presets,
  so a palette edited in the Site Editor still reaches the theme.
- The last scale colours in use move to tokens: rating stars to accent, the
  grey texts to foreground and muted.
The base theme.json still held the font sizes, fonts and radii an earlier
build had copied from Tailwind's defaults. The base wins over @theme, so a
change to --text-lg or --radius-lg in app.css reached the front end and never
the editor.

The base holds none of them now. @theme declares the scale the theme uses,
with Tailwind's values, so nothing changes on the page: sizes xs to 5xl
(6xl to 9xl were never used), radii xs to 2xl, and the sans and mono fonts.
The editor shows them under readable labels.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant