| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
Sorry, something went wrong.
|
Here's a script you can use to update the snapshots once the actual.html files have been generated: #!/bin/bash
for actual in $( find . -name 'actual.html' ); do
expected=${actual/actual/expected};
echo "$actual => $expected"
mv "$actual" "$expected"
doneThere should probably be something like this added to scripts in package.json. |
Sorry, something went wrong.
Hello @westonruter I didn't get your above message. Is this for updating PHP unit tests ? |
Sorry, something went wrong.
|
Yes, the unit test failures are due to the HTML snapshots being out for date now that the media query is updated. So you need to move all the actual.html files generated during the unit tests over to replace the expected.html (if indeed the changes are as expected!) That bash script is a way to do so in bulk. |
Sorry, something went wrong.
| 'min_width' => 0, | ||
| 'max_width' => 320, | ||
| 'expected' => '(max-width: 320px)', | ||
| 'expected' => null, |
There was a problem hiding this comment.
Why is this null? It should be unchanged.
Sorry, something went wrong.
| 'min_width' => null, | ||
| 'max_width' => 320, | ||
| 'expected' => '(max-width: 320px)', | ||
| 'expected' => null, |
There was a problem hiding this comment.
Same. This should be unchanged, right?
Sorry, something went wrong.
| 'expected' => '(min-width: 601px)', | ||
| 'expected' => null, | ||
| ), | ||
| 'desktop_alt' => array( | ||
| 'min_width' => 601, | ||
| 'max_width' => null, | ||
| 'expected' => '(min-width: 601px)', | ||
| 'expected' => null, |
There was a problem hiding this comment.
Ditto
Sorry, something went wrong.
Co-authored-by: Weston Ruter <westonruter@google.com>
Codecov ReportAll modified and coverable lines are covered by tests ✅ Additional details and impacted files @@ Coverage Diff @@
## trunk #1833 +/- ##
==========================================
+ Coverage 65.82% 65.86% +0.03%
==========================================
Files 88 88
Lines 6865 6873 +8
==========================================
+ Hits 4519 4527 +8
Misses 2346 2346
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. |
Sorry, something went wrong.
|
The following accounts have interacted with this PR and/or linked issues. I will continue to update these lists as activity occurs. You can also manually ask me to refresh this list by adding the props-bot label. If you're merging code through a pull request on GitHub, copy and paste the following into the bottom of the merge commit message. Co-authored-by: SohamPatel46 <sohampate1@git.wordpress.org> Co-authored-by: westonruter <westonruter@git.wordpress.org> To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook. |
Sorry, something went wrong.
|
I'm just realizing that this isn't going to solve the potential sub-pixel rendering issue. Look at this diff: Note that min-width: 481px and 481px < width are identical in behavior. Only the syntax is different. For there to be any change in behavior the new syntax would need to change to 480px < width, so decrementing the minimum bound by one. See correction below: #1833 (comment) |
Sorry, something went wrong.
There was a problem hiding this comment.
See #1833 (comment).
The od_generate_media_query() function may need to have the semantics of its parameters changed, so that it is understood somehow the passed $minimum_viewport_width is not inclusive meaning that the viewport can never exactly equal that minimum width but it can be greater than it. In contrast, the $maximum_viewport_width is inclusive, in that the viewport width can exactly equal the max.
This may end up going down a rabbit hole because the URL Metric Groups have minimum and maximum viewport widths too, so then their semantics would probably need to change as well.
This will take some more thought.
Sorry, something went wrong.
| if ( $has_min_width && $has_max_width ) { | ||
| $media_attributes = sprintf( '( %dpx < width <= %dpx )', $minimum_viewport_width, $maximum_viewport_width ); | ||
| } elseif ( $has_min_width ) { | ||
| $media_attributes = sprintf( '(min-width: %dpx)', $minimum_viewport_width ); |
There was a problem hiding this comment.
Can the new syntax be used?
Sorry, something went wrong.
| } elseif ( $has_min_width ) { | ||
| $media_attributes = sprintf( '(min-width: %dpx)', $minimum_viewport_width ); | ||
| } elseif ( $has_max_width ) { | ||
| $media_attributes = sprintf( '(max-width: %dpx)', $maximum_viewport_width ); |
There was a problem hiding this comment.
Ditto
Sorry, something went wrong.
Correction: they aren't actually identical in behavior. In the min-width: 481px syntax, the viewport width can be exactly 481px whereas in the new syntax it can never be exactly 481px since it must be greater. So this means the result is worse. This emphasizes the need to somehow have this output 480px < width. |
Sorry, something went wrong.
Take a look at #1839. |
Sorry, something went wrong.
… feat/use-media-queries-in-range
| $style_rules[] = sprintf( | ||
| '@media %s { #%s { min-height: %dpx; } }', | ||
| od_generate_media_query( $minimum['group']->get_minimum_viewport_width(), $minimum['group']->get_maximum_viewport_width() ), | ||
| $style_rule = sprintf( | ||
| '#%s { min-height: %dpx; }', | ||
| $element_id, | ||
| $minimum['height'] | ||
| ); | ||
|
|
||
| $media_feature = od_generate_media_query( $minimum['group']->get_minimum_viewport_width(), $minimum['group']->get_maximum_viewport_width() ); | ||
| if ( null !== $media_feature ) { | ||
| $style_rule = sprintf( | ||
| '@media %s { %s }', | ||
| $media_feature, | ||
| $style_rule | ||
| ); | ||
| } | ||
| $style_rules[] = $style_rule; |
There was a problem hiding this comment.
This change fixes a bug I noticed which can happen when a site is configured to have zero breakpoints (which is very unlikely). In this case, the return value of od_generate_media_query() is null since the minimum is 0 and the maximum is null.
Sorry, something went wrong.
There was a problem hiding this comment.
This is working well in my testing!
Sorry, something went wrong.
|
@felixarntz Please take a look when you get a chance. |
Sorry, something went wrong.
| Back | FazBrowse Home | New Git URL |
Summary
Fixes #1696
Relevant technical choices
Using CSS range syntax helps eliminate frontend issues where windows are sized sub-pixel dimensions.
This converts media queries from
to
The above conversion results in eliminating sub-pixel dimension issues possible between 600px to 601px screen.