-
Notifications
You must be signed in to change notification settings - Fork 70
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
Fix the cx()
function's class collection at runtime as it generated class instances rather than strings.
#1697
Conversation
… class instances rather than strings Migrate from `ac()` which generates `AtomicGroups` classes to `ax()` which strictly collects strings. This is because passing `<Component xcss={cx({ … })}>` around resulted in errors, `'cls.split is not a function'` trying to iterate over non-strings.
🦋 Changeset detectedLatest commit: f0f1899 The changes in this PR will be included in the next version bump. This PR includes changesets to release 1 package
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 |
✅ Deploy Preview for compiled-css-in-js canceled.
|
@@ -208,5 +208,5 @@ export const cx = <TStyles extends [...XCSSProp<any, any>[]]>( | |||
|
|||
// The output should be a union type of passed in styles. This ensures the call | |||
// site of xcss prop can raise violations when disallowed styles have been passed. | |||
return ac(actualStyles) as TStyles[number]; | |||
return ax(actualStyles) as TStyles[number]; |
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.
I'm worried this doesn't fail tests, not sure how to test this to be honest. I don't think anything is testing this properly (else it would've been failing before).
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.
a setup like that in packages/react/src/create-strict-api/__tests__/css-func.test.tsx
could work for testing it right?
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.
I thought this would've failed in this test before to be frank:
const { getByTestId } = render(<Button xcss={cx(stylesOne.primary, stylesTwo.hover)} />); |
<div className={xcss}>
it wasn't a problem, it's when it's wrapped in <Component xcss={xcss}>
it becomes a problem…?
Added tests in f0f1899 and can confirm, without this ax
diff it breaks:
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.
lgtm as long as you're confident that cx
will continue to work
Alternative to #1696
Migrate from
ac()
which generatesAtomicGroups
classes toax()
which strictly generates strings (I think that's what this all does).This is because passing
<Component xcss={cx(style, style)}>
around resulted in errors,'cls.split is not a function'
trying to iterate over non-strings.Previously this generated classes collected into
ac
like:PR checklist
I have...
website/