@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.
Files changed (125) hide show
  1. package/build/components/global-styles/font-library-modal/collection-font-variant.js +2 -2
  2. package/build/components/global-styles/font-library-modal/collection-font-variant.js.map +1 -1
  3. package/build/components/global-styles/font-library-modal/context.js +51 -58
  4. package/build/components/global-styles/font-library-modal/context.js.map +1 -1
  5. package/build/components/global-styles/font-library-modal/font-card.js +10 -15
  6. package/build/components/global-styles/font-library-modal/font-card.js.map +1 -1
  7. package/build/components/global-styles/font-library-modal/font-collection.js +115 -62
  8. package/build/components/global-styles/font-library-modal/font-collection.js.map +1 -1
  9. package/build/components/global-styles/font-library-modal/font-demo.js +29 -8
  10. package/build/components/global-styles/font-library-modal/font-demo.js.map +1 -1
  11. package/build/components/global-styles/font-library-modal/index.js +17 -4
  12. package/build/components/global-styles/font-library-modal/index.js.map +1 -1
  13. package/build/components/global-styles/font-library-modal/installed-fonts.js +151 -79
  14. package/build/components/global-styles/font-library-modal/installed-fonts.js.map +1 -1
  15. package/build/components/global-styles/font-library-modal/library-font-variant.js +2 -2
  16. package/build/components/global-styles/font-library-modal/library-font-variant.js.map +1 -1
  17. package/build/components/global-styles/font-library-modal/upload-fonts.js +8 -14
  18. package/build/components/global-styles/font-library-modal/upload-fonts.js.map +1 -1
  19. package/build/components/global-styles/font-library-modal/utils/index.js +11 -4
  20. package/build/components/global-styles/font-library-modal/utils/index.js.map +1 -1
  21. package/build/components/global-styles/screen-revisions/index.js +2 -2
  22. package/build/components/global-styles/screen-revisions/index.js.map +1 -1
  23. package/build/components/global-styles/ui.js +27 -2
  24. package/build/components/global-styles/ui.js.map +1 -1
  25. package/build/components/header-edit-mode/index.js +1 -1
  26. package/build/components/header-edit-mode/index.js.map +1 -1
  27. package/build/components/page-patterns/index.js +14 -14
  28. package/build/components/page-patterns/index.js.map +1 -1
  29. package/build/components/resizable-frame/index.js +2 -1
  30. package/build/components/resizable-frame/index.js.map +1 -1
  31. package/build/components/sidebar/index.js +3 -2
  32. package/build/components/sidebar/index.js.map +1 -1
  33. package/build/components/sidebar-dataviews/default-views.js +2 -0
  34. package/build/components/sidebar-dataviews/default-views.js.map +1 -1
  35. package/build/components/sidebar-navigation-screen-templates-browse/content.js +2 -2
  36. package/build/components/sidebar-navigation-screen-templates-browse/content.js.map +1 -1
  37. package/build/components/sidebar-navigation-screen-templates-browse/index.js +7 -5
  38. package/build/components/sidebar-navigation-screen-templates-browse/index.js.map +1 -1
  39. package/build/components/style-book/index.js +2 -0
  40. package/build/components/style-book/index.js.map +1 -1
  41. package/build-module/components/global-styles/font-library-modal/collection-font-variant.js +4 -4
  42. package/build-module/components/global-styles/font-library-modal/collection-font-variant.js.map +1 -1
  43. package/build-module/components/global-styles/font-library-modal/context.js +51 -58
  44. package/build-module/components/global-styles/font-library-modal/context.js.map +1 -1
  45. package/build-module/components/global-styles/font-library-modal/font-card.js +11 -16
  46. package/build-module/components/global-styles/font-library-modal/font-card.js.map +1 -1
  47. package/build-module/components/global-styles/font-library-modal/font-collection.js +118 -65
  48. package/build-module/components/global-styles/font-library-modal/font-collection.js.map +1 -1
  49. package/build-module/components/global-styles/font-library-modal/font-demo.js +30 -9
  50. package/build-module/components/global-styles/font-library-modal/font-demo.js.map +1 -1
  51. package/build-module/components/global-styles/font-library-modal/index.js +17 -4
  52. package/build-module/components/global-styles/font-library-modal/index.js.map +1 -1
  53. package/build-module/components/global-styles/font-library-modal/installed-fonts.js +151 -79
  54. package/build-module/components/global-styles/font-library-modal/installed-fonts.js.map +1 -1
  55. package/build-module/components/global-styles/font-library-modal/library-font-variant.js +4 -4
  56. package/build-module/components/global-styles/font-library-modal/library-font-variant.js.map +1 -1
  57. package/build-module/components/global-styles/font-library-modal/upload-fonts.js +9 -15
  58. package/build-module/components/global-styles/font-library-modal/upload-fonts.js.map +1 -1
  59. package/build-module/components/global-styles/font-library-modal/utils/index.js +11 -4
  60. package/build-module/components/global-styles/font-library-modal/utils/index.js.map +1 -1
  61. package/build-module/components/global-styles/screen-revisions/index.js +2 -2
  62. package/build-module/components/global-styles/screen-revisions/index.js.map +1 -1
  63. package/build-module/components/global-styles/ui.js +27 -2
  64. package/build-module/components/global-styles/ui.js.map +1 -1
  65. package/build-module/components/header-edit-mode/index.js +1 -1
  66. package/build-module/components/header-edit-mode/index.js.map +1 -1
  67. package/build-module/components/page-patterns/index.js +14 -14
  68. package/build-module/components/page-patterns/index.js.map +1 -1
  69. package/build-module/components/resizable-frame/index.js +2 -1
  70. package/build-module/components/resizable-frame/index.js.map +1 -1
  71. package/build-module/components/sidebar/index.js +3 -2
  72. package/build-module/components/sidebar/index.js.map +1 -1
  73. package/build-module/components/sidebar-dataviews/default-views.js +3 -1
  74. package/build-module/components/sidebar-dataviews/default-views.js.map +1 -1
  75. package/build-module/components/sidebar-navigation-screen-templates-browse/content.js +2 -2
  76. package/build-module/components/sidebar-navigation-screen-templates-browse/content.js.map +1 -1
  77. package/build-module/components/sidebar-navigation-screen-templates-browse/index.js +7 -5
  78. package/build-module/components/sidebar-navigation-screen-templates-browse/index.js.map +1 -1
  79. package/build-module/components/style-book/index.js +2 -0
  80. package/build-module/components/style-book/index.js.map +1 -1
  81. package/build-style/style-rtl.css +36 -23
  82. package/build-style/style.css +36 -23
  83. package/package.json +18 -18
  84. package/src/components/global-styles/font-library-modal/collection-font-variant.js +4 -4
  85. package/src/components/global-styles/font-library-modal/context.js +92 -104
  86. package/src/components/global-styles/font-library-modal/font-card.js +11 -26
  87. package/src/components/global-styles/font-library-modal/font-collection.js +307 -211
  88. package/src/components/global-styles/font-library-modal/font-demo.js +38 -4
  89. package/src/components/global-styles/font-library-modal/index.js +21 -14
  90. package/src/components/global-styles/font-library-modal/installed-fonts.js +243 -114
  91. package/src/components/global-styles/font-library-modal/library-font-variant.js +4 -4
  92. package/src/components/global-styles/font-library-modal/style.scss +15 -8
  93. package/src/components/global-styles/font-library-modal/upload-fonts.js +16 -18
  94. package/src/components/global-styles/font-library-modal/utils/index.js +10 -4
  95. package/src/components/global-styles/font-library-modal/utils/test/getDisplaySrcFromFontFace.spec.js +7 -18
  96. package/src/components/global-styles/screen-revisions/index.js +5 -2
  97. package/src/components/global-styles/ui.js +26 -2
  98. package/src/components/header-edit-mode/index.js +3 -1
  99. package/src/components/page-patterns/index.js +20 -20
  100. package/src/components/resizable-frame/index.js +1 -0
  101. package/src/components/sidebar/index.js +2 -1
  102. package/src/components/sidebar-dataviews/default-views.js +3 -1
  103. package/src/components/sidebar-navigation-screen-templates-browse/content.js +2 -2
  104. package/src/components/sidebar-navigation-screen-templates-browse/index.js +5 -3
  105. package/src/components/style-book/index.js +5 -1
  106. package/build/components/global-styles/font-library-modal/collection-font-details.js +0 -50
  107. package/build/components/global-styles/font-library-modal/collection-font-details.js.map +0 -1
  108. package/build/components/global-styles/font-library-modal/confirm-delete-dialog.js +0 -30
  109. package/build/components/global-styles/font-library-modal/confirm-delete-dialog.js.map +0 -1
  110. package/build/components/global-styles/font-library-modal/library-font-card.js +0 -39
  111. package/build/components/global-styles/font-library-modal/library-font-card.js.map +0 -1
  112. package/build/components/global-styles/font-library-modal/tab-panel-layout.js +0 -67
  113. package/build/components/global-styles/font-library-modal/tab-panel-layout.js.map +0 -1
  114. package/build-module/components/global-styles/font-library-modal/collection-font-details.js +0 -42
  115. package/build-module/components/global-styles/font-library-modal/collection-font-details.js.map +0 -1
  116. package/build-module/components/global-styles/font-library-modal/confirm-delete-dialog.js +0 -23
  117. package/build-module/components/global-styles/font-library-modal/confirm-delete-dialog.js.map +0 -1
  118. package/build-module/components/global-styles/font-library-modal/library-font-card.js +0 -31
  119. package/build-module/components/global-styles/font-library-modal/library-font-card.js.map +0 -1
  120. package/build-module/components/global-styles/font-library-modal/tab-panel-layout.js +0 -60
  121. package/build-module/components/global-styles/font-library-modal/tab-panel-layout.js.map +0 -1
  122. package/src/components/global-styles/font-library-modal/collection-font-details.js +0 -56
  123. package/src/components/global-styles/font-library-modal/confirm-delete-dialog.js +0 -33
  124. package/src/components/global-styles/font-library-modal/library-font-card.js +0 -34
  125. 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 { getFacePreviewStyle } from './utils/preview-styles';
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 FontFaceDemo( { customPreviewUrl, fontFace, text, style = {} } ) {
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 FontFaceDemo;
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 DEFAULT_TABS = [
23
- {
24
- id: 'installed-fonts',
25
- title: __( 'Library' ),
26
- },
27
- {
28
- id: 'upload-fonts',
29
- title: __( 'Upload' ),
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
- const tabs = [
49
- ...DEFAULT_TABS,
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
- 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
14
  __experimentalText as Text,
11
- Button,
15
+ __experimentalVStack as VStack,
16
+ Flex,
17
+ Notice,
12
18
  Spinner,
13
- FlexItem,
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 handleUnselectFont = () => {
42
- handleSetLibraryFontSelected( null );
43
- };
44
-
45
- const handleSelectFont = ( font ) => {
46
- handleSetLibraryFontSelected( font );
47
- };
48
-
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
- } );
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
- // 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
- } );
69
- }
70
- };
68
+ const shouldDisplayDeleteButton =
69
+ !! libraryFontSelected &&
70
+ libraryFontSelected?.source !== 'theme' &&
71
+ canUserDelete;
71
72
 
72
- const handleUninstallClick = async () => {
73
+ const handleUninstallClick = () => {
73
74
  setIsConfirmDeleteOpen( true );
74
75
  };
75
76
 
76
- const handleCancelUninstall = () => {
77
- setIsConfirmDeleteOpen( false );
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 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';
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
- handleSelectFont( libraryFontSelected );
109
+ handleSetLibraryFontSelected( libraryFontSelected );
91
110
  refreshLibrary();
92
- // eslint-disable-next-line react-hooks/exhaustive-deps
93
111
  }, [] );
94
112
 
95
113
  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>
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
- <LibraryFontCard
146
+ <FontCard
128
147
  font={ font }
129
148
  key={ font.slug }
149
+ navigatorPath={ '/fontFamily' }
150
+ variantsText={ getFontCardVariantsText(
151
+ font
152
+ ) }
130
153
  onClick={ () => {
131
- handleSelectFont( font );
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
- <LibraryFontCard
169
+ <FontCard
148
170
  font={ font }
149
171
  key={ font.slug }
172
+ navigatorPath={ '/fontFamily' }
173
+ variantsText={ getFontCardVariantsText(
174
+ font
175
+ ) }
150
176
  onClick={ () => {
151
- handleSelectFont( font );
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
- { libraryFontSelected && (
162
- <LibraryFontDetails
163
- font={ libraryFontSelected }
164
- isConfirmDeleteOpen={ isConfirmDeleteOpen }
165
- handleConfirmUninstall={ handleConfirmUninstall }
166
- handleCancelUninstall={ handleCancelUninstall }
167
- />
168
- ) }
169
- </TabPanelLayout>
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
- function Footer( { shouldDisplayDeleteButton, handleUninstallClick } ) {
174
- const { saveFontFamilies, fontFamiliesHasChanges, isInstalling } =
175
- useContext( FontLibraryContext );
176
- return (
177
- <HStack justify="flex-end">
178
- { isInstalling && <ProgressBar /> }
179
- <div>
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
- </div>
190
- <Button
191
- variant="primary"
192
- onClick={ saveFontFamilies }
193
- disabled={ ! fontFamiliesHasChanges }
194
- __experimentalIsFocusable
195
- >
196
- { __( 'Update' ) }
197
- </Button>
198
- </HStack>
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 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};
@@ -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: 250px;
128
- max-width: 350px;
134
+ min-width: 350px;
135
+ max-width: 400px;
129
136
  }
130
137
  }