-
Notifications
You must be signed in to change notification settings - Fork 626
feat: add createStyledComponent helper to styled-react package #6588
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
Conversation
|
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 adds a new createStyledComponent
utility function to the @primer/styled-react
package that enables creating Box-compatible styled component variants during migration from components that no longer support sx
or styled-system props.
- Adds
createStyledComponent
utility function with full styled-system andsx
prop support - Introduces browser test configuration to support DOM-based testing for the styled-react package
- Sets up comprehensive test coverage for the new utility function
Reviewed Changes
Copilot reviewed 7 out of 8 changed files in this pull request and generated 2 comments.
Show a summary per file
File | Description |
---|---|
packages/styled-react/src/utils/createStyledComponent.ts | Main utility function implementation with styled-system integration |
packages/styled-react/src/utils/tests/createStyledComponent.browser.test.tsx | Browser tests for sx prop, as prop, and component prop support |
packages/styled-react/vitest.config.browser.ts | New browser test configuration with Playwright setup |
packages/styled-react/vitest.config.ts | Updated to exclude browser tests from node environment |
packages/styled-react/config/vitest/browser/setup.ts | Test setup file for browser environment |
packages/styled-react/package.json | Added @vitejs/plugin-react dependency for browser tests |
packages/styled-react/tsconfig.json | Updated to include vitest config directory |
* component. For example: | ||
* | ||
* ```tsx | ||
* const Link = \/*#__PURE__*\/ createStyledComponent(PrimerLink) |
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 comment contains an escaped forward slash that makes the example code invalid. Remove the backslash to show the correct usage: /*#__PURE__*/
Copilot uses AI. Check for mistakes.
browser: { | ||
provider: 'playwright', | ||
enabled: true, | ||
headless: process.env.DEBUG_BROWSER_TESTS === 'true' ? false : true, |
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.
[nitpick] The conditional can be simplified to headless: process.env.DEBUG_BROWSER_TESTS !== 'true'
for better readability.
headless: process.env.DEBUG_BROWSER_TESTS === 'true' ? false : true, | |
headless: process.env.DEBUG_BROWSER_TESTS !== 'true', |
Copilot uses AI. Check for mistakes.
size-limit report 📦
|
Closes https://github.com/github/primer/issues/5704
Add a utility function,
createStyledComponent
, that helps to create variants of components that work with Box-style props (as
,sx
, styled-system props, etc). This isChangelog
New
createStyledComponent
utility to@primer/styled-react
to create Box-compatible components during migrationChanged
styled-react
Removed