Skip to content

Conversation

siddharthkp
Copy link
Member

@siddharthkp siddharthkp commented Sep 23, 2025

These are the tokens that are swapped from custom theme to default theme:

theme.space.2
theme.colors.success.fg
theme.colors.border.default
theme.colors.border.muted
theme.animation.easeOutCubic

This means that if a custom theme is passed to ThemeProvider, which modifies any of these tokens, they will not be used. Instead the default primer theme will be used. This should mean no changes for github/github-ui, but might surprise external users that have changed any of the tokens above in their custom themes.

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

Testing & Reviewing

Merge checklist

Copy link

changeset-bot bot commented Sep 23, 2025

🦋 Changeset detected

Latest commit: b81af99

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/styled-react Major

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

@siddharthkp siddharthkp self-assigned this Sep 23, 2025
Copy link
Contributor

👋 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!

@github-actions github-actions bot added the integration-tests: recommended This change needs to be tested for breaking changes. See https://arc.net/l/quote/tdmpakpm label Sep 25, 2025
@github-actions github-actions bot temporarily deployed to storybook-preview-6897 September 25, 2025 14:23 Inactive
@siddharthkp siddharthkp added the skip changeset This change does not need a changelog label Sep 25, 2025
@github-actions github-actions bot temporarily deployed to storybook-preview-6897 October 6, 2025 12:00 Inactive
@siddharthkp siddharthkp added major release breaking changes and removed skip changeset This change does not need a changelog labels Oct 6, 2025
@siddharthkp siddharthkp marked this pull request as ready for review October 6, 2025 12:17
@siddharthkp siddharthkp requested a review from a team as a code owner October 6, 2025 12:17
@siddharthkp siddharthkp requested review from jonrohan, Copilot and francinelucca and removed request for jonrohan October 6, 2025 12:17
Copy link
Contributor

@Copilot Copilot AI left a 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 removes useTheme hook usage and replaces it with direct theme imports as part of cleanup efforts. The primary purpose is to use default theme values instead of context-derived themes for specific tokens.

Key changes:

  • Replaced useTheme hook with direct theme imports or CSS custom properties
  • Updated 5 specific tokens to use default theme values instead of custom theme context
  • This is a breaking change that may affect external users with custom themes

Reviewed Changes

Copilot reviewed 9 out of 9 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
packages/react/src/stories/useFocusZone.stories.tsx Replaced theme context usage with CSS custom property for accent color
packages/react/src/UnderlineNav/styles.ts Converted function-based divider styles to static object with CSS custom properties
packages/react/src/UnderlineNav/UnderlineNavContext.tsx Removed theme from context interface
packages/react/src/UnderlineNav/UnderlineNav.tsx Removed theme context usage and updated divider style reference
packages/react/src/SegmentedControl/SegmentedControl.tsx Replaced theme context with CSS custom property for border color
packages/react/src/Overlay/Overlay.tsx Replaced theme context with direct theme import for space and animation values
packages/react/src/LabelGroup/LabelGroup.tsx Replaced theme context with direct theme import for space value
packages/react/src/ConfirmationDialog/ConfirmationDialog.features.stories.tsx Replaced theme context with CSS custom property for success color
.changeset/replace-usetheme-with-theme.md Added changeset documenting the breaking change

const {theme} = useTheme()
const slideAnimationDistance = parseInt(get('space.2')(theme).replace('px', ''))
const slideAnimationEasing = get('animation.easeOutCubic')(theme)
const slideAnimationDistance = parseInt(theme.space[2], 10)
Copy link
Preview

Copilot AI Oct 6, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The parseInt function should specify a radix (base 10) to avoid potential parsing issues. While you've added the radix parameter, the original code was parsing a string with 'px' suffix, but theme.space[2] may not have the 'px' suffix that the original code was handling with .replace('px', '').

Suggested change
const slideAnimationDistance = parseInt(theme.space[2], 10)
const slideAnimationDistance = parseInt(String(theme.space[2]).replace('px', ''), 10)

Copilot uses AI. Check for mistakes.

Copy link
Member Author

@siddharthkp siddharthkp Oct 6, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is fine because theme.space[2] is hardcoded to '8px'

parseInt('8px', 10) = 8

@siddharthkp siddharthkp changed the title Cleanup usetheme instances Replace theme=useTheme() instances with default theme Oct 6, 2025
@primer-integration
Copy link

👋 Hi from github/github-ui! Your integration PR is ready: https://github.com/github/github-ui/pull/3859

@github-actions github-actions bot added integration-tests: failing Changes in this PR cause breaking changes in gh/gh and removed integration-tests: recommended This change needs to be tested for breaking changes. See https://arc.net/l/quote/tdmpakpm labels Oct 6, 2025
Copy link
Member

@francinelucca francinelucca left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@primer-integration
Copy link

🟢 ci completed with status success.

@github-actions github-actions bot added integration-tests: passing Changes in this PR do NOT cause breaking changes in gh/gh and removed integration-tests: failing Changes in this PR cause breaking changes in gh/gh labels Oct 6, 2025
@siddharthkp siddharthkp added this pull request to the merge queue Oct 6, 2025
Merged via the queue into main with commit c1448cc Oct 6, 2025
45 checks passed
@siddharthkp siddharthkp deleted the cleanup-usetheme-instances branch October 6, 2025 17:57
@primer primer bot mentioned this pull request Oct 6, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
integration-tests: passing Changes in this PR do NOT cause breaking changes in gh/gh major release breaking changes
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants