Repository navigation
Conversation
… manual rendering Responsive breakpoint states (mobile/tablet) are now represented as first-class style nodes in get_block_nodes(), matching the existing pattern used for pseudo states. This replaces ~160 lines of manual breakpoint loops in get_styles_for_block() with a simple media_query wrapper, reducing duplication and improving maintainability.
|
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 If you're merging code through a pull request on GitHub, copy and paste the following into the bottom of the merge commit message. To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook. |
tellthemachines
left a comment
There was a problem hiding this comment.
Yeah this LGTM! It reduces a lot of the duplication and works well in testing 🎉
| $nodes[] = array( | ||
| 'name' => $name, | ||
| 'path' => array( 'styles', 'blocks', $name, $breakpoint ), | ||
| 'media_query' => static::RESPONSIVE_BREAKPOINTS[ $breakpoint ], |
There was a problem hiding this comment.
Elsewhere we've been using viewport, though in #77513 we also use media_query as an option to get_layout_styles. Should we standardise on one of these? viewport is already used for block visibility too.
There was a problem hiding this comment.
I think media_query is ok here, as it does represent the media query string for the generated css.
| // 8. Wrap the entire block output in a media query if this is a responsive node. | ||
| // Responsive nodes are created by get_block_nodes() for each breakpoint and carry | ||
| // a 'media_query' key. This replaces the previous manual responsive sections that | ||
| // duplicated rendering logic for each breakpoint. |
There was a problem hiding this comment.
I think we can probably remove the last sentence if we're merging this into #77513 😄
c919c21
into
try/responsive-global-block-styles
What?
Based on #77513 and merges into that branch
Tries a variation of the theme.json code in that branch.
Instead of looping through and building styles for responsive breakpoints inside
get_styles_for_block, this PR instead tries assembling the breakpoint styles as nodes insideget_block_nodes.Does so by adding a
media_queryproperty to a node, which when presentget_styles_for_blockwill use to wrap the output styles.