Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Try using a user-specific variable for blockGap #36680

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion lib/block-supports/layout.php
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ function gutenberg_get_layout_style( $selector, $layout, $has_block_gap_support
$style = "$selector {";
$style .= 'display: flex;';
if ( $has_block_gap_support ) {
$style .= 'gap: var( --wp--style--block-gap, 0.5em );';
$style .= 'gap: var(--wp--style--block-gap--self, var(--wp--style--block-gap, 0.5em));';
} else {
$style .= 'gap: 0.5em;';
}
Expand Down
2 changes: 1 addition & 1 deletion lib/block-supports/spacing.php
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ function gutenberg_render_spacing_gap_support( $block_content, $block ) {
}

$style = sprintf(
'--wp--style--block-gap: %s',
'--wp--style--block-gap--self: %s',
esc_attr( $gap_value )
);

Expand Down
2 changes: 1 addition & 1 deletion packages/block-editor/src/layouts/flex.js
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ export default {
display: flex;
gap: ${
hasBlockGapStylesSupport
? 'var( --wp--style--block-gap, 0.5em )'
? 'var(--wp--style--block-gap--self, var(--wp--style--block-gap, 0.5em))'
Copy link
Contributor

Choose a reason for hiding this comment

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

Should we also update flow.js, why is this only applied to flex.js

: '0.5em'
};
flex-wrap: ${ flexWrap };
Expand Down
6 changes: 3 additions & 3 deletions packages/block-library/src/button/style.scss
Original file line number Diff line number Diff line change
Expand Up @@ -50,15 +50,15 @@ $blocks-block__margin: 0.5em;
}

&.wp-block-button__width-25 {
width: calc(25% - (var(--wp--style--block-gap, #{$blocks-block__margin}) * 0.75));
width: calc(25% - (var(--wp--style--block-gap--self, var(--wp--style--block-gap, #{$blocks-block__margin}) * 0.75)));
}

&.wp-block-button__width-50 {
width: calc(50% - (var(--wp--style--block-gap, #{$blocks-block__margin}) * 0.5));
width: calc(50% - (var(--wp--style--block-gap--self, var(--wp--style--block-gap, #{$blocks-block__margin}) * 0.5)));
}

&.wp-block-button__width-75 {
width: calc(75% - (var(--wp--style--block-gap, #{$blocks-block__margin}) * 0.25));
width: calc(75% - (var(--wp--style--block-gap--self, var(--wp--style--block-gap, #{$blocks-block__margin}) * 0.25)));
}

&.wp-block-button__width-100 {
Expand Down
4 changes: 2 additions & 2 deletions packages/block-library/src/columns/editor.scss
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,14 @@
@include break-small() {
.editor-styles-wrapper
.block-editor-block-list__block.wp-block-column:nth-child(even) {
margin-left: var(--wp--style--block-gap, 2em);
margin-left: var(--wp--style--block-gap--self, var(--wp--style--block-gap, 2em));
}
}

@include break-medium() {
.editor-styles-wrapper
.block-editor-block-list__block.wp-block-column:not(:first-child) {
margin-left: var(--wp--style--block-gap, 2em);
margin-left: var(--wp--style--block-gap--self, var(--wp--style--block-gap, 2em));
}
}

Expand Down
8 changes: 4 additions & 4 deletions packages/block-library/src/columns/style.scss
Original file line number Diff line number Diff line change
Expand Up @@ -43,14 +43,14 @@
// As with mobile styles, this must be important since the Column
// assigns its own width as an inline style, which should take effect
// starting at `break-medium`.
flex-basis: calc(50% - calc(var(--wp--style--block-gap, 2em) / 2)) !important;
flex-basis: calc(50% - calc(var(--wp--style--block-gap--self, var(--wp--style--block-gap, 2em)) / 2)) !important;
flex-grow: 0;
}

// Add space between the multiple columns. Themes can customize this if they wish to work differently.
// Only apply this beyond the mobile breakpoint, as there's only a single column on mobile.
&:nth-child(even) {
margin-left: var(--wp--style--block-gap, 2em);
margin-left: var(--wp--style--block-gap--self, var(--wp--style--block-gap, 2em));
}
}

Expand All @@ -74,7 +74,7 @@

// When columns are in a single row, add space before all except the first.
&:not(:first-child) {
margin-left: var(--wp--style--block-gap, 2em);
margin-left: var(--wp--style--block-gap--self, var(--wp--style--block-gap, 2em));
}
}
}
Expand All @@ -95,7 +95,7 @@

// When columns are in a single row, add space before all except the first.
&:not(:first-child) {
margin-left: var(--wp--style--block-gap, 2em);
margin-left: var(--wp--style--block-gap--self, var(--wp--style--block-gap, 2em));
}
}
}
Expand Down
4 changes: 2 additions & 2 deletions packages/block-library/src/navigation/style.scss
Original file line number Diff line number Diff line change
Expand Up @@ -258,7 +258,7 @@ button.wp-block-navigation-item__content {
.wp-block-navigation .wp-block-page-list,
.wp-block-navigation__container,
.wp-block-navigation__responsive-container-content {
gap: var(--wp--style--block-gap, 2em);
gap: var(--wp--style--block-gap--self, var(--wp--style--block-gap, 2em));
}

// Menu items with background.
Expand All @@ -269,7 +269,7 @@ button.wp-block-navigation-item__content {
&,
.wp-block-navigation .wp-block-page-list,
.wp-block-navigation__container {
gap: var(--wp--style--block-gap, 0.5em);
gap: var(--wp--style--block-gap--self, var(--wp--style--block-gap, 0.5em));
}
}

Expand Down
2 changes: 1 addition & 1 deletion packages/blocks/src/api/constants.js
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ export const __EXPERIMENTAL_STYLE_PROPERTY = {
value: [ 'typography', 'letterSpacing' ],
support: [ 'typography', '__experimentalLetterSpacing' ],
},
'--wp--style--block-gap': {
'--wp--style--block-gap--self': {
value: [ 'spacing', 'blockGap' ],
support: [ 'spacing', 'blockGap' ],
},
Expand Down