Skip to content

Conversation

Andarist
Copy link
Member

closes #1769

@Andarist Andarist requested a review from emmatown March 14, 2020 12:43
@changeset-bot
Copy link

changeset-bot bot commented Mar 14, 2020

🦋 Changeset is good to go

Latest commit: 74db10f

We got this.

This PR includes changesets to release 9 packages
Name Type
@emotion/utils Minor
@emotion/react Patch
@emotion/cache Patch
@emotion/css Patch
@emotion/serialize Patch
@emotion/server Patch
@emotion/styled Patch
@emotion/jest Patch
@emotion/babel-plugin Patch

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

@codesandbox-ci
Copy link

codesandbox-ci bot commented Mar 14, 2020

This pull request is automatically built and testable in CodeSandbox.

To see build info of the built libraries, click here or the icon next to each commit SHA.

Latest deployment of this branch, based on commit 74db10f:

Sandbox Source
Emotion Configuration
goofy-poitras-btibf Issue #1769

@Andarist Andarist force-pushed the fix/classnames-cx-composition branch from 311b2ac to c3d5beb Compare March 14, 2020 12:46
@codecov
Copy link

codecov bot commented Mar 14, 2020

Codecov Report

Merging #1802 into next will decrease coverage by 0.03%.
The diff coverage is 94.73%.

Impacted Files Coverage Δ
packages/react/src/jsx.js 100% <ø> (ø) ⬆️
packages/styled/src/base.js 100% <ø> (ø) ⬆️
packages/css/src/create-instance.js 100% <ø> (ø) ⬆️
packages/utils/src/index.js 100% <100%> (ø) ⬆️
packages/react/src/class-names.js 98.38% <94.44%> (-1.62%) ⬇️

@Andarist Andarist force-pushed the fix/classnames-cx-composition branch from c3d5beb to 74db10f Compare March 14, 2020 12:55
Copy link
Member

@emmatown emmatown left a comment

Choose a reason for hiding this comment

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

I don't think I agree with this change. cx is meant to compose together class names and the return value of @emotion/react's css function is not a class name

@Andarist
Copy link
Member Author

In such a case the documentation should be tweaked because right now it states:

If you have used versions of Emotion prior to Emotion 10 or used vanilla Emotion, the css and cx functions work exactly like they do in those versions.

And while it is true to some extent this is surprising that it was not able to compose regular React styles (so not exactly the same like in previous versions, people dont tend to think about those things as "string styles" and "opaque styles", conceptually they are just "styles").

The use case like this seems valid:

import { css } from `@emotion/react`

;<ClassNames>
  {({ cx }) => <div className={cx(css`color:hotpink;`, 'other-cls')} />}
</ClassNames>

This can be "fixed" by calling received css on your styles, but both identifiers are the same, so it become quite cumbersome as you either have to hoist the styles or rename one of those identifiers.

At the very least we could introduce a dev warning telling people what to do if they misuse the API.

@emmatown
Copy link
Member

At the very least we could introduce a dev warning telling people what to do if they misuse the API.

This sounds good to me.

@Andarist
Copy link
Member Author

Closed in favor of #1810

@Andarist Andarist closed this Mar 16, 2020
@Andarist Andarist deleted the fix/classnames-cx-composition branch March 16, 2020 22:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants