-
Notifications
You must be signed in to change notification settings - Fork 327
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
Wrap sass-mq as govuk-media-query #763
Changes from 2 commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,12 @@ | ||
// Import sass-mq as a helper for media queries | ||
//// | ||
/// @group helpers | ||
//// | ||
|
||
|
||
|
||
// ========================================================= | ||
// Wrangle sass-mq config... | ||
// ========================================================= | ||
|
||
// Pass our breakpoints and static breakpoint definitions through to sass-mq. | ||
$mq-breakpoints: if(variable-exists(govuk-breakpoints), $govuk-breakpoints, ()); | ||
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. Because we do this configuration 'at import time', any changes to Thoughts? |
||
|
@@ -13,10 +21,9 @@ $mq-show-breakpoints: (); | |
// When building a stylesheet for IE8, set $mq-responsive to false in order to | ||
// 'rasterize' any media queries. | ||
|
||
$mq-responsive: true; | ||
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. Moving this because the way Sass variable scoping works means that unless |
||
@if (variable-exists(govuk-is-ie8) and $govuk-is-ie8) { | ||
$mq-responsive: false; | ||
} @else { | ||
$mq-responsive: true; | ||
} | ||
|
||
// This is a horrible, horrible hack to prevent the 'dev mode' CSS to display | ||
|
@@ -33,3 +40,62 @@ $sass-mq-already-included: false !default; | |
@import "../vendor/sass-mq"; | ||
|
||
$sass-mq-already-included: true; | ||
|
||
|
||
|
||
// ========================================================= | ||
// Helpers | ||
// ========================================================= | ||
|
||
/// Media Query | ||
/// | ||
/// This is a currently a wrapper for sass-mq - abstracted so that we can | ||
/// replace it in the future if we so choose. | ||
/// | ||
/// @param {String | Boolean} $from [false] - One of $govuk-breakpoints | ||
/// @param {String | Boolean} $until [false] - One of $govuk-breakpoints | ||
/// @param {String | Boolean} $and [false] - Additional media query parameters | ||
/// @param {String} $media-type [all] - Media type: screen, print… | ||
/// | ||
/// @ignore Undocumented API, for advanced use only: | ||
/// @ignore @param {Map} $breakpoints [$govuk-breakpoints] | ||
/// @ignore @param {String} $static-breakpoint [$govuk-ie8-breakpoint] | ||
/// @ignore @param {Boolean} $responsive [$govuk-is-ie8] | ||
/// | ||
/// @content styling rules, wrapped into a @media query when $responsive is true | ||
/// | ||
/// @example scss | ||
/// .element { | ||
/// @include govuk-media-query($from: mobile) { | ||
/// color: red; | ||
/// } | ||
/// @include govuk-media-query($until: tablet) { | ||
/// color: blue; | ||
/// } | ||
/// @include govuk-media-query(mobile, tablet) { | ||
/// color: green; | ||
/// } | ||
/// @include govuk-media-query($from: tablet, $and: '(orientation: landscape)') { | ||
/// color: teal; | ||
/// } | ||
/// @include govuk-media-query(950px) { | ||
/// color: hotpink; | ||
/// } | ||
/// @include govuk-media-query(tablet, $media-type: screen) { | ||
/// color: hotpink; | ||
/// } | ||
/// | ||
/// @example scss Advanced use: | ||
/// $my-breakpoints: (L: 900px, XL: 1200px); | ||
/// @include govuk-media-query(L, $breakpoints: $my-breakpoints, $static-breakpoint: L) { | ||
/// color: hotpink; | ||
/// } | ||
/// } | ||
/// | ||
/// @access public | ||
|
||
@mixin govuk-media-query($args...) { | ||
@include mq($args...) { | ||
@content; | ||
}; | ||
} |
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.
+1 for not using single letter variables for this new mixin