Skip to content

Commit

Permalink
Add block styles for padding
Browse files Browse the repository at this point in the history
This way we don't have a ton of wrapper elements just for a bit of
padding.
  • Loading branch information
Inwerpsel committed Apr 20, 2022
1 parent 1eac73c commit dca5e5e
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 0 deletions.
16 changes: 16 additions & 0 deletions admin/js/editor.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,4 +32,20 @@ wp.domReady(() => {
];

registerBlockStyle('core/button', styles);

const coreBlocks = ['core/media-text', 'core/group', 'core/column'];
coreBlocks.forEach(block => {
registerBlockStyle(block, {
name: 'small-padding',
label: 'Small padding',
});
registerBlockStyle(block, {
name: 'medium-padding',
label: 'Medium padding',
});
registerBlockStyle(block, {
name: 'large-padding',
label: 'Large padding',
});
});
});
15 changes: 15 additions & 0 deletions assets/src/styles/blocks.scss
Original file line number Diff line number Diff line change
Expand Up @@ -32,3 +32,18 @@
// Other
@import "blocks/WideBlocks";
@import "blocks/Editor";

.is-style-small-padding {
padding: 8px;
align-self: stretch;
}

.is-style-medium-padding {
padding: 16px;
align-self: stretch;
}

.is-style-large-padding {
padding: 32px;
align-self: stretch;
}

0 comments on commit dca5e5e

Please sign in to comment.