Can't use media query presets if nested
Closed this issue · 6 comments
Using media
works but if you do something like:
<img
src={}
css={{
height: 10,
width: 10,
[presets.tablet]: {
height: 20,
width: 20,
}
}}
/>
you get an error like: Unsupported style property (min-width: 750px). Did you mean (minWidth: 750px)?
It'd be ideal to be able to use the presets with both media
and the nested syntax.
hmm fair, but tricky. a quick workaround is to do [@media${presets.tablet}
], but I guess I can put recognition in for strings starting with '('. problem is that this won't catch all media queries (for example, all
is a valid media query). what do you think?
Maybe I'll special case it just for values from the presets object
Yeah... both of those feel quite hacky unfortunately. Maybe instead let media
take objects and switch the presets to objects?
I went with a much simpler (dumber?) solution - use capitalized keys to get presets with the @media
prefix.
// these 2 are the same
media(presets.mobile, {...})
css({ [presets.Mobile]: {...} })
this should go live in 2.20.
this is live in 2.20.1
👍 works for me!