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

fix: add the print media query for the right media query combinations #10979

Merged
merged 2 commits into from Dec 5, 2019
Merged

fix: add the print media query for the right media query combinations #10979

merged 2 commits into from Dec 5, 2019

Conversation

DanielRuf
Copy link
Contributor

This covers more down, up and only cases.

Reference: #10976

@DanielRuf DanielRuf requested a review from SassNinja February 22, 2018 23:32
@@ -166,7 +168,7 @@ $breakpoint-classes: (small medium large) !default;
// Otherwise, wrap the content in a media query
@else {
// For named breakpoints less than or equal to $print-breakpoint, add print to the media types
@if $bp != null and $bp <= $pbp {
@if ($bp != null and $bp == $pbp and ($dir == '' or $dir == 'up' or $dir == 'only')) or ($bp != null and $bp < $pbp and ($dir == '' or $dir == 'up')) or ($bp != null and $bp >= $pbp and ($dir == 'down')) {
Copy link
Contributor

Choose a reason for hiding this comment

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

I think we should move this to a cleaner "breakpoint compairaison" function. Putting all the cases here in a if is really confusing.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Definitely. Could need some assistance here as I've not often written mixins and functions.

Copy link
Contributor

Choose a reason for hiding this comment

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

I'll take care of this.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thanks =)

Copy link
Contributor

Choose a reason for hiding this comment

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

... this weekend :)

Copy link
Contributor

Choose a reason for hiding this comment

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

@DanielRuf @ncoden I'm not sure if this line has to be changed at all... what is the goal?

The comment says 'for named breakpoints less than or equal to $print-breakpoint' what I interpreted as starting point . The original @include breakpoint(large) was actually a @include breakpoint(large up) and thus also affects breakpoints greater than large.

So is the goal that breakpoint(large only) and breakpoint(large down) do affect print but breakpoint(large) does not? (although this would be a breaking change)
If not the condition $bp != null and $bp <= $pbp doesn't need to be changed imo

Copy link
Contributor

@ncoden ncoden Mar 1, 2018

Choose a reason for hiding this comment

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

I had some trouble to retrieve the problem here and the purpose of this change as we are working with confusing intervals here, but I think I got it.

If I understand $print-breakpoint correctly, it must be used to prevent print to consider highest breakpoints because, despite the high resolution of the paper (which is good for reading), this is not a good support for small interfaces and interactive elements. Paper should almost be considered as a tablet giving a fake resolution (like iPads, but we are faking the resolution).

Following this, the objective is to make printable the styles applied on $print-breakpoint or below like if higher breakpoints did not exists. This means that, for $print-breakpoint: large;:

  • large up/only/down, medium up/only/down, xlarge down should be printable because their styles are applied to a large (or smaller) screen so we should consider them as displayable on a large (or smaller) print support.
  • xlarge only/up should be not printable like before.

@SassNinja What do you think ?

Copy link
Contributor

Choose a reason for hiding this comment

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

Ok @ncoden so the rule would be to generate print if the breakpoint affects the print-breakpoint (or smaller).
This means the current condition only needs to be extended so 'down' always generates print.

Since @DanielRuf has already added $dir I would simply change the condition to

@if $bp != null and ($bp <= $pbp or $dir == down) {

Copy link
Contributor

@ncoden ncoden Mar 2, 2018

Choose a reason for hiding this comment

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

Yes, and we can add an explantation comment and a link to the comment here. @DanielRuf What do you think ?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Sounds good. I might have thought to complex. Not sure what I covered that would not be covered by the simple or condition. 🤔

@ncoden
Copy link
Contributor

ncoden commented Feb 22, 2018

Also, there is a lot of cleaning to do in the breakpoint function and mixin. See https://github.com/zurb/foundation-sites/pull/9661/files ;)

@DanielRuf DanielRuf mentioned this pull request Feb 24, 2018
@ncoden ncoden self-assigned this Feb 26, 2018
@ncoden ncoden added this to the 6.5.0 milestone Mar 2, 2018
@DanielRuf
Copy link
Contributor Author

Also, there is a lot of cleaning to do in the breakpoint function and mixin. See https://github.com/zurb/foundation-sites/pull/9661/files ;)

Do we need any further changes in this PR here as we also need #9661?

@ncoden
Copy link
Contributor

ncoden commented Mar 17, 2018

Do we need any further changes in this PR here as we also need #9661?

See #10979 (comment)

@DanielRuf
Copy link
Contributor Author

DanielRuf commented Mar 17, 2018

But doesn't this exclude / miss some cases?

Think about print breakpoint large.
I have an element which uses medium down. But this would be printed with the code of the comment I guess. But it should not because it should include $bp >= $pbp and ($dir == 'down')

@DanielRuf
Copy link
Contributor Author

Think about print breakpoint large.
I have an element which uses medium down. But this would be printed with the code of the comment I guess. But it should not because it should include $bp >= $pbp and ($dir == 'down')

/cc @SassNinja

@ncoden
Copy link
Contributor

ncoden commented Mar 17, 2018

@DanielRuf
I'm not sure to understand the case. Do you mean an element using breakpoint(medium down) with $print-breakpoint: large ? If so, "print" will be in the generated breakpoint because medium < large.

@DanielRuf
Copy link
Contributor Author

DanielRuf commented Mar 17, 2018

But the element will not be visible on large so there should not be a print media query.

@media print, screen and (max-width: medium) { would not be right then.

@ncoden
Copy link
Contributor

ncoden commented Mar 17, 2018

hmm... There is a problem with the current implementation:

@media print, screen and (max-width: medium) {

...means "print OR (screen and max-width: medium)".

So for the following code:

$print-breakpoint: medium;
.only-for-small,
.only-for-medium {
    display: none;
}

@include breakpoint(small only) {
    .only-for-small { display: block }
}

@include breakpoint(medium only) {
    .only-for-medium { display: block }
}
<div class="only-for-small">SMALL</div>
<div class="only-for-medium">MEDIUM</div>

Both SMALL and MEDIUM would be visible on print... I don't think this is expected.
See: https://codepen.io/ncoden/pen/RMGOdx

So we may have to change that to https://codepen.io/ncoden/pen/BrLEeO OR https://codepen.io/ncoden/pen/wmzZLQ

@DanielRuf
Copy link
Contributor Author

Both SMALL and MEDIUM would be visible on print... I don't think this is expected.
See: https://codepen.io/ncoden/pen/RMGOdx

Huh? I don't think so. At least with my proposed version it should be on only and down afaik.

@ncoden
Copy link
Contributor

ncoden commented Mar 22, 2018

Huh? I don't think so. At least with my proposed version it should be on only and down afaik.

Your proposed version does not resolve the case but hide some of its effects. The bug has nothing to do with "when do we add print" but is caused by the way we generate the mediaquery, with "print OR [breakpoint]".

@DanielRuf
Copy link
Contributor Author

Ah okay.

@DanielRuf
Copy link
Contributor Author

What are the next steps here?

@ncoden
Copy link
Contributor

ncoden commented Jul 1, 2018

I took a look at the whole discussion and I think that the todo-list is:

But it's not a priority before v6.5.0 stable version is released.

@kball
Copy link
Contributor

kball commented Aug 12, 2019

@DanielRuf do you have a sense of current status of this PR?

@DanielRuf
Copy link
Contributor Author

@DanielRuf do you have a sense of current status of this PR?

I'll check it this week.

@DanielRuf
Copy link
Contributor Author

@DanielRuf do you have a sense of current status of this PR?

Probably just needs the proposed change from https://github.com/zurb/foundation-sites/pull/10979/files#r171845415

generate print if the breakpoint affects the print-breakpoint (or smaller).
This means the current condition only needs to be extended so 'down' always generates print.
@joeworkman joeworkman self-requested a review December 5, 2019 22:17
Copy link
Member

@joeworkman joeworkman left a comment

Choose a reason for hiding this comment

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

LGTM

@joeworkman joeworkman self-requested a review December 5, 2019 22:25
@joeworkman joeworkman merged commit 30ede00 into foundation:develop Dec 5, 2019
@joeworkman
Copy link
Member

This pull request has been mentioned on Foundation Open Source Community. There might be relevant details there:

https://foundation.discourse.group/t/foundation-for-sites-v6-6-0-is-here-farout/30/1

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants