Skip to content

Conversation

mperrotti
Copy link
Contributor

@mperrotti mperrotti commented Sep 10, 2025

Relates to https://github.com/github/primer/issues/5424 and https://github.com/github/primer/issues/5425

Changelog

New

Changed

Removed

  • sx support was removed from
    • Announce
    • AriaStatus
    • AriaAlert
    • Dialog
    • Heading
    • Link
    • NavList and children
    • PageLayout and children
    • UnderlineNav
    • UnderlineNav.Item

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 10, 2025

🦋 Changeset detected

Latest commit: 06ae495

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 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 10, 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!

@mperrotti mperrotti marked this pull request as ready for review September 10, 2025 23:32
@mperrotti mperrotti requested a review from a team as a code owner September 10, 2025 23:32
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 the Box component usage and sx prop from multiple components as part of a major migration. The changes eliminate the legacy styled-components dependency and styled system support, transitioning components to use CSS modules and modern polymorphic patterns instead.

Key Changes:

  • Removes sx prop support from components like Announce, AriaStatus, Dialog, Heading, Link, NavList, PageLayout, and UnderlineNav
  • Replaces Box component wrapping with direct HTML element rendering or CSS modules
  • Implements modern polymorphic component patterns using fixedForwardRef and PolymorphicProps

Reviewed Changes

Copilot reviewed 36 out of 36 changed files in this pull request and generated 5 comments.

Show a summary per file
File Description
packages/styled-react/src/types/AriaRole.ts Adds AriaRole type definitions for backwards compatibility
packages/styled-react/src/sx.ts Creates sx utility function for styled-components compatibility layer
packages/styled-react/src/index.tsx Updates exports and creates wrapped components with sx support
packages/styled-react/src/components/ New component wrappers that restore sx prop functionality
packages/react/src/utils/modern-polymorphic.ts New utility for modern polymorphic component patterns
packages/react/src/*/index.ts Updates component exports and type definitions
packages/react/src//.tsx Component implementations migrated from Box+sx to direct elements+CSS modules
packages/react/src//.module.css New CSS module styles replacing sx-based styling
packages/react/src//.docs.json Documentation updates removing deprecated sx prop references
packages/react/src//.test.tsx Test updates removing sx-related test cases

Comment on lines +20 to +21
// @ts-expect-error - PrimerPageLayout is not recognized as a valid component type
return <Wrapper as={PrimerPageLayout} ref={ref} {...props} />
Copy link
Preview

Copilot AI Sep 10, 2025

Choose a reason for hiding this comment

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

The @ts-expect-error comment indicates a type system issue that should be properly resolved rather than suppressed. Consider creating proper type definitions for PrimerPageLayout or using a more specific typing approach to avoid the need for error suppression.

Copilot uses AI. Check for mistakes.

Comment on lines 48 to 58
export type UnderlineItemProps<As extends React.ElementType = 'a'> = {
as?: As
className?: string
iconsVisible?: boolean
loadingCounters?: boolean
counter?: number | string
icon?: FC<IconProps> | React.ReactElement
id?: string
ref?: React.Ref<unknown>
} & SxProp
children?: React.ReactNode
} & SxProp &
PolymorphicProps<As, 'a'>
Copy link
Preview

Copilot AI Sep 10, 2025

Choose a reason for hiding this comment

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

The type definition includes both SxProp and modern polymorphic props. Since this PR is removing sx support, the SxProp should be removed from this type definition to maintain consistency with the migration goals.

Copilot uses AI. Check for mistakes.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Stop judging me, Copilot. That's a separate issue. We'll get to it...

Comment on lines +146 to +148
// typecasting to get around a confusing mismatch between `as` props
// between UnderlineNavItem and UnderlineItem
as={as as React.ElementType}
Copy link
Preview

Copilot AI Sep 10, 2025

Choose a reason for hiding this comment

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

The type casting and comment indicate a type system mismatch that should be resolved properly. Consider aligning the type definitions between UnderlineNavItem and UnderlineItem to eliminate the need for this workaround.

Suggested change
// typecasting to get around a confusing mismatch between `as` props
// between UnderlineNavItem and UnderlineItem
as={as as React.ElementType}
as={as}

Copilot uses AI. Check for mistakes.

Comment on lines 328 to 330
// @ts-expect-error unsure why this started to cause an error after ActionList.Item removed
// the legacy `as PolymorphicForwardRefComponent<'li', ActionListItemProps>`
ref={forwardedRef}
Copy link
Preview

Copilot AI Sep 10, 2025

Choose a reason for hiding this comment

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

The @ts-expect-error comment indicates incomplete migration from the legacy polymorphic component system. This should be properly resolved by updating the ActionList.Item type definitions to work with the new system rather than suppressing the error.

Suggested change
// @ts-expect-error unsure why this started to cause an error after ActionList.Item removed
// the legacy `as PolymorphicForwardRefComponent<'li', ActionListItemProps>`
ref={forwardedRef}
ref={forwardedRef as React.Ref<HTMLButtonElement>}

Copilot uses AI. Check for mistakes.

Comment on lines 264 to 265
// @ts-ignore this can be a `button` or `li`, so the type of ref will be different
ref={forwardedRef}
Copy link
Preview

Copilot AI Sep 10, 2025

Choose a reason for hiding this comment

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

The @ts-ignore comment indicates a polymorphic ref typing issue. Consider using a more robust typing approach with proper union types or generic constraints to handle the different ref types without suppressing TypeScript errors.

Copilot uses AI. Check for mistakes.

Copy link
Contributor

github-actions bot commented Sep 10, 2025

size-limit report 📦

Path Size
packages/react/dist/browser.esm.js 89.49 KB (-0.22% 🔽)
packages/react/dist/browser.umd.js 89.38 KB (-0.57% 🔽)

@github-actions github-actions bot requested a deployment to storybook-preview-6825 September 10, 2025 23:36 Abandoned
@github-actions github-actions bot temporarily deployed to storybook-preview-6825 September 10, 2025 23:50 Inactive
@mperrotti
Copy link
Contributor Author

mperrotti commented Sep 17, 2025

This has spiraled way out of control. Unless this gets reviewed soon, I'm going to split it out into multiple PRs:

  • This PR
  • ActionList/NavList/Autocomplete
  • UnderlineNav
  • PageHeader
  • PageLayout

@github-actions github-actions bot requested a deployment to storybook-preview-6825 September 17, 2025 02:56 Abandoned
@github-actions github-actions bot temporarily deployed to storybook-preview-6825 September 17, 2025 03:04 Inactive
@github-actions github-actions bot requested a deployment to storybook-preview-6825 September 17, 2025 03:51 Abandoned
@primer-integration
Copy link

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

@primer-integration
Copy link

🔴 ci completed with status failure.

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.

1 participant