Refactor theme provider with scoped Panda tokens#1
Merged
nathan2slime merged 5 commits intomasterfrom Mar 18, 2026
Merged
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
There was a problem hiding this comment.
Pull request overview
Refactors the UI theme system into focused modules, adds derived semantic “action” tokens plus data-color-mode scoping for Panda token resolution, and expands automated coverage around theme resolution behavior (including system preference changes).
Changes:
- Split theme concerns into
theme-context,theme-definitions,theme-helpers,use-system-theme, anduse-ui-theme, simplifyingUiThemeProvider. - Add derived semantic action tokens and apply
data-color-modeon provider scope so Panda semantic colors resolve correctly within themed subtrees. - Add/expand unit tests for helpers, hooks, and provider behavior; add commit tooling (commitlint + lefthook) and Storybook CSS/alias updates.
Reviewed changes
Copilot reviewed 19 out of 20 changed files in this pull request and generated 4 comments.
Show a summary per file
| File | Description |
|---|---|
| src/theme/use-ui-theme.ts | Adds dedicated hook for consuming the theme context with provider guard. |
| src/theme/use-system-theme.ts | Adds dedicated hook to track OS color scheme changes via matchMedia. |
| src/theme/ui-theme-provider.tsx | Simplifies provider, derives tokens, and adds data-color-mode scoping attribute. |
| src/theme/theme-helpers.ts | Extracts helper functions for resolving themes, generating CSS vars, and deriving semantic action tokens. |
| src/theme/theme-definitions.ts | Moves built-in light/dark token definitions into a dedicated module. |
| src/theme/theme-context.ts | Centralizes the theme React context creation. |
| src/theme/tests/use-ui-theme.test.tsx | Adds coverage for hook behavior (throws outside provider, returns nearest context). |
| src/theme/tests/use-system-theme.test.tsx | Adds coverage for system theme tracking and listener cleanup. |
| src/theme/tests/ui-theme-provider.test.tsx | Adds coverage for scoping attributes, token merging, and system theme updates. |
| src/theme/tests/theme-helpers.test.ts | Adds coverage for helper functions (resolution, CSS var mapping, derived token outputs). |
| src/theme/index.ts | Updates exports to reflect new module split (useUiTheme moved out of provider file). |
| package.json | Adds commitlint script and dev dependencies for commit hooks. |
| pnpm-lock.yaml | Locks new dev dependencies (commitlint + lefthook and transitive deps). |
| lefthook.yml | Adds commit-msg and pre-commit hooks (commitlint, lint, test). |
| biome.json | Adjusts Biome linter configuration (disables noUselessLoneBlockStatements). |
| AGENTS.md | Documents Conventional Commits requirement and adds tooling notes. |
| .storybook/styles/reset.css | Adds Storybook-only CSS reset layer. |
| .storybook/styles/index.css | Imports reset and sets Storybook font-family baseline. |
| .storybook/main.ts | Adds rsbuild alias configuration for @ and styled-system in Storybook. |
| .commitlintrc | Adds commitlint conventional config. |
Files not reviewed (1)
- pnpm-lock.yaml: Language not supported
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
You can also share your feedback on Copilot code review. Take the survey.
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
theme-context,theme-definitions,theme-helpers,use-system-theme, anduse-ui-theme) to keep provider responsibilities focuseddata-color-modescoping so Panda semantic colors resolve correctly for themed subtrees