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

Add a new buttons block #17523

Closed
wants to merge 1 commit 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
1 change: 1 addition & 0 deletions packages/block-library/src/button/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ export const settings = {
description: __( 'Prompt visitors to take action with a button-style link.' ),
icon,
keywords: [ __( 'link' ) ],
parent: [ 'core/buttons' ],
supports: {
align: true,
alignWide: false,
Expand Down
5 changes: 5 additions & 0 deletions packages/block-library/src/buttons/block.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"name": "core/buttons",
"category": "layout",
"attributes": {}
}
31 changes: 31 additions & 0 deletions packages/block-library/src/buttons/edit.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
/**
* WordPress dependencies
*/

import {
InnerBlocks,
} from '@wordpress/block-editor';

/**
* Internal dependencies
*/
const ALLOWED_BLOCKS = [ 'core/button' ];

// Template contains the links that show when start.
const TEMPLATE = [
[ 'core/button' ],
];

export const ButtonsEdit = function( { className } ) {
return (
<div className={ className }>
<InnerBlocks
allowedBlocks={ ALLOWED_BLOCKS }
templateLock={ false }
template={ TEMPLATE }
/>
</div>
);
};

export default ButtonsEdit;
6 changes: 6 additions & 0 deletions packages/block-library/src/buttons/editor.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
.wp-block-buttons {
.editor-block-list__layout {
display: flex;
justify-content: flex-start;
}
}
33 changes: 33 additions & 0 deletions packages/block-library/src/buttons/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
/**
* WordPress dependencies
*/
import { __ } from '@wordpress/i18n';

/**
* Internal dependencies
*/
import edit from './edit';
import icon from '../button/icon';
import metadata from './block.json';
import save from './save';

const { name } = metadata;

export { metadata, name };

export const settings = {
title: __( 'Buttons' ),
description: __( 'Create a block of buttons' ),
icon,
keywords: [ __( 'link' ) ],
supports: {
align: true,
alignWide: false,
},
styles: [
{ name: 'fill', label: __( 'Fill' ), isDefault: true },
{ name: 'outline', label: __( 'Outline' ) },
],
edit,
save,
};
12 changes: 12 additions & 0 deletions packages/block-library/src/buttons/save.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
/**
* WordPress dependencies
*/
import { InnerBlocks } from '@wordpress/block-editor';

export default function save( { className } ) {
return (
<ul className={ className }>
<InnerBlocks.Content />
</ul>
);
}
4 changes: 4 additions & 0 deletions packages/block-library/src/buttons/style.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
.wp-block-buttons {
display: flex;
justify-content: flex-start;
}
1 change: 1 addition & 0 deletions packages/block-library/src/editor.scss
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
@import "./audio/editor.scss";
@import "./block/editor.scss";
@import "./button/editor.scss";
@import "./buttons/editor.scss";
@import "./categories/editor.scss";
@import "./code/editor.scss";
@import "./columns/editor.scss";
Expand Down
2 changes: 2 additions & 0 deletions packages/block-library/src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ import * as gallery from './gallery';
import * as archives from './archives';
import * as audio from './audio';
import * as button from './button';
import * as buttons from './buttons';
import * as calendar from './calendar';
import * as categories from './categories';
import * as code from './code';
Expand Down Expand Up @@ -105,6 +106,7 @@ export const registerCoreBlocks = () => {
archives,
audio,
button,
buttons,
calendar,
categories,
code,
Expand Down
1 change: 1 addition & 0 deletions packages/block-library/src/style.scss
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
@import "./audio/style.scss";
@import "./button/style.scss";
@import "./buttons/style.scss";
@import "./calendar/style.scss";
@import "./categories/style.scss";
@import "./columns/style.scss";
Expand Down