-
+
{ tabs.map( ( { id, title } ) => (
@@ -98,5 +108,3 @@ function FontLibraryModal( {
);
}
-
-export default FontLibraryModal;
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 f051fcf62c2b4c..8b643f23d4fcc5 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 TabPanelLayout from './tab-panel-layout';
-import { FontLibraryContext } from './context';
+import { FontLibraryContext } from '../font-library-provider';
import FontsGrid from './fonts-grid';
import LibraryFontDetails from './library-font-details';
import LibraryFontCard from './library-font-card';
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 e37a28a5c95282..9dd4b29b6583f1 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
@@ -8,7 +8,7 @@ import { useContext } from '@wordpress/element';
* Internal dependencies
*/
import FontCard from './font-card';
-import { FontLibraryContext } from './context';
+import { FontLibraryContext } from '../font-library-provider';
function LibraryFontCard( { font, ...props } ) {
const { getFontFacesActivated } = useContext( FontLibraryContext );
diff --git a/packages/edit-site/src/components/global-styles/font-library-modal/library-font-variant.js b/packages/edit-site/src/components/global-styles/font-library-modal/library-font-variant.js
index cc62a85193669b..43185ba609d341 100644
--- a/packages/edit-site/src/components/global-styles/font-library-modal/library-font-variant.js
+++ b/packages/edit-site/src/components/global-styles/font-library-modal/library-font-variant.js
@@ -12,7 +12,7 @@ import {
* Internal dependencies
*/
import { getFontFaceVariantName } from './utils';
-import { FontLibraryContext } from './context';
+import { FontLibraryContext } from '../font-library-provider';
import FontFaceDemo from './font-demo';
import { unlock } from '../../../lock-unlock';
diff --git a/packages/edit-site/src/components/global-styles/font-library-modal/upload-fonts.js b/packages/edit-site/src/components/global-styles/font-library-modal/upload-fonts.js
index f183ff962c7781..5ed91b7b6aa33f 100644
--- a/packages/edit-site/src/components/global-styles/font-library-modal/upload-fonts.js
+++ b/packages/edit-site/src/components/global-styles/font-library-modal/upload-fonts.js
@@ -18,7 +18,7 @@ import { useContext, useState } from '@wordpress/element';
* Internal dependencies
*/
import { ALLOWED_FILE_EXTENSIONS } from './utils/constants';
-import { FontLibraryContext } from './context';
+import { FontLibraryContext } from '../font-library-provider';
import { Font } from '../../../../lib/lib-font.browser';
import makeFamiliesFromFaces from './utils/make-families-from-faces';
import { loadFontFaceInBrowser } from './utils';
diff --git a/packages/edit-site/src/components/global-styles/font-library-modal/context.js b/packages/edit-site/src/components/global-styles/font-library-provider.js
similarity index 97%
rename from packages/edit-site/src/components/global-styles/font-library-modal/context.js
rename to packages/edit-site/src/components/global-styles/font-library-provider.js
index 2b9efd2ddccd69..0e06c1c127c235 100644
--- a/packages/edit-site/src/components/global-styles/font-library-modal/context.js
+++ b/packages/edit-site/src/components/global-styles/font-library-provider.js
@@ -20,8 +20,8 @@ import {
fetchUninstallFontFamily,
fetchFontCollections,
fetchFontCollection,
-} from './resolvers';
-import { unlock } from '../../../lock-unlock';
+} from './font-library-modal/resolvers';
+import { unlock } from '../../lock-unlock';
const { useGlobalSetting } = unlock( blockEditorPrivateApis );
import {
setUIValuesNeeded,
@@ -32,8 +32,8 @@ import {
makeFontFamilyFormData,
batchInstallFontFaces,
checkFontFaceInstalled,
-} from './utils';
-import { toggleFont } from './utils/toggleFont';
+} from './font-library-modal/utils';
+import { toggleFont } from './font-library-modal/utils/toggleFont';
export const FontLibraryContext = createContext( {} );
@@ -110,7 +110,6 @@ function FontLibraryProvider( { children } ) {
};
// Library Fonts
- const [ modalTabOpen, setModalTabOpen ] = useState( false );
const [ libraryFontSelected, setLibraryFontSelected ] = useState( null );
const baseThemeFonts = baseFontFamilies?.theme
@@ -137,12 +136,6 @@ function FontLibraryProvider( { children } ) {
.sort( ( a, b ) => a.name.localeCompare( b.name ) )
: [];
- useEffect( () => {
- if ( ! modalTabOpen ) {
- setLibraryFontSelected( null );
- }
- }, [ modalTabOpen ] );
-
const handleSetLibraryFontSelected = ( font ) => {
setNotice( null );
@@ -164,10 +157,6 @@ function FontLibraryProvider( { children } ) {
} );
};
- const toggleModal = ( tabName ) => {
- setModalTabOpen( tabName || null );
- };
-
// Demo
const [ loadedFontUrls ] = useState( new Set() );
@@ -480,8 +469,6 @@ function FontLibraryProvider( { children } ) {
uninstallFontFamily,
toggleActivateFont,
getAvailableFontsOutline,
- modalTabOpen,
- toggleModal,
refreshLibrary,
notice,
setNotice,
diff --git a/packages/edit-site/src/components/layout/index.js b/packages/edit-site/src/components/layout/index.js
index 163d4fe6e938ff..6fa016b0824aff 100644
--- a/packages/edit-site/src/components/layout/index.js
+++ b/packages/edit-site/src/components/layout/index.js
@@ -52,6 +52,7 @@ import { useCommonCommands } from '../../hooks/commands/use-common-commands';
import { useEditModeCommands } from '../../hooks/commands/use-edit-mode-commands';
import { useIsSiteEditorLoading } from './hooks';
import useLayoutAreas from './router';
+import FontLibraryModal from '../global-styles/font-library-modal';
const { useCommands } = unlock( coreCommandsPrivateApis );
const { useCommandContext } = unlock( commandsPrivateApis );
@@ -159,6 +160,7 @@ export default function Layout() {
return (
<>
+
{ fullResizer }