-
-
Notifications
You must be signed in to change notification settings - Fork 78.9k
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
Media query mixins #13014
Media query mixins #13014
Changes from 14 commits
5342317
0076434
eea324b
a9e965e
af320a8
00a6b6d
00cc837
bff7098
eb439cb
242bcbf
21ea0ac
3e6a7b2
5871836
b41a2e7
df3cdf7
fd5ff6b
525de67
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
// Media query mixins | ||
|
||
.screen-xs(@rules) { | ||
@media (max-width: @screen-xs-max) { @rules(); } | ||
} | ||
|
||
.screen-sm(@rules) { | ||
@media (min-width: @screen-sm-min) { @rules(); } | ||
} | ||
|
||
.screen-sm-max(@rules) { | ||
@media (min-width: @screen-sm-min) and (max-width: @screen-sm-max) { @rules(); } | ||
} | ||
|
||
.screen-md(@rules) { | ||
@media (min-width: @screen-md-min) { @rules(); } | ||
} | ||
|
||
.screen-md-max(@rules) { | ||
@media (min-width: @screen-md-min) and (max-width: @screen-md-max) { @rules(); } | ||
} | ||
|
||
.screen-lg(@rules) { | ||
@media (min-width: @screen-lg-min) { @rules(); } | ||
} | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -119,8 +119,8 @@ | |
} | ||
|
||
// Scale up the modal | ||
@media (min-width: @screen-sm-min) { | ||
// Automatically set modal's width for larger viewports | ||
.screen-sm({ | ||
// Automatically set modal\'s width for larger viewports | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Unnecessary backslash? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @cvrebert I made a comment about that in the commit - but maybe it's worth adding a comment in the file itself. That is needed to escape the ' which for some reason causes a parsing error in that comment once you use a mixin with a ruleset. Other option would be to have bad punctuation and just drop the ' altogether. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Let's report that upstream to the Less folks—we make extensive use of apostrophes 😁. |
||
.modal-dialog { | ||
width: @modal-md; | ||
margin: 30px auto; | ||
|
@@ -131,8 +131,8 @@ | |
|
||
// Modal sizes | ||
.modal-sm { width: @modal-sm; } | ||
} | ||
}); | ||
|
||
@media (min-width: @screen-md-min) { | ||
.screen-md({ | ||
.modal-lg { width: @modal-lg; } | ||
} | ||
}); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
-max
doesn't seem too clear, IMHO. Maybe.screen-sm-only
?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah I don't think screen is that great either as it actually isn't representing a query that explicitly targets screen. I definitely think we should iron out the names before merging this. They could be better.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The query doesn't target 'screen' media but it uses the
@screen-*
variables as reference.I also think, that the naming is misleading.
.screen-sm()
should cover only small screens while.screen-sm-max()
should cover small screens and below. There should also be a third mixin.screen-sm-min()
which covers small screens an above. Same for medium screen queries...I made a revision of my previous gist to clarify what i mean. I think you just adopted the names from the first dirty version. This revision also contains some
.screen()
mixins to quickly assign rules to multiple media queries.