Skip to content

Commit

Permalink
Remove start blank option in template pattern suggestions and add `…
Browse files Browse the repository at this point in the history
…skip` button (#50099)

* Update `start blank` in template pattern suggestions

* add skip button

* add empty line in changelog

* Make actions bar sticky

* z-index

* update snapshots

---------

Co-authored-by: James Koster <james@jameskoster.co.uk>
  • Loading branch information
ntsekouras and jameskoster authored May 2, 2023
1 parent bdb22cd commit 305c93f
Show file tree
Hide file tree
Showing 7 changed files with 69 additions and 51 deletions.
3 changes: 3 additions & 0 deletions packages/base-styles/_z-index.scss
Original file line number Diff line number Diff line change
Expand Up @@ -189,6 +189,9 @@ $z-layers: (
".edit-site-layout__canvas-container.is-resizing::after": 100,
// Title needs to appear above other UI the section content.
".edit-site-sidebar-navigation-screen__title-icon": 1,

// Ensure modal footer actions appear above modal contents
".edit-site-start-template-options__modal__actions": 1,
);

@function z-index( $key ) {
Expand Down
4 changes: 4 additions & 0 deletions packages/components/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,10 @@

- `TreeGrid`: Update docs with `data-expanded` attribute usage ([#50026](https://github.com/WordPress/gutenberg/pull/50026)).

### Enhancements

- `Modal`: Add css class to children container ([#50099](https://github.com/WordPress/gutenberg/pull/50099)).

## 23.9.0 (2023-04-26)

### Internal
Expand Down
7 changes: 6 additions & 1 deletion packages/components/src/modal/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -252,7 +252,12 @@ function UnforwardedModal(
) }
</div>
) }
<div ref={ childrenContainerRef }>{ children }</div>
<div
ref={ childrenContainerRef }
className="components-modal__children-container"
>
{ children }
</div>
</div>
</div>
</StyleProvider>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,9 @@ exports[`KeyboardShortcutHelpModal should match snapshot when the modal is activ
</svg>
</button>
</div>
<div>
<div
class="components-modal__children-container"
>
<section
class="edit-post-keyboard-shortcut-help-modal__section edit-post-keyboard-shortcut-help-modal__main-shortcuts"
>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,9 @@ exports[`EditPostPreferencesModal should match snapshot when the modal is active
</svg>
</button>
</div>
<div>
<div
class="components-modal__children-container"
>
<div
class="interface-preferences__tabs"
>
Expand Down Expand Up @@ -723,7 +725,9 @@ exports[`EditPostPreferencesModal should match snapshot when the modal is active
</svg>
</button>
</div>
<div>
<div
class="components-modal__children-container"
>
<div
class="components-navigator-provider interface-preferences__provider emotion-0 emotion-1"
data-wp-c16t="true"
Expand Down
46 changes: 19 additions & 27 deletions packages/edit-site/src/components/start-template-options/index.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/**
* WordPress dependencies
*/
import { Modal } from '@wordpress/components';
import { Modal, Flex, FlexItem, Button } from '@wordpress/components';
import { __ } from '@wordpress/i18n';
import { useState, useEffect, useMemo } from '@wordpress/element';
import {
Expand Down Expand Up @@ -36,8 +36,6 @@ function useFallbackTemplateContent( slug, isCustom = false ) {
return templateContent;
}

const START_BLANK_TITLE = __( 'Start blank' );

function useStartPatterns( fallbackContent ) {
const { slug, patterns } = useSelect( ( select ) => {
const { getEditedPostType, getEditedPostId } = select( editSiteStore );
Expand Down Expand Up @@ -72,13 +70,6 @@ function useStartPatterns( fallbackContent ) {
.map( ( pattern ) => {
return { ...pattern, blocks: parse( pattern.content ) };
} ),
{
name: 'start-blank',
blocks: parse(
'<!-- wp:paragraph --><p></p><!-- /wp:paragraph -->'
),
title: START_BLANK_TITLE,
},
];
}, [ fallbackContent, slug, patterns ] );
}
Expand All @@ -87,25 +78,15 @@ function PatternSelection( { fallbackContent, onChoosePattern, postType } ) {
const [ , , onChange ] = useEntityBlockEditor( 'postType', postType );
const blockPatterns = useStartPatterns( fallbackContent );
const shownBlockPatterns = useAsyncList( blockPatterns );

return (
<div
className="edit-site-start-template-options__pattern-container"
style={ {
'--wp-edit-site-start-template-options-start-blank': `"${ START_BLANK_TITLE }"`,
<BlockPatternsList
blockPatterns={ blockPatterns }
shownPatterns={ shownBlockPatterns }
onClickPattern={ ( pattern, blocks ) => {
onChange( blocks, { selection: undefined } );
onChoosePattern();
} }
>
<BlockPatternsList
blockPatterns={ blockPatterns }
shownPatterns={ shownBlockPatterns }
onClickPattern={ ( pattern, blocks ) => {
onChange( 'start-blank' === pattern.name ? [] : blocks, {
selection: undefined,
} );
onChoosePattern();
} }
/>
</div>
/>
);
}

Expand Down Expand Up @@ -134,6 +115,17 @@ function StartModal( { slug, isCustom, onClose, postType } ) {
} }
/>
</div>
<Flex
className="edit-site-start-template-options__modal__actions"
justify="flex-end"
expanded={ false }
>
<FlexItem>
<Button variant="tertiary" onClick={ onClose }>
{ __( 'Skip' ) }
</Button>
</FlexItem>
</Flex>
</Modal>
);
}
Expand Down
48 changes: 28 additions & 20 deletions packages/edit-site/src/components/start-template-options/style.scss
Original file line number Diff line number Diff line change
@@ -1,3 +1,31 @@
.edit-site-start-template-options__modal {
.components-modal__content {
padding-bottom: 0;
}

.components-modal__children-container {
display: flex;
height: 100%;
flex-direction: column;

.edit-site-start-template-options__modal__actions {
margin-top: auto;
position: sticky;
bottom: 0;
background-color: $white;
margin-left: - $grid-unit-40;
margin-right: - $grid-unit-40;
padding: $grid-unit-30 $grid-unit-40 $grid-unit-40;
border-top: 1px solid $gray-300;
z-index: z-index(".edit-site-start-template-options__modal__actions");
}
}

.block-editor-block-patterns-list {
padding-bottom: $grid-unit-40;
}
}

.edit-site-start-template-options__modal-content .block-editor-block-patterns-list {
column-count: 2;
column-gap: $grid-unit-30;
Expand Down Expand Up @@ -28,24 +56,4 @@
box-shadow: 0 0 0 1px $gray-300;
}
}

// The start blank pattern is the last and we are selecting it.
.block-editor-block-patterns-list__list-item:nth-last-child(2) {
.block-editor-block-preview__container {
position: absolute;
padding: 0;
background: #f0f0f0;
min-height: $grid-unit-50 * 4;
&::after {
width: 100%;
top: 50%;
margin-top: -1em;
content: var(--wp-edit-site-start-template-options-start-blank);
text-align: center;
}
}
iframe {
display: none;
}
}
}

0 comments on commit 305c93f

Please sign in to comment.