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 20, 2023
1 parent 7d849e6 commit 4933817
Show file tree
Hide file tree
Showing 7 changed files with 30 additions and 28 deletions.
12 changes: 0 additions & 12 deletions lib/blocks.php
Original file line number Diff line number Diff line change
Expand Up @@ -352,15 +352,3 @@ function gutenberg_register_legacy_social_link_blocks() {
}

add_action( 'init', 'gutenberg_register_legacy_social_link_blocks' );

register_block_pattern(
'custom-pattern',
array(
'title' => _x( 'Start post pattern', 'Block pattern title', 'gutenberg' ),
'blockTypes' => array( 'core/paragraph', 'core/post-content' ),
// 'postTypes' => array( 'page' ),
'content' => '<!-- wp:paragraph -->
<p>A start post pattern</p>
<!-- /wp:paragraph -->',
)
);
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
2 changes: 1 addition & 1 deletion packages/edit-site/src/components/editor/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,7 @@ export default function Editor() {
<GlobalStylesProvider>
<BlockContextProvider value={ blockContext }>
<SidebarComplementaryAreaFills />
<StartTemplateOptions />
{ isEditMode && <StartTemplateOptions /> }
<InterfaceSkeleton
enableRegionNavigation={ false }
className={
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,14 +57,15 @@ 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'
)?.offsetWidth;
if ( elementOffSetWidth ) {
setGridHeight( `${ ( elementOffSetWidth * 4 ) / 3 }px` );
}
}, [ blockPatterns, sizes.width ] );
}, [ shownBlockPatterns, sizes.width ] );
return (
<div
className="edit-site-start-template-options__pattern-container"
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 4933817

Please sign in to comment.