-
Notifications
You must be signed in to change notification settings - Fork 673
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
Implement Theme UI to Custom properties utility transformer #235
Conversation
Awesome, thanks for working on this! I'll try to address some of your questions below, but generally this is looking great!
The As for individual scales within the theme object, e.g.
CSS custom properties are case sensitive, so using the same convention should be okay. For dot-notation, I think keys could be separated by hyphens, e.g.
Since the theme scales are objects and arrays, the plural naming convention makes sense in the theme object, but for the custom properties, we can probably use something like
Yeah, I think using the object keys as-is is the most straight-forward naming convention, and since arrays are zero-based,
An optional prefix would be fantastic, but I don't think it's necessary to ship this. The default could be un-prefixed, even though there might be potential for collisions. If you want to add that to the PR, feel free to do so.
For the initial use-case, I think being able to pass a style object to either the React
For number values, we'll probably want to convert some CSS properties to use pixel units and leave properties like |
Thanks for all the great points. I am out for a few days but will jump back into this later in the week. |
Co-Authored-By: Brent Jackson <[email protected]>
I have gone through and fixed up the following based on the feedback:
Not including units may be intentional ( if it is I would love to know why ). For now the function returns the values based on the input. I would feel a bit dirty appending I feel like there could be a linter to make sure that certain properties have units ( |
Awesome! Will take another look in a few!
With Emotion, unitless number values are converted to pixel values for CSS properties where it makes sense. This is also how the |
This is super interesting! Thanks for the context 💯 |
This feels pretty polished now. Let me know if there are any additional changes 👍 |
This looks great! Thanks for working on this! |
Hey all, just for awareness, this broke compatibility with IE11, which does not support CSS variables. I love this lib but I imagine quite a few people still need to support this unfortunate browser... |
@eschaefer you can use theme-ui in multiple ways this is just one option. You could try using tachyons or tailwind package if you want to generate css classes which would work in IE11. |
@eschaefer you can turn off custom properties with this flag in your theme: https://theme-ui.com/color-modes#turn-off-custom-properties |
Thanks @jxnblk! This solves the issue perfectly! I was searching for the wrong text ("css variables") in the documentation. 🙄 |
@jxnblk had some time to dig into #128. Let me know if this should be a package in this project or split a part. Some things I would like feedback on or would like to investigate further my self before merging:
kebabcase
,camelcase
etc?--colors-text
->--color-text
.element.style.setProperty(key, value);
? I personally don't mind but would love to know how other people want to use this.Here is an example of how the following theme object turns into css:
Example of css variables generated: