Skip to content

Commit

Permalink
Rename the Page Patterns concept (from Page Templates)
Browse files Browse the repository at this point in the history
  • Loading branch information
p-jackson committed Mar 18, 2021
1 parent 41ee893 commit 5392c8b
Show file tree
Hide file tree
Showing 32 changed files with 573 additions and 576 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ describe( 'Full Site Editing Back Button', () => {
await activateTheme( 'maywood' );
// Creates a new page and uses the blank page layout.
await createNewPost( { postType: 'page', title: 'New e2e Page!' } );
await page.click( '.page-template-modal__buttons .components-button.is-primary.is-large' );
await page.click( '.page-pattern-modal__buttons .components-button.is-primary.is-large' );
} );

it( 'Should have an overriden button', async () => {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
@import '~@automattic/page-template-modal/src/styles/page-template-modal';
@import '~@automattic/page-pattern-modal/src/styles/page-pattern-modal';

.sidebar-modal-opener {
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
.template-selector-item__label {
.pattern-selector-item__label {
max-width: 300px;
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,20 +3,20 @@
*/
import { registerPlugin } from '@wordpress/plugins';
import { dispatch } from '@wordpress/data';
import { initializeTracksWithIdentity, LayoutDefinition } from '@automattic/page-template-modal';
import { initializeTracksWithIdentity, PatternDefinition } from '@automattic/page-pattern-modal';
import React from '@wordpress/element';

/**
* Internal dependencies
*/
import { PageTemplatesPlugin } from './page-template-plugin';
import { PagePatternsPlugin } from './page-patterns-plugin';
import './store';
import './index.scss';

declare global {
interface Window {
starterPageTemplatesConfig?: {
templates?: LayoutDefinition[];
templates?: PatternDefinition[];
locale?: string;
theme?: string;
screenAction?: string;
Expand All @@ -26,7 +26,7 @@ declare global {
}

// Load config passed from backend.
const { templates = [], tracksUserData, screenAction, theme, locale } =
const { templates: patterns = [], tracksUserData, screenAction, theme, locale } =
window.starterPageTemplatesConfig ?? {};

if ( tracksUserData ) {
Expand All @@ -39,9 +39,9 @@ if ( screenAction === 'add' ) {
}

// Always register ability to open from document sidebar.
registerPlugin( 'page-templates', {
registerPlugin( 'page-patterns', {
render: () => {
return <PageTemplatesPlugin templates={ templates } theme={ theme } locale={ locale } />;
return <PagePatternsPlugin patterns={ patterns } theme={ theme } locale={ locale } />;
},

// `registerPlugin()` types assume `icon` is mandatory however it isn't
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,19 +5,19 @@ import { stubTrue } from 'lodash';
import '@wordpress/nux';
import { useSelect, useDispatch } from '@wordpress/data';
import { addFilter, removeFilter } from '@wordpress/hooks';
import { LayoutDefinition, PageTemplateModal } from '@automattic/page-template-modal';
import { PagePatternModal, PatternDefinition } from '@automattic/page-pattern-modal';
import React, { useCallback } from '@wordpress/element';

const INSERTING_HOOK_NAME = 'isInsertingPageTemplate';
const INSERTING_HOOK_NAMESPACE = 'automattic/full-site-editing/inserting-template';
const INSERTING_HOOK_NAME = 'isInsertingPagePattern';
const INSERTING_HOOK_NAMESPACE = 'automattic/full-site-editing/inserting-pattern';

interface PageTemplatesPluginProps {
templates: LayoutDefinition[];
interface PagePatternsPluginProps {
patterns: PatternDefinition[];
locale?: string;
theme?: string;
}

export function PageTemplatesPlugin( props: PageTemplatesPluginProps ): JSX.Element {
export function PagePatternsPlugin( props: PagePatternsPluginProps ): JSX.Element {
const { setOpenState } = useDispatch( 'automattic/starter-page-layouts' );
const { replaceInnerBlocks } = useDispatch( 'core/block-editor' );
const { editPost } = useDispatch( 'core/editor' );
Expand All @@ -44,9 +44,9 @@ export function PageTemplatesPlugin( props: PageTemplatesPluginProps ): JSX.Elem
};
} );

const saveTemplateChoice = useCallback(
const savePatternChoice = useCallback(
( name: string ) => {
// Save selected template slug in meta.
// Save selected pattern slug in meta.
const currentMeta = getMeta();
editPost( {
meta: {
Expand All @@ -58,9 +58,9 @@ export function PageTemplatesPlugin( props: PageTemplatesPluginProps ): JSX.Elem
[ editPost, getMeta ]
);

const insertTemplate = useCallback(
const insertPattern = useCallback(
( title, blocks ) => {
// Add filter to let the tracking library know we are inserting a template.
// Add filter to let the tracking library know we are inserting a pattern.
addFilter( INSERTING_HOOK_NAME, INSERTING_HOOK_NAMESPACE, stubTrue );

// Set post title.
Expand Down Expand Up @@ -90,11 +90,11 @@ export function PageTemplatesPlugin( props: PageTemplatesPluginProps ): JSX.Elem
}, [ areTipsEnabled, disableTips, isWelcomeGuideActive, toggleFeature ] );

return (
<PageTemplateModal
<PagePatternModal
{ ...selectProps }
setOpenState={ setOpenState }
saveTemplateChoice={ saveTemplateChoice }
insertTemplate={ insertTemplate }
savePatternChoice={ savePatternChoice }
insertPattern={ insertPattern }
hideWelcomeGuide={ hideWelcomeGuide }
{ ...props }
/>
Expand Down
2 changes: 1 addition & 1 deletion apps/editing-toolkit/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@
"@automattic/i18n-utils": "^1.0.0",
"@automattic/launch": "^1.0.0",
"@automattic/onboarding": "^1.0.0",
"@automattic/page-template-modal": "^1.0.0-alpha.0",
"@automattic/page-pattern-modal": "^1.0.0-alpha.0",
"@automattic/plans-grid": "^1.0.0-alpha.0",
"@automattic/react-i18n": "^1.0.0-alpha.0",
"@automattic/typography": "^1.0.0",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,9 +75,9 @@ class GutenbergEditorComponent extends AsyncBaseContainer {
}

async dismissPageTemplateSelector() {
if ( await driverHelper.isElementPresent( this.driver, By.css( '.page-template-modal' ) ) ) {
if ( await driverHelper.isElementPresent( this.driver, By.css( '.page-pattern-modal' ) ) ) {
const useBlankButton = await this.driver.findElement(
By.css( '.page-template-modal__buttons .components-button.is-primary' )
By.css( '.page-pattern-modal__buttons .components-button.is-primary' )
);
await this.driver.executeScript( 'arguments[0].click()', useBlankButton );
}
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
# Page Template Modal
# Page Pattern Modal

A modal for choosing a starting template for a new page, extracted from the editing toolkit
A modal for choosing a starting pattern for a new page, extracted from the editing toolkit

## Development Workflow

This package is developed as part of the Calypso monorepo. Run `yarn`
in the root of the repository to get the required `devDependencies`.
in the root of the repository to get the required `devDependencies`.
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "@automattic/page-template-modal",
"name": "@automattic/page-pattern-modal",
"version": "1.0.0-alpha.0",
"description": "Automattic Page Template Modal",
"description": "Automattic Page Pattern Modal",
"homepage": "https://github.com/Automattic/wp-calypso",
"license": "GPL-2.0-or-later",
"author": "Automattic Inc.",
Expand All @@ -15,7 +15,7 @@
"repository": {
"type": "git",
"url": "git+https://github.com/Automattic/wp-calypso.git",
"directory": "packages/page-template-modal"
"directory": "packages/page-pattern-modal"
},
"publishConfig": {
"access": "public"
Expand Down
Loading

0 comments on commit 5392c8b

Please sign in to comment.