-
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 initial quick inserter * Smaller quick inserter * Default to 6 blocks * Add the browse all button * Show one inserter at a time * Fix small visual glitches * Fix border radius and focus. * Fix patterns insertion * Inserter close button * Announce search results * Fix search close button * Label browse all button * Default to bottom for the position of the quick inserter * Fix inserter padding after rebase * changes per review * Fix unit tests * Fix end2end tests * Block types tab tests * Fix end2end tests Co-authored-by: jasmussen <[email protected]>
- Loading branch information
1 parent
9d27f7b
commit 1bec21f
Showing
31 changed files
with
587 additions
and
165 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
59 changes: 59 additions & 0 deletions
59
packages/block-editor/src/components/block-patterns-list/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,59 @@ | ||
/** | ||
* WordPress dependencies | ||
*/ | ||
import { useMemo } from '@wordpress/element'; | ||
import { parse } from '@wordpress/blocks'; | ||
import { ENTER, SPACE } from '@wordpress/keycodes'; | ||
|
||
/** | ||
* Internal dependencies | ||
*/ | ||
import BlockPreview from '../block-preview'; | ||
|
||
function BlockPattern( { pattern, onClick } ) { | ||
const { content, viewportWidth } = pattern; | ||
const blocks = useMemo( () => parse( content ), [ content ] ); | ||
|
||
return ( | ||
<div | ||
className="block-editor-block-patterns-list__item" | ||
role="button" | ||
onClick={ () => onClick( pattern, blocks ) } | ||
onKeyDown={ ( event ) => { | ||
if ( ENTER === event.keyCode || SPACE === event.keyCode ) { | ||
onClick( pattern, blocks ); | ||
} | ||
} } | ||
tabIndex={ 0 } | ||
aria-label={ pattern.title } | ||
> | ||
<BlockPreview blocks={ blocks } viewportWidth={ viewportWidth } /> | ||
<div className="block-editor-block-patterns-list__item-title"> | ||
{ pattern.title } | ||
</div> | ||
</div> | ||
); | ||
} | ||
|
||
function BlockPatternPlaceholder() { | ||
return ( | ||
<div className="block-editor-block-patterns-list__item is-placeholder" /> | ||
); | ||
} | ||
|
||
function BlockPatternList( { blockPatterns, shownPatterns, onClickPattern } ) { | ||
return blockPatterns.map( ( pattern ) => { | ||
const isShown = shownPatterns.includes( pattern ); | ||
return isShown ? ( | ||
<BlockPattern | ||
key={ pattern.name } | ||
pattern={ pattern } | ||
onClick={ onClickPattern } | ||
/> | ||
) : ( | ||
<BlockPatternPlaceholder key={ pattern.name } /> | ||
); | ||
} ); | ||
} | ||
|
||
export default BlockPatternList; |
30 changes: 30 additions & 0 deletions
30
packages/block-editor/src/components/block-patterns-list/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,30 @@ | ||
.block-editor-block-patterns-list__item { | ||
|
||
border-radius: $radius-block-ui; | ||
cursor: pointer; | ||
margin-top: $grid-unit-20; | ||
transition: all 0.05s ease-in-out; | ||
position: relative; | ||
border: $border-width solid transparent; | ||
|
||
&:hover { | ||
border: $border-width solid var(--wp-admin-theme-color); | ||
} | ||
|
||
&:focus { | ||
box-shadow: inset 0 0 0 1px $white, 0 0 0 $border-width-focus var(--wp-admin-theme-color); | ||
|
||
// Windows High Contrast mode will show this outline, but not the box-shadow. | ||
outline: 2px solid transparent; | ||
} | ||
|
||
&.is-placeholder { | ||
min-height: 100px; | ||
} | ||
} | ||
|
||
.block-editor-block-patterns-list__item-title { | ||
padding: $grid-unit-05; | ||
font-size: 12px; | ||
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
Oops, something went wrong.