Add @pierre/theme-kit: shared theming package#777
Open
necolas wants to merge 6 commits into
Open
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: c8ab317ecc
ℹ️ About Codex in GitHub
Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".
c8ab317 to
4ed10da
Compare
4ed10da to
db0115c
Compare
The build-output artifact and the test job hard-coded package names, so newly added workspace packages were silently excluded from CI: - The artifact listed specific dist dirs and omitted other packages. The lint and typecheck jobs need to download those artifacts. - The test job ran only diffs, trees, and path-store, other package tests never ran. Use `packages/*` globs so any new package is picked up automatically. Run in sequence so CI output is short and readable.
Every job duplicated the Setup Bun + cache + install steps, and the pinned Bun version was repeated per job — the copies had already drifted (1.3.12 for build, 1.3.8 elsewhere) from the 1.3.14 pinned in .prototools. Extract the three steps into a local composite action (.github/actions/setup) that reads the Bun version straight from .prototools, giving the toolchain version a single source of truth shared by proto locally, assert-bun-version on publish, and now every CI job. Each job drops to a checkout plus one `uses: ./.github/actions/setup`, and new jobs get the same cached-deps fast path for free.
Introduce a framework-agnostic theming package that owns the color and contrast primitives, theme/chrome token derivation, and theme resolution previously scattered across diffs, trees, and the docs app. - color/contrast primitives and surface reconciliation (modules/color, resolveSurfaces, types) - buildThemeTokens and buildChromeTokens for shared surface + chrome derivation - createThemeResolver: a generic, cache-backed theme resolver - a controller with resolvedTheme + pluggable persistence, plus React bindings - entry points: root, /controller, /resolve, /shiki, /pierre, /react - catalog metadata and theme definitions, with themes.ts moved here from the docs diffshub components so every consumer shares one canonical catalog - tsdown build config, dist guards (assert-core-clean), and test coverage - wire the package into the root tsconfig references and the lockfile
Delegate diffs' theme resolution to @pierre/theme-kit's createThemeResolver and run the resolved foreground/background through buildThemeTokens, so diffs, trees, and the docs app share one canonical token derivation. - resolveTheme/resolveThemes and the resolved-theme cache now sit on top of the shared resolver (themeResolution, themeResolverState) - getHighlighterThemeStyles fg/bg flow through buildThemeTokens, keeping the emitted style string byte-identical to the pre-theme-kit output - ThemeName picks up the theme-kit catalog literals - adds resolveTheme and getHighlighterThemeStyles regression tests
themeToTreeStyles is now a thin wrapper over @pierre/theme-kit's buildThemeTokens, drawing tree styles from the same surface derivation diffs and the docs app use. Adds an assert-no-theming-deps build guard so the trees dist stays free of heavy theming dependencies.
Back the docs ThemeProvider with the shared theme-kit controller and resolve chrome/tree styles through the package rather than reaching into @pierre/diffs. - theme-provider and themeController wrap a single theme-kit controller instance (resolvedTheme + pluggable persistence), replacing usePersistedState - diffshub theme-name selection and useResolvedTreeThemeStyles use the shared resolver and buildChromeTokens - the ShikiThemes and trees demos consume the shared catalog getters - chrome golden tests assert byte-for-byte parity with the pre-theme-kit output
db0115c to
da0e242
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Introduces
@pierre/theme-kit, a framework-agnostic package derived from diffs. It becomes the single source of truth for theming: the theme-name catalog, theme resolution + caching, the color math that derives neutral UI tokens, and a stateful controller for the selected mode/theme.@pierre/diffs,@pierre/trees, and the docs app are rewired to draw their colors from it, so a given theme resolves to the same surfaces everywhere.Why
Theming logic was duplicated and drifting across diffs, trees, and the docs app — each carried its own copy of the catalog, color derivation, and resolution/caching. This consolidates it behind one dependency-light API with a single place to evolve the color math. The package splits into opt-in entry points (
/resolve,/controller,/react,/pierre,/shiki) so consumers only bundle what they call, and a build-time guard keeps the core dependency-free.Integrations
resolveTheme/resolveThemesand the resolved-theme cache sit on top of the shared resolver;getHighlighterThemeStylesruns fg/bg throughbuildThemeTokens.themeToTreeStylesbecomes a thin wrapper overbuildThemeTokens, with a build guard keeping the dist free of heavy theming deps.ThemeProviderwraps a single controller instance (resolvedTheme+ pluggable persistence, replacingusePersistedState); diffshub selection and tree styles use the shared resolver andbuildChromeTokens.Parity
This is a refactor, not a visual change — the builders emit byte-identical output to the pre-theme-kit code. New unit coverage lands for the resolver, controller, color math, loaders, and the core-clean build invariant.