Replies: 8 comments
-
Thanks for the proposal @vibdev! Overall, I like the direction and intention of this. We definitely need a way to provide consumers with an easier way to do RTL styling. Here are a few thoughts:
|
Beta Was this translation helpful? Give feedback.
-
Hi @anicholls thanks for the feedback would defiantly love to discuss how to make this easier for people to use.
|
Beta Was this translation helpful? Give feedback.
-
My biggest concern is raising the bar for minimum environment when it comes to examples. Right now, our minimum environment is bundler + JSX transformer (something that understands This hook relies on a transparent use of Our examples could always do the following: /** @jsx jsx */
import {jsx} from '@emotion/core'; I don't think copy/pasting that into an environment with the babel transform will cause a problem. |
Beta Was this translation helpful? Give feedback.
-
I didn't mean to say that a theme-based RTL function was "black boxy" - that's definitely needed. I was referring to the way that the hook spreads both attributes, which looks a bit foreign at first glance. I realize this removes the Emotion abstraction, but I think most developers would be more comfortable with something like this: <div css={useThemeRTL(myStyles)} style={useThemeRTL(myDynamicStyles)} > It's a lot more obvious what this is doing at first glance IMO |
Beta Was this translation helpful? Give feedback.
-
@anicholls I think that is a good middle ground. Clients up-taking CKR's useThemeRTL could always abstract things away into one file. Maybe we could just give an example how to do it similar to how we give examples for compound components. |
Beta Was this translation helpful? Give feedback.
-
@vibdev Sounds like a good compromise 👍 How do you feel about contributing |
Beta Was this translation helpful? Give feedback.
-
@anicholls can do 👍 |
Beta Was this translation helpful? Give feedback.
-
PR: #1041 |
Beta Was this translation helpful? Give feedback.
-
🚀 RFC
Replace styled components with a purpose build method that will improve developer experience, provide a consistent theme, and perhaps most importantly make upgrading/migrating css libraries much simpler.
Motivation
Abstract away emotion so consumers don't have to manage the dependency. This will also allow organizations using CKR to more easily update major versions. Consumer can update emotion just by updating CKR and will not have to worry about manually changing every component every major release.
Provide a painless way to apply a theme giving benefits like RTL automation for free. useWithThemedStyles will automatically apply the theme similar to the current styled wrapper in CKR.
Provide an alternative to using styled components. Styled components obscure html markup, obscure what is actually a component vs just a plain html tag with style, can be very difficult to read, and are slow. useWithThemedStyles will provide an easy way to use string or object based styles.
Provide a more performant way of applying dynamic styles. Using emotion for highly dynamic styles, e.g. changing height based on scroll position, is extremely inefficient. useWithThemedStyles will provide a simple way to denote dynamic styles and will apply them directly to an element instead of running through emotion.
MVP Example
https://codesandbox.io/s/upbeat-sun-3u9od?file=/src/withStyles.js
Beta Was this translation helpful? Give feedback.
All reactions