-
Notifications
You must be signed in to change notification settings - Fork 640
Move ThemeProvider implementation to styled-react #6817
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
|
|
👋 Hi, this pull request contains changes to the source code that github/github depends on. If you are GitHub staff, we recommend testing these changes with github/github using the integration workflow. Thanks! |
size-limit report 📦
|
|
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR moves the ThemeProvider implementation from @primer/react to @primer/styled-react as part of a migration strategy. The main purpose is to create a standalone ThemeProvider implementation in the styled-react package that supports styled-components, while maintaining the API and functionality.
Key changes:
- Added complete ThemeProvider implementation with theme utilities and color scheme support
- Exported new hooks (
useId,useSyncedState) from@primer/reactto support the ThemeProvider - Updated test configuration to support both node and browser testing environments
Reviewed Changes
Copilot reviewed 16 out of 17 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
vitest.config.mts |
Updated test project paths to include both .ts and .mts browser config files |
packages/styled-react/vitest.config.ts |
Added test name configuration for node environment |
packages/styled-react/vitest.config.browser.ts |
Added test name configuration for browser environment |
packages/styled-react/tsconfig.json |
Added browser vitest config to TypeScript includes |
packages/styled-react/src/theming/utils/types/KeyPaths.ts |
Added utility type for generating dot-delimited key paths |
packages/styled-react/src/theming/utils/theme.ts |
Added theme utility functions for font stacks, color/shadow partitioning |
packages/styled-react/src/theming/themeGet.ts |
Added theme getter utility using styled-system |
packages/styled-react/src/theming/theme.ts |
Added complete theme configuration with color schemes and type definitions |
packages/styled-react/src/theming/ThemeProvider.tsx |
Added full ThemeProvider implementation with color mode switching |
packages/styled-react/src/theming/README.md |
Added documentation explaining the theming folder purpose |
packages/styled-react/src/index.tsx |
Updated exports to include theming utilities from local implementation |
packages/styled-react/src/__tests__/ThemeProvider.browser.test.tsx |
Added comprehensive test suite for ThemeProvider functionality |
packages/react/src/index.ts |
Exported useId and useSyncedState hooks for ThemeProvider usage |
.prettierignore |
Added styled-react color schemes file to prettier ignore list |
| // Temporarily disabling since this is originally a JavaScript that needed to be | ||
| // migrated to TypeScript for exports to work as correctly in Vite. | ||
| // eslint-disable-next-line @typescript-eslint/ban-ts-comment | ||
| // @ts-nocheck |
Copilot
AI
Sep 10, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The @ts-nocheck directive disables all TypeScript checking for this file, which defeats the purpose of migrating to TypeScript. Consider removing this directive and properly typing the functions instead of bypassing type safety entirely.
| const defaultNightScheme = 'dark' | ||
|
|
||
| // eslint-disable-next-line @typescript-eslint/no-explicit-any | ||
| export type Theme = {[key: string]: any} |
Copilot
AI
Sep 10, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Using any type defeats TypeScript's type safety. Consider defining a more specific interface for the Theme type or using unknown if the structure is truly dynamic.
| export type Theme = {[key: string]: any} | |
| export type Theme = {[key: string]: unknown} |
|
Realising this is maybe not the right step to start with 🤔 Going to go on a different path in another PR: #6867 |
@primer/reactintegration-tests: skipped manuallybecause I'm only adding a couple exports for hooks in primer/react, there are no modificationsRollout strategy
Testing & Reviewing
Merge checklist