-
-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
Working directly with classNames using createEmotion post-Emotion v10 #1264
Comments
(on same team) I'll also extend this question
And wonder if you'd be open to providing more configuration to control how style elements are added to the document? Primarily we'd like to prepend the style tags to the Also a general meta question is: Do you think Emotion is a good tool to use for library authors in addition to application authors? |
+1 We are currently experiencing this same issue - with an older component library that we're trying to slowly bring emotion into. Styles being appended to head is problematic in that we have a lot of usages of classNames being used to override local component styles. Appending styles makes it potentially impossible to fully bring emotion in as it may break lots of legacy usages. An option to be able to simply choose to prepend vs append would be really nice. |
By this sole description, I'm not sure what is not working correctly. I see that you have reported a dedicated issue for this and it's basically about this #1417 . I'm afraid that there is not much that we can do regarding that right now.
The answer to this depends on why do you have to use custom cache/instance. If you can't expect the consumer to wrap their app with your CacheProvider then you can still use
With
We'll give it a thought, thanks for the feedback.
Definitely, emotion is composable and we plan to support vanilla flavor indefinitely (AFAIK).
Definitely yes, I personally work on an emotion-based UI kit library. It comes with a few caveats though (mainly around cache/instance customization mentioned above). |
Understood.
We need a custom instance to ensure that styles are prepended, not appended to the document
Makes sense. Since this issue was written, we've adopted patterns to work with Emotion a bit more, rather than against it.
Thank you – this is currently our largest pain-point with Emotion, and otherwise we love using Emotion!
Good to hear 😁 |
Out of curiosity - how applications are supposed to overwrite your emotion styles which have hashes in then?
Great to hear that! I hope you like it. |
We allow passing a string for a className to our components and compose them with |
+1 to include an option for prepending rather than appending the styles. @Andarist have you already thought into this? Is it difficult to implement? |
@Andarist Would be here? given an option, prepend/append? |
|
Cheers @Andarist! Looking forward to it |
Closing this issue as I believe the OP has found a way to work around this limitation. |
emotion
version: 10.0.7react
version: 16.4.2Problem description:
I'm a developer on a UI library that uses Emotion. We use it because we want styles to be bundled and applied with each component when they're imported, so we don't add any implementation complexity (importing more than one file to use a component, adding a context provider to the consuming app, etc.) to the consuming app.
We have had to work through a few issues with Emotion:
<div>
to the document head, and configuring the instance to use that as the container. It is less than ideal, but works in all the browsers we support.cx()
, wasn't handling certain uses of the& + &
selector that the library seems to support otherwise. We now combine classNames with a simple(...args) => args.join(' ');
(simplistic, but gets the job done effectively).We're undertaking the upgrade from Emotion 9 -> 10 now, and it seems like classNames are being abstracted away, and
createEmotion
is being phased out forCacheProvider
.Quite simply, while we have managed to upgrade to version 10 of the original
create-emotion
package, we haven't been able to get our individually-consumable components working usingCacheProvider
+ the scoped@emotion/x
packages.Suggested solution:
Ideally, we would continue to create classNames through the
css()
template literal processor function, and work without abstracting classNames away in favor of thecss
prop / composition. I'm aware of the newClassNames
component, but given the sheer length of the styles of some of our components, it would be horrible to compose those styles in the render method of the components.Additionally, having some way to more easily have style tags prepended, rather than appended to the document head would be excellent.
What we would like clarity on is: are you planning on continuing support of the
emotion
andcreate-emotion
packages?The text was updated successfully, but these errors were encountered: