diff --git a/packages/edit-site/src/components/global-styles/font-library-modal/font-collection.js b/packages/edit-site/src/components/global-styles/font-library-modal/font-collection.js index 08ff1a95d6e41..062ad232e3ca9 100644 --- a/packages/edit-site/src/components/global-styles/font-library-modal/font-collection.js +++ b/packages/edit-site/src/components/global-styles/font-library-modal/font-collection.js @@ -21,7 +21,7 @@ import { search, closeSmall } from '@wordpress/icons'; /** * Internal dependencies */ -import TabLayout from './tab-layout'; +import TabPanelLayout from './tab-panel-layout'; import { FontLibraryContext } from './context'; import FontsGrid from './fonts-grid'; import FontCard from './font-card'; @@ -156,7 +156,7 @@ function FontCollection( { id } ) { }; return ( - ) } - + ); } diff --git a/packages/edit-site/src/components/global-styles/font-library-modal/index.js b/packages/edit-site/src/components/global-styles/font-library-modal/index.js index 1128ca0811977..65a284560687c 100644 --- a/packages/edit-site/src/components/global-styles/font-library-modal/index.js +++ b/packages/edit-site/src/components/global-styles/font-library-modal/index.js @@ -2,7 +2,10 @@ * WordPress dependencies */ import { __ } from '@wordpress/i18n'; -import { Modal, TabPanel } from '@wordpress/components'; +import { + Modal, + privateApis as componentsPrivateApis, +} from '@wordpress/components'; import { useContext } from '@wordpress/element'; /** @@ -12,33 +15,33 @@ import InstalledFonts from './installed-fonts'; import FontCollection from './font-collection'; import UploadFonts from './upload-fonts'; import { FontLibraryContext } from './context'; +import { unlock } from '../../../lock-unlock'; + +const { Tabs } = unlock( componentsPrivateApis ); const DEFAULT_TABS = [ { - name: 'installed-fonts', + id: 'installed-fonts', title: __( 'Library' ), - className: 'installed-fonts', }, { - name: 'upload-fonts', + id: 'upload-fonts', title: __( 'Upload' ), - className: 'upload-fonts', }, ]; const tabsFromCollections = ( collections ) => collections.map( ( { id, name } ) => ( { - name: id, + id, title: collections.length === 1 && id === 'default-font-collection' ? __( 'Install Fonts' ) : name, - className: 'collection', } ) ); function FontLibraryModal( { onRequestClose, - initialTabName = 'installed-fonts', + initialTabId = 'installed-fonts', } ) { const { collections } = useContext( FontLibraryContext ); @@ -54,22 +57,39 @@ function FontLibraryModal( { isFullScreen className="font-library-modal" > - - { ( tab ) => { - switch ( tab.name ) { - case 'upload-fonts': - return ; - case 'installed-fonts': - return ; - default: - return ; - } - } } - +
+ + + { tabs.map( ( { id, title } ) => ( + + { title } + + ) ) } + + { tabs.map( ( { id } ) => { + let contents; + switch ( id ) { + case 'upload-fonts': + contents = ; + break; + case 'installed-fonts': + contents = ; + break; + default: + contents = ; + } + return ( + + { contents } + + ); + } ) } + +
); } 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 2a8d1e591e084..d493a2a297b18 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 @@ -16,7 +16,7 @@ import { /** * Internal dependencies */ -import TabLayout from './tab-layout'; +import TabPanelLayout from './tab-panel-layout'; import { FontLibraryContext } from './context'; import FontsGrid from './fonts-grid'; import LibraryFontDetails from './library-font-details'; @@ -92,7 +92,7 @@ function InstalledFonts() { }, [ notice ] ); return ( - ) } - + ); } diff --git a/packages/edit-site/src/components/global-styles/font-library-modal/style.scss b/packages/edit-site/src/components/global-styles/font-library-modal/style.scss index 86cac4244dea9..cf7de98d6fbbb 100644 --- a/packages/edit-site/src/components/global-styles/font-library-modal/style.scss +++ b/packages/edit-site/src/components/global-styles/font-library-modal/style.scss @@ -24,7 +24,7 @@ } } -.font-library-modal__tab-layout { +.font-library-modal__tabpanel-layout { main { padding-bottom: 4rem; @@ -75,7 +75,7 @@ padding-bottom: 1rem; } -.font-library-modal__tab-panel { +.font-library-modal__tabs { [role="tablist"] { position: sticky; top: 0; diff --git a/packages/edit-site/src/components/global-styles/font-library-modal/tab-layout.js b/packages/edit-site/src/components/global-styles/font-library-modal/tab-panel-layout.js similarity index 85% rename from packages/edit-site/src/components/global-styles/font-library-modal/tab-layout.js rename to packages/edit-site/src/components/global-styles/font-library-modal/tab-panel-layout.js index 07f27cd31ea79..a7151c6e908d6 100644 --- a/packages/edit-site/src/components/global-styles/font-library-modal/tab-layout.js +++ b/packages/edit-site/src/components/global-styles/font-library-modal/tab-panel-layout.js @@ -11,9 +11,15 @@ import { } from '@wordpress/components'; import { chevronLeft } from '@wordpress/icons'; -function TabLayout( { title, description, handleBack, children, footer } ) { +function TabPanelLayout( { + title, + description, + handleBack, + children, + footer, +} ) { return ( -
+
@@ -47,4 +53,4 @@ function TabLayout( { title, description, handleBack, children, footer } ) { ); } -export default TabLayout; +export default TabPanelLayout;