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

Starter Page Templates: Add all SPT themes home templates to the template selector #37407

Merged
merged 5 commits into from
Nov 15, 2019
Merged
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
Original file line number Diff line number Diff line change
Expand Up @@ -206,10 +206,7 @@ public function fetch_vertical_data() {
if ( false === $vertical_templates || ( defined( 'WP_DEBUG' ) && WP_DEBUG ) ) {
$vertical_id = get_option( 'site_vertical', 'default' );
$request_url = add_query_arg(
[
'_locale' => $this->get_iso_639_locale(),
'theme' => get_stylesheet(),
],
[ '_locale' => $this->get_iso_639_locale() ],
Copy link
Member

Choose a reason for hiding this comment

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

Nice

'https://public-api.wordpress.com/wpcom/v2/verticals/' . $vertical_id . '/templates'
);
$response = wp_remote_get( esc_url_raw( $request_url ) );
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
/* eslint-disable import/no-extraneous-dependencies */
import { isEmpty, isArray, debounce } from 'lodash';
/* eslint-enable import/no-extraneous-dependencies */
import classnames from 'classnames';

/**
* WordPress dependencies
Expand Down Expand Up @@ -104,7 +105,7 @@ const TemplateSelectorPreview = ( { blocks, viewportWidth, title } ) => {

if ( isEmpty( blocks ) || ! isArray( blocks ) ) {
return (
<div className="template-selector-preview">
<div className={ classnames( 'template-selector-preview', 'is-blank-preview' ) }>
<div className="template-selector-preview__placeholder">
{ __( 'Select a layout to preview.', 'full-site-editing' ) }
</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
/**
* External dependencies
*/
import { isEmpty, reduce, get, keyBy, mapValues } from 'lodash';
import { isEmpty, reduce, get, keyBy, mapValues, partition } from 'lodash';
import classnames from 'classnames';
import '@wordpress/nux';
import { __, sprintf } from '@wordpress/i18n';
Expand Down Expand Up @@ -170,6 +170,10 @@ class PageTemplateModal extends Component {
return null;
}

const [ homepage_templates, default_templates ] = partition( templates, {
category: 'home',
} );

return (
<Modal
title={ __( 'Select Page Layout', 'full-site-editing' ) }
Expand Down Expand Up @@ -211,7 +215,22 @@ class PageTemplateModal extends Component {
</legend>
<TemplateSelectorControl
label={ __( 'Layout', 'full-site-editing' ) }
templates={ templates }
templates={ default_templates }
blocksByTemplates={ blocksByTemplateSlug }
onTemplateSelect={ this.previewTemplate }
useDynamicPreview={ false }
siteInformation={ siteInformation }
selectedTemplate={ previewedTemplate }
handleTemplateConfirmation={ this.handleConfirmation }
/>
</fieldset>
<fieldset className="page-template-modal__list">
<legend className="page-template-modal__form-title">
{ __( 'Homepage layouts', 'full-site-editing' ) }
</legend>
<TemplateSelectorControl
label={ __( 'Layout', 'full-site-editing' ) }
templates={ homepage_templates }
blocksByTemplates={ blocksByTemplateSlug }
onTemplateSelect={ this.previewTemplate }
useDynamicPreview={ false }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,10 @@ body.admin-bar:not( .is-fullscreen-mode ) .page-template-modal-screen-overlay {
}
}

.page-template-modal__list {
margin-bottom: 20px;
}

.page-template-modal__list,
.sidebar-modal-opener {
.components-base-control__label {
Expand Down Expand Up @@ -346,6 +350,14 @@ body.admin-bar:not( .is-fullscreen-mode ) .page-template-modal-screen-overlay {
height: calc( 100vh - 130px );
}

@media screen and ( min-width: 660px ) {
&.is-blank-preview {
align-items: center;
display: flex;
justify-content: center;
}
}

position: fixed;
top: 111px;
bottom: 24px;
Expand Down Expand Up @@ -410,22 +422,9 @@ body:not( .is-fullscreen-mode ) .template-selector-preview {
}

.template-selector-preview__placeholder {
position: absolute;
top: 24%;
left: 50%;
transform: translateX( -50% );
width: 80%;
text-align: center;
color: var( --color-text-subtle );
font-size: 15px;
font-weight: 400;
color: var( --color-text-subtle );

@media screen and ( min-width: 1441px ) {
left: auto;
right: 0;
transform: none;
width: calc( 70% - #{$wp-org-sidebar-reduced + (24px * 2 ) } );
}
}

// Preview adjustments.
Expand Down Expand Up @@ -515,7 +514,7 @@ body:not( .is-fullscreen-mode ) .template-selector-preview {
.template-selector-item__label {
max-width: 300px;
}

.template-selector-item__template-title {
font-size: 1.2rem;
}
Expand Down