-
-
Notifications
You must be signed in to change notification settings - Fork 955
fix(preset-mini): resolve nested theme colors with dashed keys #5021
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
Conversation
Theme colors defined with dashes in nested objects (e.g.,
`{ brand: { 'dark-blue': 'unocss#123' } }`) were not resolving at runtime when used as `text-brand-dark-blue`.
The color lookup only tried camelCase conversion (`darkBlue`) but never checked the original dashed form (`dark-blue`).
Closes unocss#4770
✅ Deploy Preview for unocss ready!Built without sensitive environment variables
To edit notification comments on pull requests, go to your Netlify project configuration. |
|
commit: |
| brand: { | ||
| 'dark-blue': '#123456', | ||
| }, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
brand: {
'dark-blue': {
DEFAULT: '#123456',
'foo-bar': {
baz: '#fff'
}
},
},Can you help test more complex test cases?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for your review, @zyyv!
I added a more complex test case and refactored the getThemeColorForKey function by borrowing wind4 algorithm.
I posted a similar issue in TW. Since tailwind.config.js (or unocss.config.js) is still supported in TW4, that would make sense to port it to wind3.
Ideally, all theme values should be resolved using that logic, not only colors.
Let me know if you would like to go further.
Theme colors defined with dashes in nested objects were not resolving at runtime. Ported wind4's deepGet algorithm that tries progressively shorter flat keys to find the best match.
Supports complex nesting like:
{ brand: { 'dark-blue': { DEFAULT: 'unocss#123', 'foo-bar': { baz: '#fff' } } } }
Resolves: text-brand-dark-blue, text-brand-dark-blue-foo-bar-baz
Closes unocss#4770
|
thanks @zyyv ! |
Theme colors defined with dashes in nested objects (e.g.,
{ brand: { 'dark-blue': '#123' } }) were not resolving at runtime when used astext-brand-dark-blue.The color lookup only tried camelCase conversion (
darkBlue) but never checked the original dashed form (dark-blue).Closes #4770