Skip to content

Decouple @primer/react ThemeProvider from legacy color-scheme merging while preserving @primer/styled-react#8193

Closed
mattcosta7 with Copilot wants to merge 2 commits into
mainfrom
copilot/remove-legacy-theme-objects
Closed

Decouple @primer/react ThemeProvider from legacy color-scheme merging while preserving @primer/styled-react#8193
mattcosta7 with Copilot wants to merge 2 commits into
mainfrom
copilot/remove-legacy-theme-objects

Conversation

Copilot AI commented Jul 18, 2026

Copy link
Copy Markdown
Contributor

Changelog

@primer/react no longer resolves legacy color schemes in its ThemeProvider path and no longer exports theme.colorSchemes, removing the heavy legacy-theme object from main runtime/export paths. Legacy color-scheme resolution remains intact in @primer/styled-react.

New

  • @primer/react now exposes a legacy subpath export for styled-react compatibility:
    • @primer/react/legacy-theme/ts/color-schemes

Changed

  • @primer/react ThemeProvider runtime path

    • Removed applyColorScheme + deepmerge usage from packages/react/src/ThemeProvider.tsx
    • Context now provides the plain theme object (no color-scheme deep merge)
    • resolvedColorMode, colorScheme, mode/scheme setters, contextOnly, and data-* attributes remain unchanged
  • @primer/react theme export shape

    • Removed colorSchemes from packages/react/src/theme.ts
    • Main theme export no longer pulls in legacy-theme/ts/color-schemes
  • @primer/styled-react compatibility path

    • ThemeProvider now imports legacy colorSchemes directly and reconstructs default theme for legacy resolution behavior:
    import {theme as defaultTheme} from '@primer/react'
    import {colorSchemes} from '@primer/react/legacy-theme/ts/color-schemes'
    
    const defaultThemeWithColorSchemes = {...defaultTheme, colorSchemes}

Removed

  • From @primer/react ThemeProvider/useTheme path:
    • resolvedColorScheme in ThemeContext shape
    • useTheme().resolvedColorScheme behavior/docs/tests
    • legacy color-scheme fallback/error path in main ThemeProvider

Rollout strategy

  • Patch release
  • Minor release
  • Major release; if selected, include a written rollout or migration plan
  • None; if selected, include a brief description as to why

Migration plan (draft PR):

  1. Land as breaking (major) with explicit release-note callouts:
    • useTheme().resolvedColorScheme removed from @primer/react
    • theme.colorSchemes removed from @primer/react default theme export
  2. Coordinate timing with consumers that still read legacy theme fields directly.
  3. For legacy JS-theme resolution needs, consume via @primer/styled-react (which continues to resolve color schemes) or import the legacy subpath explicitly.

Testing & Reviewing

  • Focus review on API-surface and ownership boundaries:
    • packages/react/src/ThemeProvider.tsx
    • packages/react/src/theme.ts
    • packages/styled-react/src/components/ThemeProvider.tsx
  • Verify that @primer/react no longer carries legacy color-scheme resolution in ThemeProvider context while @primer/styled-react behavior remains unchanged for existing tests/consumers.

@changeset-bot

changeset-bot Bot commented Jul 18, 2026

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: 50b90b5

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 2 packages
Name Type
@primer/react Major
@primer/mcp Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

…@primer/react

Co-authored-by: mattcosta7 <8616962+mattcosta7@users.noreply.github.com>
Copilot AI changed the title [WIP] Remove heavy legacy-theme objects from ThemeProvider Decouple @primer/react ThemeProvider from legacy color-scheme merging while preserving @primer/styled-react Jul 18, 2026
Copilot AI requested a review from mattcosta7 July 18, 2026 20:28
@mattcosta7 mattcosta7 closed this Jul 18, 2026
@primer
primer Bot deleted the copilot/remove-legacy-theme-objects branch July 19, 2026 00:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants