Skip to content

feat: generate the editor's palette, type scale and radii from @theme - #2

Merged
ogorzalka merged 2 commits into
mainfrom
feat/theme-json-from-tailwind
Sep 28, 2026
Merged

ogorzalka merged 2 commits into
mainfrom
feat/theme-json-from-tailwind

Conversation

@ogorzalka

Copy link
Copy Markdown
Member

Why

theme.json held the palette by hand and @theme read it back through the presets: two places to keep in step, and a colour changed in app.css never reached the editor. apiary takes the other road (Pollora/theme-apiary#11): app.css is the source and the build writes theme.json. Both themes now work the same way.

Changes

  • @theme static holds the 10 colours, the type scale (xs–7xl) and the radii (sm–2xl) with concrete values; wordpressThemeJson copies them into the built theme.json. The base keeps no palette and no font sizes.
  • 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.
  • Inter stays in theme.json: its fontFace can only be declared there, so fonts are left out of the generation (disableTailwindFonts). This is also the documented example of keeping a family out of Tailwind.
  • Readable labels for sizes and radii in the editor.
  • README: a "Design tokens" section.

⚠️ Changed

The font size slugs follow Tailwind (sm, base, 4xl…) instead of small, medium, large, x-large. Themes already generated are not affected; content made with a theme generated from the old template would lose those sizes.

Checked

On a fresh copy of the template (placeholders replaced) built and activated on pollora-test:

  • The built palette has the theme's colours plus white (used by text-white), and no scale colour.
  • Global styles on the front: --wp--preset--color--primary: #ff5334, --wp--preset--font-size--4-xl: 2.25rem, --wp--preset--font-family--inter-var, --wp--preset--border-radius--lg: .5rem; no --wp--preset--color--red-500.
  • Every Tailwind variable theme.json references (--container-xl, --text-5xl--line-height, --default-font-family, --spacing…) is still emitted.

theme.json held the palette by hand, and @theme read it back through the
presets; the two had to be kept in step, and a colour changed in app.css
never reached the editor. apiary takes the other road: app.css is the source,
and the build writes theme.json. Both themes now work the same way.

- @theme is `static` and holds the colours, the type scale (xs to 7xl) and the
  radii with concrete values; wordpressThemeJson copies them into theme.json,
  whose base keeps no palette and no font sizes.
- A :root rule points the colour utilities at the WordPress presets, so a
  palette edited in the Site Editor still reaches the theme.
- Inter stays in theme.json: its @font-face can only be declared there, so
  the fonts are left out of the generation (disableTailwindFonts).

The font size slugs follow Tailwind now (sm, base, 4xl…) instead of small,
medium, large and x-large.
@ogorzalka
ogorzalka merged commit e9c6c93 into main Sep 28, 2026
3 checks passed
@ogorzalka
ogorzalka deleted the feat/theme-json-from-tailwind branch September 28, 2026 07:44
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