-
Notifications
You must be signed in to change notification settings - Fork 636
Adapt Button to styled-react and remove sx #6904
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: 562b7d9 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 |
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 adapts the Button component to the styled-react package and removes the sx prop implementation from the main @primer/react package. The changes introduce custom styled-react implementations for Button, IconButton, and ActionMenu components that support the SxProp interface for backward compatibility.
Key changes:
- Creates new styled-react wrapper components for Button, ActionMenu, and IconButton
- Moves CSSCustomProperties type to a shared location in sx.ts
- Updates package exports to use the new styled-react implementations
Reviewed Changes
Copilot reviewed 6 out of 6 changed files in this pull request and generated 3 comments.
Show a summary per file
File | Description |
---|---|
packages/styled-react/src/sx.ts | Adds CSSCustomProperties type export for shared use |
packages/styled-react/src/index.tsx | Updates exports to use new styled-react components instead of direct @primer/react exports |
packages/styled-react/src/components/PageHeader.tsx | Updates import to use shared CSSCustomProperties type |
packages/styled-react/src/components/IconButton.tsx | Creates new styled-react wrapper for IconButton with sx prop support |
packages/styled-react/src/components/Button.tsx | Creates new styled-react wrapper for Button with custom sx prop handling |
packages/styled-react/src/components/ActionMenu.tsx | Creates new styled-react wrapper for ActionMenu with sx prop support |
// @ts-ignore sx can have color attribute | ||
const {color} = sx |
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.
Replace @ts-ignore with proper TypeScript typing. Consider extending the SxProp type to include color or use type assertion instead of suppressing the error.
// @ts-ignore sx can have color attribute | |
const {color} = sx | |
const {color} = sx as {color?: string} |
Copilot uses AI. Check for mistakes.
// @ts-expect-error type mismatch between Box usage here and PrimerButton | ||
return <Box {...rest} as={PrimerButton} style={style} sx={sxStyles} /> |
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.
Replace @ts-expect-error with proper type resolution. The type mismatch should be resolved by properly typing the component props or using a type assertion.
// @ts-expect-error type mismatch between Box usage here and PrimerButton | |
return <Box {...rest} as={PrimerButton} style={style} sx={sxStyles} /> | |
// Type assertion used to resolve type mismatch between Box and PrimerButton | |
return (<Box {...rest} as={PrimerButton} style={style} sx={sxStyles} />) as JSX.Element |
Copilot uses AI. Check for mistakes.
// }, | ||
// '&': { | ||
// width : 320px | ||
// } |
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.
Fix spacing inconsistency in the comment. Should be 'width: 320px' with consistent spacing around the colon.
Copilot uses AI. Check for mistakes.
😢 Hi from github/github-ui. The integration workflow has failed: https://github.com/github/github-ui/actions/runs/17979041956 |
👋 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! |
Working on #6760
Changelog
New
Changed
Removed
Rollout strategy
Testing & Reviewing
Merge checklist