Skip to content

Commit

Permalink
🩹 fix: core/button block style (#3130)
Browse files Browse the repository at this point in the history
  • Loading branch information
kellymears authored May 9, 2023
1 parent 505c310 commit 27a63ec
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 12 deletions.
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' }],
};
}

0 comments on commit 27a63ec

Please sign in to comment.