-
Notifications
You must be signed in to change notification settings - Fork 192
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
Container Queries? #223
Comments
@andreimoment Its just unit support for |
@jackmcpickle I think the main addition is the
A good example by Rachel Andrew - shows the same card displayed in two places - and the card reflows based on the parent element width, not the screen width: https://codepen.io/rachelandrew/pen/NWdaxde One more nuance of container queries is that the I think it would be great to be able to specify dimensions for I'll be happy to contribute - let me know how I can help. Details: https://developer.mozilla.org/en-US/docs/Web/CSS/CSS_Container_Queries |
Yes you're right. I think it makes sense to add it in here. I can look at over the weekend, or feel free to have a crack and submit a PR. 😉 |
We are speaking of creating |
Yes probably initially just to and a part 2 to support the named containers |
How would you approach the named container api? A mixin needs all of its
variables in the variables section.
I was thinking along the by lines of (… “named: thename”) as a parameter.
|
Yeah lets start with that. Input @include container(">=tablet") {
width: 50%;
} output @container (min-width: 768px) {
width: 50%;
} and named Input @include container("named: sidebar", ">=tablet") {
width: 50%;
} output @container sidebar (min-width: 768px) {
width: 50%;
} ideally we can drop the |
@andreimoment added PR for initial container queries. Basically the same as media, since is does all the same stuff. If you could have a look and test on your end that would be great. |
there is probably a better way, but this seems to work as a draft. @andreimoment , could you test please? You should be able to patch it into your _include-media.scss: /// @example scss - Mixing everything
/// @include container('>=350px', '<tablet') { }
///
/// or the first argument can be the named container
/// @include container(':named-container', '>=350px', '<tablet') { }
///
@mixin container($conditions...) {
@if ($im-media-support and list.length($conditions)==0) {
@content;
}
@else if (not $im-media-support and im-intercepts-static-breakpoint($conditions...)) {
@content;
}
@else if ($im-media-support and list.length($conditions) > 0) {
$first-condition: list.nth($conditions, 1);
$first-character: string.slice($first-condition, 1, 1);
$container-name: "" !default;
@if ($first-character ==':') {
$container-name : str-slice($first-condition, 2, -1);
}
@if ($container-name =="") {
@container #{string.unquote(parse-expression($first-condition))} {
$actual_conditions: slice($conditions, 2);
@include container($actual_conditions...) {
@content;
}
}
}
@else {
@container #{string.unquote($container-name)} #{string.unquote(parse-expression(list.nth($conditions, 2)))} {
$actual_conditions: slice($conditions, 3);
@if (list.length($actual_conditions) > 0) {
@include container($first-condition, $actual_conditions...) {
@content;
}
}
@else {
@content;
}
}
}
}
} |
I have a fork here as well @eduardoboucas , please let me know if this is okay to send as PR. |
@container
queries just landed in Chromium and Firefox, now covering most evergreen browsers. https://caniuse.com/?search=containerDoes include-media provide a facility for using them? If not yet, would you consider adding it?
The text was updated successfully, but these errors were encountered: