@wordpress/edit-site 5.12.1 → 5.12.3

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 (153) hide show
  1. package/build/components/add-new-pattern/index.js +9 -9
  2. package/build/components/add-new-pattern/index.js.map +1 -1
  3. package/build/components/add-new-template/new-template.js +69 -14
  4. package/build/components/add-new-template/new-template.js.map +1 -1
  5. package/build/components/create-pattern-modal/index.js +1 -1
  6. package/build/components/create-pattern-modal/index.js.map +1 -1
  7. package/build/components/create-template-part-modal/index.js +1 -1
  8. package/build/components/create-template-part-modal/index.js.map +1 -1
  9. package/build/components/editor/index.js +1 -0
  10. package/build/components/editor/index.js.map +1 -1
  11. package/build/components/global-styles/ui.js +7 -2
  12. package/build/components/global-styles/ui.js.map +1 -1
  13. package/build/components/header-edit-mode/index.js +36 -9
  14. package/build/components/header-edit-mode/index.js.map +1 -1
  15. package/build/components/header-edit-mode/more-menu/index.js +36 -2
  16. package/build/components/header-edit-mode/more-menu/index.js.map +1 -1
  17. package/build/components/keyboard-shortcuts/edit-mode.js +32 -1
  18. package/build/components/keyboard-shortcuts/edit-mode.js.map +1 -1
  19. package/build/components/keyboard-shortcuts/register.js +9 -0
  20. package/build/components/keyboard-shortcuts/register.js.map +1 -1
  21. package/build/components/layout/index.js +86 -12
  22. package/build/components/layout/index.js.map +1 -1
  23. package/build/components/page-content-focus-manager/back-to-page-notification.js +9 -3
  24. package/build/components/page-content-focus-manager/back-to-page-notification.js.map +1 -1
  25. package/build/components/page-library/grid-item.js +11 -7
  26. package/build/components/page-library/grid-item.js.map +1 -1
  27. package/build/components/preferences-modal/enable-feature.js +5 -1
  28. package/build/components/preferences-modal/enable-feature.js.map +1 -1
  29. package/build/components/preferences-modal/index.js +30 -0
  30. package/build/components/preferences-modal/index.js.map +1 -1
  31. package/build/components/sidebar-edit-mode/index.js +4 -2
  32. package/build/components/sidebar-edit-mode/index.js.map +1 -1
  33. package/build/components/sidebar-navigation-screen/index.js +7 -3
  34. package/build/components/sidebar-navigation-screen/index.js.map +1 -1
  35. package/build/components/sidebar-navigation-screen-global-styles/index.js +15 -3
  36. package/build/components/sidebar-navigation-screen-global-styles/index.js.map +1 -1
  37. package/build/components/sidebar-navigation-screen-library/category-item.js +1 -1
  38. package/build/components/sidebar-navigation-screen-library/category-item.js.map +1 -1
  39. package/build/components/sidebar-navigation-screen-navigation-menu/index.js +1 -1
  40. package/build/components/sidebar-navigation-screen-navigation-menu/index.js.map +1 -1
  41. package/build/components/sidebar-navigation-screen-navigation-menu/rename-modal.js +10 -1
  42. package/build/components/sidebar-navigation-screen-navigation-menu/rename-modal.js.map +1 -1
  43. package/build/components/sidebar-navigation-screen-navigation-menu/use-navigation-menu-handlers.js +5 -1
  44. package/build/components/sidebar-navigation-screen-navigation-menu/use-navigation-menu-handlers.js.map +1 -1
  45. package/build/components/sidebar-navigation-screen-navigation-menus/index.js +14 -3
  46. package/build/components/sidebar-navigation-screen-navigation-menus/index.js.map +1 -1
  47. package/build/hooks/commands/use-common-commands.js +22 -0
  48. package/build/hooks/commands/use-common-commands.js.map +1 -1
  49. package/build/hooks/commands/use-edit-mode-commands.js +170 -42
  50. package/build/hooks/commands/use-edit-mode-commands.js.map +1 -1
  51. package/build/index.js +1 -0
  52. package/build/index.js.map +1 -1
  53. package/build/store/selectors.js +2 -1
  54. package/build/store/selectors.js.map +1 -1
  55. package/build-module/components/add-new-pattern/index.js +8 -8
  56. package/build-module/components/add-new-pattern/index.js.map +1 -1
  57. package/build-module/components/add-new-template/new-template.js +72 -17
  58. package/build-module/components/add-new-template/new-template.js.map +1 -1
  59. package/build-module/components/create-pattern-modal/index.js +1 -1
  60. package/build-module/components/create-pattern-modal/index.js.map +1 -1
  61. package/build-module/components/create-template-part-modal/index.js +1 -1
  62. package/build-module/components/create-template-part-modal/index.js.map +1 -1
  63. package/build-module/components/editor/index.js +1 -0
  64. package/build-module/components/editor/index.js.map +1 -1
  65. package/build-module/components/global-styles/ui.js +8 -3
  66. package/build-module/components/global-styles/ui.js.map +1 -1
  67. package/build-module/components/header-edit-mode/index.js +38 -11
  68. package/build-module/components/header-edit-mode/index.js.map +1 -1
  69. package/build-module/components/header-edit-mode/more-menu/index.js +35 -3
  70. package/build-module/components/header-edit-mode/more-menu/index.js.map +1 -1
  71. package/build-module/components/keyboard-shortcuts/edit-mode.js +29 -1
  72. package/build-module/components/keyboard-shortcuts/edit-mode.js.map +1 -1
  73. package/build-module/components/keyboard-shortcuts/register.js +9 -0
  74. package/build-module/components/keyboard-shortcuts/register.js.map +1 -1
  75. package/build-module/components/layout/index.js +86 -12
  76. package/build-module/components/layout/index.js.map +1 -1
  77. package/build-module/components/page-content-focus-manager/back-to-page-notification.js +9 -3
  78. package/build-module/components/page-content-focus-manager/back-to-page-notification.js.map +1 -1
  79. package/build-module/components/page-library/grid-item.js +11 -7
  80. package/build-module/components/page-library/grid-item.js.map +1 -1
  81. package/build-module/components/preferences-modal/enable-feature.js +5 -1
  82. package/build-module/components/preferences-modal/enable-feature.js.map +1 -1
  83. package/build-module/components/preferences-modal/index.js +27 -0
  84. package/build-module/components/preferences-modal/index.js.map +1 -1
  85. package/build-module/components/sidebar-edit-mode/index.js +4 -2
  86. package/build-module/components/sidebar-edit-mode/index.js.map +1 -1
  87. package/build-module/components/sidebar-navigation-screen/index.js +7 -3
  88. package/build-module/components/sidebar-navigation-screen/index.js.map +1 -1
  89. package/build-module/components/sidebar-navigation-screen-global-styles/index.js +14 -3
  90. package/build-module/components/sidebar-navigation-screen-global-styles/index.js.map +1 -1
  91. package/build-module/components/sidebar-navigation-screen-library/category-item.js +1 -1
  92. package/build-module/components/sidebar-navigation-screen-library/category-item.js.map +1 -1
  93. package/build-module/components/sidebar-navigation-screen-navigation-menu/index.js +1 -1
  94. package/build-module/components/sidebar-navigation-screen-navigation-menu/index.js.map +1 -1
  95. package/build-module/components/sidebar-navigation-screen-navigation-menu/rename-modal.js +11 -1
  96. package/build-module/components/sidebar-navigation-screen-navigation-menu/rename-modal.js.map +1 -1
  97. package/build-module/components/sidebar-navigation-screen-navigation-menu/use-navigation-menu-handlers.js +5 -1
  98. package/build-module/components/sidebar-navigation-screen-navigation-menu/use-navigation-menu-handlers.js.map +1 -1
  99. package/build-module/components/sidebar-navigation-screen-navigation-menus/index.js +14 -4
  100. package/build-module/components/sidebar-navigation-screen-navigation-menus/index.js.map +1 -1
  101. package/build-module/hooks/commands/use-common-commands.js +23 -1
  102. package/build-module/hooks/commands/use-common-commands.js.map +1 -1
  103. package/build-module/hooks/commands/use-edit-mode-commands.js +170 -44
  104. package/build-module/hooks/commands/use-edit-mode-commands.js.map +1 -1
  105. package/build-module/index.js +1 -0
  106. package/build-module/index.js.map +1 -1
  107. package/build-module/store/selectors.js +2 -1
  108. package/build-module/store/selectors.js.map +1 -1
  109. package/build-style/style-rtl.css +110 -18
  110. package/build-style/style.css +110 -18
  111. package/package.json +15 -15
  112. package/src/components/add-new-pattern/index.js +8 -10
  113. package/src/components/add-new-template/new-template.js +120 -24
  114. package/src/components/add-new-template/style.scss +30 -2
  115. package/src/components/create-pattern-modal/index.js +1 -1
  116. package/src/components/create-template-part-modal/index.js +1 -1
  117. package/src/components/editor/index.js +1 -0
  118. package/src/components/editor/style.scss +4 -0
  119. package/src/components/global-styles/ui.js +34 -24
  120. package/src/components/header-edit-mode/index.js +96 -54
  121. package/src/components/header-edit-mode/more-menu/index.js +52 -7
  122. package/src/components/keyboard-shortcuts/edit-mode.js +35 -2
  123. package/src/components/keyboard-shortcuts/register.js +10 -0
  124. package/src/components/layout/index.js +115 -46
  125. package/src/components/layout/style.scss +58 -1
  126. package/src/components/page-content-focus-manager/back-to-page-notification.js +7 -2
  127. package/src/components/page-library/grid-item.js +9 -9
  128. package/src/components/page-library/style.scss +2 -2
  129. package/src/components/preferences-modal/enable-feature.js +5 -2
  130. package/src/components/preferences-modal/index.js +25 -0
  131. package/src/components/sidebar-button/style.scss +1 -1
  132. package/src/components/sidebar-edit-mode/index.js +4 -2
  133. package/src/components/sidebar-navigation-item/style.scss +1 -1
  134. package/src/components/sidebar-navigation-screen/index.js +4 -2
  135. package/src/components/sidebar-navigation-screen/style.scss +2 -1
  136. package/src/components/sidebar-navigation-screen-details-panel/style.scss +1 -1
  137. package/src/components/sidebar-navigation-screen-global-styles/index.js +15 -3
  138. package/src/components/sidebar-navigation-screen-library/category-item.js +1 -1
  139. package/src/components/sidebar-navigation-screen-library/style.scss +0 -4
  140. package/src/components/sidebar-navigation-screen-navigation-menu/index.js +1 -1
  141. package/src/components/sidebar-navigation-screen-navigation-menu/rename-modal.js +12 -1
  142. package/src/components/sidebar-navigation-screen-navigation-menu/style.scss +2 -2
  143. package/src/components/sidebar-navigation-screen-navigation-menu/use-navigation-menu-handlers.js +5 -1
  144. package/src/components/sidebar-navigation-screen-navigation-menus/index.js +31 -8
  145. package/src/components/sidebar-navigation-screen-pattern/style.scss +25 -0
  146. package/src/components/sidebar-navigation-screen-template/style.scss +15 -15
  147. package/src/components/site-hub/style.scss +4 -3
  148. package/src/hooks/commands/use-common-commands.js +20 -1
  149. package/src/hooks/commands/use-edit-mode-commands.js +155 -36
  150. package/src/index.js +1 -0
  151. package/src/store/selectors.js +5 -0
  152. package/src/store/test/selectors.js +2 -0
  153. package/src/style.scss +1 -0
@@ -3,12 +3,16 @@
3
3
  */
4
4
  import { __, _x } from '@wordpress/i18n';
5
5
  import { useReducer } from '@wordpress/element';
6
+ import { useSelect, useDispatch, useRegistry } from '@wordpress/data';
6
7
  import { useShortcut } from '@wordpress/keyboard-shortcuts';
7
8
  import { displayShortcut } from '@wordpress/keycodes';
8
9
  import { external } from '@wordpress/icons';
9
10
  import { MenuGroup, MenuItem, VisuallyHidden } from '@wordpress/components';
10
11
  import { ActionItem, MoreMenuDropdown } from '@wordpress/interface';
11
- import { PreferenceToggleMenuItem } from '@wordpress/preferences';
12
+ import {
13
+ PreferenceToggleMenuItem,
14
+ store as preferencesStore,
15
+ } from '@wordpress/preferences';
12
16
 
13
17
  /**
14
18
  * Internal dependencies
@@ -20,6 +24,7 @@ import SiteExport from './site-export';
20
24
  import WelcomeGuideMenuItem from './welcome-guide-menu-item';
21
25
  import CopyContentMenuItem from './copy-content-menu-item';
22
26
  import ModeSwitcher from '../mode-switcher';
27
+ import { store as siteEditorStore } from '../../../store';
23
28
 
24
29
  export default function MoreMenu( { showIconLabels } ) {
25
30
  const [ isModalActive, toggleModal ] = useReducer(
@@ -32,6 +37,29 @@ export default function MoreMenu( { showIconLabels } ) {
32
37
  false
33
38
  );
34
39
 
40
+ const registry = useRegistry();
41
+ const isDistractionFree = useSelect(
42
+ ( select ) =>
43
+ select( preferencesStore ).get(
44
+ 'core/edit-site',
45
+ 'distractionFree'
46
+ ),
47
+ []
48
+ );
49
+
50
+ const { setIsInserterOpened, setIsListViewOpened, closeGeneralSidebar } =
51
+ useDispatch( siteEditorStore );
52
+ const { set: setPreference } = useDispatch( preferencesStore );
53
+
54
+ const toggleDistractionFree = () => {
55
+ registry.batch( () => {
56
+ setPreference( 'core/edit-site', 'fixedToolbar', false );
57
+ setIsInserterOpened( false );
58
+ setIsListViewOpened( false );
59
+ closeGeneralSidebar();
60
+ } );
61
+ };
62
+
35
63
  useShortcut( 'core/edit-site/keyboard-shortcuts', toggleModal );
36
64
 
37
65
  return (
@@ -48,6 +76,7 @@ export default function MoreMenu( { showIconLabels } ) {
48
76
  <PreferenceToggleMenuItem
49
77
  scope="core/edit-site"
50
78
  name="fixedToolbar"
79
+ disabled={ isDistractionFree }
51
80
  label={ __( 'Top toolbar' ) }
52
81
  info={ __(
53
82
  'Access all block and document tools in a single place'
@@ -71,14 +100,30 @@ export default function MoreMenu( { showIconLabels } ) {
71
100
  'Spotlight mode deactivated'
72
101
  ) }
73
102
  />
74
- <ModeSwitcher />
75
- <ActionItem.Slot
76
- name="core/edit-site/plugin-more-menu"
77
- label={ __( 'Plugins' ) }
78
- as={ MenuGroup }
79
- fillProps={ { onClick: onClose } }
103
+ <PreferenceToggleMenuItem
104
+ scope="core/edit-site"
105
+ name="distractionFree"
106
+ onToggle={ toggleDistractionFree }
107
+ label={ __( 'Distraction free' ) }
108
+ info={ __( 'Write with calmness' ) }
109
+ messageActivated={ __(
110
+ 'Distraction free mode activated'
111
+ ) }
112
+ messageDeactivated={ __(
113
+ 'Distraction free mode deactivated'
114
+ ) }
115
+ shortcut={ displayShortcut.primaryShift(
116
+ '\\'
117
+ ) }
80
118
  />
81
119
  </MenuGroup>
120
+ <ModeSwitcher />
121
+ <ActionItem.Slot
122
+ name="core/edit-site/plugin-more-menu"
123
+ label={ __( 'Plugins' ) }
124
+ as={ MenuGroup }
125
+ fillProps={ { onClick: onClose } }
126
+ />
82
127
  <MenuGroup label={ __( 'Tools' ) }>
83
128
  <SiteExport />
84
129
  <MenuItem
@@ -1,12 +1,15 @@
1
1
  /**
2
2
  * WordPress dependencies
3
3
  */
4
+ import { __ } from '@wordpress/i18n';
4
5
  import { useShortcut } from '@wordpress/keyboard-shortcuts';
5
6
  import { useDispatch, useSelect } from '@wordpress/data';
6
7
  import { store as coreStore } from '@wordpress/core-data';
7
8
  import { store as blockEditorStore } from '@wordpress/block-editor';
8
9
  import { store as interfaceStore } from '@wordpress/interface';
9
10
  import { createBlock } from '@wordpress/blocks';
11
+ import { store as preferencesStore } from '@wordpress/preferences';
12
+ import { store as noticesStore } from '@wordpress/notices';
10
13
 
11
14
  /**
12
15
  * Internal dependencies
@@ -29,8 +32,14 @@ function KeyboardShortcutsEditMode() {
29
32
  []
30
33
  );
31
34
  const { redo, undo } = useDispatch( coreStore );
32
- const { setIsListViewOpened, switchEditorMode } =
33
- useDispatch( editSiteStore );
35
+ const {
36
+ isFeatureActive,
37
+ setIsListViewOpened,
38
+ switchEditorMode,
39
+ toggleFeature,
40
+ setIsInserterOpened,
41
+ closeGeneralSidebar,
42
+ } = useDispatch( editSiteStore );
34
43
  const { enableComplementaryArea, disableComplementaryArea } =
35
44
  useDispatch( interfaceStore );
36
45
 
@@ -38,6 +47,16 @@ function KeyboardShortcutsEditMode() {
38
47
  const { getBlockName, getSelectedBlockClientId, getBlockAttributes } =
39
48
  useSelect( blockEditorStore );
40
49
 
50
+ const { set: setPreference } = useDispatch( preferencesStore );
51
+ const { createInfoNotice } = useDispatch( noticesStore );
52
+
53
+ const toggleDistractionFree = () => {
54
+ setPreference( 'core/edit-site', 'fixedToolbar', false );
55
+ setIsInserterOpened( false );
56
+ setIsListViewOpened( false );
57
+ closeGeneralSidebar();
58
+ };
59
+
41
60
  const handleTextLevelShortcut = ( event, level ) => {
42
61
  event.preventDefault();
43
62
  const destinationBlockName =
@@ -114,6 +133,20 @@ function KeyboardShortcutsEditMode() {
114
133
  );
115
134
  } );
116
135
 
136
+ useShortcut( 'core/edit-site/toggle-distraction-free', () => {
137
+ toggleDistractionFree();
138
+ toggleFeature( 'distractionFree' );
139
+ createInfoNotice(
140
+ isFeatureActive( 'distractionFree' )
141
+ ? __( 'Distraction free mode turned on.' )
142
+ : __( 'Distraction free mode turned off.' ),
143
+ {
144
+ id: 'core/edit-site/distraction-free-mode/notice',
145
+ type: 'snackbar',
146
+ }
147
+ );
148
+ } );
149
+
117
150
  return null;
118
151
  }
119
152
 
@@ -149,6 +149,16 @@ function KeyboardShortcutsRegister() {
149
149
  },
150
150
  } );
151
151
  } );
152
+
153
+ registerShortcut( {
154
+ name: 'core/edit-site/toggle-distraction-free',
155
+ category: 'global',
156
+ description: __( 'Toggle distraction free mode.' ),
157
+ keyCombination: {
158
+ modifier: 'primaryShift',
159
+ character: '\\',
160
+ },
161
+ } );
152
162
  }, [ registerShortcut ] );
153
163
 
154
164
  return null;
@@ -72,24 +72,36 @@ export default function Layout() {
72
72
  const isMobileViewport = useViewportMatch( 'medium', '<' );
73
73
  const isListPage = getIsListPage( params, isMobileViewport );
74
74
  const isEditorPage = ! isListPage;
75
- const { hasFixedToolbar, canvasMode, previousShortcut, nextShortcut } =
76
- useSelect( ( select ) => {
77
- const { getAllShortcutKeyCombinations } = select(
78
- keyboardShortcutsStore
79
- );
80
- const { getCanvasMode } = unlock( select( editSiteStore ) );
81
- return {
82
- canvasMode: getCanvasMode(),
83
- previousShortcut: getAllShortcutKeyCombinations(
84
- 'core/edit-site/previous-region'
85
- ),
86
- nextShortcut: getAllShortcutKeyCombinations(
87
- 'core/edit-site/next-region'
88
- ),
89
- hasFixedToolbar:
90
- select( preferencesStore ).get( 'fixedToolbar' ),
91
- };
92
- }, [] );
75
+
76
+ const {
77
+ isDistractionFree,
78
+ hasFixedToolbar,
79
+ canvasMode,
80
+ previousShortcut,
81
+ nextShortcut,
82
+ } = useSelect( ( select ) => {
83
+ const { getAllShortcutKeyCombinations } = select(
84
+ keyboardShortcutsStore
85
+ );
86
+ const { getCanvasMode } = unlock( select( editSiteStore ) );
87
+ return {
88
+ canvasMode: getCanvasMode(),
89
+ previousShortcut: getAllShortcutKeyCombinations(
90
+ 'core/edit-site/previous-region'
91
+ ),
92
+ nextShortcut: getAllShortcutKeyCombinations(
93
+ 'core/edit-site/next-region'
94
+ ),
95
+ hasFixedToolbar: select( preferencesStore ).get(
96
+ 'core/edit-site',
97
+ 'fixedToolbar'
98
+ ),
99
+ isDistractionFree: select( preferencesStore ).get(
100
+ 'core/edit-site',
101
+ 'distractionFree'
102
+ ),
103
+ };
104
+ }, [] );
93
105
  const isEditing = canvasMode === 'edit';
94
106
  const navigateRegionsProps = useNavigateRegions( {
95
107
  previous: previousShortcut,
@@ -110,6 +122,27 @@ export default function Layout() {
110
122
  const [ isResizing ] = useState( false );
111
123
  const isEditorLoading = useIsSiteEditorLoading();
112
124
 
125
+ // This determines which animation variant should apply to the header.
126
+ // There is also a `isDistractionFreeHovering` state that gets priority
127
+ // when hovering the `edit-site-layout__header-container` in distraction
128
+ // free mode. It's set via framer and trickles down to all the children
129
+ // so they can use this variant state too.
130
+ //
131
+ // TODO: The issue with this is we want to have the hover state stick when hovering
132
+ // a popover opened via the header. We'll probably need to lift this state to
133
+ // handle it ourselves. Also, focusWithin the header needs to be handled.
134
+ let headerAnimationState;
135
+
136
+ if ( canvasMode === 'view' ) {
137
+ // We need 'view' to always take priority so 'isDistractionFree'
138
+ // doesn't bleed over into the view (sidebar) state
139
+ headerAnimationState = 'view';
140
+ } else if ( isDistractionFree ) {
141
+ headerAnimationState = 'isDistractionFree';
142
+ } else {
143
+ headerAnimationState = canvasMode; // edit, view, init
144
+ }
145
+
113
146
  // Sets the right context for the command center
114
147
  const commandContext =
115
148
  canvasMode === 'edit' && isEditorPage
@@ -140,41 +173,77 @@ export default function Layout() {
140
173
  'edit-site-layout',
141
174
  navigateRegionsProps.className,
142
175
  {
176
+ 'is-distraction-free': isDistractionFree && isEditing,
143
177
  'is-full-canvas': isFullCanvas,
144
178
  'is-edit-mode': isEditing,
145
179
  'has-fixed-toolbar': hasFixedToolbar,
146
180
  }
147
181
  ) }
148
182
  >
149
- <SiteHub ref={ hubRef } className="edit-site-layout__hub" />
150
-
151
- <AnimatePresence initial={ false }>
152
- { isEditorPage && isEditing && (
153
- <NavigableRegion
154
- className="edit-site-layout__header"
155
- ariaLabel={ __( 'Editor top bar' ) }
156
- as={ motion.div }
157
- animate={ {
158
- y: 0,
159
- } }
160
- initial={ {
161
- y: '-100%',
162
- } }
163
- exit={ {
164
- y: '-100%',
165
- } }
166
- transition={ {
183
+ <motion.div
184
+ className="edit-site-layout__header-container"
185
+ variants={ {
186
+ isDistractionFree: {
187
+ opacity: 0,
188
+ transition: {
167
189
  type: 'tween',
168
- duration: disableMotion
169
- ? 0
170
- : ANIMATION_DURATION,
171
- ease: 'easeOut',
172
- } }
173
- >
174
- { isEditing && <Header /> }
175
- </NavigableRegion>
176
- ) }
177
- </AnimatePresence>
190
+ delay: 0.8,
191
+ delayChildren: 0.8,
192
+ }, // How long to wait before the header exits
193
+ },
194
+ isDistractionFreeHovering: {
195
+ opacity: 1,
196
+ transition: {
197
+ type: 'tween',
198
+ delay: 0.2,
199
+ delayChildren: 0.2,
200
+ }, // How long to wait before the header shows
201
+ },
202
+ view: { opacity: 1 },
203
+ edit: { opacity: 1 },
204
+ } }
205
+ whileHover={
206
+ isDistractionFree
207
+ ? 'isDistractionFreeHovering'
208
+ : undefined
209
+ }
210
+ animate={ headerAnimationState }
211
+ >
212
+ <SiteHub
213
+ as={ motion.div }
214
+ variants={ {
215
+ isDistractionFree: { x: '-100%' },
216
+ isDistractionFreeHovering: { x: 0 },
217
+ view: { x: 0 },
218
+ edit: { x: 0 },
219
+ } }
220
+ ref={ hubRef }
221
+ className="edit-site-layout__hub"
222
+ />
223
+
224
+ <AnimatePresence initial={ false }>
225
+ { isEditorPage && isEditing && (
226
+ <NavigableRegion
227
+ className="edit-site-layout__header"
228
+ ariaLabel={ __( 'Editor top bar' ) }
229
+ as={ motion.div }
230
+ variants={ {
231
+ isDistractionFree: { opacity: 0 },
232
+ isDistractionFreeHovering: { opacity: 1 },
233
+ view: { opacity: 1 },
234
+ edit: { opacity: 1 },
235
+ } }
236
+ transition={ {
237
+ type: 'tween',
238
+ duration: disableMotion ? 0 : 0.2,
239
+ ease: 'easeOut',
240
+ } }
241
+ >
242
+ { isEditing && <Header /> }
243
+ </NavigableRegion>
244
+ ) }
245
+ </AnimatePresence>
246
+ </motion.div>
178
247
 
179
248
  <div className="edit-site-layout__content">
180
249
  <AnimatePresence initial={ false }>
@@ -1,9 +1,20 @@
1
1
  .edit-site-layout {
2
2
  height: 100%;
3
3
  background: $gray-900;
4
- color: $white;
4
+ color: $gray-400;
5
5
  display: flex;
6
6
  flex-direction: column;
7
+
8
+ // Expand the fixed block toolbar to cover the document title control.
9
+ .block-editor-block-contextual-toolbar {
10
+ @include break-medium() {
11
+ &.is-fixed {
12
+ // the combined with of the tools at the right of the header and the margin left
13
+ width: calc(100% - 240px - #{$grid-unit-80} - #{$grid-unit-70});
14
+ }
15
+ }
16
+ }
17
+
7
18
  }
8
19
 
9
20
  .edit-site-layout__hub {
@@ -36,6 +47,10 @@
36
47
  }
37
48
  }
38
49
 
50
+ .edit-site-layout__header-container {
51
+ z-index: z-index(".edit-site-layout__header-container");
52
+ }
53
+
39
54
  .edit-site-layout__header {
40
55
  height: $header-height;
41
56
  display: flex;
@@ -249,6 +264,9 @@
249
264
  // so the fixed toolbar can be positioned on top of it
250
265
  // but only on desktop
251
266
  @include break-medium() {
267
+ .edit-site-layout__canvas-container {
268
+ z-index: 5;
269
+ }
252
270
  .edit-site-site-hub {
253
271
  z-index: 4;
254
272
  }
@@ -258,3 +276,42 @@
258
276
  }
259
277
  }
260
278
 
279
+ .is-edit-mode.is-distraction-free {
280
+
281
+ .edit-site-layout__header-container {
282
+ height: $header-height;
283
+ position: absolute;
284
+ top: 0;
285
+ left: 0;
286
+ right: 0;
287
+ z-index: z-index(".edit-site-layout__header-container");
288
+ width: 100%;
289
+
290
+ // We need ! important because we override inline styles
291
+ // set by the motion component.
292
+ &:focus-within {
293
+ opacity: 1 !important;
294
+ div {
295
+ transform: translateX(0) translateY(0) translateZ(0) !important;
296
+ }
297
+
298
+ .edit-site-layout__header {
299
+ opacity: 1 !important;
300
+ }
301
+ }
302
+ }
303
+
304
+ .edit-site-site-hub,
305
+ .edit-site-layout__header {
306
+ position: absolute;
307
+ top: 0;
308
+ z-index: z-index(".edit-site-layout__header");
309
+ }
310
+ .edit-site-site-hub {
311
+ z-index: z-index(".edit-site-layout__hub");
312
+ }
313
+ .edit-site-layout__header {
314
+ width: 100%;
315
+ }
316
+
317
+ }
@@ -25,8 +25,11 @@ export default function BackToPageNotification() {
25
25
  * switches from focusing on editing page content to editing a template.
26
26
  */
27
27
  export function useBackToPageNotification() {
28
- const hasPageContentFocus = useSelect(
29
- ( select ) => select( editSiteStore ).hasPageContentFocus(),
28
+ const { isPage, hasPageContentFocus } = useSelect(
29
+ ( select ) => ( {
30
+ isPage: select( editSiteStore ).isPage(),
31
+ hasPageContentFocus: select( editSiteStore ).hasPageContentFocus(),
32
+ } ),
30
33
  []
31
34
  );
32
35
 
@@ -39,6 +42,7 @@ export function useBackToPageNotification() {
39
42
  useEffect( () => {
40
43
  if (
41
44
  ! alreadySeen.current &&
45
+ isPage &&
42
46
  prevHasPageContentFocus.current &&
43
47
  ! hasPageContentFocus
44
48
  ) {
@@ -57,6 +61,7 @@ export function useBackToPageNotification() {
57
61
  prevHasPageContentFocus.current = hasPageContentFocus;
58
62
  }, [
59
63
  alreadySeen,
64
+ isPage,
60
65
  prevHasPageContentFocus,
61
66
  hasPageContentFocus,
62
67
  createInfoNotice,
@@ -49,6 +49,12 @@ export default function GridItem( { categoryId, composite, icon, item } ) {
49
49
  canvas: 'edit',
50
50
  } );
51
51
 
52
+ const onKeyDown = ( event ) => {
53
+ if ( DELETE === event.keyCode || BACKSPACE === event.keyCode ) {
54
+ setIsDeleteDialogOpen( true );
55
+ }
56
+ };
57
+
52
58
  const isEmpty = ! item.blocks?.length;
53
59
  const patternClassNames = classnames( 'edit-site-library__pattern', {
54
60
  'is-placeholder': isEmpty,
@@ -72,8 +78,9 @@ export default function GridItem( { categoryId, composite, icon, item } ) {
72
78
  }
73
79
  };
74
80
 
81
+ const isUserPattern = item.type === USER_PATTERNS;
75
82
  let ariaDescription;
76
- if ( item.type === USER_PATTERNS ) {
83
+ if ( isUserPattern ) {
77
84
  // User patterns don't have descriptions, but can be edited and deleted, so include some help text.
78
85
  ariaDescription = __(
79
86
  'Press Enter to edit, or Delete to delete the pattern.'
@@ -91,18 +98,11 @@ export default function GridItem( { categoryId, composite, icon, item } ) {
91
98
  as="div"
92
99
  { ...composite }
93
100
  onClick={ item.type !== PATTERNS ? onClick : undefined }
101
+ onKeyDown={ isUserPattern ? onKeyDown : undefined }
94
102
  aria-label={ item.title }
95
103
  aria-describedby={
96
104
  ariaDescription ? descriptionId : undefined
97
105
  }
98
- onKeyDown={ ( event ) => {
99
- if (
100
- DELETE === event.keyCode ||
101
- BACKSPACE === event.keyCode
102
- ) {
103
- setIsDeleteDialogOpen( true );
104
- }
105
- } }
106
106
  >
107
107
  { isEmpty && __( 'Empty pattern' ) }
108
108
  { ! isEmpty && <BlockPreview blocks={ item.blocks } /> }
@@ -6,7 +6,7 @@
6
6
  }
7
7
 
8
8
  .components-heading {
9
- color: $white;
9
+ color: $gray-200;
10
10
  }
11
11
 
12
12
  @include break-medium {
@@ -78,7 +78,7 @@
78
78
  .edit-site-library__search {
79
79
  &#{&} input[type="search"] {
80
80
  background: $gray-800;
81
- color: $gray-100;
81
+ color: $gray-200;
82
82
 
83
83
  &:focus {
84
84
  background: $gray-800;
@@ -6,14 +6,17 @@ import { ___unstablePreferencesModalBaseOption as BaseOption } from '@wordpress/
6
6
  import { store as preferencesStore } from '@wordpress/preferences';
7
7
 
8
8
  export default function EnableFeature( props ) {
9
- const { featureName, ...remainingProps } = props;
9
+ const { featureName, onToggle = () => {}, ...remainingProps } = props;
10
10
  const isChecked = useSelect(
11
11
  ( select ) =>
12
12
  !! select( preferencesStore ).get( 'core/edit-site', featureName ),
13
13
  [ featureName ]
14
14
  );
15
15
  const { toggle } = useDispatch( preferencesStore );
16
- const onChange = () => toggle( 'core/edit-site', featureName );
16
+ const onChange = () => {
17
+ onToggle();
18
+ toggle( 'core/edit-site', featureName );
19
+ };
17
20
  return (
18
21
  <BaseOption
19
22
  onChange={ onChange }
@@ -8,16 +8,33 @@ import {
8
8
  } from '@wordpress/interface';
9
9
  import { useMemo } from '@wordpress/element';
10
10
  import { __ } from '@wordpress/i18n';
11
+ import { useDispatch, useRegistry } from '@wordpress/data';
12
+ import { store as preferencesStore } from '@wordpress/preferences';
11
13
 
12
14
  /**
13
15
  * Internal dependencies
14
16
  */
15
17
  import EnableFeature from './enable-feature';
18
+ import { store as siteEditorStore } from '../../store';
16
19
 
17
20
  export default function EditSitePreferencesModal( {
18
21
  isModalActive,
19
22
  toggleModal,
20
23
  } ) {
24
+ const registry = useRegistry();
25
+ const { closeGeneralSidebar, setIsListViewOpened, setIsInserterOpened } =
26
+ useDispatch( siteEditorStore );
27
+
28
+ const { set: setPreference } = useDispatch( preferencesStore );
29
+ const toggleDistractionFree = () => {
30
+ registry.batch( () => {
31
+ setPreference( 'core/edit-site', 'fixedToolbar', false );
32
+ setIsInserterOpened( false );
33
+ setIsListViewOpened( false );
34
+ closeGeneralSidebar();
35
+ } );
36
+ };
37
+
21
38
  const sections = useMemo( () => [
22
39
  {
23
40
  name: 'general',
@@ -29,6 +46,14 @@ export default function EditSitePreferencesModal( {
29
46
  'Customize options related to the block editor interface and editing flow.'
30
47
  ) }
31
48
  >
49
+ <EnableFeature
50
+ featureName="distractionFree"
51
+ onToggle={ toggleDistractionFree }
52
+ help={ __(
53
+ 'Reduce visual distractions by hiding the toolbar and other elements to focus on writing.'
54
+ ) }
55
+ label={ __( 'Distraction free' ) }
56
+ />
32
57
  <EnableFeature
33
58
  featureName="focusMode"
34
59
  help={ __(
@@ -19,6 +19,6 @@
19
19
  &:focus,
20
20
  &:not([aria-disabled="true"]):active,
21
21
  &[aria-expanded="true"] {
22
- color: $white;
22
+ color: $gray-100;
23
23
  }
24
24
  }
@@ -56,11 +56,13 @@ export function SidebarComplementaryAreaFills() {
56
56
  useEffect( () => {
57
57
  // Don't automatically switch tab when the sidebar is closed or when we
58
58
  // are focused on page content.
59
- if ( ! isEditorSidebarOpened || hasPageContentFocus ) {
59
+ if ( ! isEditorSidebarOpened ) {
60
60
  return;
61
61
  }
62
62
  if ( hasBlockSelection ) {
63
- enableComplementaryArea( STORE_NAME, SIDEBAR_BLOCK );
63
+ if ( ! hasPageContentFocus ) {
64
+ enableComplementaryArea( STORE_NAME, SIDEBAR_BLOCK );
65
+ }
64
66
  } else {
65
67
  enableComplementaryArea( STORE_NAME, SIDEBAR_TEMPLATE );
66
68
  }
@@ -9,7 +9,7 @@
9
9
  &:hover,
10
10
  &:focus,
11
11
  &[aria-current] {
12
- color: $white;
12
+ color: $gray-200;
13
13
  background: $gray-800;
14
14
  }
15
15
 
@@ -61,7 +61,8 @@ export default function SidebarNavigationScreen( {
61
61
  <NavigatorToParentButton
62
62
  as={ SidebarButton }
63
63
  icon={ isRTL() ? chevronRight : chevronLeft }
64
- aria-label={ __( 'Back' ) }
64
+ label={ __( 'Back' ) }
65
+ showTooltip={ false }
65
66
  />
66
67
  ) }
67
68
  { ! isRoot && backPath && (
@@ -69,6 +70,7 @@ export default function SidebarNavigationScreen( {
69
70
  onClick={ () => goTo( backPath, { isBack: true } ) }
70
71
  icon={ icon }
71
72
  label={ __( 'Back' ) }
73
+ showTooltip={ false }
72
74
  />
73
75
  ) }
74
76
  { isRoot && (
@@ -88,7 +90,7 @@ export default function SidebarNavigationScreen( {
88
90
  ) }
89
91
  <Heading
90
92
  className="edit-site-sidebar-navigation-screen__title"
91
- color={ 'white' }
93
+ color={ '#e0e0e0' /* $gray-200 */ }
92
94
  level={ 1 }
93
95
  size={ 20 }
94
96
  >