@wordpress/edit-site 5.28.3 → 5.28.4
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/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 +113 -60
- 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/installed-fonts.js +142 -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 +6 -4
- package/build/components/global-styles/font-library-modal/upload-fonts.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/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/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 +116 -63
- 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/installed-fonts.js +142 -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 +7 -5
- package/build-module/components/global-styles/font-library-modal/upload-fonts.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/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 +28 -22
- package/build-style/style.css +28 -22
- 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/font-card.js +11 -26
- package/src/components/global-styles/font-library-modal/font-collection.js +304 -210
- package/src/components/global-styles/font-library-modal/font-demo.js +38 -4
- package/src/components/global-styles/font-library-modal/installed-fonts.js +226 -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 +13 -5
- 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/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
|
@@ -1,27 +1,35 @@
|
|
|
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 { useContext, useEffect, useState } from '@wordpress/element';
|
|
22
|
+
import { __, sprintf } from '@wordpress/i18n';
|
|
23
|
+
import { chevronLeft } from '@wordpress/icons';
|
|
15
24
|
|
|
16
25
|
/**
|
|
17
26
|
* Internal dependencies
|
|
18
27
|
*/
|
|
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
28
|
import { unlock } from '../../../lock-unlock';
|
|
29
|
+
import { FontLibraryContext } from './context';
|
|
30
|
+
import FontCard from './font-card';
|
|
31
|
+
import LibraryFontVariant from './library-font-variant';
|
|
32
|
+
import { sortFontFaces } from './utils/sort-font-faces';
|
|
25
33
|
const { ProgressBar } = unlock( componentsPrivateApis );
|
|
26
34
|
|
|
27
35
|
function InstalledFonts() {
|
|
@@ -33,102 +41,100 @@ function InstalledFonts() {
|
|
|
33
41
|
refreshLibrary,
|
|
34
42
|
uninstallFontFamily,
|
|
35
43
|
isResolvingLibrary,
|
|
44
|
+
isInstalling,
|
|
45
|
+
saveFontFamilies,
|
|
46
|
+
getFontFacesActivated,
|
|
47
|
+
fontFamiliesHasChanges,
|
|
36
48
|
notice,
|
|
37
49
|
setNotice,
|
|
38
50
|
} = useContext( FontLibraryContext );
|
|
39
51
|
const [ isConfirmDeleteOpen, setIsConfirmDeleteOpen ] = useState( false );
|
|
40
52
|
|
|
41
|
-
const
|
|
42
|
-
|
|
43
|
-
};
|
|
53
|
+
const shouldDisplayDeleteButton =
|
|
54
|
+
!! libraryFontSelected && libraryFontSelected?.source !== 'theme';
|
|
44
55
|
|
|
45
|
-
const
|
|
46
|
-
|
|
56
|
+
const handleUninstallClick = () => {
|
|
57
|
+
setIsConfirmDeleteOpen( true );
|
|
47
58
|
};
|
|
48
59
|
|
|
49
|
-
const
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
try {
|
|
53
|
-
await uninstallFontFamily( libraryFontSelected );
|
|
54
|
-
setNotice( {
|
|
55
|
-
type: 'success',
|
|
56
|
-
message: __( 'Font family uninstalled successfully.' ),
|
|
57
|
-
} );
|
|
58
|
-
|
|
59
|
-
// If the font was succesfully uninstalled it is unselected.
|
|
60
|
-
handleUnselectFont();
|
|
61
|
-
setIsConfirmDeleteOpen( false );
|
|
62
|
-
} catch ( error ) {
|
|
63
|
-
setNotice( {
|
|
64
|
-
type: 'error',
|
|
65
|
-
message:
|
|
66
|
-
__( 'There was an error uninstalling the font family. ' ) +
|
|
67
|
-
error.message,
|
|
68
|
-
} );
|
|
60
|
+
const getFontFacesToDisplay = ( font ) => {
|
|
61
|
+
if ( ! font ) {
|
|
62
|
+
return [];
|
|
69
63
|
}
|
|
64
|
+
if ( ! font.fontFace || ! font.fontFace.length ) {
|
|
65
|
+
return [
|
|
66
|
+
{
|
|
67
|
+
fontFamily: font.fontFamily,
|
|
68
|
+
fontStyle: 'normal',
|
|
69
|
+
fontWeight: '400',
|
|
70
|
+
},
|
|
71
|
+
];
|
|
72
|
+
}
|
|
73
|
+
return sortFontFaces( font.fontFace );
|
|
70
74
|
};
|
|
71
75
|
|
|
72
|
-
const
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
76
|
+
const getFontCardVariantsText = ( font ) => {
|
|
77
|
+
const variantsInstalled =
|
|
78
|
+
font?.fontFace?.length > 0 ? font.fontFace.length : 1;
|
|
79
|
+
const variantsActive = getFontFacesActivated(
|
|
80
|
+
font.slug,
|
|
81
|
+
font.source
|
|
82
|
+
).length;
|
|
83
|
+
return sprintf(
|
|
84
|
+
/* translators: 1: Active font variants, 2: Total font variants. */
|
|
85
|
+
__( '%1$s/%2$s variants active' ),
|
|
86
|
+
variantsActive,
|
|
87
|
+
variantsInstalled
|
|
88
|
+
);
|
|
78
89
|
};
|
|
79
90
|
|
|
80
|
-
const tabDescription = !! libraryFontSelected
|
|
81
|
-
? __(
|
|
82
|
-
'Choose font variants. Keep in mind that too many variants could make your site slower.'
|
|
83
|
-
)
|
|
84
|
-
: null;
|
|
85
|
-
|
|
86
|
-
const shouldDisplayDeleteButton =
|
|
87
|
-
!! libraryFontSelected && libraryFontSelected?.source !== 'theme';
|
|
88
|
-
|
|
89
91
|
useEffect( () => {
|
|
90
|
-
|
|
92
|
+
handleSetLibraryFontSelected( libraryFontSelected );
|
|
91
93
|
refreshLibrary();
|
|
92
|
-
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
93
94
|
}, [] );
|
|
94
95
|
|
|
95
96
|
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>
|
|
97
|
+
<div className="font-library-modal__tabpanel-layout">
|
|
98
|
+
{ isResolvingLibrary && (
|
|
99
|
+
<HStack align="center">
|
|
100
|
+
<Spacer />
|
|
101
|
+
<Spinner />
|
|
102
|
+
<Spacer />
|
|
103
|
+
</HStack>
|
|
104
|
+
) }
|
|
105
|
+
|
|
106
|
+
<NavigatorProvider
|
|
107
|
+
initialPath={ libraryFontSelected ? '/fontFamily' : '/' }
|
|
108
|
+
>
|
|
109
|
+
<NavigatorScreen path="/">
|
|
110
|
+
{ notice && (
|
|
111
|
+
<>
|
|
112
|
+
<Spacer margin={ 1 } />
|
|
113
|
+
<Notice
|
|
114
|
+
status={ notice.type }
|
|
115
|
+
onRemove={ () => setNotice( null ) }
|
|
116
|
+
>
|
|
117
|
+
{ notice.message }
|
|
118
|
+
</Notice>
|
|
119
|
+
<Spacer margin={ 1 } />
|
|
120
|
+
</>
|
|
123
121
|
) }
|
|
124
122
|
{ baseCustomFonts.length > 0 && (
|
|
125
123
|
<>
|
|
124
|
+
<Text className="font-library-modal__subtitle">
|
|
125
|
+
{ __( 'Installed Fonts' ) }
|
|
126
|
+
</Text>
|
|
127
|
+
<Spacer margin={ 2 } />
|
|
126
128
|
{ baseCustomFonts.map( ( font ) => (
|
|
127
|
-
<
|
|
129
|
+
<FontCard
|
|
128
130
|
font={ font }
|
|
129
131
|
key={ font.slug }
|
|
132
|
+
navigatorPath={ '/fontFamily' }
|
|
133
|
+
variantsText={ getFontCardVariantsText(
|
|
134
|
+
font
|
|
135
|
+
) }
|
|
130
136
|
onClick={ () => {
|
|
131
|
-
|
|
137
|
+
handleSetLibraryFontSelected( font );
|
|
132
138
|
} }
|
|
133
139
|
/>
|
|
134
140
|
) ) }
|
|
@@ -141,42 +147,93 @@ function InstalledFonts() {
|
|
|
141
147
|
<Text className="font-library-modal__subtitle">
|
|
142
148
|
{ __( 'Theme Fonts' ) }
|
|
143
149
|
</Text>
|
|
144
|
-
|
|
145
150
|
<Spacer margin={ 2 } />
|
|
146
151
|
{ baseThemeFonts.map( ( font ) => (
|
|
147
|
-
<
|
|
152
|
+
<FontCard
|
|
148
153
|
font={ font }
|
|
149
154
|
key={ font.slug }
|
|
155
|
+
navigatorPath={ '/fontFamily' }
|
|
156
|
+
variantsText={ getFontCardVariantsText(
|
|
157
|
+
font
|
|
158
|
+
) }
|
|
150
159
|
onClick={ () => {
|
|
151
|
-
|
|
160
|
+
handleSetLibraryFontSelected( font );
|
|
152
161
|
} }
|
|
153
162
|
/>
|
|
154
163
|
) ) }
|
|
155
164
|
</>
|
|
156
165
|
) }
|
|
157
166
|
<Spacer margin={ 16 } />
|
|
158
|
-
|
|
159
|
-
) }
|
|
167
|
+
</NavigatorScreen>
|
|
160
168
|
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
169
|
+
<NavigatorScreen path="/fontFamily">
|
|
170
|
+
<ConfirmDeleteDialog
|
|
171
|
+
font={ libraryFontSelected }
|
|
172
|
+
isOpen={ isConfirmDeleteOpen }
|
|
173
|
+
setIsOpen={ setIsConfirmDeleteOpen }
|
|
174
|
+
setNotice={ setNotice }
|
|
175
|
+
uninstallFontFamily={ uninstallFontFamily }
|
|
176
|
+
handleSetLibraryFontSelected={
|
|
177
|
+
handleSetLibraryFontSelected
|
|
178
|
+
}
|
|
179
|
+
/>
|
|
172
180
|
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
181
|
+
<Flex justify="flex-start">
|
|
182
|
+
<NavigatorToParentButton
|
|
183
|
+
icon={ chevronLeft }
|
|
184
|
+
isSmall
|
|
185
|
+
onClick={ () => {
|
|
186
|
+
handleSetLibraryFontSelected( null );
|
|
187
|
+
} }
|
|
188
|
+
aria-label={ __( 'Navigate to the previous view' ) }
|
|
189
|
+
/>
|
|
190
|
+
<Heading
|
|
191
|
+
level={ 2 }
|
|
192
|
+
size={ 13 }
|
|
193
|
+
className="edit-site-global-styles-header"
|
|
194
|
+
>
|
|
195
|
+
{ libraryFontSelected?.name }
|
|
196
|
+
</Heading>
|
|
197
|
+
</Flex>
|
|
198
|
+
{ notice && (
|
|
199
|
+
<>
|
|
200
|
+
<Spacer margin={ 1 } />
|
|
201
|
+
<Notice
|
|
202
|
+
status={ notice.type }
|
|
203
|
+
onRemove={ () => setNotice( null ) }
|
|
204
|
+
>
|
|
205
|
+
{ notice.message }
|
|
206
|
+
</Notice>
|
|
207
|
+
<Spacer margin={ 1 } />
|
|
208
|
+
</>
|
|
209
|
+
) }
|
|
210
|
+
<Spacer margin={ 4 } />
|
|
211
|
+
<Text>
|
|
212
|
+
{ __(
|
|
213
|
+
'Choose font variants. Keep in mind that too many variants could make your site slower.'
|
|
214
|
+
) }
|
|
215
|
+
</Text>
|
|
216
|
+
<Spacer margin={ 4 } />
|
|
217
|
+
<VStack spacing={ 0 }>
|
|
218
|
+
<Spacer margin={ 8 } />
|
|
219
|
+
{ getFontFacesToDisplay( libraryFontSelected ).map(
|
|
220
|
+
( face, i ) => (
|
|
221
|
+
<LibraryFontVariant
|
|
222
|
+
font={ libraryFontSelected }
|
|
223
|
+
face={ face }
|
|
224
|
+
key={ `face${ i }` }
|
|
225
|
+
/>
|
|
226
|
+
)
|
|
227
|
+
) }
|
|
228
|
+
</VStack>
|
|
229
|
+
</NavigatorScreen>
|
|
230
|
+
</NavigatorProvider>
|
|
231
|
+
|
|
232
|
+
<HStack
|
|
233
|
+
justify="flex-end"
|
|
234
|
+
className="font-library-modal__tabpanel-layout__footer"
|
|
235
|
+
>
|
|
236
|
+
{ isInstalling && <ProgressBar /> }
|
|
180
237
|
{ shouldDisplayDeleteButton && (
|
|
181
238
|
<Button
|
|
182
239
|
isDestructive
|
|
@@ -186,16 +243,71 @@ function Footer( { shouldDisplayDeleteButton, handleUninstallClick } ) {
|
|
|
186
243
|
{ __( 'Delete' ) }
|
|
187
244
|
</Button>
|
|
188
245
|
) }
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
</
|
|
198
|
-
</
|
|
246
|
+
<Button
|
|
247
|
+
variant="primary"
|
|
248
|
+
onClick={ saveFontFamilies }
|
|
249
|
+
disabled={ ! fontFamiliesHasChanges }
|
|
250
|
+
__experimentalIsFocusable
|
|
251
|
+
>
|
|
252
|
+
{ __( 'Update' ) }
|
|
253
|
+
</Button>
|
|
254
|
+
</HStack>
|
|
255
|
+
</div>
|
|
256
|
+
);
|
|
257
|
+
}
|
|
258
|
+
|
|
259
|
+
function ConfirmDeleteDialog( {
|
|
260
|
+
font,
|
|
261
|
+
isOpen,
|
|
262
|
+
setIsOpen,
|
|
263
|
+
setNotice,
|
|
264
|
+
uninstallFontFamily,
|
|
265
|
+
handleSetLibraryFontSelected,
|
|
266
|
+
} ) {
|
|
267
|
+
const navigator = useNavigator();
|
|
268
|
+
|
|
269
|
+
const handleConfirmUninstall = async () => {
|
|
270
|
+
setNotice( null );
|
|
271
|
+
setIsOpen( false );
|
|
272
|
+
try {
|
|
273
|
+
await uninstallFontFamily( font );
|
|
274
|
+
navigator.goBack();
|
|
275
|
+
handleSetLibraryFontSelected( null );
|
|
276
|
+
setNotice( {
|
|
277
|
+
type: 'success',
|
|
278
|
+
message: __( 'Font family uninstalled successfully.' ),
|
|
279
|
+
} );
|
|
280
|
+
} catch ( error ) {
|
|
281
|
+
setNotice( {
|
|
282
|
+
type: 'error',
|
|
283
|
+
message:
|
|
284
|
+
__( 'There was an error uninstalling the font family. ' ) +
|
|
285
|
+
error.message,
|
|
286
|
+
} );
|
|
287
|
+
}
|
|
288
|
+
};
|
|
289
|
+
|
|
290
|
+
const handleCancelUninstall = () => {
|
|
291
|
+
setIsOpen( false );
|
|
292
|
+
};
|
|
293
|
+
|
|
294
|
+
return (
|
|
295
|
+
<ConfirmDialog
|
|
296
|
+
isOpen={ isOpen }
|
|
297
|
+
cancelButtonText={ __( 'Cancel' ) }
|
|
298
|
+
confirmButtonText={ __( 'Delete' ) }
|
|
299
|
+
onCancel={ handleCancelUninstall }
|
|
300
|
+
onConfirm={ handleConfirmUninstall }
|
|
301
|
+
>
|
|
302
|
+
{ font &&
|
|
303
|
+
sprintf(
|
|
304
|
+
/* translators: %s: Name of the font. */
|
|
305
|
+
__(
|
|
306
|
+
'Are you sure you want to delete "%s" font and all its variants and assets?'
|
|
307
|
+
),
|
|
308
|
+
font.name
|
|
309
|
+
) }
|
|
310
|
+
</ConfirmDialog>
|
|
199
311
|
);
|
|
200
312
|
}
|
|
201
313
|
|
|
@@ -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
|
}
|
|
@@ -3,11 +3,12 @@
|
|
|
3
3
|
*/
|
|
4
4
|
import { __ } from '@wordpress/i18n';
|
|
5
5
|
import {
|
|
6
|
-
Button,
|
|
7
|
-
DropZone,
|
|
8
6
|
__experimentalSpacer as Spacer,
|
|
9
7
|
__experimentalText as Text,
|
|
10
8
|
__experimentalVStack as VStack,
|
|
9
|
+
Button,
|
|
10
|
+
DropZone,
|
|
11
|
+
Notice,
|
|
11
12
|
FormFileUpload,
|
|
12
13
|
FlexItem,
|
|
13
14
|
privateApis as componentsPrivateApis,
|
|
@@ -22,7 +23,6 @@ import { FontLibraryContext } from './context';
|
|
|
22
23
|
import { Font } from '../../../../lib/lib-font.browser';
|
|
23
24
|
import makeFamiliesFromFaces from './utils/make-families-from-faces';
|
|
24
25
|
import { loadFontFaceInBrowser } from './utils';
|
|
25
|
-
import TabPanelLayout from './tab-panel-layout';
|
|
26
26
|
import { unlock } from '../../../lock-unlock';
|
|
27
27
|
|
|
28
28
|
const { ProgressBar } = unlock( componentsPrivateApis );
|
|
@@ -171,9 +171,17 @@ function UploadFonts() {
|
|
|
171
171
|
};
|
|
172
172
|
|
|
173
173
|
return (
|
|
174
|
-
<
|
|
174
|
+
<div className="font-library-modal__tabpanel-layout">
|
|
175
175
|
<DropZone onFilesDrop={ handleDropZone } />
|
|
176
176
|
<VStack className="font-library-modal__local-fonts">
|
|
177
|
+
{ notice && (
|
|
178
|
+
<Notice
|
|
179
|
+
status={ notice.type }
|
|
180
|
+
onRemove={ () => setNotice( null ) }
|
|
181
|
+
>
|
|
182
|
+
{ notice.message }
|
|
183
|
+
</Notice>
|
|
184
|
+
) }
|
|
177
185
|
{ isUploading && (
|
|
178
186
|
<FlexItem>
|
|
179
187
|
<div className="font-library-modal__upload-area">
|
|
@@ -205,7 +213,7 @@ function UploadFonts() {
|
|
|
205
213
|
) }
|
|
206
214
|
</Text>
|
|
207
215
|
</VStack>
|
|
208
|
-
</
|
|
216
|
+
</div>
|
|
209
217
|
);
|
|
210
218
|
}
|
|
211
219
|
|
|
@@ -73,7 +73,11 @@ function ScreenRevisions() {
|
|
|
73
73
|
|
|
74
74
|
const onCloseRevisions = () => {
|
|
75
75
|
goTo( '/' ); // Return to global styles main panel.
|
|
76
|
-
|
|
76
|
+
const canvasContainerView =
|
|
77
|
+
editorCanvasContainerView === 'global-styles-revisions:style-book'
|
|
78
|
+
? 'style-book'
|
|
79
|
+
: undefined;
|
|
80
|
+
setEditorCanvasContainerView( canvasContainerView );
|
|
77
81
|
};
|
|
78
82
|
|
|
79
83
|
const restoreRevision = ( revision ) => {
|
|
@@ -99,7 +103,6 @@ function ScreenRevisions() {
|
|
|
99
103
|
! editorCanvasContainerView.startsWith( 'global-styles-revisions' )
|
|
100
104
|
) {
|
|
101
105
|
goTo( '/' ); // Return to global styles main panel.
|
|
102
|
-
setEditorCanvasContainerView( editorCanvasContainerView );
|
|
103
106
|
}
|
|
104
107
|
}, [ editorCanvasContainerView ] );
|
|
105
108
|
|
|
@@ -230,12 +230,14 @@ function GlobalStylesBlockLink() {
|
|
|
230
230
|
}
|
|
231
231
|
|
|
232
232
|
function GlobalStylesEditorCanvasContainerLink() {
|
|
233
|
-
const { goTo } = useNavigator();
|
|
233
|
+
const { goTo, location } = useNavigator();
|
|
234
234
|
const editorCanvasContainerView = useSelect(
|
|
235
235
|
( select ) =>
|
|
236
236
|
unlock( select( editSiteStore ) ).getEditorCanvasContainerView(),
|
|
237
237
|
[]
|
|
238
238
|
);
|
|
239
|
+
const path = location?.path;
|
|
240
|
+
const isRevisionsOpen = path === '/revisions';
|
|
239
241
|
|
|
240
242
|
// If the user switches the editor canvas container view, redirect
|
|
241
243
|
// to the appropriate screen. This effectively allows deep linking to the
|
|
@@ -249,11 +251,33 @@ function GlobalStylesEditorCanvasContainerLink() {
|
|
|
249
251
|
case 'global-styles-css':
|
|
250
252
|
goTo( '/css' );
|
|
251
253
|
break;
|
|
254
|
+
case 'style-book':
|
|
255
|
+
/*
|
|
256
|
+
* The stand-alone style book is open
|
|
257
|
+
* and the revisions panel is open,
|
|
258
|
+
* close the revisions panel.
|
|
259
|
+
* Otherwise keep the style book open while
|
|
260
|
+
* browsing global styles panel.
|
|
261
|
+
*/
|
|
262
|
+
if ( isRevisionsOpen ) {
|
|
263
|
+
goTo( '/' );
|
|
264
|
+
}
|
|
265
|
+
break;
|
|
252
266
|
default:
|
|
267
|
+
/*
|
|
268
|
+
* Example: the user has navigated to "Browse styles" or elsewhere
|
|
269
|
+
* and changes the editorCanvasContainerView, e.g., closes the style book.
|
|
270
|
+
* The panel should not be affected.
|
|
271
|
+
* Exclude revisions panel from this behavior,
|
|
272
|
+
* as it should close when the editorCanvasContainerView doesn't correspond.
|
|
273
|
+
*/
|
|
274
|
+
if ( path !== '/' && ! isRevisionsOpen ) {
|
|
275
|
+
return;
|
|
276
|
+
}
|
|
253
277
|
goTo( '/' );
|
|
254
278
|
break;
|
|
255
279
|
}
|
|
256
|
-
}, [ editorCanvasContainerView, goTo ] );
|
|
280
|
+
}, [ editorCanvasContainerView, isRevisionsOpen, goTo ] );
|
|
257
281
|
}
|
|
258
282
|
|
|
259
283
|
function GlobalStylesUI() {
|
|
@@ -134,7 +134,9 @@ export default function HeaderEditMode() {
|
|
|
134
134
|
className={ classnames(
|
|
135
135
|
'selected-block-tools-wrapper',
|
|
136
136
|
{
|
|
137
|
-
'is-collapsed':
|
|
137
|
+
'is-collapsed':
|
|
138
|
+
isBlockToolsCollapsed ||
|
|
139
|
+
! hasBlockSelected,
|
|
138
140
|
}
|
|
139
141
|
) }
|
|
140
142
|
>
|
|
@@ -210,6 +210,26 @@ function Title( { item, categoryId } ) {
|
|
|
210
210
|
}
|
|
211
211
|
return (
|
|
212
212
|
<HStack alignment="center" justify="flex-start" spacing={ 2 }>
|
|
213
|
+
<Flex
|
|
214
|
+
as="div"
|
|
215
|
+
gap={ 0 }
|
|
216
|
+
justify="left"
|
|
217
|
+
className="edit-site-patterns__pattern-title"
|
|
218
|
+
>
|
|
219
|
+
{ item.type === PATTERN_TYPES.theme ? (
|
|
220
|
+
item.title
|
|
221
|
+
) : (
|
|
222
|
+
<Button
|
|
223
|
+
variant="link"
|
|
224
|
+
onClick={ onClick }
|
|
225
|
+
// Required for the grid's roving tab index system.
|
|
226
|
+
// See https://github.com/WordPress/gutenberg/pull/51898#discussion_r1243399243.
|
|
227
|
+
tabIndex="-1"
|
|
228
|
+
>
|
|
229
|
+
{ item.title || item.name }
|
|
230
|
+
</Button>
|
|
231
|
+
) }
|
|
232
|
+
</Flex>
|
|
213
233
|
{ itemIcon && ! isNonUserPattern && (
|
|
214
234
|
<Tooltip
|
|
215
235
|
placement="top"
|
|
@@ -235,26 +255,6 @@ function Title( { item, categoryId } ) {
|
|
|
235
255
|
/>
|
|
236
256
|
</Tooltip>
|
|
237
257
|
) }
|
|
238
|
-
<Flex
|
|
239
|
-
as="div"
|
|
240
|
-
gap={ 0 }
|
|
241
|
-
justify="left"
|
|
242
|
-
className="edit-site-patterns__pattern-title"
|
|
243
|
-
>
|
|
244
|
-
{ item.type === PATTERN_TYPES.theme ? (
|
|
245
|
-
item.title
|
|
246
|
-
) : (
|
|
247
|
-
<Button
|
|
248
|
-
variant="link"
|
|
249
|
-
onClick={ onClick }
|
|
250
|
-
// Required for the grid's roving tab index system.
|
|
251
|
-
// See https://github.com/WordPress/gutenberg/pull/51898#discussion_r1243399243.
|
|
252
|
-
tabIndex="-1"
|
|
253
|
-
>
|
|
254
|
-
{ item.title || item.name }
|
|
255
|
-
</Button>
|
|
256
|
-
) }
|
|
257
|
-
</Flex>
|
|
258
258
|
</HStack>
|
|
259
259
|
);
|
|
260
260
|
}
|