From 12e50cf7e66f9796449059a3c458e97fc24d50f4 Mon Sep 17 00:00:00 2001 From: ntsekouras Date: Mon, 15 May 2023 13:05:51 +0300 Subject: [PATCH] use single Modal part 1 --- .../add-custom-generic-template-modal.js | 91 ++++----- .../add-custom-template-modal.js | 39 ++-- .../add-new-template/new-template.js | 175 +++++++++++------- .../components/add-new-template/style.scss | 36 +++- 4 files changed, 189 insertions(+), 152 deletions(-) diff --git a/packages/edit-site/src/components/add-new-template/add-custom-generic-template-modal.js b/packages/edit-site/src/components/add-new-template/add-custom-generic-template-modal.js index 05688d032a591..97c6fc041a2cf 100644 --- a/packages/edit-site/src/components/add-new-template/add-custom-generic-template-modal.js +++ b/packages/edit-site/src/components/add-new-template/add-custom-generic-template-modal.js @@ -10,22 +10,12 @@ import { useState } from '@wordpress/element'; import { __ } from '@wordpress/i18n'; import { Button, - Modal, TextControl, __experimentalHStack as HStack, __experimentalVStack as VStack, } from '@wordpress/components'; -/** - * Internal dependencies - */ -import TemplateActionsLoadingScreen from './template-actions-loading-screen'; - -function AddCustomGenericTemplateModal( { - onClose, - createTemplate, - isCreatingTemplate, -} ) { +function AddCustomGenericTemplateModal( { onClose, createTemplate } ) { const [ title, setTitle ] = useState( '' ); const defaultTitle = __( 'Custom Template' ); const [ isBusy, setIsBusy ] = useState( false ); @@ -50,51 +40,42 @@ function AddCustomGenericTemplateModal( { } } return ( - { - onClose(); - } } - overlayClassName="edit-site-custom-generic-template__modal" - > - { isCreatingTemplate && } -
- - - + + + + + - - - - -
+ { __( 'Create' ) } + + + + ); } diff --git a/packages/edit-site/src/components/add-new-template/add-custom-template-modal.js b/packages/edit-site/src/components/add-new-template/add-custom-template-modal.js index ccab5d82bd058..b6e91da3cb589 100644 --- a/packages/edit-site/src/components/add-new-template/add-custom-template-modal.js +++ b/packages/edit-site/src/components/add-new-template/add-custom-template-modal.js @@ -2,12 +2,11 @@ * WordPress dependencies */ import { useState, useMemo, useEffect } from '@wordpress/element'; -import { __, sprintf } from '@wordpress/i18n'; +import { __ } from '@wordpress/i18n'; import { Button, Flex, FlexItem, - Modal, SearchControl, TextHighlight, __experimentalText as Text, @@ -23,7 +22,6 @@ import { decodeEntities } from '@wordpress/html-entities'; /** * Internal dependencies */ -import TemplateActionsLoadingScreen from './template-actions-loading-screen'; import { mapToIHasNameAndId } from './utils'; const EMPTY_ARRAY = []; @@ -179,36 +177,25 @@ function SuggestionList( { entityForSuggestions, onSelect } ) { ); } -function AddCustomTemplateModal( { - onClose, - onSelect, - entityForSuggestions, - isCreatingTemplate, -} ) { +function AddCustomTemplateModal( { onSelect, entityForSuggestions } ) { const [ showSearchEntities, setShowSearchEntities ] = useState( entityForSuggestions.hasGeneralTemplate ); - const baseCssClass = 'edit-site-custom-template-modal'; return ( - - { isCreatingTemplate && } + <> { ! showSearchEntities && ( - + { __( 'Select whether to create a single template for all items or a specific one.' ) } @@ -275,7 +262,11 @@ function AddCustomTemplateModal( { ) } { showSearchEntities && ( - + { __( 'This template will be used only for the specific item chosen.' @@ -287,7 +278,7 @@ function AddCustomTemplateModal( { /> ) } - + ); } diff --git a/packages/edit-site/src/components/add-new-template/new-template.js b/packages/edit-site/src/components/add-new-template/new-template.js index 1ae6dcca087d6..e90931e5e6c30 100644 --- a/packages/edit-site/src/components/add-new-template/new-template.js +++ b/packages/edit-site/src/components/add-new-template/new-template.js @@ -1,3 +1,8 @@ +/** + * External dependencies + */ +import classnames from 'classnames'; + /** * WordPress dependencies */ @@ -54,7 +59,12 @@ const DEFAULT_TEMPLATE_SLUGS = [ function TemplateListItem( { title, description, onClick } ) { return (