Skip to content

Conversation

@liuliu-dev
Copy link
Contributor

@liuliu-dev liuliu-dev commented Aug 19, 2025

Migrates the ToggleSwitch component away from Box components and sx prop support to use CSS modules, closes #4826

What Changed

  • Removed Box wrapper and sx prop support from the main ToggleSwitch component

  • Replaced sx prop styling with CSS modules and data attributes for state-based styling

  • Added ToggleSwitch to the styled-react package for repos still using sx props

  • Note: SwitchButton and ToggleKnob still use styled-components (styled.button and styled.div) and will be migrated in a future iteration

Rollout strategy

  • Major release; if selected, include a written rollout or migration plan

@changeset-bot
Copy link

changeset-bot bot commented Aug 19, 2025

🦋 Changeset detected

Latest commit: d073e36

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

@github-actions
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 Aug 19, 2025
@github-actions github-actions bot temporarily deployed to storybook-preview-6627 August 19, 2025 23:09 Inactive
@github-actions
Copy link
Contributor

github-actions bot commented Aug 19, 2025

size-limit report 📦

Path Size
packages/react/dist/browser.esm.js 90.03 KB (+0.02% 🔺)
packages/react/dist/browser.umd.js 90.18 KB (-0.05% 🔽)

@github-actions github-actions bot requested a deployment to storybook-preview-6627 August 20, 2025 00:09 Abandoned
@github-actions github-actions bot temporarily deployed to storybook-preview-6627 August 20, 2025 00:20 Inactive
@primer-integration
Copy link

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

@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 Aug 20, 2025
@primer-integration
Copy link

🔴 golden-jobs completed with status failure.

@liuliu-dev liuliu-dev marked this pull request as ready for review August 25, 2025 19:52
Copilot AI review requested due to automatic review settings August 25, 2025 19:52
@liuliu-dev liuliu-dev requested a review from a team as a code owner August 25, 2025 19:52
Copy link
Contributor

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

Removes sx prop support from the ToggleSwitch component by migrating from Box-based layout to CSS modules and data attributes for styling. This is part of the broader effort to move away from styled-components and sx prop usage throughout the design system.

  • Replaced Box wrapper components with native HTML elements styled via CSS modules
  • Removed sx prop support from ToggleSwitch component interface
  • Added backward compatibility by providing an sx-enabled wrapper in the @primer/styled-react package

Reviewed Changes

Copilot reviewed 7 out of 7 changed files in this pull request and generated no comments.

Show a summary per file
File Description
packages/styled-react/src/index.ts Adds ToggleSwitch with sx support using createStyledComponent wrapper
packages/styled-react/src/tests/snapshots/exports.test.ts.snap Updates test snapshot to reflect ToggleSwitch export order change
packages/react/src/ToggleSwitch/ToggleSwitchStoryWrapper.tsx Converts Box-based layout to CSS module styling
packages/react/src/ToggleSwitch/ToggleSwitchStoryWrapper.module.css Defines CSS module styles for story wrapper component
packages/react/src/ToggleSwitch/ToggleSwitch.tsx Removes sx prop and Box components, implements CSS module styling with data attributes
packages/react/src/ToggleSwitch/ToggleSwitch.module.css CSS module implementation of component styles with state-based data attribute selectors
.changeset/bright-parents-flow.md Documents breaking change for ToggleSwitch sx removal


exports[`@primer/styled-react exports 1`] = `
[
"ToggleSwitch",
Copy link
Member

Choose a reason for hiding this comment

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

looks like this was previously following alphabetical order, can we fix back ?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

exports.test.ts.snap is auto-generated by the test runner.
I guess the reason ToggleSwitch appears first is that it's handled differently from other components, it's wrapped with createStyledComponent and exported separately.

@liuliu-dev
Copy link
Contributor Author

integration checks manually ran here: https://github.com/github/github-ui/pull/1177

@liuliu-dev liuliu-dev added this pull request to the merge queue Aug 26, 2025
Merged via the queue into main with commit 6111046 Aug 26, 2025
43 checks passed
@liuliu-dev liuliu-dev deleted the liuliu/migrate-toggleswitch branch August 26, 2025 17:04
@primer primer bot mentioned this pull request Aug 26, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

integration-tests: failing Changes in this PR cause breaking changes in gh/gh

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants