Skip to content
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

use API className={css} #6

Open
xialvjun opened this issue May 7, 2018 · 3 comments
Open

use API className={css} #6

xialvjun opened this issue May 7, 2018 · 3 comments

Comments

@xialvjun
Copy link

xialvjun commented May 7, 2018

In README.md at 2018.05.08,
to use emotion/next, we can only use either jsx or styled.xxx.

I don't like any of them.

Can we have an api className={css``}?

@emmatown
Copy link
Member

emmatown commented May 8, 2018

Could you explain why you prefer className={css``}? One of the main reasons for emotion-js/next was to move style insertion into the React tree and this can't happen by using className={css``}.

@xialvjun
Copy link
Author

xialvjun commented May 8, 2018

Well, I see, className={css``} is impossible.

Then how about:

// wrong because it's global... or we can just use it as global
<Style css={`.abc { color: red; }`}>
  <div className="abc">123</div>
</Style>


<Style css={`background:blue; & .abc { color: red; }`}>
  {css => <div className={css.default}><div className={css.abc}>123</div></div>}
</Style>

// or

<Style css={`background:blue; & .abc { color: red; }`}>
  {className => <div className={className}><div className="abc">123</div></div>}
</Style>

I don't like jsx is just because I don't think jsx function is not clean.

I don't like styled.xxx is because I need to define extra Component.

@emmatown
Copy link
Member

emmatown commented May 8, 2018

I don't think the API you're proposing would be very good and I think that they would cause problems because both of your examples force you to name a class which is something that we're trying to avoid. Also, the first example would cause problems if you use the same class name down further down the tree. The second example would be difficult to implement well because of the way emotion works and supporting that would make it less performant. It would also create many edge cases, for example what if the selector is #some-id?

Could explain why you think jsx is not clean?

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

No branches or pull requests

2 participants