You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
There are probably a large number of dragons to consider with this approach, but if it's limited to only a few shorthand properties (e.g. border, background) maybe it's manageable?
The text was updated successfully, but these errors were encountered:
Would love to support this sort of functionality! Generally, I'm a little bit skeptical of attempting to parse string values in CSS, but I think this proposal has some legs. To start this with a smaller scope, I'd suggest starting with only handling CSS properties that include colors, so that the logic for using keys from the theme.colors object to replace strings in places like border and boxShadow can be vetted before attempting other theme keys. I also suspect this would be the biggest win in the short term.
Other things to consider:
Color objects can be nested, so this should support values like blue.dark.2
A decent amount of work here would probably be adding some test fixtures to make sure this works with a lot of edge cases
Thanks so much for the idea here. This feature would be awesome to have, but introduces a lot of complexity to the parsing & a lot of edge cases for various properties, which will almost certainly slow down Theme UI further. For now, we’re going to stick to encouraging functional values (e.g. (theme) => \3px solid ${theme.colors.blue}``) & keep this on the back burner for a potential Babel plugin.
Right now, there's no support for shorthand properties. This means that I can't set something like this:
One idea for allowing this could be to split the shorthand into string tokens using
.split
, then look for tokens and replace.The edge case here would be comma-separated values (e.g. multiple backgrounds):
This could be worked around with regex 😱 (e.g.
/([,\s]*)(\w+)([,\s]*)/
) to capture non-word characters and drop them back in:There are probably a large number of dragons to consider with this approach, but if it's limited to only a few shorthand properties (e.g.
border
,background
) maybe it's manageable?The text was updated successfully, but these errors were encountered: