-
-
Notifications
You must be signed in to change notification settings - Fork 79k
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
Issue #8883: make responsive visibility classes mixable with each other #9692
Conversation
visible-* classes now compatible with each other and hidden-* too For example class="visible-xs visible-sm" will be visible at extra small and small screens, class="hidden-xs hidden-lg" hidden for extra small and large screen but visible for small and middle
+1 for @turchenkoalex - Well done, I did a small test with your pull request on my fork, and the multi-classing works. Love the inverting of the base display properties ( hidden-* states as visible, and visible-* as invisible ) very smart and did the trick! @mdo any feedback? this is a great little tweak. @cfarquharson - this will help us deal with the hiding over multiple discrete breakpoints. |
👍 |
Definitely agree! Reviewed this yesterday and the approach is both elegant and functional. 🍻 |
Haven't played with it too much, but I think the downside here is that these classes are not entirely mixin-friendly now, correct? Since there are two declarations per class, Less won't pick it all up I believe. Done any tests for that? |
FYI, if we can fix this, we can slate it for 3.1 when we add new features. We won't be able to get this into 3.0 I'm afraid due to timing. |
yes, I fully agree! |
Saw this got punted to 3.1 by @mdo. I think its a great approach and would love to see it sooner. Cheers to @turchenkoalex and all the others who took a whack at this. |
Sorry for that message, it's not worked idea For @mdo request I removed double declaration of class visible-* and hidden-* Visible classes: The basic idea is that Code: .visible-xs {
.responsive-invisibility();
@media (max-width: @screen-tablet) {
.responsive-visibility();
}
}
.visible-sm {
.responsive-invisibility();
@media (min-width: @screen-tablet) and (max-width: @screen-tablet-max) {
.responsive-visibility();
}
}
.visible-md {
.responsive-invisibility();
@media (min-width: @screen-desktop) and (max-width: @screen-desktop-max) {
.responsive-visibility();
}
}
.visible-lg {
.responsive-invisibility();
@media (min-width: @screen-large-desktop) {
.responsive-visibility();
}
} Someone else can test it? Or I misunderstood what @mdo said? |
@turchenkoalex - I believe @mdo, just wants the code well tested. Your original pull request is elegant and works well but it changes the behaviour of the responsive utilities a bit. @mdo want to be sure to add this correctly and is pushing this off to 3.1 since they have a small window for 3.0. I will working on the tests for this later this week since I am curious on how this performs and would adopt for my own fork if everything works out. Feel free to correct me if I am wrong @mdo Thanks again @turchenkoalex - great work on this. |
@masterbee thanks, I fully agree! |
@turchenkoalex Your new solution now work fine for mixins .tablet-phone {
.visible-xs;
.visible-sm;
}
|
@eratzlaff, shouldn't that be |
@pixelchutes fixed tanks |
.visible-xs {
@media (max-width: @screen-phone-max) {
.responsive-visibility();
}
@media (min-width: @screen-tablet) and (max-width: @screen-tablet-max) {
.responsive-invisibility();
}
&.visible-sm {
@media (min-width: @screen-tablet) and (max-width: @screen-tablet-max) {
.responsive-visibility();
}
}
@media (min-width: @screen-desktop) and (max-width: @screen-desktop-max) {
.responsive-invisibility();
}
&.visible-md {
@media (min-width: @screen-desktop) and (max-width: @screen-desktop-max) {
.responsive-visibility();
}
}
@media (min-width: @screen-large-desktop) {
.responsive-invisibility();
}
&.visible-lg {
@media (min-width: @screen-large-desktop) {
.responsive-visibility();
}
}
}
.visible-sm {
@media (max-width: @screen-phone-max) {
.responsive-invisibility();
}
&.visible-xs {
@media (max-width: @screen-phone-max) {
.responsive-visibility();
}
}
@media (min-width: @screen-tablet) and (max-width: @screen-tablet-max) {
.responsive-visibility();
}
@media (min-width: @screen-desktop) and (max-width: @screen-desktop-max) {
.responsive-invisibility();
}
&.visible-md {
@media (min-width: @screen-desktop) and (max-width: @screen-desktop-max) {
.responsive-visibility();
}
}
@media (min-width: @screen-large-desktop) {
.responsive-invisibility();
}
&.visible-lg {
@media (min-width: @screen-large-desktop) {
.responsive-visibility();
}
}
}
.visible-md {
@media (max-width: @screen-phone-max) {
.responsive-invisibility();
}
&.visible-xs {
@media (max-width: @screen-phone-max) {
.responsive-visibility();
}
}
@media (min-width: @screen-tablet) and (max-width: @screen-tablet-max) {
.responsive-invisibility();
}
&.visible-sm {
@media (min-width: @screen-tablet) and (max-width: @screen-tablet-max) {
.responsive-visibility();
}
}
@media (min-width: @screen-desktop) and (max-width: @screen-desktop-max) {
.responsive-visibility();
}
@media (min-width: @screen-large-desktop) {
.responsive-invisibility();
}
&.visible-lg {
@media (min-width: @screen-large-desktop) {
.responsive-visibility();
}
}
}
.visible-lg {
@media (max-width: @screen-phone-max) {
.responsive-invisibility();
}
&.visible-xs {
@media (max-width: @screen-phone-max) {
.responsive-visibility();
}
}
@media (min-width: @screen-tablet) and (max-width: @screen-tablet-max) {
.responsive-invisibility();
}
&.visible-sm {
@media (min-width: @screen-tablet) and (max-width: @screen-tablet-max) {
.responsive-visibility();
}
}
@media (min-width: @screen-desktop) and (max-width: @screen-desktop-max) {
.responsive-invisibility();
}
&.visible-md {
@media (min-width: @screen-desktop) and (max-width: @screen-desktop-max) {
.responsive-visibility();
}
}
@media (min-width: @screen-large-desktop) {
.responsive-visibility();
}
} Ugly code, but its work fine on my test cases. .show-xs {
.visible-xs;
}
.show-sm {
.visible-sm;
}
.show-md {
.visible-md;
}
.show-lg {
.visible-lg;
}
.show-xs-sm {
.visible-xs;
.visible-sm;
}
.show-xs-md {
.visible-xs;
.visible-md;
}
.show-xs-lg {
.visible-xs;
.visible-lg;
}
.show-sm-md {
.visible-sm;
.visible-md;
}
.show-sm-lg {
.visible-sm;
.visible-lg;
}
.show-md-lg {
.visible-md;
.visible-lg;
}
.show-xs-sm-md {
.visible-xs;
.visible-sm;
.visible-md;
}
.show-xs-sm-lg {
.visible-xs;
.visible-sm;
.visible-lg;
}
.show-xs-md-lg {
.visible-xs;
.visible-md;
.visible-lg;
}
.show-sm-md-lg {
.visible-sm;
.visible-md;
.visible-lg;
} HTML <div class="col-xs-6">
<div class="visible-xs">visible-xs</div>
<div class="visible-sm">visible-sm</div>
<div class="visible-md">visible-md</div>
<div class="visible-lg">visible-lg</div>
</div>
<div class="col-xs-6">
<div class="show-xs">visible-xs</div>
<div class="show-sm">visible-sm</div>
<div class="show-md">visible-md</div>
<div class="show-lg">visible-lg</div>
</div>
<div class="col-xs-6">
<div class="visible-xs visible-sm">visible-xs visible-sm</div>
<div class="visible-xs visible-md">visible-xs visible-md</div>
<div class="visible-xs visible-lg">visible-xs visible-lg</div>
<div class="visible-sm visible-md">visible-sm visible-md</div>
<div class="visible-sm visible-lg">visible-sm visible-lg</div>
<div class="visible-md visible-lg">visible-md visible-lg</div>
</div>
<div class="col-xs-6">
<div class="show-xs-sm">visible-xs visible-sm</div>
<div class="show-xs-md">visible-xs visible-md</div>
<div class="show-xs-lg">visible-xs visible-lg</div>
<div class="show-sm-md">visible-sm visible-md</div>
<div class="show-sm-lg">visible-sm visible-lg</div>
<div class="show-md-lg">visible-md visible-lg</div>
</div>
<div class="col-xs-6">
<div class="visible-xs visible-sm visible-md">visible-xs visible-sm visible-md</div>
<div class="visible-xs visible-sm visible-lg">visible-xs visible-sm visible-lg</div>
<div class="visible-xs visible-md visible-lg">visible-xs visible-md visible-lg</div>
<div class="visible-sm visible-md visible-lg">visible-sm visible-md visible-lg</div>
</div>
<div class="col-xs-6">
<div class="show-xs-sm-md">visible-xs visible-sm visible-md</div>
<div class="show-xs-sm-lg">visible-xs visible-sm visible-lg</div>
<div class="show-xs-md-lg">visible-xs visible-md visible-lg</div>
<div class="show-sm-md-lg">visible-sm visible-md visible-lg</div>
</div> Sorry for the long comment. |
Some code cleaned .visible-xs {
.responsive-invisibility();
@media (max-width: @screen-phone-max) {
.responsive-visibility();
}
&.visible-sm {
@media (min-width: @screen-tablet) and (max-width: @screen-tablet-max) {
.responsive-visibility();
}
}
&.visible-md {
@media (min-width: @screen-desktop) and (max-width: @screen-desktop-max) {
.responsive-visibility();
}
}
&.visible-lg {
@media (min-width: @screen-large-desktop) {
.responsive-visibility();
}
}
}
.visible-sm {
.responsive-invisibility();
&.visible-xs {
@media (max-width: @screen-phone-max) {
.responsive-visibility();
}
}
@media (min-width: @screen-tablet) and (max-width: @screen-tablet-max) {
.responsive-visibility();
}
&.visible-md {
@media (min-width: @screen-desktop) and (max-width: @screen-desktop-max) {
.responsive-visibility();
}
}
&.visible-lg {
@media (min-width: @screen-large-desktop) {
.responsive-visibility();
}
}
}
.visible-md {
.responsive-invisibility();
&.visible-xs {
@media (max-width: @screen-phone-max) {
.responsive-visibility();
}
}
&.visible-sm {
@media (min-width: @screen-tablet) and (max-width: @screen-tablet-max) {
.responsive-visibility();
}
}
@media (min-width: @screen-desktop) and (max-width: @screen-desktop-max) {
.responsive-visibility();
}
&.visible-lg {
@media (min-width: @screen-large-desktop) {
.responsive-visibility();
}
}
}
.visible-lg {
.responsive-invisibility();
&.visible-xs {
@media (max-width: @screen-phone-max) {
.responsive-visibility();
}
}
&.visible-sm {
@media (min-width: @screen-tablet) and (max-width: @screen-tablet-max) {
.responsive-visibility();
}
}
&.visible-md {
@media (min-width: @screen-desktop) and (max-width: @screen-desktop-max) {
.responsive-visibility();
}
}
@media (min-width: @screen-large-desktop) {
.responsive-visibility();
}
} |
visible-xs and hidden-xs media query changed from (max-width: @screen-tablet) to (max-width: @screen-phone-max). -xs media query intersects with the -sm media query before.
What's the status on this? Unsure what the last commit accomplishes with regards to the latest comments. Plus, looks like there are conflicts. At this point, we'll have to slate this for v3.1 btw. |
@mdo Please try my solution. The last one. I try it with mixins and all work as far I try. |
@mdo missing part for hidden-* .hidden-xs {
.responsive-visibility();
@media (max-width: @screen-phone-max) {
.responsive-invisibility();
}
&.hidden-sm {
@media (min-width: @screen-tablet) and (max-width: @screen-tablet-max) {
.responsive-invisibility();
}
}
&.hidden-md {
@media (min-width: @screen-desktop) and (max-width: @screen-desktop-max) {
.responsive-invisibility();
}
}
&.hidden-lg {
@media (min-width: @screen-large-desktop) {
.responsive-invisibility();
}
}
}
.hidden-sm {
.responsive-visibility();
&.hidden-xs {
@media (max-width: @screen-phone-max) {
.responsive-invisibility();
}
}
@media (min-width: @screen-tablet) and (max-width: @screen-tablet-max) {
.responsive-invisibility();
}
&.hidden-md {
@media (min-width: @screen-desktop) and (max-width: @screen-desktop-max) {
.responsive-invisibility();
}
}
&.hidden-lg {
@media (min-width: @screen-large-desktop) {
.responsive-invisibility();
}
}
}
.hidden-md {
.responsive-visibility();
&.hidden-xs {
@media (max-width: @screen-phone-max) {
.responsive-invisibility();
}
}
&.hidden-sm {
@media (min-width: @screen-tablet) and (max-width: @screen-tablet-max) {
.responsive-invisibility();
}
}
@media (min-width: @screen-desktop) and (max-width: @screen-desktop-max) {
.responsive-invisibility();
}
&.hidden-lg {
@media (min-width: @screen-large-desktop) {
.responsive-invisibility();
}
}
}
.hidden-lg {
.responsive-visibility();
&.hidden-xs {
@media (max-width: @screen-phone-max) {
.responsive-invisibility();
}
}
&.hidden-sm {
@media (min-width: @screen-tablet) and (max-width: @screen-tablet-max) {
.responsive-invisibility();
}
}
&.hidden-md {
@media (min-width: @screen-desktop) and (max-width: @screen-desktop-max) {
.responsive-invisibility();
}
}
@media (min-width: @screen-large-desktop) {
.responsive-invisibility();
}
} |
Fixed via #9821. |
👍 awesome! |
Thx @turchenkoalex @eratzlaff @mdo! Pulled down and working as advertised. Love that this will be baked into 3.0, too. |
I don't see this on the master on github anymore, although I can on the 3.0.3 version from getbootstrap.com. Any advise? |
#11214 #11302 |
@eratzlaff Should be fixed in |
visible-* classes now can be mixable with each other and hidden-* too (Issue #8883)
For example class="visible-xs visible-sm" will be visible at extra small and small screens, class="hidden-xs hidden-lg" hidden for extra small and large screen but visible for small and middle