Skip to content

fix: move editor ad block padding to Sass#2713

Open
faisalahammad wants to merge 1 commit into
Automattic:trunkfrom
faisalahammad:fix/1700-consistent-ad-styles
Open

fix: move editor ad block padding to Sass#2713
faisalahammad wants to merge 1 commit into
Automattic:trunkfrom
faisalahammad:fix/1700-consistent-ad-styles

Conversation

@faisalahammad
Copy link
Copy Markdown
Contributor

Summary

The editor ad block had padding: 8px conditionally applied in color-patterns.php only when a custom ad background color was set. This made spacing inconsistent — padding was absent with default colors, present with custom colors. Moved it to style-editor-base.scss so it always applies, matching front-end behavior.

Fixes #1700

Changes

newspack-theme/inc/color-patterns.php

Before:

.wp-block-newspack-ads-blocks-ad-unit > div {
    background-color: ' . esc_attr( get_theme_mod( 'ads_color_hex', '#ffffff' ) ) . ';
    padding: 8px;
}

After:

.wp-block-newspack-ads-blocks-ad-unit > div {
    background-color: ' . esc_attr( get_theme_mod( 'ads_color_hex', '#ffffff' ) ) . ';
}

Why: Padding is a layout concern, not a color concern. Keeping it in the color-conditional block made editor spacing depend on customizer state.

newspack-theme/sass/style-editor-base.scss

Before:

.wp-block-newspack-ads-blocks-ad-unit {
    > div {
        align-items: center;
        display: flex;
        justify-content: center;
    }
}

After:

.wp-block-newspack-ads-blocks-ad-unit {
    > div {
        align-items: center;
        display: flex;
        justify-content: center;
        padding: 8px;
    }
}

Why: Consolidates editor ad block styles in one location. Padding now applies unconditionally, consistent with how the front-end handles ad widget padding in newspack-ads.scss.

Testing

  1. Inspect compiled style-editor.css.wp-block-newspack-ads-blocks-ad-unit > div should contain padding:8px
  2. In color-patterns.php, the ad editor block should only output background-color
  3. With Newspack Ads plugin: insert ad unit block in editor, verify consistent padding regardless of customizer ad color setting

Padding: 8px was conditionally applied in color-patterns.php only
when custom ad background color was set. Moved to style-editor-base.scss
so it always applies, matching front-end behavior.

Fixes Automattic#1700
@faisalahammad faisalahammad requested a review from a team as a code owner May 15, 2026 17:14
@laurelfulford laurelfulford added the [Status] Needs Review The issue or pull request needs to be reviewed label May 19, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

[Status] Needs Review The issue or pull request needs to be reviewed

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Make ad styles more consistent

2 participants