Skip to content

Conversation

@JorgenStenshaugen
Copy link
Contributor

@JorgenStenshaugen JorgenStenshaugen commented Nov 4, 2025

This pull request introduces a major refactor to the block theme’s layout and spacing system. The changes focus on standardizing layout wrappers, centralizing layout-related CSS, and overhauling the spacing configuration for better consistency and maintainability. Additionally, some legacy or redundant features have been removed to streamline the theme.

Layout and Structure Improvements:

  • Added a new layout.css file with comprehensive layout rules and imported it into the main config and view styles, centralizing layout logic for easier maintenance. (packages/themes/block-theme/src/config/layout.css, packages/themes/block-theme/src/config/_index.css, packages/themes/block-theme/src/view.css) [1] [2] [3]
  • Updated all main content templates (404.html, index.html, search.html, singular.html) to use a standardized content-wrapper class, improving layout consistency across pages. (packages/themes/block-theme/templates/404.html, packages/themes/block-theme/templates/index.html, packages/themes/block-theme/templates/search.html, packages/themes/block-theme/templates/singular.html) [1] [2] [3] [4]

Spacing System Overhaul:

  • Disabled default spacing sizes and margin/padding options, then defined a custom set of spacing sizes using clamp() for responsive design, providing fine-grained control over spacing throughout the theme. (packages/themes/block-theme/theme.json)
  • Removed block-specific spacing settings for core blocks (buttons, columns, group, post-template) and the caption element, consolidating spacing logic in the new layout CSS and theme-wide configuration. (packages/themes/block-theme/theme.json) [1] [2]
  • Removed the global block gap setting from the theme configuration, further centralizing spacing control to the new system. (packages/themes/block-theme/theme.json)

Feature Cleanup:

  • Removed the legacy custom-block-margin feature from the theme’s feature registry and configuration, as its functionality is now handled by the new layout and spacing system. (packages/themes/block-theme/t2.json) [1] [2]

Why?

Frontend should be solved with frontend, having a tool created with backend components seems very redundant when CSS is the superior choice when it comes to tweaking on something as fundamental as the layout spacing. The suggested CSS file is clean, easy to understand and makes sure you are 100% in control, no unfortunate margins here and there. The designers have put effort and thought into the UX and how it should visually be presented, if we miss this then the whole flow of readability and the total end result of the site will appear poorly.

@stian-overasen
Copy link
Member

stian-overasen commented Nov 4, 2025

I'm not sure I like this approach. The current Custom Block Margin extension in combination with the default spacing system in WordPress works really well. Have you tried it? This seems like more code and unnecessary wrapper classes to solve the exact same issue.

That being said; I'm open for moving to CSS if the new setup actually solves the same issues and supports the same containers.

A couple of things:

  1. WordPress comes with a default spacing range that we should strive to reuse. If we are to override that range in Project Base, we should also expect every future design to stick with the new values, otherwise this becomes something we need to delete on every project start.
  2. Use margin-block, margin-block-start and margin-block-end to fully support rtl.

<!-- wp:template-part {"slug":"header","area":"header","tagName":"header","className":"header-wrapper"} /-->
<!-- wp:post-content {"tagName":"main","align":"full","layout":{"type":"constrained"}} /-->
<!-- wp:group {"tagName":"main","layout":{"type":"constrained"},"className":"content-wrapper"} -->
<main class="wp-block-group content-wrapper">
Copy link
Member

@stian-overasen stian-overasen Nov 4, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Very unnecessary to wrap Post Content. You should target .is-layout-flow instead of .wp-block-group/.wp-block-post-content. There are a few additional container, like Media & Text, Columns, Factbox, Accordion Content etc, that also needs this that already have is-layout-flow in place.

"radius": "unset"
}
},
"core/buttons": {
Copy link
Member

@stian-overasen stian-overasen Nov 4, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please note that this is horizontal gap between buttons, not vertical block margin.

},
"core/columns": {
"spacing": {
"blockGap": "var(--wp--preset--spacing--50)"
Copy link
Member

@stian-overasen stian-overasen Nov 4, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is horizontal gap between columns. Not related to the vertical block margins.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants