From efd61055e9dc14d5d13ce8ed12786221d59d6363 Mon Sep 17 00:00:00 2001 From: Jason Crist Date: Wed, 14 Feb 2024 15:22:12 -0500 Subject: [PATCH 01/15] Use NavigatorProvider in installed fonts panel --- .../font-library-modal/installed-fonts.js | 93 ++++++++++--------- .../font-library-modal/library-font-card.js | 13 ++- 2 files changed, 63 insertions(+), 43 deletions(-) diff --git a/packages/edit-site/src/components/global-styles/font-library-modal/installed-fonts.js b/packages/edit-site/src/components/global-styles/font-library-modal/installed-fonts.js index 99c99e44a43af..456e58d68d3f2 100644 --- a/packages/edit-site/src/components/global-styles/font-library-modal/installed-fonts.js +++ b/packages/edit-site/src/components/global-styles/font-library-modal/installed-fonts.js @@ -8,10 +8,14 @@ import { __experimentalHStack as HStack, __experimentalSpacer as Spacer, __experimentalText as Text, + __experimentalNavigatorProvider as NavigatorProvider, + __experimentalNavigatorScreen as NavigatorScreen, + __experimentalNavigatorToParentButton as NavigatorToParentButton, Button, Spinner, FlexItem, } from '@wordpress/components'; +import { chevronLeft } from '@wordpress/icons'; /** * Internal dependencies @@ -38,14 +42,6 @@ function InstalledFonts() { } = useContext( FontLibraryContext ); const [ isConfirmDeleteOpen, setIsConfirmDeleteOpen ] = useState( false ); - const handleUnselectFont = () => { - handleSetLibraryFontSelected( null ); - }; - - const handleSelectFont = ( font ) => { - handleSetLibraryFontSelected( font ); - }; - const handleConfirmUninstall = async () => { setNotice( null ); @@ -57,7 +53,7 @@ function InstalledFonts() { } ); // If the font was succesfully uninstalled it is unselected. - handleUnselectFont(); + handleSetLibraryFontSelected( null ); setIsConfirmDeleteOpen( false ); } catch ( error ) { setNotice( { @@ -77,27 +73,17 @@ function InstalledFonts() { setIsConfirmDeleteOpen( false ); }; - const tabDescription = !! libraryFontSelected - ? __( - 'Choose font variants. Keep in mind that too many variants could make your site slower.' - ) - : null; - const shouldDisplayDeleteButton = !! libraryFontSelected && libraryFontSelected?.source !== 'theme'; useEffect( () => { - handleSelectFont( libraryFontSelected ); + handleSetLibraryFontSelected( libraryFontSelected ); refreshLibrary(); - // eslint-disable-next-line react-hooks/exhaustive-deps }, [] ); return ( - { ! libraryFontSelected && ( - <> - { isResolvingLibrary && ( - - - - - - ) } + { isResolvingLibrary && ( + + + + + + ) } + + + { baseCustomFonts.length > 0 && ( <> + + { __( 'Installed Fonts' ) } + + + + { baseCustomFonts.map( ( font ) => ( { - handleSelectFont( font ); + handleSetLibraryFontSelected( font ); } } /> ) ) } @@ -143,29 +136,45 @@ function InstalledFonts() { + { baseThemeFonts.map( ( font ) => ( { - handleSelectFont( font ); + handleSetLibraryFontSelected( font ); } } /> ) ) } ) } - - ) } - - { libraryFontSelected && ( - - ) } + + + + + + { __( 'Return to Library' ) } + + + + { libraryFontSelected?.name } + + + + { __( + 'Choose font variants. Keep in mind that too many variants could make your site slower.' + ) } + + + + + ); } diff --git a/packages/edit-site/src/components/global-styles/font-library-modal/library-font-card.js b/packages/edit-site/src/components/global-styles/font-library-modal/library-font-card.js index aae43fcf63eba..b84ff2ad163c3 100644 --- a/packages/edit-site/src/components/global-styles/font-library-modal/library-font-card.js +++ b/packages/edit-site/src/components/global-styles/font-library-modal/library-font-card.js @@ -3,6 +3,7 @@ */ import { __, sprintf } from '@wordpress/i18n'; import { useContext } from '@wordpress/element'; +import { __experimentalUseNavigator as useNavigator } from '@wordpress/components'; /** * Internal dependencies @@ -26,8 +27,18 @@ function LibraryFontCard( { font, ...props } ) { variantsInstalled ); + const navi = useNavigator(); + return ( - + { + props.onClick(); + navi.goTo( '/fontFamily' ); + } } + /> ); } From b3135c6bfb5a27b5814d267eac6eceaf23811fc1 Mon Sep 17 00:00:00 2001 From: Jason Crist Date: Thu, 15 Feb 2024 13:33:25 -0500 Subject: [PATCH 02/15] Style Changes to font modal installed font details page --- .../font-library-modal/installed-fonts.js | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/packages/edit-site/src/components/global-styles/font-library-modal/installed-fonts.js b/packages/edit-site/src/components/global-styles/font-library-modal/installed-fonts.js index 456e58d68d3f2..ff5799bc8a3b2 100644 --- a/packages/edit-site/src/components/global-styles/font-library-modal/installed-fonts.js +++ b/packages/edit-site/src/components/global-styles/font-library-modal/installed-fonts.js @@ -11,6 +11,7 @@ import { __experimentalNavigatorProvider as NavigatorProvider, __experimentalNavigatorScreen as NavigatorScreen, __experimentalNavigatorToParentButton as NavigatorToParentButton, + __experimentalHeading as Heading, Button, Spinner, FlexItem, @@ -152,15 +153,18 @@ function InstalledFonts() { - - - { __( 'Return to Library' ) } - - - + + + + { libraryFontSelected?.name } - + + { __( 'Choose font variants. Keep in mind that too many variants could make your site slower.' From c4e6ab566f52f5147dfff607d3195365bef1c50e Mon Sep 17 00:00:00 2001 From: Jason Crist Date: Mon, 19 Feb 2024 08:55:39 -0500 Subject: [PATCH 03/15] Simplified Font Face Demo component so it can be more easily reused --- .../collection-font-variant.js | 2 +- .../font-library-modal/font-card.js | 25 +--------------- .../font-library-modal/font-demo.js | 30 +++++++++++++++++-- .../library-font-variant.js | 2 +- 4 files changed, 31 insertions(+), 28 deletions(-) diff --git a/packages/edit-site/src/components/global-styles/font-library-modal/collection-font-variant.js b/packages/edit-site/src/components/global-styles/font-library-modal/collection-font-variant.js index 0db8932a98e34..96fd1d51d9567 100644 --- a/packages/edit-site/src/components/global-styles/font-library-modal/collection-font-variant.js +++ b/packages/edit-site/src/components/global-styles/font-library-modal/collection-font-variant.js @@ -45,7 +45,7 @@ function CollectionFontVariant( { />