-
Notifications
You must be signed in to change notification settings - Fork 5.5k
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
Conversation
scss/util/_breakpoint.scss
Outdated
@@ -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')) { |
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.
I think we should move this to a cleaner "breakpoint compairaison" function. Putting all the cases here in a if
is really confusing.
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.
Definitely. Could need some assistance here as I've not often written mixins and functions.
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.
I'll take care of this.
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.
Thanks =)
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.
... this weekend :)
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.
@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
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.
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 ?
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.
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) {
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.
Yes, and we can add an explantation comment and a link to the comment here. @DanielRuf What do you think ?
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.
Sounds good. I might have thought to complex. Not sure what I covered that would not be covered by the simple or
condition. 🤔
Also, there is a lot of cleaning to do in the |
Do we need any further changes in this PR here as we also need #9661? |
See #10979 (comment) |
But doesn't this exclude / miss some cases? Think about print breakpoint large. |
/cc @SassNinja |
@DanielRuf |
But the element will not be visible on large so there should not be a print media query.
|
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 So we may have to change that to https://codepen.io/ncoden/pen/BrLEeO OR https://codepen.io/ncoden/pen/wmzZLQ |
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 |
Ah okay. |
What are the next steps here? |
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. |
@DanielRuf do you have a sense of current status of this PR? |
I'll check it this week. |
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.
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.
LGTM
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 |
This covers more
down
,up
andonly
cases.Reference: #10976