-
Notifications
You must be signed in to change notification settings - Fork 4.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add a minimal multi-selection block panel (#12050)
* Add a minimal multi-selection block panel * Polish a little bit. * Address feedback. * Add missing style for icon. * Change the block tab.
- Loading branch information
1 parent
dfa4e04
commit b198e5c
Showing
6 changed files
with
89 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
41 changes: 41 additions & 0 deletions
41
packages/editor/src/components/multi-selection-inspector/index.js
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,41 @@ | ||
/** | ||
* WordPress dependencies | ||
*/ | ||
import { sprintf, __ } from '@wordpress/i18n'; | ||
import { withSelect } from '@wordpress/data'; | ||
import { serialize } from '@wordpress/blocks'; | ||
import { count as wordCount } from '@wordpress/wordcount'; | ||
import { | ||
Path, | ||
SVG, | ||
} from '@wordpress/components'; | ||
|
||
/** | ||
* Internal Dependencies | ||
*/ | ||
import BlockIcon from '../block-icon'; | ||
|
||
function MultiSelectionInspector( { blocks } ) { | ||
return ( | ||
<div className="editor-multi-selection-inspector__card"> | ||
<BlockIcon icon={ | ||
<SVG xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24"><Path d="M3 5H1v16c0 1.1.9 2 2 2h16v-2H3V5zm18-4H7c-1.1 0-2 .9-2 2v14c0 1.1.9 2 2 2h14c1.1 0 2-.9 2-2V3c0-1.1-.9-2-2-2zm0 16H7V3h14v14z" /></SVG> | ||
} showColors /> | ||
<div className="editor-multi-selection-inspector__card-content"> | ||
<div className="editor-multi-selection-inspector__card-title"> | ||
{ sprintf( __( '%d blocks' ), blocks.length ) } | ||
</div> | ||
<div className="editor-multi-selection-inspector__card-description"> | ||
{ sprintf( __( '%d words.' ), wordCount( serialize( blocks ), 'words' ) ) } | ||
</div> | ||
</div> | ||
</div> | ||
); | ||
} | ||
|
||
export default withSelect( ( select ) => { | ||
const { getMultiSelectedBlocks } = select( 'core/editor' ); | ||
return { | ||
blocks: getMultiSelectedBlocks(), | ||
}; | ||
} )( MultiSelectionInspector ); |
27 changes: 27 additions & 0 deletions
27
packages/editor/src/components/multi-selection-inspector/style.scss
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,27 @@ | ||
.editor-multi-selection-inspector__card { | ||
display: flex; | ||
align-items: flex-start; | ||
margin: -16px; | ||
padding: 16px; | ||
} | ||
|
||
.editor-multi-selection-inspector__card-content { | ||
flex-grow: 1; | ||
} | ||
|
||
.editor-multi-selection-inspector__card-title { | ||
font-weight: 500; | ||
margin-bottom: 5px; | ||
} | ||
|
||
.editor-multi-selection-inspector__card-description { | ||
font-size: $default-font-size; | ||
} | ||
|
||
.editor-multi-selection-inspector__card .editor-block-icon { | ||
margin-left: -2px; | ||
margin-right: 10px; | ||
padding: 0 3px; | ||
width: $icon-button-size; | ||
height: $icon-button-size-small; | ||
} |
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