Skip to content

Commit

Permalink
Merge pull request #1833 from SohamPatel46/feat/use-media-queries-in-…
Browse files Browse the repository at this point in the history
…range

Use CSS range syntax in media queries
  • Loading branch information
westonruter authored Feb 4, 2025
2 parents 5a1e472 + 4c01373 commit 2fa59f0
Show file tree
Hide file tree
Showing 39 changed files with 217 additions and 156 deletions.
15 changes: 12 additions & 3 deletions plugins/embed-optimizer/class-embed-optimizer-tag-visitor.php
Original file line number Diff line number Diff line change
Expand Up @@ -185,12 +185,21 @@ private function reduce_layout_shifts( OD_Tag_Visitor_Context $context ): void {

$style_rules = array();
foreach ( $minimums as $minimum ) {
$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;
}

$processor->append_head_html( sprintf( "<style>\n%s\n</style>\n", join( "\n", $style_rules ) ) );
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
<html lang="en">
<head>
<meta charset="utf-8">
<title>...</title>
</head>
<body>
<div class="wp-site-blocks">
<figure class="wp-block-embed is-type-rich is-provider-twitter wp-block-embed-twitter">
<div class="wp-block-embed__wrapper">
<blockquote class="twitter-tweet" data-width="550" data-dnt="true"><p lang="en" dir="ltr">We want your feedback for the Privacy Sandbox 📨<br><br>Learn why your feedback is critical through real examples and learn how to provide it ↓ <a href="https://t.co/anGk6gWkbc">https://t.co/anGk6gWkbc</a></p>&mdash; Chrome for Developers (@ChromiumDev) <a href="https://twitter.com/ChromiumDev/status/1636796541368139777?ref_src=twsrc%5Etfw">March 17, 2023</a></blockquote>
<script async src="https://platform.twitter.com/widgets.js" charset="utf-8"></script>
</div>
</figure>
</div>
</body>
</html>

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
<?php
return static function ( Test_Embed_Optimizer_Optimization_Detective $test_case ): void {
add_filter( 'od_breakpoint_max_widths', '__return_empty_array' );

$test_case->populate_url_metrics(
array(
array(
'xpath' => '/HTML/BODY/DIV[@class=\'wp-site-blocks\']/*[1][self::FIGURE]/*[1][self::DIV]',
'isLCP' => true,
'intersectionRatio' => 1,
'resizedBoundingClientRect' => array_merge( $test_case->get_sample_dom_rect(), array( 'height' => 500 ) ),
),
)
);
};

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit 2fa59f0

Please sign in to comment.