Skip to content

Refactor spacing to use CSS custom properties (#982) - #1114

Merged
stephaniehobson merged 2 commits into
mainfrom
spacing-vars
Jan 23, 2026
Merged

Refactor spacing to use CSS custom properties (#982)#1114
stephaniehobson merged 2 commits into
mainfrom
spacing-vars

Conversation

@stephaniehobson

@stephaniehobsonstephaniehobson commented Jan 21, 2026

Copy link
Copy Markdown
Contributor

Description

Refactor spacing system to use CSS custom properties. This is the third PR in a refactor of how we use CSS variables (#982), following the typography (#1107) and color (#1109) refactors. Introduces --theme-spacing-between-block and --theme-spacing-between-inline for responsive layout spacing while retaining Sass $spacing-* variables for component-internal spacing. (We do need to standardize that but it's not nearly as straight forward)

  • Modernization:
    • Default to CSS vars for layout spacing (block and inline)
    • Removed float fallbacks in callout, split and card layout
    • Responsive breakpoints defined in root/_spacing.scss
    • Updated components to use new spacing vars: containers, card, callout, split, breadcrumb, navigation, newsletter-form, section-heading, card-layout, multi-column
  • Reorganization:
    • Removed includes/_themes-sass.scss (no longer needed)
    • Removed bidi-grid-spacing() mixin
    • Removed deprecated grid-gap from stylelint ignored shorthands
  • Simplification:
    • Simplified split component (removed pop and overflow options in separate PR)
    • Removed max-width restrictions from cards, they will always fill the available space now
      • moved image size recommendations off individual card sizes and onto the parent
  • Documentation:
    • Added section-heading mzp-t-section-heading-nospace theme class
    • Added spacing migration guide to docs/02-usage/migration.md
    • Updated CHANGELOG with spacing system changes

Issue

#982

Testing

Spot-check.

There are some expected visual regressions in section headings and the card documentation (but not the cards themselves). And the layout spacing has changed in some places where it needed standardization.


  • I have documented this change in the design system.
  • I have recorded this change in CHANGELOG.md.

@stephaniehobson

Copy link
Copy Markdown
ContributorAuthor

This will address some of what's in #1099 (comment) too.

Refactor spacing system to use CSS custom properties. This is the third PR in a refactor of how we use CSS variables (#982), following the typography (#1107) and color refactors. Introduces --theme-spacing-between-block and --theme-spacing-between-inline for responsive layout spacing while retaining Sass $spacing-* variables for component-internal spacing.
Modernization:
Default to CSS vars for layout spacing (block and inline)
Responsive breakpoints defined in root/_spacing.scss
Updated components to use new spacing vars: containers, card, callout, split, breadcrumb, navigation, newsletter-form, section-heading, card-layout, multi-column
Reorganization:
Removed includes/_themes-sass.scss (no longer needed)
Removed bidi-grid-spacing() mixin
Removed deprecated grid-gap from stylelint ignored shorthands
Simplification:
Simplified split component (removed pop and overflow options in separate PR)
Simplified card-layout and multi-column templates
Reduced newsletter-form complexity
Documentation:
Added section-heading mzp-t-section-heading-nospace theme class
Added spacing migration guide to docs/02-usage/migration.md
Updated CHANGELOG with spacing system changes
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
margin: 0 auto;
max-width: $content-max;
padding: 0 $h-grid-xs;
padding: 0 $layout-xs;

Copy link
Copy Markdown
ContributorAuthor

Choose a reason for hiding this comment

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

❄️ 🤷‍♀️

--h-grid-xl: 80px;
@media #{tokens.$mq-xl} {
--theme-spacing-between-block: #{tokens.$layout-xl}; // 96px
--theme-spacing-between-inline: 80px;

Copy link
Copy Markdown
ContributorAuthor

Choose a reason for hiding this comment

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

❄️ 🤷‍♀️

@stephaniehobson

stephaniehobson commented Jan 21, 2026

Copy link
Copy Markdown
ContributorAuthor

Can I remove floats from hero layout?

Edit: No, there's no grid based fallback so I'm going to consider this one out of scope.

CopilotAI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Pull request overview

This PR refactors the spacing system to use CSS custom properties (--theme-spacing-between-block and --theme-spacing-between-inline) for responsive layout spacing, following previous typography and color refactors. It modernizes the codebase by removing legacy fallbacks and deprecated variables while simplifying component implementations.

Changes:

  • Introduced new CSS custom properties for spacing that are responsive across breakpoints
  • Renamed card size classes (mzp-c-card-extra-smallmzp-c-card-small) and removed mzp-c-card-medium as the default
  • Removed legacy Sass spacing variables, float-based fallbacks, and deprecated grid-gap shorthand

Reviewed changes

Copilot reviewed 29 out of 29 changed files in this pull request and generated no comments.

Show a summary per file
FileDescription
theme/assets/sass/components/_grid-list.scssUpdated grid-gap to standard gap property
theme/assets/sass/components/_color.scssUpdated grid-gap to standard gap property
docs/02-usage/migration.mdAdded migration guide for card component changes
components/section-heading/readme.mdDocumented new mzp-t-section-heading-nospace theme class
components/navigation/02-menu/readme.mdUpdated reference from Extra Small Card to Small Card
components/navigation/02-menu/menu.htmlUpdated card class from mzp-c-card-extra-small to mzp-c-card-small
components/layout/03-card-layout/card-layout.config.ymlUpdated card size recommendations in layout documentation
components/layout/03-card-layout/03-card-layout--quarter.htmlUpdated card renders to use @card--small instead of @card--extra-small
components/card/readme.mdUpdated card size documentation and image size recommendations
components/card/card.config.ymlRemoved extra-small variant, updated medium variant to be default
components/_preview-card.htmlAdded new preview template for card components
components/_preview-card-dark.htmlAdded new dark theme preview template for card components
assets/sass/protocol/templates/_multi-column.scssMigrated to new spacing CSS variables and removed legacy fallbacks
assets/sass/protocol/templates/_card-layout.scssMigrated to new spacing CSS variables and removed max-width restrictions
assets/sass/protocol/root/_spacing.scssReplaced legacy grid variables with new theme spacing variables
assets/sass/protocol/includes/mixins/_utils.scssRemoved unused import of themes-sass
assets/sass/protocol/includes/_themes-sass.scssDeleted file containing legacy Sass spacing variables
assets/sass/protocol/includes/_lib.scssRemoved forward of deleted themes-sass module
assets/sass/protocol/components/_split.scssMigrated to new spacing variables and removed float-based fallbacks
assets/sass/protocol/components/_section-heading.scssMigrated to new spacing variables and added nospace theme class
assets/sass/protocol/components/_newsletter-form.scssMigrated to new spacing variables and removed float-based fallbacks
assets/sass/protocol/components/_navigation.scssSimplified spacing with new CSS variables
assets/sass/protocol/components/_card.scssRenamed extra-small to small, removed medium class, removed max-width restrictions
assets/sass/protocol/components/_callout.scssMigrated to new spacing variables and removed float-based fallbacks
assets/sass/protocol/components/_breadcrumb.scssMigrated to new spacing variables
assets/sass/protocol/base/elements/_containers.scssMigrated to new spacing variables and removed legacy fallbacks
assets/sass/protocol/base/elements/_common.scssMigrated hr element spacing to new CSS variables
CHANGELOG.mdDocumented spacing system changes and card component updates
.stylelintrc.jsonRemoved deprecated grid-gap from ignored shorthands list

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@stephaniehobson
stephaniehobson marked this pull request as draft January 21, 2026 23:31
@stephaniehobson
stephaniehobson marked this pull request as ready for review January 22, 2026 00:11
@maureenlhollandmaureenlholland self-assigned this Jan 22, 2026

@maureenlhollandmaureenlholland left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

r+wc 💫

Non-blocking stuff, doesn't affect actual styles

It's unclear from comments whether we removed the float fallback in Split component

Card demo/docs still has places where it assumes small is default

padding: var(--theme-spacing-between-block) var(--theme-spacing-between-inline);
position: relative;

@media #{$mq-md} {

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

🧹 🧹 🧹


.mzp-l-split-reversed & {
@include bidi(((float, right, left),));
grid-template-areas: 'media body';

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

nice!

Comment threadassets/sass/protocol/components/_split.scss Outdated
Comment threadassets/sass/protocol/components/_split.scss Outdated
Comment threadcomponents/card/readme.md
Comment threadcomponents/section-heading/readme.md
Comment threadcomponents/card/card.config.yml Outdated
@stephaniehobson
stephaniehobson merged commit fcf9016 into mainJan 23, 2026
1 check passed
@stephaniehobson
stephaniehobson deleted the spacing-vars branch January 23, 2026 16:31
@stephaniehobsonstephaniehobson mentioned this pull request Jan 23, 2026
Sign up for freeto 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

@stephaniehobson@maureenlholland