-
Notifications
You must be signed in to change notification settings - Fork 768
Media queries via (s)CSS #783
Comments
So, to clarify, what you're asking for is a Flex Layout CSS exported mixin that takes a breakpoint and returns the media query? |
Exactly!!! <button [ngClass.xs]="class1" [ngClass.sm]="class2" [ngClass.gt-md]="class3" [ngClass.xs]="class3">HI!</button> Which generate a bit of noise in the markup! And some other things are not doable with this approach eg is style an html element or class (like i've written above) with media queries button {
background-color: yellow;
@include media-breakpoint(xs) {
background-color: red;
}
@include media-breakpoint(md) {
background-color: blue;
}
} would be great of you could expose a set of mixin functions like this one @include media-breakpoint(xs), so this lib will be very powerfull @CaerusKaru How this is addressed now this requirement from people that are using flex-layout? Are they creating a custom set of media query mixin? |
@CaerusKaru do you think that this is feasible? |
@kurtommy Definitely feasible, just needs design and sign-off from @ThomasBurleson. It might come down to publishing the mixin on the docs to avoid increasing the bundle size for everyone else. |
@CaerusKaru @ThomasBurleson I'm simply asking for something like this |
We're going to move ahead with this and try to get it in by the next release (likely early next year). |
@CaerusKaru means sometime in January '19. ;-) |
First pass is here: #940 |
This feature will be included in today's beta 22 release. To use, simply do the following in your SASS files: @import '~@angular/flex-layout/mq';
// This works for all Flex Layout breakpoints
@include layout-bp(xs) {
background-color: red;
} |
Yeah! in the meantime we've switched to bootstrap for gird and material components. we'll evaluate this when stable for new projects! thanks |
Does the feature support custom breakpoints, whose boundaries are only supplied at run time? Or are they hard coded to use the 600px etc as boundaries? |
It’s hardcoded right now, but we can workshop adding support for custom bps in a future release depending on interest and design. |
@CaerusKaru Are the map keys correctly defined for gt and lt? I'm assuming they should be lt- and gt-, but they are the same as the standard breakpoints. flex-layout/src/lib/core/sass/_layout-bp.scss Lines 31 to 46 in d9c520f
|
@fabiocarneiro I think you’re right, the keys need to be updated, good catch. I’ll put in a PR for that shortly. |
@fabiocarneiro see #987 |
This issue has been automatically locked due to inactivity. Read more about our automatic conversation locking policy. This action has been performed automatically by a bot. |
Feature Request
What is the desired behavior?
Use media query via mixin in CSS
What is the use-case or motivation for the desired behavior?
From what i've read in the DOC if i want a style eg a button with different background color based on breakpoints i can only do something like
<button [ngClass.xs]="xs-button" [ngClass.xs]="md-button">HI!</button>
and in CSS
This surely works but leads a lot of pollution in the markup, could you also export a mixins to do the below?
With CSS media query:
<button>HI!</button>
I can of course crate a set of mixins to do the above but would be great if this would exposed by flex-layout matching configured breakpoints..
Thanks
The text was updated successfully, but these errors were encountered: