Skip to content

Components: migrate Surface to SCSS module#79445

Merged
ciampo merged 11 commits into
trunkfrom
codex/components-surface-scss-module
Jun 24, 2026
Merged

Components: migrate Surface to SCSS module#79445
ciampo merged 11 commits into
trunkfrom
codex/components-surface-scss-module

Conversation

@ciampo

@ciampo ciampo commented Jun 23, 2026

Copy link
Copy Markdown
Contributor

Part of #66806.

What?

Migrates Surface away from Emotion styles and onto an SCSS Module.

Why?

This is one of the canary components for the refreshed Emotion migration plan. It validates the SCSS Modules path while preserving the public components-surface class name.

How?

  • Replaces the Emotion styles.ts file with style.module.scss.
  • Uses clsx for variant and border classes, without adding public data attributes.
  • Keeps physical border properties because Surface exposes physical border props.
  • Keeps backgroundSize dynamic through scoped CSS custom properties.
  • Keeps as support through the underlying View component; migrating View itself remains separate.
  • Removes unused Surface config values and the Surface entry from the Emotion bulk suppression.
  • Replaces snapshot/style implementation tests with DOM contract coverage.
Hardcoded/shared values moved to WPDS tokens
Previous value/source WPDS token
#fff / Surface background values --wpds-color-background-surface-neutral-strong
#1e1e1e / COLORS.gray[ 900 ] --wpds-color-foreground-content-neutral
#f5f5f5 / secondary background --wpds-color-background-surface-neutral-weak
rgba(0, 0, 0, 0.1) / border and dotted backing color --wpds-color-stroke-surface-neutral
rgba(0, 0, 0, 0.05) / grid line color --wpds-color-stroke-surface-neutral-weak
1px / border and grid stroke width --wpds-border-width-xs

Testing Instructions

  • npm run test:unit packages/components/src/surface/test/index.tsx -- --runInBand
  • npm run lint:js -- packages/components/src/surface
  • npm run lint:css -- packages/components/src/surface/style.module.scss
  • npx tsgo --build packages/components/tsconfig.json
  • git diff --check

Testing Instructions for Keyboard

No keyboard-specific behavior changed. Surface is a non-interactive primitive.

Screenshots or screencast

Not applicable; this should preserve the existing visual output.

Use of AI Tools

Used AI assistance to inspect the existing component implementation, apply the migration, and draft this PR description. The changes were reviewed and verified locally.

@github-actions github-actions Bot added the [Package] Components /packages/components label Jun 23, 2026
@github-actions

github-actions Bot commented Jun 23, 2026

Copy link
Copy Markdown

Flaky tests detected in 31227de.
Some tests passed with failed attempts. The failures may not be related to this commit but are still reported for visibility. See the documentation for more information.

🔍 Workflow run URL: https://github.com/WordPress/gutenberg/actions/runs/28092506671
📝 Reported issues:

@ciampo ciampo changed the base branch from codex/components-view-polymorphic to trunk June 24, 2026 09:27
@ciampo ciampo force-pushed the codex/components-surface-scss-module branch from 2f1386a to 43cbacb Compare June 24, 2026 09:29
@github-actions

github-actions Bot commented Jun 24, 2026

Copy link
Copy Markdown

Size Change: +255 B (0%)

Total Size: 7.51 MB

📦 View Changed
Filename Size Change
build/scripts/components/index.min.js 264 kB +255 B (+0.1%)

compressed-size-action

Comment on lines -135 to -137
case 'tertiary': {
return tertiary;
}

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

The tertiary variants wasn't actually producing any visually different style, the refactor simply ignores it

@ciampo ciampo self-assigned this Jun 24, 2026
@ciampo ciampo added the [Type] Code Quality Issues or PRs that relate to code quality label Jun 24, 2026
@ciampo ciampo marked this pull request as ready for review June 24, 2026 10:38
@ciampo ciampo requested review from a team, ajitbohra and manzoorwanijk as code owners June 24, 2026 10:38
@github-actions

github-actions Bot commented Jun 24, 2026

Copy link
Copy Markdown

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 props-bot label.

If you're merging code through a pull request on GitHub, copy and paste the following into the bottom of the merge commit message.

Co-authored-by: ciampo <mciampini@git.wordpress.org>
Co-authored-by: mirka <0mirka00@git.wordpress.org>

To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook.

@mirka mirka left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Tests well 👍

Comment on lines -60 to -66
surfaceBackgroundColor: COLORS.white,
surfaceBackgroundSubtleColor: '#F3F3F3',
surfaceBackgroundTintColor: '#F5F5F5',
surfaceBorderColor: 'rgba(0, 0, 0, 0.1)',
surfaceBorderBoldColor: 'rgba(0, 0, 0, 0.15)',
surfaceBorderSubtleColor: 'rgba(0, 0, 0, 0.05)',
surfaceBackgroundTertiaryColor: COLORS.white,

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

😍

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I know! Working on this migration feels like an alternative kind of therapy 🤣

position: relative;
}

.borderBottom {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

These class names should all be kebab case.

Looks like the selector-class-pattern stylelint rule would enforce this, but it is disabled for the repo 🤔 Maybe we can enable it in the components-related packages?

'selector-class-pattern': [
'^([a-z][a-z0-9]*)(-[a-z0-9]+)*$',
{
message:
'Selector should use lowercase and separate words with hyphens (selector-class-pattern)',
},

Comment thread packages/components/CHANGELOG.md Outdated
@ciampo ciampo force-pushed the codex/components-surface-scss-module branch from c88a8f9 to d1c9495 Compare June 24, 2026 16:48
@ciampo ciampo merged commit 3717269 into trunk Jun 24, 2026
45 checks passed
@ciampo ciampo deleted the codex/components-surface-scss-module branch June 24, 2026 19:42
@github-actions github-actions Bot added this to the Gutenberg 23.6 milestone Jun 24, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

[Package] Components /packages/components [Type] Code Quality Issues or PRs that relate to code quality

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants