-
Notifications
You must be signed in to change notification settings - Fork 628
Remove Box usage and sx
prop from components
#6825
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
🦋 Changeset detectedLatest commit: 06ae495 The changes in this PR will be included in the next version bump. This PR includes changesets to release 2 packages
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 |
👋 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! |
There was a problem hiding this 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
andPolymorphicProps
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 |
// @ts-expect-error - PrimerPageLayout is not recognized as a valid component type | ||
return <Wrapper as={PrimerPageLayout} ref={ref} {...props} /> |
There was a problem hiding this comment.
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.
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'> |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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...
// typecasting to get around a confusing mismatch between `as` props | ||
// between UnderlineNavItem and UnderlineItem | ||
as={as as React.ElementType} |
There was a problem hiding this comment.
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.
// 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.
// @ts-expect-error unsure why this started to cause an error after ActionList.Item removed | ||
// the legacy `as PolymorphicForwardRefComponent<'li', ActionListItemProps>` | ||
ref={forwardedRef} |
There was a problem hiding this comment.
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.
// @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.
// @ts-ignore this can be a `button` or `li`, so the type of ref will be different | ||
ref={forwardedRef} |
There was a problem hiding this comment.
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.
size-limit report 📦
|
…react into mp/rm-box-and-sx-from-components
This has spiraled way out of control. Unless this gets reviewed soon, I'm going to split it out into multiple PRs:
|
👋 Hi from github/github-ui! Your integration PR is ready: https://github.com/github/github-ui/pull/2681 |
🔴 ci completed with status |
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 fromRollout strategy
Testing & Reviewing
Merge checklist