Skip to content

feat: pick a theme from installed theme packages - #26

Merged
Seb-GRAF merged 1 commit into
mainfrom
feat/theme-packages
Oct 16, 2026
Merged

Seb-GRAF merged 1 commit into
mainfrom
feat/theme-packages

Conversation

@Seb-GRAF

Copy link
Copy Markdown
Collaborator

Problem

A theme today is an ordinary include or package. Several can be enabled at once and layer over each other, setup and Customize have no theme picker, widget packages have no shared token names to rely on, and the Packages tab reviews a theme for commands it never needs. Fixes #19.

Changes

  • "kind": "theme" in package.json. A theme may contain only tokens, defaults, bar, groups and profiles, and its profiles are checked too. Widgets, templates, overrides, providers, environment and popups are rejected with a WidgetPackageError at install, review and load.
  • A root "theme": { "id": "…", "version": "…" } selects one installed theme. A theme can't be listed in packages, and a widget package can't be used as theme.
  • Load order: widget packages, then the theme, then includes and the main file. The issue put the theme before widget packages. With it after them, a package's own tokens act as fallbacks that any theme replaces, so a package can write @token.textMuted, pass review on its own and still follow the active theme. Your includes and main file still win over the theme.
  • README "Theme packages" documents the shared token names: surface, surfaceRaised, text, textMuted, accent, track, hairline, warning and critical.
  • Theme pickers in Customize → Editor → Bar (with undo, redo, Save and Discard), in setup step 2, and in the Packages tab, where Enable sets theme and themes have no Commands section. All of them write a new theme edit in ConfigurationEdits.swift, which --batch can also use. Built-in removes the key. --inspect-package and --install-package skip the commands heading for themes.
  • Setup: choosing an installed theme hides the Appearance choice and removes setup's five colour keys from the root defaults, which would otherwise beat the theme.
  • Example: examples/themes/slate, defining all nine tokens with a dark variant as a profile.

Testing

  • swift test: 104 passed.
    • New in ThemePackageTests: forbidden content is rejected, including inside profiles; themes and widget packages can't take each other's place; precedence: the theme beats a package's token, a package-only token keeps its value, includes and the main file beat the theme, and the theme's dark profile applies.
    • New WidgetTests setup case: choosing a theme removes setup's colour keys and keeps the rest of defaults.
  • Slate installs with no commands, and a configuration selecting it passes --validate. examples/modular, examples/interactive and the starter configuration still validate.
  • Not yet checked in the running app: the setup and Customize pickers and the Packages tab. Screenshots to follow.

Known limitations:

  • Root profiles replace the theme's profiles, so anyone with a profile of their own loses the theme's dark variant. Tracked in Merge profiles by name across includes, packages and the main file #24.
  • Setup removes the five colour keys whatever their values, including colours set by hand under the same keys.
  • A theme selected in an include still applies after choosing Built-in, because the pickers only edit the main file.
  • Theme folders may hold static files, but a theme has no layouts that could use them.

Merging

One commit, so any merge method keeps it in the changelog.

Claude Opus 5.5 via Claude Code

@stablebar-releases

Copy link
Copy Markdown

🎉 This PR is included in version 0.5.0 🎉

The release is available on GitHub release

Your semantic-release bot 📦🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Pick a theme from installed theme packages

1 participant