@wordpress/edit-site 5.28.2 → 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.
Files changed (162) hide show
  1. package/build/components/add-new-pattern/index.js +18 -8
  2. package/build/components/add-new-pattern/index.js.map +1 -1
  3. package/build/components/editor/index.js +1 -1
  4. package/build/components/editor/index.js.map +1 -1
  5. package/build/components/global-styles/block-preview-panel.js +2 -2
  6. package/build/components/global-styles/block-preview-panel.js.map +1 -1
  7. package/build/components/global-styles/font-library-modal/collection-font-variant.js +2 -2
  8. package/build/components/global-styles/font-library-modal/collection-font-variant.js.map +1 -1
  9. package/build/components/global-styles/font-library-modal/font-card.js +10 -15
  10. package/build/components/global-styles/font-library-modal/font-card.js.map +1 -1
  11. package/build/components/global-styles/font-library-modal/font-collection.js +167 -37
  12. package/build/components/global-styles/font-library-modal/font-collection.js.map +1 -1
  13. package/build/components/global-styles/font-library-modal/font-demo.js +29 -8
  14. package/build/components/global-styles/font-library-modal/font-demo.js.map +1 -1
  15. package/build/components/global-styles/font-library-modal/google-fonts-confirm-dialog.js +1 -1
  16. package/build/components/global-styles/font-library-modal/google-fonts-confirm-dialog.js.map +1 -1
  17. package/build/components/global-styles/font-library-modal/installed-fonts.js +149 -83
  18. package/build/components/global-styles/font-library-modal/installed-fonts.js.map +1 -1
  19. package/build/components/global-styles/font-library-modal/library-font-variant.js +2 -2
  20. package/build/components/global-styles/font-library-modal/library-font-variant.js.map +1 -1
  21. package/build/components/global-styles/font-library-modal/upload-fonts.js +6 -4
  22. package/build/components/global-styles/font-library-modal/upload-fonts.js.map +1 -1
  23. package/build/components/global-styles/screen-revisions/index.js +2 -2
  24. package/build/components/global-styles/screen-revisions/index.js.map +1 -1
  25. package/build/components/global-styles/ui.js +27 -2
  26. package/build/components/global-styles/ui.js.map +1 -1
  27. package/build/components/header-edit-mode/index.js +1 -1
  28. package/build/components/header-edit-mode/index.js.map +1 -1
  29. package/build/components/layout/index.js +8 -3
  30. package/build/components/layout/index.js.map +1 -1
  31. package/build/components/layout/router.js +26 -5
  32. package/build/components/layout/router.js.map +1 -1
  33. package/build/components/page-patterns/index.js +14 -14
  34. package/build/components/page-patterns/index.js.map +1 -1
  35. package/build/components/page-patterns/use-patterns.js +10 -5
  36. package/build/components/page-patterns/use-patterns.js.map +1 -1
  37. package/build/components/page-templates-template-parts/index.js +1 -0
  38. package/build/components/page-templates-template-parts/index.js.map +1 -1
  39. package/build/components/sidebar/index.js +6 -3
  40. package/build/components/sidebar/index.js.map +1 -1
  41. package/build/components/sidebar-dataviews/default-views.js +2 -0
  42. package/build/components/sidebar-dataviews/default-views.js.map +1 -1
  43. package/build/components/sidebar-navigation-screen-pages/index.js +3 -1
  44. package/build/components/sidebar-navigation-screen-pages/index.js.map +1 -1
  45. package/build/components/sidebar-navigation-screen-templates-browse/content.js +2 -2
  46. package/build/components/sidebar-navigation-screen-templates-browse/content.js.map +1 -1
  47. package/build/components/sidebar-navigation-screen-templates-browse/index.js +7 -5
  48. package/build/components/sidebar-navigation-screen-templates-browse/index.js.map +1 -1
  49. package/build/components/style-book/index.js +2 -0
  50. package/build/components/style-book/index.js.map +1 -1
  51. package/build/store/private-actions.js +3 -1
  52. package/build/store/private-actions.js.map +1 -1
  53. package/build-module/components/add-new-pattern/index.js +18 -8
  54. package/build-module/components/add-new-pattern/index.js.map +1 -1
  55. package/build-module/components/editor/index.js +1 -1
  56. package/build-module/components/editor/index.js.map +1 -1
  57. package/build-module/components/global-styles/block-preview-panel.js +2 -2
  58. package/build-module/components/global-styles/block-preview-panel.js.map +1 -1
  59. package/build-module/components/global-styles/font-library-modal/collection-font-variant.js +4 -4
  60. package/build-module/components/global-styles/font-library-modal/collection-font-variant.js.map +1 -1
  61. package/build-module/components/global-styles/font-library-modal/font-card.js +11 -16
  62. package/build-module/components/global-styles/font-library-modal/font-card.js.map +1 -1
  63. package/build-module/components/global-styles/font-library-modal/font-collection.js +172 -42
  64. package/build-module/components/global-styles/font-library-modal/font-collection.js.map +1 -1
  65. package/build-module/components/global-styles/font-library-modal/font-demo.js +30 -9
  66. package/build-module/components/global-styles/font-library-modal/font-demo.js.map +1 -1
  67. package/build-module/components/global-styles/font-library-modal/google-fonts-confirm-dialog.js +1 -1
  68. package/build-module/components/global-styles/font-library-modal/google-fonts-confirm-dialog.js.map +1 -1
  69. package/build-module/components/global-styles/font-library-modal/installed-fonts.js +149 -83
  70. package/build-module/components/global-styles/font-library-modal/installed-fonts.js.map +1 -1
  71. package/build-module/components/global-styles/font-library-modal/library-font-variant.js +4 -4
  72. package/build-module/components/global-styles/font-library-modal/library-font-variant.js.map +1 -1
  73. package/build-module/components/global-styles/font-library-modal/upload-fonts.js +7 -5
  74. package/build-module/components/global-styles/font-library-modal/upload-fonts.js.map +1 -1
  75. package/build-module/components/global-styles/screen-revisions/index.js +2 -2
  76. package/build-module/components/global-styles/screen-revisions/index.js.map +1 -1
  77. package/build-module/components/global-styles/ui.js +27 -2
  78. package/build-module/components/global-styles/ui.js.map +1 -1
  79. package/build-module/components/header-edit-mode/index.js +1 -1
  80. package/build-module/components/header-edit-mode/index.js.map +1 -1
  81. package/build-module/components/layout/index.js +8 -3
  82. package/build-module/components/layout/index.js.map +1 -1
  83. package/build-module/components/layout/router.js +26 -5
  84. package/build-module/components/layout/router.js.map +1 -1
  85. package/build-module/components/page-patterns/index.js +14 -14
  86. package/build-module/components/page-patterns/index.js.map +1 -1
  87. package/build-module/components/page-patterns/use-patterns.js +10 -5
  88. package/build-module/components/page-patterns/use-patterns.js.map +1 -1
  89. package/build-module/components/page-templates-template-parts/index.js +1 -0
  90. package/build-module/components/page-templates-template-parts/index.js.map +1 -1
  91. package/build-module/components/sidebar/index.js +6 -3
  92. package/build-module/components/sidebar/index.js.map +1 -1
  93. package/build-module/components/sidebar-dataviews/default-views.js +3 -1
  94. package/build-module/components/sidebar-dataviews/default-views.js.map +1 -1
  95. package/build-module/components/sidebar-navigation-screen-pages/index.js +3 -1
  96. package/build-module/components/sidebar-navigation-screen-pages/index.js.map +1 -1
  97. package/build-module/components/sidebar-navigation-screen-templates-browse/content.js +2 -2
  98. package/build-module/components/sidebar-navigation-screen-templates-browse/content.js.map +1 -1
  99. package/build-module/components/sidebar-navigation-screen-templates-browse/index.js +7 -5
  100. package/build-module/components/sidebar-navigation-screen-templates-browse/index.js.map +1 -1
  101. package/build-module/components/style-book/index.js +2 -0
  102. package/build-module/components/style-book/index.js.map +1 -1
  103. package/build-module/store/private-actions.js +3 -1
  104. package/build-module/store/private-actions.js.map +1 -1
  105. package/build-style/style-rtl.css +52 -25
  106. package/build-style/style.css +52 -25
  107. package/package.json +18 -18
  108. package/src/components/add-new-pattern/index.js +27 -11
  109. package/src/components/editor/index.js +1 -0
  110. package/src/components/global-styles/block-preview-panel.js +2 -2
  111. package/src/components/global-styles/font-library-modal/collection-font-variant.js +4 -4
  112. package/src/components/global-styles/font-library-modal/font-card.js +11 -26
  113. package/src/components/global-styles/font-library-modal/font-collection.js +328 -129
  114. package/src/components/global-styles/font-library-modal/font-demo.js +38 -4
  115. package/src/components/global-styles/font-library-modal/google-fonts-confirm-dialog.js +1 -1
  116. package/src/components/global-styles/font-library-modal/installed-fonts.js +246 -132
  117. package/src/components/global-styles/font-library-modal/library-font-variant.js +4 -4
  118. package/src/components/global-styles/font-library-modal/style.scss +17 -13
  119. package/src/components/global-styles/font-library-modal/upload-fonts.js +13 -5
  120. package/src/components/global-styles/screen-revisions/index.js +5 -2
  121. package/src/components/global-styles/ui.js +26 -2
  122. package/src/components/header-edit-mode/index.js +3 -1
  123. package/src/components/layout/index.js +47 -30
  124. package/src/components/layout/router.js +31 -2
  125. package/src/components/layout/style.scss +7 -0
  126. package/src/components/page-patterns/index.js +20 -20
  127. package/src/components/page-patterns/style.scss +10 -0
  128. package/src/components/page-patterns/use-patterns.js +13 -5
  129. package/src/components/page-templates-template-parts/index.js +1 -0
  130. package/src/components/page-templates-template-parts/style.scss +6 -0
  131. package/src/components/sidebar/index.js +9 -4
  132. package/src/components/sidebar-dataviews/default-views.js +3 -1
  133. package/src/components/sidebar-navigation-screen-pages/index.js +10 -6
  134. package/src/components/sidebar-navigation-screen-templates-browse/content.js +2 -2
  135. package/src/components/sidebar-navigation-screen-templates-browse/index.js +5 -3
  136. package/src/components/style-book/index.js +5 -1
  137. package/src/store/private-actions.js +4 -0
  138. package/build/components/global-styles/font-library-modal/collection-font-details.js +0 -50
  139. package/build/components/global-styles/font-library-modal/collection-font-details.js.map +0 -1
  140. package/build/components/global-styles/font-library-modal/confirm-delete-dialog.js +0 -30
  141. package/build/components/global-styles/font-library-modal/confirm-delete-dialog.js.map +0 -1
  142. package/build/components/global-styles/font-library-modal/fonts-grid.js +0 -57
  143. package/build/components/global-styles/font-library-modal/fonts-grid.js.map +0 -1
  144. package/build/components/global-styles/font-library-modal/library-font-card.js +0 -39
  145. package/build/components/global-styles/font-library-modal/library-font-card.js.map +0 -1
  146. package/build/components/global-styles/font-library-modal/tab-panel-layout.js +0 -67
  147. package/build/components/global-styles/font-library-modal/tab-panel-layout.js.map +0 -1
  148. package/build-module/components/global-styles/font-library-modal/collection-font-details.js +0 -42
  149. package/build-module/components/global-styles/font-library-modal/collection-font-details.js.map +0 -1
  150. package/build-module/components/global-styles/font-library-modal/confirm-delete-dialog.js +0 -23
  151. package/build-module/components/global-styles/font-library-modal/confirm-delete-dialog.js.map +0 -1
  152. package/build-module/components/global-styles/font-library-modal/fonts-grid.js +0 -50
  153. package/build-module/components/global-styles/font-library-modal/fonts-grid.js.map +0 -1
  154. package/build-module/components/global-styles/font-library-modal/library-font-card.js +0 -31
  155. package/build-module/components/global-styles/font-library-modal/library-font-card.js.map +0 -1
  156. package/build-module/components/global-styles/font-library-modal/tab-panel-layout.js +0 -60
  157. package/build-module/components/global-styles/font-library-modal/tab-panel-layout.js.map +0 -1
  158. package/src/components/global-styles/font-library-modal/collection-font-details.js +0 -56
  159. package/src/components/global-styles/font-library-modal/confirm-delete-dialog.js +0 -33
  160. package/src/components/global-styles/font-library-modal/fonts-grid.js +0 -59
  161. package/src/components/global-styles/font-library-modal/library-font-card.js +0 -34
  162. 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
- privateApis as componentsPrivateApis,
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
- Button,
14
+ __experimentalText as Text,
15
+ __experimentalVStack as VStack,
16
+ Flex,
17
+ Notice,
11
18
  Spinner,
12
- FlexItem,
19
+ privateApis as componentsPrivateApis,
13
20
  } from '@wordpress/components';
21
+ import { useContext, useEffect, useState } from '@wordpress/element';
22
+ import { __, sprintf } from '@wordpress/i18n';
23
+ import { chevronLeft } from '@wordpress/icons';
14
24
 
15
25
  /**
16
26
  * Internal dependencies
17
27
  */
18
- import TabPanelLayout from './tab-panel-layout';
19
- import { FontLibraryContext } from './context';
20
- import FontsGrid from './fonts-grid';
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,148 +41,199 @@ 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 handleUnselectFont = () => {
42
- handleSetLibraryFontSelected( null );
43
- };
53
+ const shouldDisplayDeleteButton =
54
+ !! libraryFontSelected && libraryFontSelected?.source !== 'theme';
44
55
 
45
- const handleSelectFont = ( font ) => {
46
- handleSetLibraryFontSelected( font );
56
+ const handleUninstallClick = () => {
57
+ setIsConfirmDeleteOpen( true );
47
58
  };
48
59
 
49
- const handleConfirmUninstall = async () => {
50
- setNotice( null );
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 handleUninstallClick = async () => {
73
- setIsConfirmDeleteOpen( true );
74
- };
75
-
76
- const handleCancelUninstall = () => {
77
- setIsConfirmDeleteOpen( false );
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
- handleSelectFont( libraryFontSelected );
92
+ handleSetLibraryFontSelected( libraryFontSelected );
91
93
  refreshLibrary();
92
- // eslint-disable-next-line react-hooks/exhaustive-deps
93
94
  }, [] );
94
95
 
95
96
  return (
96
- <TabPanelLayout
97
- title={ libraryFontSelected?.name || '' }
98
- description={ tabDescription }
99
- notice={ notice }
100
- handleBack={ !! libraryFontSelected && handleUnselectFont }
101
- footer={
102
- <Footer
103
- shouldDisplayDeleteButton={ shouldDisplayDeleteButton }
104
- handleUninstallClick={ handleUninstallClick }
105
- />
106
- }
107
- >
108
- <ConfirmDeleteDialog
109
- font={ libraryFontSelected }
110
- isConfirmDeleteOpen={ isConfirmDeleteOpen }
111
- handleConfirmUninstall={ handleConfirmUninstall }
112
- handleCancelUninstall={ handleCancelUninstall }
113
- />
114
-
115
- { ! libraryFontSelected && (
116
- <>
117
- { isResolvingLibrary && (
118
- <FlexItem>
119
- <Spacer margin={ 2 } />
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
  <>
126
- <FontsGrid>
127
- { baseCustomFonts.map( ( font ) => (
128
- <LibraryFontCard
129
- font={ font }
130
- key={ font.slug }
131
- onClick={ () => {
132
- handleSelectFont( font );
133
- } }
134
- />
135
- ) ) }
136
- </FontsGrid>
124
+ <Text className="font-library-modal__subtitle">
125
+ { __( 'Installed Fonts' ) }
126
+ </Text>
127
+ <Spacer margin={ 2 } />
128
+ { baseCustomFonts.map( ( font ) => (
129
+ <FontCard
130
+ font={ font }
131
+ key={ font.slug }
132
+ navigatorPath={ '/fontFamily' }
133
+ variantsText={ getFontCardVariantsText(
134
+ font
135
+ ) }
136
+ onClick={ () => {
137
+ handleSetLibraryFontSelected( font );
138
+ } }
139
+ />
140
+ ) ) }
137
141
  <Spacer margin={ 8 } />
138
142
  </>
139
143
  ) }
140
144
 
141
145
  { baseThemeFonts.length > 0 && (
142
146
  <>
143
- <FontsGrid title={ __( 'Theme Fonts' ) }>
144
- { baseThemeFonts.map( ( font ) => (
145
- <LibraryFontCard
146
- font={ font }
147
- key={ font.slug }
148
- onClick={ () => {
149
- handleSelectFont( font );
150
- } }
151
- />
152
- ) ) }
153
- </FontsGrid>
147
+ <Text className="font-library-modal__subtitle">
148
+ { __( 'Theme Fonts' ) }
149
+ </Text>
150
+ <Spacer margin={ 2 } />
151
+ { baseThemeFonts.map( ( font ) => (
152
+ <FontCard
153
+ font={ font }
154
+ key={ font.slug }
155
+ navigatorPath={ '/fontFamily' }
156
+ variantsText={ getFontCardVariantsText(
157
+ font
158
+ ) }
159
+ onClick={ () => {
160
+ handleSetLibraryFontSelected( font );
161
+ } }
162
+ />
163
+ ) ) }
154
164
  </>
155
165
  ) }
156
- </>
157
- ) }
166
+ <Spacer margin={ 16 } />
167
+ </NavigatorScreen>
158
168
 
159
- { libraryFontSelected && (
160
- <LibraryFontDetails
161
- font={ libraryFontSelected }
162
- isConfirmDeleteOpen={ isConfirmDeleteOpen }
163
- handleConfirmUninstall={ handleConfirmUninstall }
164
- handleCancelUninstall={ handleCancelUninstall }
165
- />
166
- ) }
167
- </TabPanelLayout>
168
- );
169
- }
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
+ />
170
180
 
171
- function Footer( { shouldDisplayDeleteButton, handleUninstallClick } ) {
172
- const { saveFontFamilies, fontFamiliesHasChanges, isInstalling } =
173
- useContext( FontLibraryContext );
174
- return (
175
- <HStack justify="flex-end">
176
- { isInstalling && <ProgressBar /> }
177
- <div>
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 /> }
178
237
  { shouldDisplayDeleteButton && (
179
238
  <Button
180
239
  isDestructive
@@ -184,16 +243,71 @@ function Footer( { shouldDisplayDeleteButton, handleUninstallClick } ) {
184
243
  { __( 'Delete' ) }
185
244
  </Button>
186
245
  ) }
187
- </div>
188
- <Button
189
- variant="primary"
190
- onClick={ saveFontFamilies }
191
- disabled={ ! fontFamiliesHasChanges }
192
- __experimentalIsFocusable
193
- >
194
- { __( 'Update' ) }
195
- </Button>
196
- </HStack>
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>
197
311
  );
198
312
  }
199
313
 
@@ -13,7 +13,7 @@ import {
13
13
  */
14
14
  import { getFontFaceVariantName } from './utils';
15
15
  import { FontLibraryContext } from './context';
16
- import FontFaceDemo from './font-demo';
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-modal__library-font-variant">
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
- <FontFaceDemo
58
- fontFace={ face }
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};
@@ -36,11 +44,8 @@
36
44
  }
37
45
  }
38
46
 
39
- .font-library-modal__fonts-grid {
40
- .font-library-modal__fonts-grid__main {
41
- display: flex;
42
- flex-direction: column;
43
- }
47
+ .font-library-modal__tabpanel-layout .components-base-control__field {
48
+ margin-bottom: 0;
44
49
  }
45
50
 
46
51
  .font-library-modal__font-card {
@@ -50,6 +55,10 @@
50
55
  padding: $grid-unit-20;
51
56
  margin-top: -1px; /* To collapse the margin with the previous element */
52
57
 
58
+ &:hover {
59
+ background-color: $gray-100;
60
+ }
61
+
53
62
  .font-library-modal__font-card__name {
54
63
  font-weight: bold;
55
64
  }
@@ -59,12 +68,6 @@
59
68
  }
60
69
  }
61
70
 
62
- .font-library-modal__library-font-variant {
63
- border: 1px solid $gray-200;
64
- padding: $grid-unit-20;
65
- margin-top: -1px; /* To collapse the margin with the previous element */
66
- }
67
-
68
71
  .font-library-modal__font-variant_demo-image {
69
72
  display: block;
70
73
  height: $grid-unit-30;
@@ -120,6 +123,7 @@ button.font-library-modal__upload-area {
120
123
  display: flex;
121
124
  justify-content: center;
122
125
  align-items: center;
126
+ margin-top: $grid-unit-80;
123
127
 
124
128
  h3 {
125
129
  font-size: 1.4rem;
@@ -127,7 +131,7 @@ button.font-library-modal__upload-area {
127
131
 
128
132
  .components-card {
129
133
  width: 50%;
130
- min-width: 250px;
131
- max-width: 350px;
134
+ min-width: 350px;
135
+ max-width: 400px;
132
136
  }
133
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
- <TabPanelLayout notice={ notice }>
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
- </TabPanelLayout>
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
- setEditorCanvasContainerView( undefined );
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': isBlockToolsCollapsed,
137
+ 'is-collapsed':
138
+ isBlockToolsCollapsed ||
139
+ ! hasBlockSelected,
138
140
  }
139
141
  ) }
140
142
  >