Skip to content

Conversation

mperrotti
Copy link
Contributor

@mperrotti mperrotti commented Aug 26, 2025

Relates to https://github.com/github/primer/issues/5422

The primary purpose of these changes is to remove usage of styled-system and styled-components utilities from the following components:

  • Caret.tsx
  • IssueLabelToken.tsx
  • ProgressBar.tsx
  • StateLabel.tsx
  • ToggleSwitch.tsx
  • deprecated/ActionList/List.tsx

Changelog

New

Changed

  • Removed styled-system and styled-components dependencies from the components listed above.
  • Removed sx prop from IssueLabelToken (can be brought back if needed)

Removed

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

  • Added/updated tests
  • Added/updated documentation
  • Added/updated previews (Storybook)
  • Changes are SSR compatible
  • Tested in Chrome (all changes)
  • Tested in Firefox (most changes)
  • Tested in Safari (most changes)
  • Tested in Edge
  • (GitHub staff only) Integration tests pass at github/github (Learn more about how to run integration tests)

Copy link

changeset-bot bot commented Aug 26, 2025

🦋 Changeset detected

Latest commit: 8437a2c

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

@mperrotti mperrotti force-pushed the mp/rm-sx/misc-components branch from d760fd4 to 7f4b498 Compare August 26, 2025 19:31
@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 26, 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!

Copy link
Contributor

github-actions bot commented Aug 26, 2025

size-limit report 📦

Path Size
packages/react/dist/browser.esm.js 88.13 KB (-2.01% 🔽)
packages/react/dist/browser.umd.js 88.23 KB (-2.1% 🔽)

variant?: 'small' | 'normal'
status: keyof typeof octiconMap
} & SxProp
Copy link
Contributor Author

Choose a reason for hiding this comment

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

I can put this back if we need. I accidentally got carried away at first because I misunderstood the scope of the issue.

@mperrotti mperrotti marked this pull request as ready for review August 26, 2025 22:19
@Copilot Copilot AI review requested due to automatic review settings August 26, 2025 22:19
@mperrotti mperrotti requested a review from a team as a code owner August 26, 2025 22:19
@mperrotti mperrotti requested a review from pksjce August 26, 2025 22:19
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 styled-system and styled-components dependencies from six components as part of a broader modernization effort. The changes migrate these components from styled-components to CSS modules with CSS custom properties and data attributes for styling.

Key Changes

  • Replaced styled-component patterns with CSS modules and data attributes
  • Converted component-specific styling to CSS custom properties for better performance and maintainability
  • Updated component interfaces to remove styled-system specific props

Reviewed Changes

Copilot reviewed 15 out of 15 changed files in this pull request and generated 9 comments.

Show a summary per file
File Description
Caret.tsx + Caret.module.css Migrated from styled-components to CSS modules with custom properties for colors and borders
IssueLabelToken.tsx + IssueLabelToken.module.css Converted complex styled-system logic to CSS modules with data attribute selectors
ToggleSwitch.tsx + ToggleSwitch.module.css Replaced styled-components with CSS modules and comprehensive state management via data attributes
StateLabel.tsx + StateLabel.module.css Simplified component by removing styled-system variants in favor of CSS modules
deprecated/ActionList/List.tsx Updated to use BoxWithFallback and removed styled-components dependencies
Test snapshots Updated to reflect new CSS class names and data attributes

const {borderColor} = getBorderColor(propsWithTheme)
const {borderWidth} = getBorderWidth(propsWithTheme)
const {size = 8, location = 'bottom'} = props
const {bg, borderColor, borderWidth, size = 8, location = 'bottom'} = props
Copy link
Preview

Copilot AI Aug 26, 2025

Choose a reason for hiding this comment

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

The destructured bg, borderColor, and borderWidth props are not provided with fallback values, but are used as CSS custom properties on lines 91-93. This could result in undefined values being set as CSS properties. Consider providing fallback values or default values.

Suggested change
const {bg, borderColor, borderWidth, size = 8, location = 'bottom'} = props
const {
bg = 'transparent',
borderColor = 'currentColor',
borderWidth = 1,
size = 8,
location = 'bottom'
} = props

Copilot uses AI. Check for mistakes.


.CaretTriangle {
/* stylelint-disable-next-line primer/colors */
fill: var(--caret-bg, var(--bgColor-default));
Copy link
Preview

Copilot AI Aug 26, 2025

Choose a reason for hiding this comment

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

The fallback CSS custom property --bgColor-default may not exist in all contexts. Consider using a more reliable fallback like a standard color value (e.g., #ffffff or currentColor).

Suggested change
fill: var(--caret-bg, var(--bgColor-default));
fill: var(--caret-bg, var(--bgColor-default, currentColor));

Copilot uses AI. Check for mistakes.

Comment on lines +110 to +112
const listStyles: React.CSSProperties = {
fontSize: 'var(--text-body-size-medium, 14px)',
// 14px font-size * 1.428571429 = 20px line height
Copy link
Preview

Copilot AI Aug 26, 2025

Choose a reason for hiding this comment

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

The hardcoded 14px fallback value duplicates the comment on line 112-113. Consider using a CSS custom property reference or extracting this value to a constant to maintain consistency.

Suggested change
const listStyles: React.CSSProperties = {
fontSize: 'var(--text-body-size-medium, 14px)',
// 14px font-size * 1.428571429 = 20px line height
const LIST_FONT_SIZE_FALLBACK = '14px'
const listStyles: React.CSSProperties = {
fontSize: `var(--text-body-size-medium, ${LIST_FONT_SIZE_FALLBACK})`,
// LIST_FONT_SIZE_FALLBACK * 1.428571429 = 20px line height

Copilot uses AI. Check for mistakes.

@@ -1,3 +1,114 @@
.IssueLabel {
Copy link
Preview

Copilot AI Aug 26, 2025

Choose a reason for hiding this comment

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

Copilot detected a code snippet with 50+ occurrences. See search results for more details.

Matched Code Snippet
-label-r: 153;
  --label-g: 153;
  --label-b: 153;
  --label-h: 0;
  --label-s: 0;
  --label-l: 60;
  --perceived-lightness: calc(
    ((var(--label-r) * 0.2126) + (var(--label-g) * 0.7152) + (var(--label-b) * 0.0722)) / 255
  );
  --lightness-switch: max(0, min(calc((var(--perceived-lightness) - var(--lightness-threshold)) * -1000), 1));

  position: relative;

Copilot uses AI. Check for mistakes.

@@ -1,3 +1,114 @@
.IssueLabel {
Copy link
Preview

Copilot AI Aug 26, 2025

Choose a reason for hiding this comment

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

Copilot detected a code snippet with 50 occurrences. See search results for more details.

Matched Code Snippet
-lightness-threshold: 0.453;
  --border-threshold: 0.96;
  --border-alpha: max(0, min(calc((var(--perceived-lightness) - var(--border-threshold)) * 100)

Copilot uses AI. Check for mistakes.

@@ -1,3 +1,114 @@
.IssueLabel {
Copy link
Preview

Copilot AI Aug 26, 2025

Choose a reason for hiding this comment

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

Copilot detected a code snippet with 50 occurrences. See search results for more details.

Matched Code Snippet
border-color: hsla(var(--label-h), calc(var(--label-s) * 1%), calc((var(--label-l) - 25) * 1%), var(--border-

Copilot uses AI. Check for mistakes.

@@ -1,3 +1,114 @@
.IssueLabel {
Copy link
Preview

Copilot AI Aug 26, 2025

Choose a reason for hiding this comment

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

Copilot detected a code snippet with 50+ occurrences. See search results for more details.

Matched Code Snippet
-lightness-threshold: 0.6;
  --background-alpha: 0.18;
  --border-alpha: 0.3;
  --lighten-by: calc(((var(--lightness-threshold) - var(--perceived-lightness)) * 100) * var(--lightness-switch)

Copilot uses AI. Check for mistakes.

@@ -1,3 +1,114 @@
.IssueLabel {
Copy link
Preview

Copilot AI Aug 26, 2025

Choose a reason for hiding this comment

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

Copilot detected a code snippet with 50+ occurrences. See search results for more details.

Matched Code Snippet
var(--label-h),
    calc(var(--label-s) * 1%),
    calc((var(--label-l) + var(--lighten-by)) * 1%),
    var(--border-alpha)
  )

Copilot uses AI. Check for mistakes.

@@ -1,3 +1,114 @@
.IssueLabel {
Copy link
Preview

Copilot AI Aug 26, 2025

Choose a reason for hiding this comment

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

Copilot detected a code snippet with 13 occurrences. See search results for more details.

Matched Code Snippet
image: linear-gradient(rgba(0, 0, 0, 0.15), rgba(0, 0, 0, 0.15)),
    linear-gradient(
      rgb(var(--label-r), var(--label-g), var(--label-b)),
      rgb(var(--label-r), var(--label-g), var(--label-b))
    );
  box-shadow:

Copilot uses AI. Check for mistakes.

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.

LGTM, let's make sure we run integration checks in dotcom before merging 🙏

Comment on lines -52 to -131
prop: 'status',
variants: {
issueClosed: {
backgroundColor: 'done.emphasis',
color: 'fg.onEmphasis',
boxShadow: 'var(--boxShadow-thin, inset 0 0 0 1px) var(--borderColor-done-emphasis, transparent)',
},
issueClosedNotPlanned: {
backgroundColor: 'neutral.emphasis',
color: 'fg.onEmphasis',
boxShadow: 'var(--boxShadow-thin, inset 0 0 0 1px) var(--borderColor-neutral-emphasis, transparent)',
},
pullClosed: {
backgroundColor: 'closed.emphasis',
color: 'fg.onEmphasis',
boxShadow: 'var(--boxShadow-thin, inset 0 0 0 1px) var(--borderColor-closed-emphasis, transparent)',
},
pullMerged: {
backgroundColor: 'done.emphasis',
color: 'fg.onEmphasis',
boxShadow: 'var(--boxShadow-thin, inset 0 0 0 1px) var(--borderColor-done-emphasis, transparent)',
},
pullQueued: {
backgroundColor: 'attention.emphasis',
color: 'fg.onEmphasis',
boxShadow: 'var(--boxShadow-thin, inset 0 0 0 1px) var(--borderColor-attention-emphasis, transparent)',
},
issueOpened: {
backgroundColor: 'open.emphasis',
color: 'fg.onEmphasis',
boxShadow: 'var(--boxShadow-thin, inset 0 0 0 1px) var(--borderColor-open-emphasis, transparent)',
},
pullOpened: {
backgroundColor: 'open.emphasis',
color: 'fg.onEmphasis',
boxShadow: 'var(--boxShadow-thin, inset 0 0 0 1px) var(--borderColor-open-emphasis, transparent)',
},
draft: {
backgroundColor: 'neutral.emphasis',
color: 'fg.onEmphasis',
boxShadow: 'var(--boxShadow-thin, inset 0 0 0 1px) var(--borderColor-neutral-emphasis, transparent)',
},
issueDraft: {
backgroundColor: 'neutral.emphasis',
color: 'fg.onEmphasis',
boxShadow: 'var(--boxShadow-thin, inset 0 0 0 1px) var(--borderColor-neutral-emphasis, transparent)',
},
unavailable: {
backgroundColor: 'neutral.emphasis',
color: 'fg.onEmphasis',
boxShadow: 'var(--boxShadow-thin, inset 0 0 0 1px) var(--borderColor-neutral-emphasis, transparent)',
},
open: {
backgroundColor: 'open.emphasis',
color: 'fg.onEmphasis',
boxShadow: 'var(--boxShadow-thin, inset 0 0 0 1px) var(--borderColor-open-emphasis, transparent)',
},
closed: {
backgroundColor: 'done.emphasis',
color: 'fg.onEmphasis',
boxShadow: 'var(--boxShadow-thin, inset 0 0 0 1px) var(--borderColor-done-emphasis, transparent)',
},
},
})

const sizeVariants = variant({
prop: 'variant',
variants: {
small: {
paddingX: 2,
paddingY: 1,
fontSize: 0,
},
normal: {
paddingX: '12px',
paddingY: 2,
fontSize: 1,
},
},
})
Copy link
Member

Choose a reason for hiding this comment

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

🔥

Comment on lines +113 to +114
// TODO: When rem-based spacing on a 4px scale lands, replace hardcoded '20px'
lineHeight: '20px',
Copy link
Member

Choose a reason for hiding this comment

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

should we do var(--base-size-20) here now?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Technically, yes, but I don't really see the value in changing it - especially for a deprecated component 🤷

@mperrotti mperrotti enabled auto-merge August 28, 2025 18:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
integration-tests: recommended This change needs to be tested for breaking changes. See https://arc.net/l/quote/tdmpakpm
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants