Skip to content

Theming: Add light/dark theming to the editor shell#48

Merged
priethor merged 7 commits into
mainfrom
priethor/add/shell-theming
May 4, 2026
Merged

Theming: Add light/dark theming to the editor shell#48
priethor merged 7 commits into
mainfrom
priethor/add/shell-theming

Conversation

@priethor

@priethor priethor commented May 4, 2026

Copy link
Copy Markdown
Collaborator

What

Closes #158

Adds light/dark theming to the Cortext shell, with a toggle in the sidebar.

The shell now uses Cortext tokens instead of raw WordPress/Gutenberg colors. The theme choice is saved in localStorage, and a small bootstrap script applies it before React mounts so dark mode does not flash light on reload.

The editor iframe and public frontend still follow the active block theme. Collection tables stay on a light canvas for now because DataViews still assumes a light admin surface.

Testing

  1. Toggle light/dark/auto from the sidebar.
  2. Open a page and confirm the shell changes while iframe content stays with the block theme.
  3. Open a collection and confirm the table stays on a light canvas.
  4. Reload in dark mode and confirm there is no light flash.

Screen recording

Grabacion.de.pantalla.2026-05-04.a.las.13.12.03.mov

priethor added 7 commits May 4, 2026 12:36
Introduces Cortext's two-surface theming model. Shell themes change the
workspace chrome via a bounded token contract (colors, typography,
spacing); content themes keep the full WordPress block-theme API for
published pages.

Phase 1 scope:
- Token contract v1 declared in src/styles/_tokens.scss and mirrored in
  Cortext\Theming\Tokens for the Gutenberg iframe (injected into
  editor_settings['styles']) and the public frontend (wp_head).
- Three-way color-scheme toggle (Light / Dark / Match system) via
  useColorScheme hook, persisted in localStorage. Dark mode is
  chrome-only: canvas stays light because blocks and pickers are
  authored for light backgrounds.
- Pre-mount bootstrap script stamps data-theme on #cortext-root before
  React mounts to avoid a flash.
- Opt-in site header/footer patterns reference tokens via inline styles.
- Docs: docs/theming.md covers the full design and phased roadmap;
  vision.md and architecture.md cross-link it.
- Canvas column now follows the shell light/dark theme via a dark
  override on --cortext-color-canvas. The iframe interior is the active
  block theme's domain and stays untouched; the iframe and frontend
  token emitters keep emitting light values.
- Sidebar @wordpress/components buttons get dark-mode tints (color,
  icon fill, pressed state). Scoped to .cortext-sidebar so the canvas
  chrome and inspector stay light, since those components are authored
  for light backgrounds.
- useColorScheme tracks the resolved scheme in state instead of
  recomputing it on every render, so consumers see the live value
  when matchMedia fires.
- Docs and Tokens.php docblocks updated to disambiguate the shell
  canvas column (chrome) from the iframe interior (theme's domain).
These got dropped by the auto-merge while rebasing onto main. The
sidebar styles inherited from main use $gray-700, $grid-unit-15, and
$grid-unit-05, which come from @wordpress/base-styles/colors and
/variables.
Public output is the active block theme's domain. The wp_head token
overlay and the cortext/header + cortext/footer patterns contradicted
that: any Cortext install pushed CSS variables onto every public page
and shipped patterns styled with those variables. That's a publishing
theme by another name, even if we never called it one.

Pulling both keeps the contract honest: shell tokens only reach the
admin shell and the Gutenberg iframe, never the public site. If we
ever want a Cortext-flavored public surface, that becomes a separate
companion theme story, not a side effect of installing the plugin.

What's gone:
- patterns/cortext-header.php, patterns/cortext-footer.php
- includes/Theming/Patterns.php (and its boot in Plugin.php)
- Tokens::print_frontend_css and ::get_frontend_inline_css
- Tokens::register and the wp_head action
- "Frontend patterns" section in docs/theming.md
- "three emitters" wording in docs/architecture.md
With the header/footer patterns gone, nothing inside the Gutenberg
iframe references --cortext-* anymore. The injection at Screen.php
was leftover infrastructure for those patterns. Pulling it (and the
Tokens class) keeps the contract honest: tokens live in _tokens.scss,
period. The shell consumes them; the iframe is the active block
theme's domain; the public frontend is the theme's domain too.

When Knowledgebase mode arrives and the iframe actually needs Cortext
tokens, this comes back with a real consumer attached.
@priethor priethor force-pushed the priethor/add/shell-theming branch from 680310e to bf7b25d Compare May 4, 2026 11:05
@priethor priethor marked this pull request as ready for review May 4, 2026 11:11
@priethor priethor merged commit 5727d36 into main May 4, 2026
6 checks passed
@priethor priethor deleted the priethor/add/shell-theming branch May 4, 2026 11:13
@priethor priethor added this to the 0.1.0 milestone May 28, 2026
@priethor priethor added type: enhancement Improvement to existing behavior. area: shell App shell, sidebar, routing, top bar, command palette, recents, favorites, trash, and layout. labels May 28, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area: shell App shell, sidebar, routing, top bar, command palette, recents, favorites, trash, and layout. type: enhancement Improvement to existing behavior.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add a theme system and light/dark mode to the shell

1 participant