Conversation
|
@copilot can you rebase this? |
|
@scruffian I've opened a new pull request, #75609, to work on those changes. Once the pull request is ready, I'll request review from you. |
|
@copilot can you open a new PR that consolidates the font size calculation function for navigation link and navigation submenu blocks to a shared helper? |
|
@scruffian I've opened a new pull request, #75672, to work on those changes. Once the pull request is ready, I'll request review from you. |
042a8ea to
b4f1e9b
Compare
…ubmenu blocks Extract the duplicated `build_css_font_sizes` function from both navigation-link and navigation-submenu into a shared helper file, following the same pattern established for item-should-render and render-submenu-icon shared helpers. Uses the IS_GUTENBERG_PLUGIN guard at call sites so the correct (prefixed vs unprefixed) function name is used in both the Gutenberg plugin build and WordPress Core. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
192cb26 to
23e4ea2
Compare
|
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. |
jeryj
left a comment
There was a problem hiding this comment.
Both home-link and page-list blocks use the same font sizes function. Let's update those to use this shared function too. Thanks for this refactor! One function instead of four identical ones is much better!
| return ''; | ||
| } | ||
|
|
||
| $font_sizes = block_core_navigation_link_build_css_font_sizes( $block->context ); |
There was a problem hiding this comment.
Same comment as in #75685 (comment), I prefer leaving this and putting the IS_GUTENBERG_PLUGIN logic within it with comments to help explain it and hide the complexity. This line could stay the same and the complexity goes within block_core_navigation_link_build_css_font_sizes
There was a problem hiding this comment.
This won't work because block_core_navigation_link_build_css_font_sizes isn't defined in core yet, so we'll get a fatal error (Uncaught Error: Call to undefined function block_core_shared_get_submenu_visibility()). That solution will only work once the function is backported to core.
Replace the duplicate block_core_page_list_build_css_font_sizes function with the shared block_core_shared_navigation_build_css_font_sizes helper, matching the pattern used by Navigation Link and Submenu blocks. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Replace the duplicate block_core_home_link_build_css_font_sizes function with the shared block_core_shared_navigation_build_css_font_sizes helper. This also fixes Home Link not supporting fluid typography for custom font sizes, aligning it with Navigation Link, Submenu, and Page List blocks. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Remove extra alignment spaces on $colors and $classes assignments that were left over after replacing the single-line $font_sizes assignment with a multi-line IS_GUTENBERG_PLUGIN conditional block. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
…ites The gutenberg_ prefix is needed because Core already defines its own per-block build_css_font_sizes functions, and the shared file cannot redeclare them without causing a fatal error. The else branch calls the unprefixed shared helper which will be available once backported to Core. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
|
@jeryj thanks for testing. I have made the comments more explicit but I don't think we can do as you suggest above. |
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
getdave
left a comment
There was a problem hiding this comment.
I tested this and it works with preset and custom sizes.
Noticed some nits.
| * Build an array with CSS classes and inline styles defining the font sizes | ||
| * which will be applied to the navigation markup in the front-end. | ||
| * | ||
| * @since 5.9.0 |
Co-authored-by: Dave Smith <getdavemail@gmail.com>
Co-authored-by: Dave Smith <getdavemail@gmail.com>
Co-authored-by: Dave Smith <getdavemail@gmail.com>
Co-authored-by: Dave Smith <getdavemail@gmail.com>
Co-authored-by: Dave Smith <getdavemail@gmail.com>
Co-authored-by: Dave Smith <getdavemail@gmail.com>
Co-authored-by: Dave Smith <getdavemail@gmail.com>
packages/block-library/src/navigation-link/shared/build-css-font-sizes.php
Outdated
Show resolved
Hide resolved
|
Flaky tests detected in c68b0d1. 🔍 Workflow run URL: https://github.com/WordPress/gutenberg/actions/runs/23674514733
|
What?
Consolidate the font size calculation function for navigation link and navigation submenu blocks to a shared helper.
Why?
Reducing duplicate code avoids bugs and makes maintenance easier.
How?
Moved the duplicate
build_css_font_sizesfunctions from navigation-link and navigation-submenu to a new shared file:packages/block-library/src/navigation-link/shared/build-css-font-sizes.phpTesting Instructions
(this applies via context to child blocks)