feat: switch header/footer to use WordPress's block visibility#432
feat: switch header/footer to use WordPress's block visibility#432laurelfulford wants to merge 5 commits intotrunkfrom
Conversation
There was a problem hiding this comment.
Pull request overview
Updates the theme’s responsive header/footer switching to rely on WordPress 7.0’s built-in block visibility controls instead of theme-provided .desktop-only / .mobile-only CSS utilities.
Changes:
- Removed the generic
.mobile-onlyand.desktop-onlyutility classes from base SCSS. - Updated header/footer template parts to use
metadata.blockVisibility.viewportto control device visibility. - Removed documentation describing the deprecated responsive utility classes.
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 3 comments.
| File | Description |
|---|---|
src/scss/_base.scss |
Removes the CSS utilities that previously enforced mobile/desktop-only display. |
parts/header.html |
Adds block visibility metadata to swap desktop vs mobile header template parts. |
parts/footer.html |
Adds block visibility metadata to swap desktop vs mobile footer template parts. |
.github/UTILITY_CLASSES.md |
Removes docs for the deleted responsive utility classes. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
|
Hey @thomasguillot! I flagged this one for your review in case this sounds like a horrible change for how the |
|
@laurelfulford this makes sense to me. I’m actually surprised we only use these classes in 2 templates. For some reason I thought they were also used in things like the overlay menu. |
.github/UTILITY_CLASSES.md
Outdated
| # Responsive Elements | ||
|
|
||
| `mobile-only` and `desktop-only` can be applied to blocks to display them based on the screen size. | ||
|
|
||
| | CLASS NAME | DESCRIPTION | | ||
| | ------------ | ------------------------------------------------------------------------------- | | ||
| | mobile-only | The block will be displayed on the screen if it is 781px wide or less. | | ||
| | desktop-only | The block will be displayed on the screen if the screen is at least 782px wide. | | ||
| The Newspack Block Theme uses WordPress's blockVisibility to show/hide certain elements on desktop and mobile, including different versions of the header and footer template parts. |
There was a problem hiding this comment.
This whole section is now uncecessary.
There was a problem hiding this comment.
Yeaaaah I was totally overthinking that -- removed in 9fa5c14!
thomasguillot
left a comment
There was a problem hiding this comment.
🚢
Thank you @laurelfulford
All Submissions:
Changes proposed in this Pull Request:
This PR replaces the
.desktop-onlyand.mobile-onlyCSS classes in the theme with WordPress's block visibility features coming in 7.0.I optimistically removed references to the classes. Hopefully the baked-in tools will be enough for this kind of thing going forward.
How to test the changes in this Pull Request:
Other information: