-
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
Theme Nesting? #1132
Comments
Yup, this would be awesome. #961 covers it as well |
@mrlubos , I just added the following to #961 (I believe its the main thread for covering this request, but just in case here as well to continue the conversation) Hi guys, Great conversation, just came across and put together a babel plugin, where we can enforce theme files to be called ie purple.theme.js to use it. https://github.com/atanasster/babel-plugin-theme-ui Can you please check if it would be an ok direction for string-based paths (the existing function shortcuts to access theme props already exist). The project is a very simple conversation starter, just to check the overall expectations. Please also add more test cases for required transformations. The examples are only for colors but it should work for any keys inside the theme. From this theme definition: It would transform to the following output: Of note: in the following example the lookup will in the current section of the theme (green.30 is inside colors) |
Like it! |
Closing in favor of #1234
There is a workaround btw. const baseColors = {
blue: {
'500': '#00f'
}
}
const moreColors = {
primary: baseColors.blue['500']
}
const colors = {
...baseColors, ...moreColors
} |
Is your feature request related to a problem? Please describe.
I want to be able to reference other theme values from the theme itself. Sorry if this is already a feature!
Describe the solution you'd like
Ideally, the same way
react-i18next
works. You can reference strings from the same file with the nesting feature.Describe alternatives you've considered
Hard-coding values or not putting nested styles inside, neither of which are ideal.
Additional context
I want to be able to set primary colour like this.
This currently does not work, I have to hard-code primary value and leave a comment explaining what it is. The same applies for other keys in the theme object I believe.
The text was updated successfully, but these errors were encountered: