-
Notifications
You must be signed in to change notification settings - Fork 27
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
theme colors in css #12
Comments
+1 on the pr! |
I think this may be a bit more complicated for supporting arbitrary depth of multiple themes, and my solution above only handles a single top-level theme (it just adds all the css attribs directly to top HTML tag.) I found this. Would it be reasonable to add this as a dep, or sort of reimplement that idea directly in |
Basically, I could see the instructions starting with "If you use a single ThemeProvider, you can also use css-variables to grab values from your theme, like this:" with very little code being changed in theme.js, or "You can use the closest theme-colors like this:" with more code being added to ThemeProvider. I see the value of both. In my own project, I wanted a menu indicator that takes whatever the top-level primary color is for it's bottom-border. I think the theme colors might change later, but we have a single theme for the whole app. In the case of multiple themes, like for different sections, this way would not work as well. |
I could also see it making more sense to just encourage people to make their own special components, using styled-components, and forget the whole thing. :) The more I look at it, the more I think maybe I should have done this with my menu thing. |
I find it handy to have CSS vars for a top-level ThemeProvider.
I am currently doing this:
This way, later in my CSS, I can use them like this:
This works for CSS on any modern browser (also PostCSS can polyfill at build-time.) With a little thought, I could probly scope it to the current
ThemeProvider
. Is there interest in a PR for this, in theme.js?The text was updated successfully, but these errors were encountered: