Replies: 2 comments 1 reply
-
Opened a PR to add support for container queries |
Beta Was this translation helpful? Give feedback.
0 replies
-
I was able to use const containerName = createContainer()
export const Card = style([
{
containerType: 'inline-size',
containerName,
minWidth: rem(288), // size of a large card at width = 320px
},
])
const wideStyle = (style: StyleRule) => ({
'@container': {
[`${containerName} (min-width: 321px)`]: style,
},
})
/* this doesn't work either
const wideStyle = (style: StyleRule) => ({
[`@container ${containerName} `]: {
[`(min-width: 321px)`]: style,
},
})
*/
export const CardContent = style([
treats({
display: 'flex',
flexDirection: 'column',
}),
wideStyle({
flexDirection: 'row',
}),
]) |
Beta Was this translation helpful? Give feedback.
1 reply
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
This is coming to browsers soon (currently available behind a flag on Chrome Canary), and already has a very solid polyfill available, and is of course insanely useful. :)
https://developer.mozilla.org/en-US/docs/Web/CSS/CSS_Container_Queries
https://github.com/GoogleChromeLabs/container-query-polyfill
It can work in the exact same way as @media currently does, so only requires very minimal changes to the codebase.
I got very basic support working by cloning
transformMedia()
, here: kolber@94930dcBut I imagine
transformMedia()
could be rewritten to handle both syntaxes in a nice clean way maybe?Beta Was this translation helpful? Give feedback.
All reactions