-
Notifications
You must be signed in to change notification settings - Fork 2
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
Add transpilation of the css prop for simple cases #78
Conversation
The latest updates on your projects. Learn more about Vercel for Git ↗︎
|
CodSpeed Performance ReportMerging #78 will not alter performanceComparing Summary
|
I believe it should also allow: const MyComponent = ({active}) =>
<div css={active && css`
padding: 10px;
`>Anything</div> which could be achieved by compiling it to the following code: const MyComponent = ({active}) =>
<div …css(active && css("yak-class-name")>Anything</div> our this approach would also work for dynamic (css variable) properties there is an additional challenge: const MyComponent = ({active, …props}) =>
<div css={active && css`
padding: 10px;
` {…props}>Anything</div> in this example all props would have to be merged maybe like this? const MyComponent = ({active}) =>
<div …_yak_css_prop(css(active && css("yak-class-name"), props)>Anything</div> |
3a33b4e
to
bd3c60e
Compare
f19b124
to
450938a
Compare
Closes #77
Add possibility to use css prop
This PR adds the possibility to use the css prop (docs for emotion, docs for styled-components) for simple cases.
Simple cases means that the css tagged template string can only be static (without any interpolations). This is a trade-off we discussed internally to not have too many edge-cases that can't be covered optimally. If you feel the need to have interpolated css we recommend to create a styled component that works better.
Why
Styled-Components and Emotion both support the css prop with the help of a babel plugin on native html elements. Makes it possible to iterate fast on small, local CSS without the overhead of a component.
Details
Simple static
This case
Would get transpiled to:
Simple merge
This case
Would get transpiled to: