-
Notifications
You must be signed in to change notification settings - Fork 4.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Add: Buttons block * Used LinkControl, Removed logic to insert block right away (it is not part of InnerBlocks), removed toolbar movers (they are now part of InnerBlocks) * Make UX closer to navigation block * Update tests * Use jsx string for property
- Loading branch information
1 parent
431f76c
commit a74921d
Showing
20 changed files
with
361 additions
and
34 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
{ | ||
"name": "core/buttons", | ||
"category": "layout", | ||
"attributes": {} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
/** | ||
* WordPress dependencies | ||
*/ | ||
import { InnerBlocks } from '@wordpress/block-editor'; | ||
|
||
/** | ||
* Internal dependencies | ||
*/ | ||
import { name as buttonBlockName } from '../button/'; | ||
|
||
const ALLOWED_BLOCKS = [ buttonBlockName ]; | ||
const BUTTONS_TEMPLATE = [ [ 'core/button' ] ]; | ||
const UI_PARTS = { | ||
hasSelectedUI: false, | ||
}; | ||
|
||
function ButtonsEdit( { className } ) { | ||
return ( | ||
<div className={ className }> | ||
<InnerBlocks | ||
allowedBlocks={ ALLOWED_BLOCKS } | ||
template={ BUTTONS_TEMPLATE } | ||
__experimentalUIParts={ UI_PARTS } | ||
__experimentalMoverDirection="horizontal" | ||
/> | ||
</div> | ||
); | ||
} | ||
|
||
export default ButtonsEdit; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
.wp-block-buttons .wp-block.block-editor-block-list__block[data-type="core/button"] { | ||
display: inline-block; | ||
width: auto; | ||
} | ||
|
||
.wp-block-buttons { | ||
div[data-type="core/button"] div[data-block] { | ||
display: block; | ||
} | ||
|
||
&[data-align="center"] .block-editor-block-list__layout { | ||
display: flex; | ||
align-items: center; | ||
flex-wrap: wrap; | ||
justify-content: center; | ||
} | ||
|
||
&[data-align="right"] .block-editor-block-list__layout { | ||
display: flex; | ||
justify-content: flex-end; | ||
} | ||
|
||
.block-list-appender { | ||
display: inline-block !important; | ||
margin: 0; | ||
} | ||
|
||
.block-editor-block-list__layout > div:last-child { | ||
display: inline-block; | ||
} | ||
|
||
.block-editor-button-block-appender { | ||
background: none; | ||
outline: none; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
/** | ||
* WordPress dependencies | ||
*/ | ||
import { G, Path, SVG } from '@wordpress/components'; | ||
|
||
export default ( | ||
<SVG viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg"><Path fill="none" d="M0 0h24v24H0V0z" /><G><Path d="M19 6H5c-1.1 0-2 .9-2 2v8c0 1.1.9 2 2 2h14c1.1 0 2-.9 2-2V8c0-1.1-.9-2-2-2zm0 10H5V8h14v8z" /></G></SVG> | ||
); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
/** | ||
* WordPress dependencies | ||
*/ | ||
import { __ } from '@wordpress/i18n'; | ||
|
||
/** | ||
* Internal dependencies | ||
*/ | ||
import edit from './edit'; | ||
import icon from './icon'; | ||
import metadata from './block.json'; | ||
import save from './save'; | ||
|
||
const { name } = metadata; | ||
|
||
export { metadata, name }; | ||
|
||
export const settings = { | ||
title: __( 'Buttons' ), | ||
description: __( 'Prompt visitors to take action with a group of button-style links.' ), | ||
icon, | ||
keywords: [ __( 'link' ) ], | ||
supports: { | ||
align: true, | ||
alignWide: false, | ||
}, | ||
edit, | ||
save, | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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() { | ||
return ( | ||
<div> | ||
<InnerBlocks.Content /> | ||
</div> | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
.wp-block-buttons .wp-block-button { | ||
display: inline-block; | ||
margin: $grid-size-small; | ||
} | ||
.wp-block-buttons.aligncenter { | ||
text-align: center; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
<!-- wp:buttons --> | ||
<div class="wp-block-buttons"> | ||
<!-- wp:button --> | ||
<div class="wp-block-button"><a class="wp-block-button__link">My button 1</a></div> | ||
<!-- /wp:button --> | ||
|
||
<!-- wp:button --> | ||
<div class="wp-block-button"><a class="wp-block-button__link">My button 2</a></div> | ||
<!-- /wp:button --> | ||
</div> | ||
<!-- /wp:buttons --> |
Oops, something went wrong.