Skip to content

Commit

Permalink
Template Part: Improve popover design.
Browse files Browse the repository at this point in the history
  • Loading branch information
epiqueras committed Jun 25, 2020
1 parent bbb0b5e commit 2769fc7
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 20 deletions.
1 change: 1 addition & 0 deletions packages/block-editor/src/components/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,7 @@ export { default as DefaultBlockAppender } from './default-block-appender';
export { default as __unstableEditorStyles } from './editor-styles';
export { default as Inserter } from './inserter';
export { default as __experimentalLibrary } from './inserter/library';
export { default as __experimentalSearchForm } from './inserter/search-form';
export { default as BlockEditorKeyboardShortcuts } from './keyboard-shortcuts';
export { default as MultiSelectScrollIntoView } from './multi-select-scroll-into-view';
export { default as NavigableToolbar } from './navigable-toolbar';
Expand Down
14 changes: 12 additions & 2 deletions packages/block-editor/src/components/inserter/search-form.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
/**
* External dependencies
*/
import classnames from 'classnames';

/**
* WordPress dependencies
*/
Expand All @@ -6,15 +11,20 @@ import { __ } from '@wordpress/i18n';
import { VisuallyHidden } from '@wordpress/components';
import { Icon, search } from '@wordpress/icons';

function InserterSearchForm( { onChange } ) {
function InserterSearchForm( { className, onChange } ) {
const instanceId = useInstanceId( InserterSearchForm );

// Disable reason (no-autofocus): The inserter menu is a modal display, not one which
// is always visible, and one which already incurs this behavior of autoFocus via
// Popover's focusOnMount.
/* eslint-disable jsx-a11y/no-autofocus */
return (
<div className="block-editor-inserter__search">
<div
className={ classnames(
'block-editor-inserter__search',
className
) }
>
<VisuallyHidden
as="label"
htmlFor={ `block-editor-inserter__search-${ instanceId }` }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,12 @@ import { useDispatch } from '@wordpress/data';
import { cleanForSlug } from '@wordpress/url';
import {
Placeholder,
TextControl,
Dropdown,
ButtonGroup,
Button,
} from '@wordpress/components';
import { blockDefault } from '@wordpress/icons';
import { __experimentalSearchForm as SearchForm } from '@wordpress/block-editor';

/**
* Internal dependencies
Expand Down Expand Up @@ -69,12 +69,9 @@ export default function TemplatePartPlaceholder( { setAttributes } ) {
) }
renderContent={ () => (
<>
<TextControl
label={ __( 'Search' ) }
placeholder={ __( 'header' ) }
value={ filterValue }
<SearchForm
onChange={ setFilterValue }
className="wp-block-template-part__placeholder-preview-filter-input"
className="wp-block-template-part__placeholder-preview-search-form"
/>
<div className="wp-block-template-part__placeholder-preview-container">
<TemplatePartPreviews
Expand Down
15 changes: 3 additions & 12 deletions packages/block-library/src/template-part/editor.scss
Original file line number Diff line number Diff line change
Expand Up @@ -2,25 +2,16 @@
.wp-block-template-part__placeholder-preview-dropdown-content {
.components-popover__content {
min-width: 320px;
padding-top: 0;
padding: 0;
}
}

.wp-block-template-part__placeholder-preview-filter-input {
background: $white;
.wp-block-template-part__placeholder-preview-search-form {
border-bottom: $border-width solid $light-gray-500;
left: 0;
margin: 0 ( -$grid-unit-15 ) $grid-unit-15;
padding: $grid-unit-15;
position: sticky;
top: 0;
z-index: z-index(".wp-block-template-part__placeholder-preview-filter-input");
}

.wp-block-template-part__placeholder-preview-container {
background: $white;
border-radius: $radius-block-ui;
border: $border-width solid $light-gray-500;
padding-bottom: 16px;

.wp-block-template-part__placeholder-preview-item {
Expand Down Expand Up @@ -49,7 +40,7 @@
.wp-block-template-part__placeholder-preview-item-title {
padding: $grid-unit-05;
font-size: 12px;
text-align: center;
text-align: left;
}

.wp-block-template-part__placeholder-panel-group-header {
Expand Down

0 comments on commit 2769fc7

Please sign in to comment.