-
Notifications
You must be signed in to change notification settings - Fork 4.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
[WIP/RFC] CSS-in-JS styling #1579
Conversation
Codecov Report
@@ Coverage Diff @@
## master #1579 +/- ##
==========================================
- Coverage 99.74% 99.58% -0.17%
==========================================
Files 141 141
Lines 2381 2383 +2
==========================================
- Hits 2375 2373 -2
- Misses 6 10 +4
Continue to review full report at Codecov.
|
Very glad to see this. I've been thinking it's time to move forward on this endeavor. I'm on vacation this week, but, will be back next week. Thanks for the PR and deep dive. |
Made some more progress tonight! The button on the left is rendered using Glamor, and the one on the right is I think the hardest part in all of this will probably be converting all of the Less over to JS. Some things that are making it easier:
I'm curious if there would be a way to generate TypeScript from Less, but I think that might be asking for too much 😅 |
SUI LESS is very minimal, mostly making use of variables only. They do not make use of nesting, complex mixins, or LESS functions. Because they are so simple, it may be possible to generate TypeScript and also style objects. I do like what Styletron offers in terms of performance and approach over others, you can read more here https://ryantsao.com/blog/virtual-css-with-styletron. @davezuko and I will investigate this endeavor a bit and offer some more ideas and feedback, hopefully soon. |
@levithomason That blog post was a very good read. Seems like Styletron has a lot going for it. |
@maxdeviant I've posted a high-level update regarding investigations and goals in #1009 (comment). You may be interested. |
I close this for housekeeping, there is no decision about CSS-in-JS library now (#1009). |
Thanks for cleaning up. So the community knows, this is still on my mind (along with a better theme customizer) but the time is not on my hands. I would love to see a concerted community effort to pull this off, though. |
This is a very early stage PR which aims to get us moving in the direction of a CSS-in-JS solution for styling SUIR. I've read over #1009 and am taking @levithomason's thoughts into account with the implementation.
The current plan is to use glamor as the CSS-in-JS solution for React. The full list of features can be found here, but some important highlights:
@media
/@font-face
/@keyframes
The base styles themselves will be distributed in a separate package, and will not be tied to React. This will allow for implementations for other JS frameworks. The one caveat here is that while the base JS style objects are generally the same between CSS-in-JS implementations, they start to vary when you get down to the pseudo-selectors,
@media
queries, etc. This means that the raw styles themselves would probably need to be glamor-specific, or at least something that looks a lot like glamor (such as cxs). Given that glamor is not tied to a particular framework, I do not see this as being a show stopper.Currently the styles are located at maxdeviant/semantic-ui-css-in-js and have a corresponding npm package. The approach here is going to look very similar to the LESS files in the main Semantic UI library. The primary difference will be that instead of exposing the styles directly, the package will expose style creators that take in the theme to allow for dynamic theming at runtime.
In way of theming, the theme configuration will be passed down using context via some sort of
ThemeProvider
component.Landing this PR will close #1009.
@levithomason Would love to hear your thoughts on this 😄