Skip to content
New issue

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

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

Already on GitHub? # to your account

🩹 fix: core/button block style #3130

Merged
merged 4 commits into from
May 9, 2023
Merged
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
14 changes: 2 additions & 12 deletions resources/scripts/editor.js
Original file line number Diff line number Diff line change
@@ -1,17 +1,7 @@
import domReady from '@roots/sage/client/dom-ready';
import { registerBlockStyle, unregisterBlockStyle } from '@wordpress/blocks';

/**
* Editor entrypoint
* @see {@link https://bud.js.org/extensions/bud-preset-wordpress/editor-integration/filters}
*/
domReady(() => {
unregisterBlockStyle('core/button', 'outline');

registerBlockStyle('core/button', {
name: 'outline',
label: 'Outline',
});
});
roots.register.filters('@scripts/filters');

/**
* @see {@link https://webpack.js.org/api/hot-module-replacement/}
Expand Down
25 changes: 25 additions & 0 deletions resources/scripts/filters/button.filter.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
/**
* @see {@link https://developer.wordpress.org/block-editor/reference-guides/filters/block-filters/#blocks-registerblocktype}
*/
export const hook = 'blocks.registerBlockType';

/**
* Filter handle
*/
export const name = 'sage/button';

/**
* Filter callback
*
* @param {object} settings
* @param {string} name
* @returns modified settings
*/
export function callback(settings, name) {
if (name !== 'core/button') return settings;

return {
...settings,
styles: [{ label: 'Outline', name: 'outline' }],
};
}