@wordpress/edit-site 5.28.3 → 5.28.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/build/components/global-styles/font-library-modal/collection-font-variant.js +2 -2
- package/build/components/global-styles/font-library-modal/collection-font-variant.js.map +1 -1
- package/build/components/global-styles/font-library-modal/context.js +51 -58
- package/build/components/global-styles/font-library-modal/context.js.map +1 -1
- package/build/components/global-styles/font-library-modal/font-card.js +10 -15
- package/build/components/global-styles/font-library-modal/font-card.js.map +1 -1
- package/build/components/global-styles/font-library-modal/font-collection.js +115 -62
- package/build/components/global-styles/font-library-modal/font-collection.js.map +1 -1
- package/build/components/global-styles/font-library-modal/font-demo.js +29 -8
- package/build/components/global-styles/font-library-modal/font-demo.js.map +1 -1
- package/build/components/global-styles/font-library-modal/index.js +17 -4
- package/build/components/global-styles/font-library-modal/index.js.map +1 -1
- package/build/components/global-styles/font-library-modal/installed-fonts.js +151 -79
- package/build/components/global-styles/font-library-modal/installed-fonts.js.map +1 -1
- package/build/components/global-styles/font-library-modal/library-font-variant.js +2 -2
- package/build/components/global-styles/font-library-modal/library-font-variant.js.map +1 -1
- package/build/components/global-styles/font-library-modal/upload-fonts.js +8 -14
- package/build/components/global-styles/font-library-modal/upload-fonts.js.map +1 -1
- package/build/components/global-styles/font-library-modal/utils/index.js +11 -4
- package/build/components/global-styles/font-library-modal/utils/index.js.map +1 -1
- package/build/components/global-styles/screen-revisions/index.js +2 -2
- package/build/components/global-styles/screen-revisions/index.js.map +1 -1
- package/build/components/global-styles/ui.js +27 -2
- package/build/components/global-styles/ui.js.map +1 -1
- package/build/components/header-edit-mode/index.js +1 -1
- package/build/components/header-edit-mode/index.js.map +1 -1
- package/build/components/page-patterns/index.js +14 -14
- package/build/components/page-patterns/index.js.map +1 -1
- package/build/components/resizable-frame/index.js +2 -1
- package/build/components/resizable-frame/index.js.map +1 -1
- package/build/components/sidebar/index.js +3 -2
- package/build/components/sidebar/index.js.map +1 -1
- package/build/components/sidebar-dataviews/default-views.js +2 -0
- package/build/components/sidebar-dataviews/default-views.js.map +1 -1
- package/build/components/sidebar-navigation-screen-templates-browse/content.js +2 -2
- package/build/components/sidebar-navigation-screen-templates-browse/content.js.map +1 -1
- package/build/components/sidebar-navigation-screen-templates-browse/index.js +7 -5
- package/build/components/sidebar-navigation-screen-templates-browse/index.js.map +1 -1
- package/build/components/style-book/index.js +2 -0
- package/build/components/style-book/index.js.map +1 -1
- package/build-module/components/global-styles/font-library-modal/collection-font-variant.js +4 -4
- package/build-module/components/global-styles/font-library-modal/collection-font-variant.js.map +1 -1
- package/build-module/components/global-styles/font-library-modal/context.js +51 -58
- package/build-module/components/global-styles/font-library-modal/context.js.map +1 -1
- package/build-module/components/global-styles/font-library-modal/font-card.js +11 -16
- package/build-module/components/global-styles/font-library-modal/font-card.js.map +1 -1
- package/build-module/components/global-styles/font-library-modal/font-collection.js +118 -65
- package/build-module/components/global-styles/font-library-modal/font-collection.js.map +1 -1
- package/build-module/components/global-styles/font-library-modal/font-demo.js +30 -9
- package/build-module/components/global-styles/font-library-modal/font-demo.js.map +1 -1
- package/build-module/components/global-styles/font-library-modal/index.js +17 -4
- package/build-module/components/global-styles/font-library-modal/index.js.map +1 -1
- package/build-module/components/global-styles/font-library-modal/installed-fonts.js +151 -79
- package/build-module/components/global-styles/font-library-modal/installed-fonts.js.map +1 -1
- package/build-module/components/global-styles/font-library-modal/library-font-variant.js +4 -4
- package/build-module/components/global-styles/font-library-modal/library-font-variant.js.map +1 -1
- package/build-module/components/global-styles/font-library-modal/upload-fonts.js +9 -15
- package/build-module/components/global-styles/font-library-modal/upload-fonts.js.map +1 -1
- package/build-module/components/global-styles/font-library-modal/utils/index.js +11 -4
- package/build-module/components/global-styles/font-library-modal/utils/index.js.map +1 -1
- package/build-module/components/global-styles/screen-revisions/index.js +2 -2
- package/build-module/components/global-styles/screen-revisions/index.js.map +1 -1
- package/build-module/components/global-styles/ui.js +27 -2
- package/build-module/components/global-styles/ui.js.map +1 -1
- package/build-module/components/header-edit-mode/index.js +1 -1
- package/build-module/components/header-edit-mode/index.js.map +1 -1
- package/build-module/components/page-patterns/index.js +14 -14
- package/build-module/components/page-patterns/index.js.map +1 -1
- package/build-module/components/resizable-frame/index.js +2 -1
- package/build-module/components/resizable-frame/index.js.map +1 -1
- package/build-module/components/sidebar/index.js +3 -2
- package/build-module/components/sidebar/index.js.map +1 -1
- package/build-module/components/sidebar-dataviews/default-views.js +3 -1
- package/build-module/components/sidebar-dataviews/default-views.js.map +1 -1
- package/build-module/components/sidebar-navigation-screen-templates-browse/content.js +2 -2
- package/build-module/components/sidebar-navigation-screen-templates-browse/content.js.map +1 -1
- package/build-module/components/sidebar-navigation-screen-templates-browse/index.js +7 -5
- package/build-module/components/sidebar-navigation-screen-templates-browse/index.js.map +1 -1
- package/build-module/components/style-book/index.js +2 -0
- package/build-module/components/style-book/index.js.map +1 -1
- package/build-style/style-rtl.css +36 -23
- package/build-style/style.css +36 -23
- package/package.json +18 -18
- package/src/components/global-styles/font-library-modal/collection-font-variant.js +4 -4
- package/src/components/global-styles/font-library-modal/context.js +92 -104
- package/src/components/global-styles/font-library-modal/font-card.js +11 -26
- package/src/components/global-styles/font-library-modal/font-collection.js +307 -211
- package/src/components/global-styles/font-library-modal/font-demo.js +38 -4
- package/src/components/global-styles/font-library-modal/index.js +21 -14
- package/src/components/global-styles/font-library-modal/installed-fonts.js +243 -114
- package/src/components/global-styles/font-library-modal/library-font-variant.js +4 -4
- package/src/components/global-styles/font-library-modal/style.scss +15 -8
- package/src/components/global-styles/font-library-modal/upload-fonts.js +16 -18
- package/src/components/global-styles/font-library-modal/utils/index.js +10 -4
- package/src/components/global-styles/font-library-modal/utils/test/getDisplaySrcFromFontFace.spec.js +7 -18
- package/src/components/global-styles/screen-revisions/index.js +5 -2
- package/src/components/global-styles/ui.js +26 -2
- package/src/components/header-edit-mode/index.js +3 -1
- package/src/components/page-patterns/index.js +20 -20
- package/src/components/resizable-frame/index.js +1 -0
- package/src/components/sidebar/index.js +2 -1
- package/src/components/sidebar-dataviews/default-views.js +3 -1
- package/src/components/sidebar-navigation-screen-templates-browse/content.js +2 -2
- package/src/components/sidebar-navigation-screen-templates-browse/index.js +5 -3
- package/src/components/style-book/index.js +5 -1
- package/build/components/global-styles/font-library-modal/collection-font-details.js +0 -50
- package/build/components/global-styles/font-library-modal/collection-font-details.js.map +0 -1
- package/build/components/global-styles/font-library-modal/confirm-delete-dialog.js +0 -30
- package/build/components/global-styles/font-library-modal/confirm-delete-dialog.js.map +0 -1
- package/build/components/global-styles/font-library-modal/library-font-card.js +0 -39
- package/build/components/global-styles/font-library-modal/library-font-card.js.map +0 -1
- package/build/components/global-styles/font-library-modal/tab-panel-layout.js +0 -67
- package/build/components/global-styles/font-library-modal/tab-panel-layout.js.map +0 -1
- package/build-module/components/global-styles/font-library-modal/collection-font-details.js +0 -42
- package/build-module/components/global-styles/font-library-modal/collection-font-details.js.map +0 -1
- package/build-module/components/global-styles/font-library-modal/confirm-delete-dialog.js +0 -23
- package/build-module/components/global-styles/font-library-modal/confirm-delete-dialog.js.map +0 -1
- package/build-module/components/global-styles/font-library-modal/library-font-card.js +0 -31
- package/build-module/components/global-styles/font-library-modal/library-font-card.js.map +0 -1
- package/build-module/components/global-styles/font-library-modal/tab-panel-layout.js +0 -60
- package/build-module/components/global-styles/font-library-modal/tab-panel-layout.js.map +0 -1
- package/src/components/global-styles/font-library-modal/collection-font-details.js +0 -56
- package/src/components/global-styles/font-library-modal/confirm-delete-dialog.js +0 -33
- package/src/components/global-styles/font-library-modal/library-font-card.js +0 -34
- package/src/components/global-styles/font-library-modal/tab-panel-layout.js +0 -85
|
@@ -8,7 +8,10 @@ import { useContext, useEffect, useState, useRef } from '@wordpress/element';
|
|
|
8
8
|
* Internal dependencies
|
|
9
9
|
*/
|
|
10
10
|
import { FontLibraryContext } from './context';
|
|
11
|
-
import {
|
|
11
|
+
import {
|
|
12
|
+
getFacePreviewStyle,
|
|
13
|
+
getFamilyPreviewStyle,
|
|
14
|
+
} from './utils/preview-styles';
|
|
12
15
|
|
|
13
16
|
function getPreviewUrl( fontFace ) {
|
|
14
17
|
if ( fontFace.preview ) {
|
|
@@ -19,8 +22,39 @@ function getPreviewUrl( fontFace ) {
|
|
|
19
22
|
}
|
|
20
23
|
}
|
|
21
24
|
|
|
22
|
-
function
|
|
25
|
+
function getDisplayFontFace( font ) {
|
|
26
|
+
// if this IS a font face return it
|
|
27
|
+
if ( font.fontStyle || font.fontWeight ) {
|
|
28
|
+
return font;
|
|
29
|
+
}
|
|
30
|
+
// if this is a font family with a collection of font faces
|
|
31
|
+
// return the first one that is normal and 400 OR just the first one
|
|
32
|
+
if ( font.fontFace && font.fontFace.length ) {
|
|
33
|
+
return (
|
|
34
|
+
font.fontFace.find(
|
|
35
|
+
( face ) =>
|
|
36
|
+
face.fontStyle === 'normal' && face.fontWeight === '400'
|
|
37
|
+
) || font.fontFace[ 0 ]
|
|
38
|
+
);
|
|
39
|
+
}
|
|
40
|
+
// This must be a font family with no font faces
|
|
41
|
+
// return a fake font face
|
|
42
|
+
return {
|
|
43
|
+
fontStyle: 'normal',
|
|
44
|
+
fontWeight: '400',
|
|
45
|
+
fontFamily: font.fontFamily,
|
|
46
|
+
fake: true,
|
|
47
|
+
};
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
function FontDemo( { font, text } ) {
|
|
23
51
|
const ref = useRef( null );
|
|
52
|
+
|
|
53
|
+
const fontFace = getDisplayFontFace( font );
|
|
54
|
+
const style = getFamilyPreviewStyle( font );
|
|
55
|
+
text = text || font.name;
|
|
56
|
+
const customPreviewUrl = font.preview;
|
|
57
|
+
|
|
24
58
|
const [ isIntersecting, setIsIntersecting ] = useState( false );
|
|
25
59
|
const [ isAssetLoaded, setIsAssetLoaded ] = useState( false );
|
|
26
60
|
const { loadFontFaceAsset } = useContext( FontLibraryContext );
|
|
@@ -34,8 +68,8 @@ function FontFaceDemo( { customPreviewUrl, fontFace, text, style = {} } ) {
|
|
|
34
68
|
fontSize: '18px',
|
|
35
69
|
lineHeight: 1,
|
|
36
70
|
opacity: isAssetLoaded ? '1' : '0',
|
|
37
|
-
...faceStyles,
|
|
38
71
|
...style,
|
|
72
|
+
...faceStyles,
|
|
39
73
|
};
|
|
40
74
|
|
|
41
75
|
useEffect( () => {
|
|
@@ -79,4 +113,4 @@ function FontFaceDemo( { customPreviewUrl, fontFace, text, style = {} } ) {
|
|
|
79
113
|
);
|
|
80
114
|
}
|
|
81
115
|
|
|
82
|
-
export default
|
|
116
|
+
export default FontDemo;
|
|
@@ -6,6 +6,8 @@ import {
|
|
|
6
6
|
Modal,
|
|
7
7
|
privateApis as componentsPrivateApis,
|
|
8
8
|
} from '@wordpress/components';
|
|
9
|
+
import { store as coreStore } from '@wordpress/core-data';
|
|
10
|
+
import { useSelect } from '@wordpress/data';
|
|
9
11
|
import { useContext } from '@wordpress/element';
|
|
10
12
|
|
|
11
13
|
/**
|
|
@@ -19,16 +21,15 @@ import { unlock } from '../../../lock-unlock';
|
|
|
19
21
|
|
|
20
22
|
const { Tabs } = unlock( componentsPrivateApis );
|
|
21
23
|
|
|
22
|
-
const
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
];
|
|
24
|
+
const DEFAULT_TAB = {
|
|
25
|
+
id: 'installed-fonts',
|
|
26
|
+
title: __( 'Library' ),
|
|
27
|
+
};
|
|
28
|
+
|
|
29
|
+
const UPLOAD_TAB = {
|
|
30
|
+
id: 'upload-fonts',
|
|
31
|
+
title: __( 'Upload' ),
|
|
32
|
+
};
|
|
32
33
|
|
|
33
34
|
const tabsFromCollections = ( collections ) =>
|
|
34
35
|
collections.map( ( { slug, name } ) => ( {
|
|
@@ -44,11 +45,17 @@ function FontLibraryModal( {
|
|
|
44
45
|
initialTabId = 'installed-fonts',
|
|
45
46
|
} ) {
|
|
46
47
|
const { collections, setNotice } = useContext( FontLibraryContext );
|
|
48
|
+
const canUserCreate = useSelect( ( select ) => {
|
|
49
|
+
const { canUser } = select( coreStore );
|
|
50
|
+
return canUser( 'create', 'font-families' );
|
|
51
|
+
}, [] );
|
|
52
|
+
|
|
53
|
+
const tabs = [ DEFAULT_TAB ];
|
|
47
54
|
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
...tabsFromCollections( collections || [] )
|
|
51
|
-
|
|
55
|
+
if ( canUserCreate ) {
|
|
56
|
+
tabs.push( UPLOAD_TAB );
|
|
57
|
+
tabs.push( ...tabsFromCollections( collections || [] ) );
|
|
58
|
+
}
|
|
52
59
|
|
|
53
60
|
// Reset notice when new tab is selected.
|
|
54
61
|
const onSelect = () => {
|
|
@@ -1,27 +1,37 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* WordPress dependencies
|
|
3
3
|
*/
|
|
4
|
-
import { __ } from '@wordpress/i18n';
|
|
5
|
-
import { useContext, useEffect, useState } from '@wordpress/element';
|
|
6
4
|
import {
|
|
7
|
-
|
|
5
|
+
Button,
|
|
6
|
+
__experimentalConfirmDialog as ConfirmDialog,
|
|
8
7
|
__experimentalHStack as HStack,
|
|
8
|
+
__experimentalHeading as Heading,
|
|
9
|
+
__experimentalNavigatorProvider as NavigatorProvider,
|
|
10
|
+
__experimentalNavigatorScreen as NavigatorScreen,
|
|
11
|
+
__experimentalNavigatorToParentButton as NavigatorToParentButton,
|
|
12
|
+
__experimentalUseNavigator as useNavigator,
|
|
9
13
|
__experimentalSpacer as Spacer,
|
|
10
14
|
__experimentalText as Text,
|
|
11
|
-
|
|
15
|
+
__experimentalVStack as VStack,
|
|
16
|
+
Flex,
|
|
17
|
+
Notice,
|
|
12
18
|
Spinner,
|
|
13
|
-
|
|
19
|
+
privateApis as componentsPrivateApis,
|
|
14
20
|
} from '@wordpress/components';
|
|
21
|
+
import { store as coreStore } from '@wordpress/core-data';
|
|
22
|
+
import { useSelect } from '@wordpress/data';
|
|
23
|
+
import { useContext, useEffect, useState } from '@wordpress/element';
|
|
24
|
+
import { __, sprintf } from '@wordpress/i18n';
|
|
25
|
+
import { chevronLeft } from '@wordpress/icons';
|
|
15
26
|
|
|
16
27
|
/**
|
|
17
28
|
* Internal dependencies
|
|
18
29
|
*/
|
|
19
|
-
import TabPanelLayout from './tab-panel-layout';
|
|
20
|
-
import { FontLibraryContext } from './context';
|
|
21
|
-
import LibraryFontDetails from './library-font-details';
|
|
22
|
-
import LibraryFontCard from './library-font-card';
|
|
23
|
-
import ConfirmDeleteDialog from './confirm-delete-dialog';
|
|
24
30
|
import { unlock } from '../../../lock-unlock';
|
|
31
|
+
import { FontLibraryContext } from './context';
|
|
32
|
+
import FontCard from './font-card';
|
|
33
|
+
import LibraryFontVariant from './library-font-variant';
|
|
34
|
+
import { sortFontFaces } from './utils/sort-font-faces';
|
|
25
35
|
const { ProgressBar } = unlock( componentsPrivateApis );
|
|
26
36
|
|
|
27
37
|
function InstalledFonts() {
|
|
@@ -33,102 +43,115 @@ function InstalledFonts() {
|
|
|
33
43
|
refreshLibrary,
|
|
34
44
|
uninstallFontFamily,
|
|
35
45
|
isResolvingLibrary,
|
|
46
|
+
isInstalling,
|
|
47
|
+
saveFontFamilies,
|
|
48
|
+
getFontFacesActivated,
|
|
49
|
+
fontFamiliesHasChanges,
|
|
36
50
|
notice,
|
|
37
51
|
setNotice,
|
|
38
52
|
} = useContext( FontLibraryContext );
|
|
39
53
|
const [ isConfirmDeleteOpen, setIsConfirmDeleteOpen ] = useState( false );
|
|
54
|
+
const customFontFamilyId =
|
|
55
|
+
libraryFontSelected?.source === 'custom' && libraryFontSelected?.id;
|
|
40
56
|
|
|
41
|
-
const
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
try {
|
|
53
|
-
await uninstallFontFamily( libraryFontSelected );
|
|
54
|
-
setNotice( {
|
|
55
|
-
type: 'success',
|
|
56
|
-
message: __( 'Font family uninstalled successfully.' ),
|
|
57
|
-
} );
|
|
57
|
+
const canUserDelete = useSelect(
|
|
58
|
+
( select ) => {
|
|
59
|
+
const { canUser } = select( coreStore );
|
|
60
|
+
return (
|
|
61
|
+
customFontFamilyId &&
|
|
62
|
+
canUser( 'delete', 'font-families', customFontFamilyId )
|
|
63
|
+
);
|
|
64
|
+
},
|
|
65
|
+
[ customFontFamilyId ]
|
|
66
|
+
);
|
|
58
67
|
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
setNotice( {
|
|
64
|
-
type: 'error',
|
|
65
|
-
message:
|
|
66
|
-
__( 'There was an error uninstalling the font family. ' ) +
|
|
67
|
-
error.message,
|
|
68
|
-
} );
|
|
69
|
-
}
|
|
70
|
-
};
|
|
68
|
+
const shouldDisplayDeleteButton =
|
|
69
|
+
!! libraryFontSelected &&
|
|
70
|
+
libraryFontSelected?.source !== 'theme' &&
|
|
71
|
+
canUserDelete;
|
|
71
72
|
|
|
72
|
-
const handleUninstallClick =
|
|
73
|
+
const handleUninstallClick = () => {
|
|
73
74
|
setIsConfirmDeleteOpen( true );
|
|
74
75
|
};
|
|
75
76
|
|
|
76
|
-
const
|
|
77
|
-
|
|
77
|
+
const getFontFacesToDisplay = ( font ) => {
|
|
78
|
+
if ( ! font ) {
|
|
79
|
+
return [];
|
|
80
|
+
}
|
|
81
|
+
if ( ! font.fontFace || ! font.fontFace.length ) {
|
|
82
|
+
return [
|
|
83
|
+
{
|
|
84
|
+
fontFamily: font.fontFamily,
|
|
85
|
+
fontStyle: 'normal',
|
|
86
|
+
fontWeight: '400',
|
|
87
|
+
},
|
|
88
|
+
];
|
|
89
|
+
}
|
|
90
|
+
return sortFontFaces( font.fontFace );
|
|
78
91
|
};
|
|
79
92
|
|
|
80
|
-
const
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
93
|
+
const getFontCardVariantsText = ( font ) => {
|
|
94
|
+
const variantsInstalled =
|
|
95
|
+
font?.fontFace?.length > 0 ? font.fontFace.length : 1;
|
|
96
|
+
const variantsActive = getFontFacesActivated(
|
|
97
|
+
font.slug,
|
|
98
|
+
font.source
|
|
99
|
+
).length;
|
|
100
|
+
return sprintf(
|
|
101
|
+
/* translators: 1: Active font variants, 2: Total font variants. */
|
|
102
|
+
__( '%1$s/%2$s variants active' ),
|
|
103
|
+
variantsActive,
|
|
104
|
+
variantsInstalled
|
|
105
|
+
);
|
|
106
|
+
};
|
|
88
107
|
|
|
89
108
|
useEffect( () => {
|
|
90
|
-
|
|
109
|
+
handleSetLibraryFontSelected( libraryFontSelected );
|
|
91
110
|
refreshLibrary();
|
|
92
|
-
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
93
111
|
}, [] );
|
|
94
112
|
|
|
95
113
|
return (
|
|
96
|
-
<
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
<Spinner />
|
|
121
|
-
<Spacer margin={ 2 } />
|
|
122
|
-
</FlexItem>
|
|
114
|
+
<div className="font-library-modal__tabpanel-layout">
|
|
115
|
+
{ isResolvingLibrary && (
|
|
116
|
+
<HStack align="center">
|
|
117
|
+
<Spacer />
|
|
118
|
+
<Spinner />
|
|
119
|
+
<Spacer />
|
|
120
|
+
</HStack>
|
|
121
|
+
) }
|
|
122
|
+
|
|
123
|
+
<NavigatorProvider
|
|
124
|
+
initialPath={ libraryFontSelected ? '/fontFamily' : '/' }
|
|
125
|
+
>
|
|
126
|
+
<NavigatorScreen path="/">
|
|
127
|
+
{ notice && (
|
|
128
|
+
<>
|
|
129
|
+
<Spacer margin={ 1 } />
|
|
130
|
+
<Notice
|
|
131
|
+
status={ notice.type }
|
|
132
|
+
onRemove={ () => setNotice( null ) }
|
|
133
|
+
>
|
|
134
|
+
{ notice.message }
|
|
135
|
+
</Notice>
|
|
136
|
+
<Spacer margin={ 1 } />
|
|
137
|
+
</>
|
|
123
138
|
) }
|
|
124
139
|
{ baseCustomFonts.length > 0 && (
|
|
125
140
|
<>
|
|
141
|
+
<Text className="font-library-modal__subtitle">
|
|
142
|
+
{ __( 'Installed Fonts' ) }
|
|
143
|
+
</Text>
|
|
144
|
+
<Spacer margin={ 2 } />
|
|
126
145
|
{ baseCustomFonts.map( ( font ) => (
|
|
127
|
-
<
|
|
146
|
+
<FontCard
|
|
128
147
|
font={ font }
|
|
129
148
|
key={ font.slug }
|
|
149
|
+
navigatorPath={ '/fontFamily' }
|
|
150
|
+
variantsText={ getFontCardVariantsText(
|
|
151
|
+
font
|
|
152
|
+
) }
|
|
130
153
|
onClick={ () => {
|
|
131
|
-
|
|
154
|
+
handleSetLibraryFontSelected( font );
|
|
132
155
|
} }
|
|
133
156
|
/>
|
|
134
157
|
) ) }
|
|
@@ -141,42 +164,93 @@ function InstalledFonts() {
|
|
|
141
164
|
<Text className="font-library-modal__subtitle">
|
|
142
165
|
{ __( 'Theme Fonts' ) }
|
|
143
166
|
</Text>
|
|
144
|
-
|
|
145
167
|
<Spacer margin={ 2 } />
|
|
146
168
|
{ baseThemeFonts.map( ( font ) => (
|
|
147
|
-
<
|
|
169
|
+
<FontCard
|
|
148
170
|
font={ font }
|
|
149
171
|
key={ font.slug }
|
|
172
|
+
navigatorPath={ '/fontFamily' }
|
|
173
|
+
variantsText={ getFontCardVariantsText(
|
|
174
|
+
font
|
|
175
|
+
) }
|
|
150
176
|
onClick={ () => {
|
|
151
|
-
|
|
177
|
+
handleSetLibraryFontSelected( font );
|
|
152
178
|
} }
|
|
153
179
|
/>
|
|
154
180
|
) ) }
|
|
155
181
|
</>
|
|
156
182
|
) }
|
|
157
183
|
<Spacer margin={ 16 } />
|
|
158
|
-
|
|
159
|
-
) }
|
|
184
|
+
</NavigatorScreen>
|
|
160
185
|
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
186
|
+
<NavigatorScreen path="/fontFamily">
|
|
187
|
+
<ConfirmDeleteDialog
|
|
188
|
+
font={ libraryFontSelected }
|
|
189
|
+
isOpen={ isConfirmDeleteOpen }
|
|
190
|
+
setIsOpen={ setIsConfirmDeleteOpen }
|
|
191
|
+
setNotice={ setNotice }
|
|
192
|
+
uninstallFontFamily={ uninstallFontFamily }
|
|
193
|
+
handleSetLibraryFontSelected={
|
|
194
|
+
handleSetLibraryFontSelected
|
|
195
|
+
}
|
|
196
|
+
/>
|
|
172
197
|
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
198
|
+
<Flex justify="flex-start">
|
|
199
|
+
<NavigatorToParentButton
|
|
200
|
+
icon={ chevronLeft }
|
|
201
|
+
isSmall
|
|
202
|
+
onClick={ () => {
|
|
203
|
+
handleSetLibraryFontSelected( null );
|
|
204
|
+
} }
|
|
205
|
+
aria-label={ __( 'Navigate to the previous view' ) }
|
|
206
|
+
/>
|
|
207
|
+
<Heading
|
|
208
|
+
level={ 2 }
|
|
209
|
+
size={ 13 }
|
|
210
|
+
className="edit-site-global-styles-header"
|
|
211
|
+
>
|
|
212
|
+
{ libraryFontSelected?.name }
|
|
213
|
+
</Heading>
|
|
214
|
+
</Flex>
|
|
215
|
+
{ notice && (
|
|
216
|
+
<>
|
|
217
|
+
<Spacer margin={ 1 } />
|
|
218
|
+
<Notice
|
|
219
|
+
status={ notice.type }
|
|
220
|
+
onRemove={ () => setNotice( null ) }
|
|
221
|
+
>
|
|
222
|
+
{ notice.message }
|
|
223
|
+
</Notice>
|
|
224
|
+
<Spacer margin={ 1 } />
|
|
225
|
+
</>
|
|
226
|
+
) }
|
|
227
|
+
<Spacer margin={ 4 } />
|
|
228
|
+
<Text>
|
|
229
|
+
{ __(
|
|
230
|
+
'Choose font variants. Keep in mind that too many variants could make your site slower.'
|
|
231
|
+
) }
|
|
232
|
+
</Text>
|
|
233
|
+
<Spacer margin={ 4 } />
|
|
234
|
+
<VStack spacing={ 0 }>
|
|
235
|
+
<Spacer margin={ 8 } />
|
|
236
|
+
{ getFontFacesToDisplay( libraryFontSelected ).map(
|
|
237
|
+
( face, i ) => (
|
|
238
|
+
<LibraryFontVariant
|
|
239
|
+
font={ libraryFontSelected }
|
|
240
|
+
face={ face }
|
|
241
|
+
key={ `face${ i }` }
|
|
242
|
+
/>
|
|
243
|
+
)
|
|
244
|
+
) }
|
|
245
|
+
</VStack>
|
|
246
|
+
</NavigatorScreen>
|
|
247
|
+
</NavigatorProvider>
|
|
248
|
+
|
|
249
|
+
<HStack
|
|
250
|
+
justify="flex-end"
|
|
251
|
+
className="font-library-modal__tabpanel-layout__footer"
|
|
252
|
+
>
|
|
253
|
+
{ isInstalling && <ProgressBar /> }
|
|
180
254
|
{ shouldDisplayDeleteButton && (
|
|
181
255
|
<Button
|
|
182
256
|
isDestructive
|
|
@@ -186,16 +260,71 @@ function Footer( { shouldDisplayDeleteButton, handleUninstallClick } ) {
|
|
|
186
260
|
{ __( 'Delete' ) }
|
|
187
261
|
</Button>
|
|
188
262
|
) }
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
</
|
|
198
|
-
</
|
|
263
|
+
<Button
|
|
264
|
+
variant="primary"
|
|
265
|
+
onClick={ saveFontFamilies }
|
|
266
|
+
disabled={ ! fontFamiliesHasChanges }
|
|
267
|
+
__experimentalIsFocusable
|
|
268
|
+
>
|
|
269
|
+
{ __( 'Update' ) }
|
|
270
|
+
</Button>
|
|
271
|
+
</HStack>
|
|
272
|
+
</div>
|
|
273
|
+
);
|
|
274
|
+
}
|
|
275
|
+
|
|
276
|
+
function ConfirmDeleteDialog( {
|
|
277
|
+
font,
|
|
278
|
+
isOpen,
|
|
279
|
+
setIsOpen,
|
|
280
|
+
setNotice,
|
|
281
|
+
uninstallFontFamily,
|
|
282
|
+
handleSetLibraryFontSelected,
|
|
283
|
+
} ) {
|
|
284
|
+
const navigator = useNavigator();
|
|
285
|
+
|
|
286
|
+
const handleConfirmUninstall = async () => {
|
|
287
|
+
setNotice( null );
|
|
288
|
+
setIsOpen( false );
|
|
289
|
+
try {
|
|
290
|
+
await uninstallFontFamily( font );
|
|
291
|
+
navigator.goBack();
|
|
292
|
+
handleSetLibraryFontSelected( null );
|
|
293
|
+
setNotice( {
|
|
294
|
+
type: 'success',
|
|
295
|
+
message: __( 'Font family uninstalled successfully.' ),
|
|
296
|
+
} );
|
|
297
|
+
} catch ( error ) {
|
|
298
|
+
setNotice( {
|
|
299
|
+
type: 'error',
|
|
300
|
+
message:
|
|
301
|
+
__( 'There was an error uninstalling the font family. ' ) +
|
|
302
|
+
error.message,
|
|
303
|
+
} );
|
|
304
|
+
}
|
|
305
|
+
};
|
|
306
|
+
|
|
307
|
+
const handleCancelUninstall = () => {
|
|
308
|
+
setIsOpen( false );
|
|
309
|
+
};
|
|
310
|
+
|
|
311
|
+
return (
|
|
312
|
+
<ConfirmDialog
|
|
313
|
+
isOpen={ isOpen }
|
|
314
|
+
cancelButtonText={ __( 'Cancel' ) }
|
|
315
|
+
confirmButtonText={ __( 'Delete' ) }
|
|
316
|
+
onCancel={ handleCancelUninstall }
|
|
317
|
+
onConfirm={ handleConfirmUninstall }
|
|
318
|
+
>
|
|
319
|
+
{ font &&
|
|
320
|
+
sprintf(
|
|
321
|
+
/* translators: %s: Name of the font. */
|
|
322
|
+
__(
|
|
323
|
+
'Are you sure you want to delete "%s" font and all its variants and assets?'
|
|
324
|
+
),
|
|
325
|
+
font.name
|
|
326
|
+
) }
|
|
327
|
+
</ConfirmDialog>
|
|
199
328
|
);
|
|
200
329
|
}
|
|
201
330
|
|
|
@@ -13,7 +13,7 @@ import {
|
|
|
13
13
|
*/
|
|
14
14
|
import { getFontFaceVariantName } from './utils';
|
|
15
15
|
import { FontLibraryContext } from './context';
|
|
16
|
-
import
|
|
16
|
+
import FontDemo from './font-demo';
|
|
17
17
|
import { unlock } from '../../../lock-unlock';
|
|
18
18
|
|
|
19
19
|
function LibraryFontVariant( { face, font } ) {
|
|
@@ -45,7 +45,7 @@ function LibraryFontVariant( { face, font } ) {
|
|
|
45
45
|
);
|
|
46
46
|
|
|
47
47
|
return (
|
|
48
|
-
<div className="font-library-
|
|
48
|
+
<div className="font-library-modal__font-card">
|
|
49
49
|
<Flex justify="flex-start" align="center" gap="1rem">
|
|
50
50
|
<CheckboxControl
|
|
51
51
|
checked={ isInstalled }
|
|
@@ -54,8 +54,8 @@ function LibraryFontVariant( { face, font } ) {
|
|
|
54
54
|
id={ checkboxId }
|
|
55
55
|
/>
|
|
56
56
|
<label htmlFor={ checkboxId }>
|
|
57
|
-
<
|
|
58
|
-
|
|
57
|
+
<FontDemo
|
|
58
|
+
font={ face }
|
|
59
59
|
text={ displayName }
|
|
60
60
|
onClick={ handleToggleActivation }
|
|
61
61
|
/>
|
|
@@ -22,9 +22,17 @@
|
|
|
22
22
|
font-weight: 500;
|
|
23
23
|
font-size: 11px;
|
|
24
24
|
}
|
|
25
|
+
|
|
26
|
+
// Add padding so the focus state outline (box-shadow) of font list items is visible
|
|
27
|
+
.components-navigator-screen {
|
|
28
|
+
padding: 3px;
|
|
29
|
+
}
|
|
25
30
|
}
|
|
26
31
|
|
|
27
32
|
.font-library-modal__tabpanel-layout {
|
|
33
|
+
|
|
34
|
+
margin-top: $grid-unit-40;
|
|
35
|
+
|
|
28
36
|
.font-library-modal__tabpanel-layout__footer {
|
|
29
37
|
border-top: 1px solid $gray-300;
|
|
30
38
|
margin: 0 #{$grid-unit-40 * -1} #{$grid-unit-40 * -1};
|
|
@@ -47,6 +55,10 @@
|
|
|
47
55
|
padding: $grid-unit-20;
|
|
48
56
|
margin-top: -1px; /* To collapse the margin with the previous element */
|
|
49
57
|
|
|
58
|
+
&:hover {
|
|
59
|
+
background-color: $gray-100;
|
|
60
|
+
}
|
|
61
|
+
|
|
50
62
|
.font-library-modal__font-card__name {
|
|
51
63
|
font-weight: bold;
|
|
52
64
|
}
|
|
@@ -56,12 +68,6 @@
|
|
|
56
68
|
}
|
|
57
69
|
}
|
|
58
70
|
|
|
59
|
-
.font-library-modal__library-font-variant {
|
|
60
|
-
border: 1px solid $gray-200;
|
|
61
|
-
padding: $grid-unit-20;
|
|
62
|
-
margin-top: -1px; /* To collapse the margin with the previous element */
|
|
63
|
-
}
|
|
64
|
-
|
|
65
71
|
.font-library-modal__font-variant_demo-image {
|
|
66
72
|
display: block;
|
|
67
73
|
height: $grid-unit-30;
|
|
@@ -117,6 +123,7 @@ button.font-library-modal__upload-area {
|
|
|
117
123
|
display: flex;
|
|
118
124
|
justify-content: center;
|
|
119
125
|
align-items: center;
|
|
126
|
+
margin-top: $grid-unit-80;
|
|
120
127
|
|
|
121
128
|
h3 {
|
|
122
129
|
font-size: 1.4rem;
|
|
@@ -124,7 +131,7 @@ button.font-library-modal__upload-area {
|
|
|
124
131
|
|
|
125
132
|
.components-card {
|
|
126
133
|
width: 50%;
|
|
127
|
-
min-width:
|
|
128
|
-
max-width:
|
|
134
|
+
min-width: 350px;
|
|
135
|
+
max-width: 400px;
|
|
129
136
|
}
|
|
130
137
|
}
|