Skip to content
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

Merged
merged 3 commits into from
Jun 7, 2018
Merged

Wrap sass-mq as govuk-media-query #763

merged 3 commits into from
Jun 7, 2018

Conversation

36degrees
Copy link
Contributor

@36degrees 36degrees commented Jun 5, 2018

‘Abstract away’ sass-mq so that we don’t expose it as part of our public API, which means we’d be able to remove it in the future if we wanted to roll our own or move to a different vendored solution.

I've added tests for the govuk-media-query mixin based off the existing tests for sass-mq, but I've removed the tests for the sass-mq functions that we're now not calling directly, as I don't think it makes sense to test the 'internals' of a vendored library when we can test its edges instead.

@govuk-design-system-ci govuk-design-system-ci temporarily deployed to govuk-frontend-review-pr-763 June 5, 2018 14:24 Inactive
@@ -130,7 +130,7 @@
/// @access public

@mixin govuk-link-print-friendly {
@include mq($media-type: print) {
@include govuk-media-query($media-type: print) {
Copy link
Contributor

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

@govuk-design-system-ci govuk-design-system-ci temporarily deployed to govuk-frontend-review-pr-763 June 5, 2018 14:26 Inactive
@36degrees 36degrees changed the title Wrap sass-mq [WIP] Wrap sass-mq Jun 5, 2018
@govuk-design-system-ci govuk-design-system-ci temporarily deployed to govuk-frontend-review-pr-763 June 6, 2018 15:01 Inactive
@36degrees 36degrees changed the title [WIP] Wrap sass-mq Wrap sass-mq as govuk-media-query Jun 6, 2018
@@ -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;
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Moving this because the way Sass variable scoping works means that unless $mq-responsive is defined before this point, the $mq-responsive declaration only works within the scope of the @if – which caused a lot of headaches in the tests.


// =========================================================
// Wrangle sass-mq config...
// =========================================================

// Pass our breakpoints and static breakpoint definitions through to sass-mq.
$mq-breakpoints: if(variable-exists(govuk-breakpoints), $govuk-breakpoints, ());
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Because we do this configuration 'at import time', any changes to $govuk-is-ie8, $govuk-breakpoints, $govuk-ie8-breakpoint made after the import has been done will not have any effect on govuk-media-query. We could move this wrangling into the govuk-media-query mixin, but it complicates the way we pass arguments somewhat, and relies on us being able to pass that config to mq which is an undocumented feature, and I can't think of any valid use cases where you'd want to change that config mid-way through your codebase.

Thoughts?

@govuk-design-system-ci govuk-design-system-ci temporarily deployed to govuk-frontend-review-pr-763 June 6, 2018 15:10 Inactive
@kr8n3r
Copy link

kr8n3r commented Jun 6, 2018

one think the abstraction is missing is adding new media-queries (somewhere up to desktop where we want them to rasterise for ie8)

you can still ad them via @include mq-add-breakpoint(whatever, size); but it might be a weird mix of govuk-media-query and this syntax

@36degrees
Copy link
Contributor Author

Is that something we think people actually want to use? I don't think we need to expose everything mq allows unless we think it's actually needed.

It's still possible to override $govuk-breakpoints to add new breakpoints globally?

@kr8n3r
Copy link

kr8n3r commented Jun 6, 2018

true. people might not do it that way / know of it. most likely will just add it to the breakpoints map

@36degrees
Copy link
Contributor Author

One thing to consider is that if in the future we wanted to move away from using sass-mq we'd have to implement everything we've exposed as part of our API – if we implement every feature that mq offers, we're committing to providing those features or we'd be forced to introduce a breaking change to remove them.

kr8n3r
kr8n3r previously requested changes Jun 7, 2018
Copy link

@kr8n3r kr8n3r left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yeah we don't want to complicate it further.
add changelog and ship it

@36degrees
Copy link
Contributor Author

@igloosi did you mean to mark that as 'request changes'?

‘Abstract away’ sass-mq so that we don’t expose it as part of our public API, which means we’d be able to remove it in the future if we wanted to roll our own or move to a different vendored solution.
@kr8n3r kr8n3r dismissed their stale review June 7, 2018 09:27

no changes to code needed, just changelog needs adding

@govuk-design-system-ci govuk-design-system-ci temporarily deployed to govuk-frontend-review-pr-763 June 7, 2018 09:33 Inactive
@36degrees 36degrees merged commit 4b6be21 into master Jun 7, 2018
@36degrees 36degrees deleted the abstract-mq branch June 7, 2018 09:48
@hannalaakso hannalaakso mentioned this pull request Jun 14, 2018
NickColley added a commit that referenced this pull request Nov 19, 2019
We wrap the media query (mq) library with `govuk-media-query` so we can change it in the future.

I think these may have been missed out when we originally did that work:
#763

There is no impact on users that I'm aware of, so this is just a tidy up.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants