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

update empty patterns #54642

Closed
wants to merge 3 commits 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
25 changes: 16 additions & 9 deletions packages/edit-site/src/components/add-new-pattern/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ import usePatternCategories from '../sidebar-navigation-screen-patterns/use-patt
const { useHistory, useLocation } = unlock( routerPrivateApis );
const { CreatePatternModal } = unlock( editPatternsPrivateApis );

export default function AddNewPattern() {
export default function AddNewPattern( { renderTrigger } ) {
const history = useHistory();
const { params } = useLocation();
const [ showPatternModal, setShowPatternModal ] = useState( false );
Expand Down Expand Up @@ -99,14 +99,21 @@ export default function AddNewPattern() {

return (
<>
<DropdownMenu
controls={ controls }
toggleProps={ {
as: SidebarButton,
} }
icon={ plus }
label={ __( 'Create pattern' ) }
/>
{ renderTrigger ? (
renderTrigger( {
setShowPatternModal,
setShowTemplatePartModal,
} )
) : (
<DropdownMenu
controls={ controls }
toggleProps={ {
as: SidebarButton,
} }
icon={ plus }
label={ __( 'Create pattern' ) }
/>
) }
{ showPatternModal && (
<CreatePatternModal
onClose={ () => setShowPatternModal( false ) }
Expand Down
43 changes: 40 additions & 3 deletions packages/edit-site/src/components/page-patterns/no-patterns.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,48 @@
* WordPress dependencies
*/
import { __ } from '@wordpress/i18n';
import {
Button,
Icon,
__experimentalVStack as VStack,
__experimentalHeading as Heading,
__experimentalText as Text,
} from '@wordpress/components';
import { symbol } from '@wordpress/icons';

/**
* Internal dependencies
*/
import AddNewPattern from '../add-new-pattern';

export default function NoPatterns() {
return (
<div className="edit-site-patterns__no-results">
{ __( 'No patterns found.' ) }
</div>
<VStack
spacing={ 6 }
alignment="center"
className="edit-site-patterns__no-results"
>
<Icon icon={ symbol } />
<VStack spacing={ 3 } alignment="center">
<Heading level={ 4 } as="h2">
{ __( 'Create a pattern' ) }
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wonder if we should still show text suggesting no patterns for accessibility reasons?

</Heading>
<Text>
{ __(
'Reuse common block combinations and layouts across your site.'
) }
</Text>
</VStack>
<AddNewPattern
renderTrigger={ ( { setShowPatternModal } ) => (
<Button
onClick={ () => setShowPatternModal( true ) }
variant="primary"
>
{ __( 'New pattern' ) }
</Button>
) }
/>
</VStack>
);
}
2 changes: 2 additions & 0 deletions packages/edit-site/src/components/page-patterns/style.scss
Original file line number Diff line number Diff line change
Expand Up @@ -195,6 +195,8 @@

.edit-site-patterns__no-results {
color: $gray-600;
fill: $gray-100;
height: 100%;
}

.edit-site-patterns__delete-modal {
Expand Down
4 changes: 2 additions & 2 deletions test/e2e/specs/site-editor/patterns.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ test.describe( 'Patterns', () => {
level: 1,
} )
).toBeVisible();
await expect( patterns.content ).toContainText( 'No patterns found.' );
await expect( patterns.content ).toContainText( 'Create a pattern' );

await patterns.navigation
.getByRole( 'button', { name: 'Create pattern' } )
Expand Down Expand Up @@ -181,7 +181,7 @@ test.describe( 'Patterns', () => {
} );

await searchBox.fill( 'no match' );
await expect( patterns.content ).toContainText( 'No patterns found.' );
await expect( patterns.content ).toContainText( 'Create a pattern' );

await patterns.content
.getByRole( 'button', { name: 'Reset search' } )
Expand Down
Loading