Skip to content

Commit

Permalink
Style adjustments
Browse files Browse the repository at this point in the history
  • Loading branch information
jameskoster authored and jorgefilipecosta committed Jan 17, 2023
1 parent 2261ba1 commit c839ae6
Show file tree
Hide file tree
Showing 5 changed files with 28 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -40,11 +40,6 @@ public function register_routes() {
'description' => __( 'The template prefix for the created template. This is used to extract the main template type ex. in `taxonomy-books` we extract the `taxonomy`', 'gutenberg' ),
'type' => 'string',
),
'ignore_empty' => array(
'description' => __( 'If true templates with empty content are ignored.', 'gutenberg' ),
'type' => 'boolean',
'default' => false,
),
),
),
)
Expand All @@ -63,14 +58,10 @@ public function register_routes() {
public function get_template_fallback( $request ) {
$hierarchy = get_template_hierarchy( $request['slug'], $request['is_custom'], $request['template_prefix'] );
$fallback_template = null;
if ( true === $request['ignore_empty'] ) {
do {
$fallback_template = resolve_block_template( $request['slug'], $hierarchy, '' );
array_shift( $hierarchy );
} while ( ! empty( $hierarchy ) && empty( $fallback_template->content ) );
} else {
do {
$fallback_template = resolve_block_template( $request['slug'], $hierarchy, '' );
}
array_shift( $hierarchy );
} while ( ! empty( $hierarchy ) && empty( $fallback_template->content ) );
$response = $this->prepare_item_for_response( $fallback_template, $request );
return rest_ensure_response( $response );
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ function PatternSelection( { fallbackContent, onChoosePattern, postType } ) {
[ fallbackContent ]
);
const shownBlockPatterns = useAsyncList( blockPatterns );
// When the width changes update the height so we keep the 3x4 proporsions.
useEffect( () => {
const elementOffSetWidth = window?.document?.querySelector(
'.edit-site-start-template-options__pattern-container .block-editor-block-patterns-list__list-item'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,16 +17,17 @@
display: grid;
width: 100%;
margin-top: $grid-unit-05;
gap: $grid-unit-10;
gap: $grid-unit-30;
grid-template-columns: repeat(auto-fit, minmax(min(100%/2, max(240px, 100%/10)), 1fr));
grid-auto-rows: var(--wp-edit-site-start-template-options-grid-height);
.block-editor-block-patterns-list__list-item {
break-inside: avoid-column;
margin-bottom: $grid-unit-30;
margin-bottom: 0;
width: 100%;

.block-editor-block-preview__container {
height: 100%;
box-shadow: 0 0 0 1px $gray-300;
}

.block-editor-block-preview__content {
Expand All @@ -37,6 +38,21 @@
.block-editor-block-patterns-list__item-title {
display: none;
}

&:hover {
.block-editor-block-preview__container {
box-shadow: 0 0 0 2px var(--wp-admin-theme-color);
}
}

&:focus {
.block-editor-block-preview__container {
box-shadow: inset 0 0 0 1px $white, 0 0 0 var(--wp-admin-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;
}
}
}

// The start blank pattern is the last and we are selecting it.
Expand Down
6 changes: 6 additions & 0 deletions phpunit/class-gutenberg-rest-templates-controller-test.php
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,12 @@ public function test_get_template_fallback() {
$response = rest_get_server()->dispatch( $request );
$this->assertSame( 'singular', $response->get_data()['slug'], 'Should fallback to `singular.html`.' );
// Should fallback to `index.html`.
$request->set_param( 'slug', 'tag' );
$request->set_param( 'ignore_empty', true );
$request->set_param( 'is_custom', false );
$response = rest_get_server()->dispatch( $request );
$this->assertSame( 'index', $response->get_data()['slug'], 'Should fallback to `index.html`.' );
// Should fallback to `index.html`.
$request->set_param( 'slug', 'tag-rigas' );
$request->set_param( 'is_custom', false );
$request->set_param( 'template_prefix', 'tag' );
Expand Down
Empty file.

0 comments on commit c839ae6

Please sign in to comment.