@wordpress/edit-site 6.0.0 → 6.0.1

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 (100) hide show
  1. package/build/components/block-editor/inserter-media-categories.js +1 -1
  2. package/build/components/block-editor/inserter-media-categories.js.map +1 -1
  3. package/build/components/editor/index.js +52 -59
  4. package/build/components/editor/index.js.map +1 -1
  5. package/build/components/editor/use-editor-title.js +39 -0
  6. package/build/components/editor/use-editor-title.js.map +1 -0
  7. package/build/components/global-styles/screen-css.js +1 -1
  8. package/build/components/global-styles/screen-css.js.map +1 -1
  9. package/build/components/global-styles/screen-revisions/revisions-buttons.js +1 -1
  10. package/build/components/global-styles/screen-revisions/revisions-buttons.js.map +1 -1
  11. package/build/components/global-styles/variations/variations-color.js +1 -1
  12. package/build/components/global-styles/variations/variations-color.js.map +1 -1
  13. package/build/components/global-styles-sidebar/index.js +2 -0
  14. package/build/components/global-styles-sidebar/index.js.map +1 -1
  15. package/build/components/layout/index.js +16 -59
  16. package/build/components/layout/index.js.map +1 -1
  17. package/build/components/page-patterns/index.js +5 -5
  18. package/build/components/page-patterns/index.js.map +1 -1
  19. package/build/components/pagination/index.js +17 -8
  20. package/build/components/pagination/index.js.map +1 -1
  21. package/build/components/sidebar-dataviews/dataview-item.js +6 -2
  22. package/build/components/sidebar-dataviews/dataview-item.js.map +1 -1
  23. package/build/components/sidebar-navigation-screen/index.js +1 -1
  24. package/build/components/sidebar-navigation-screen/index.js.map +1 -1
  25. package/build/components/sidebar-navigation-screen-navigation-menu/rename-modal.js +1 -0
  26. package/build/components/sidebar-navigation-screen-navigation-menu/rename-modal.js.map +1 -1
  27. package/build/components/sidebar-navigation-screen-patterns/category-item.js +1 -1
  28. package/build/components/sidebar-navigation-screen-patterns/category-item.js.map +1 -1
  29. package/build/components/sidebar-navigation-screen-patterns/index.js +1 -1
  30. package/build/components/sidebar-navigation-screen-patterns/index.js.map +1 -1
  31. package/build/components/site-hub/index.js +38 -128
  32. package/build/components/site-hub/index.js.map +1 -1
  33. package/build/hooks/push-changes-to-global-styles/index.js +1 -0
  34. package/build/hooks/push-changes-to-global-styles/index.js.map +1 -1
  35. package/build/store/private-actions.js +33 -18
  36. package/build/store/private-actions.js.map +1 -1
  37. package/build-module/components/block-editor/inserter-media-categories.js +1 -1
  38. package/build-module/components/block-editor/inserter-media-categories.js.map +1 -1
  39. package/build-module/components/editor/index.js +52 -59
  40. package/build-module/components/editor/index.js.map +1 -1
  41. package/build-module/components/editor/use-editor-title.js +31 -0
  42. package/build-module/components/editor/use-editor-title.js.map +1 -0
  43. package/build-module/components/global-styles/screen-css.js +1 -1
  44. package/build-module/components/global-styles/screen-css.js.map +1 -1
  45. package/build-module/components/global-styles/screen-revisions/revisions-buttons.js +1 -1
  46. package/build-module/components/global-styles/screen-revisions/revisions-buttons.js.map +1 -1
  47. package/build-module/components/global-styles/variations/variations-color.js +2 -2
  48. package/build-module/components/global-styles/variations/variations-color.js.map +1 -1
  49. package/build-module/components/global-styles-sidebar/index.js +2 -0
  50. package/build-module/components/global-styles-sidebar/index.js.map +1 -1
  51. package/build-module/components/layout/index.js +18 -61
  52. package/build-module/components/layout/index.js.map +1 -1
  53. package/build-module/components/page-patterns/index.js +5 -5
  54. package/build-module/components/page-patterns/index.js.map +1 -1
  55. package/build-module/components/pagination/index.js +17 -8
  56. package/build-module/components/pagination/index.js.map +1 -1
  57. package/build-module/components/sidebar-dataviews/dataview-item.js +6 -2
  58. package/build-module/components/sidebar-dataviews/dataview-item.js.map +1 -1
  59. package/build-module/components/sidebar-navigation-screen/index.js +1 -1
  60. package/build-module/components/sidebar-navigation-screen/index.js.map +1 -1
  61. package/build-module/components/sidebar-navigation-screen-navigation-menu/rename-modal.js +1 -0
  62. package/build-module/components/sidebar-navigation-screen-navigation-menu/rename-modal.js.map +1 -1
  63. package/build-module/components/sidebar-navigation-screen-patterns/category-item.js +2 -2
  64. package/build-module/components/sidebar-navigation-screen-patterns/category-item.js.map +1 -1
  65. package/build-module/components/sidebar-navigation-screen-patterns/index.js +1 -1
  66. package/build-module/components/sidebar-navigation-screen-patterns/index.js.map +1 -1
  67. package/build-module/components/site-hub/index.js +40 -130
  68. package/build-module/components/site-hub/index.js.map +1 -1
  69. package/build-module/hooks/push-changes-to-global-styles/index.js +1 -0
  70. package/build-module/hooks/push-changes-to-global-styles/index.js.map +1 -1
  71. package/build-module/store/private-actions.js +33 -18
  72. package/build-module/store/private-actions.js.map +1 -1
  73. package/build-style/style-rtl.css +43 -85
  74. package/build-style/style.css +43 -85
  75. package/package.json +41 -41
  76. package/src/components/block-editor/inserter-media-categories.js +1 -3
  77. package/src/components/block-editor/style.scss +11 -0
  78. package/src/components/editor/index.js +67 -95
  79. package/src/components/editor/style.scss +1 -5
  80. package/src/components/editor/use-editor-title.js +35 -0
  81. package/src/components/global-styles/screen-css.js +1 -1
  82. package/src/components/global-styles/screen-revisions/revisions-buttons.js +1 -1
  83. package/src/components/global-styles/screen-revisions/style.scss +4 -8
  84. package/src/components/global-styles/variations/variations-color.js +6 -3
  85. package/src/components/global-styles-sidebar/index.js +2 -0
  86. package/src/components/layout/index.js +17 -67
  87. package/src/components/layout/style.scss +18 -58
  88. package/src/components/page-patterns/index.js +15 -12
  89. package/src/components/pagination/index.js +21 -16
  90. package/src/components/sidebar-dataviews/dataview-item.js +6 -2
  91. package/src/components/sidebar-navigation-screen/index.js +1 -1
  92. package/src/components/sidebar-navigation-screen/style.scss +2 -2
  93. package/src/components/sidebar-navigation-screen-navigation-menu/rename-modal.js +1 -0
  94. package/src/components/sidebar-navigation-screen-patterns/category-item.js +11 -2
  95. package/src/components/sidebar-navigation-screen-patterns/index.js +5 -1
  96. package/src/components/site-hub/index.js +55 -146
  97. package/src/components/site-hub/style.scss +1 -4
  98. package/src/components/site-icon/style.scss +0 -4
  99. package/src/hooks/push-changes-to-global-styles/index.js +1 -0
  100. package/src/store/private-actions.js +58 -30
@@ -7,19 +7,11 @@ import clsx from 'clsx';
7
7
  * WordPress dependencies
8
8
  */
9
9
  import { useSelect, useDispatch } from '@wordpress/data';
10
- import {
11
- Button,
12
- __unstableMotion as motion,
13
- __unstableAnimatePresence as AnimatePresence,
14
- __experimentalHStack as HStack,
15
- } from '@wordpress/components';
16
- import { useReducedMotion } from '@wordpress/compose';
10
+ import { Button, __experimentalHStack as HStack } from '@wordpress/components';
17
11
  import { __ } from '@wordpress/i18n';
18
- import { store as blockEditorStore } from '@wordpress/block-editor';
19
12
  import { store as coreStore } from '@wordpress/core-data';
20
- import { store as editorStore } from '@wordpress/editor';
21
13
  import { decodeEntities } from '@wordpress/html-entities';
22
- import { memo } from '@wordpress/element';
14
+ import { memo, forwardRef } from '@wordpress/element';
23
15
  import { search } from '@wordpress/icons';
24
16
  import { store as commandsStore } from '@wordpress/commands';
25
17
  import { displayShortcut } from '@wordpress/keycodes';
@@ -32,14 +24,10 @@ import { store as editSiteStore } from '../../store';
32
24
  import SiteIcon from '../site-icon';
33
25
  import { unlock } from '../../lock-unlock';
34
26
 
35
- const HUB_ANIMATION_DURATION = 0.3;
36
-
37
- const SiteHub = memo( ( { isTransparent, className } ) => {
38
- const { canvasMode, dashboardLink, homeUrl, siteTitle } = useSelect(
39
- ( select ) => {
40
- const { getCanvasMode, getSettings } = unlock(
41
- select( editSiteStore )
42
- );
27
+ const SiteHub = memo(
28
+ forwardRef( ( { isTransparent }, ref ) => {
29
+ const { dashboardLink, homeUrl, siteTitle } = useSelect( ( select ) => {
30
+ const { getSettings } = unlock( select( editSiteStore ) );
43
31
 
44
32
  const {
45
33
  getSite,
@@ -47,7 +35,6 @@ const SiteHub = memo( ( { isTransparent, className } ) => {
47
35
  } = select( coreStore );
48
36
  const _site = getSite();
49
37
  return {
50
- canvasMode: getCanvasMode(),
51
38
  dashboardLink:
52
39
  getSettings().__experimentalDashboardLink || 'index.php',
53
40
  homeUrl: getUnstableBase()?.home,
@@ -56,141 +43,63 @@ const SiteHub = memo( ( { isTransparent, className } ) => {
56
43
  ? filterURLForDisplay( _site?.url )
57
44
  : _site?.title,
58
45
  };
59
- },
60
- []
61
- );
62
- const { open: openCommandCenter } = useDispatch( commandsStore );
63
-
64
- const disableMotion = useReducedMotion();
65
- const { setCanvasMode } = unlock( useDispatch( editSiteStore ) );
66
- const { clearSelectedBlock } = useDispatch( blockEditorStore );
67
- const { setDeviceType } = useDispatch( editorStore );
68
- const isBackToDashboardButton = canvasMode === 'view';
69
- const siteIconButtonProps = isBackToDashboardButton
70
- ? {
71
- href: dashboardLink,
72
- label: __( 'Go to the Dashboard' ),
73
- }
74
- : {
75
- href: dashboardLink, // We need to keep the `href` here so the component doesn't remount as a `<button>` and break the animation.
76
- role: 'button',
77
- label: __( 'Open Navigation' ),
78
- onClick: ( event ) => {
79
- event.preventDefault();
80
- if ( canvasMode === 'edit' ) {
81
- clearSelectedBlock();
82
- setDeviceType( 'Desktop' );
83
- setCanvasMode( 'view' );
84
- }
85
- },
86
- };
46
+ }, [] );
47
+ const { open: openCommandCenter } = useDispatch( commandsStore );
87
48
 
88
- return (
89
- <motion.div
90
- className={ clsx( 'edit-site-site-hub', className ) }
91
- variants={ {
92
- isDistractionFree: { x: '-100%' },
93
- isDistractionFreeHovering: { x: 0 },
94
- view: { x: 0 },
95
- edit: { x: 0 },
96
- } }
97
- initial={ false }
98
- transition={ {
99
- type: 'tween',
100
- duration: disableMotion ? 0 : HUB_ANIMATION_DURATION,
101
- ease: 'easeOut',
102
- } }
103
- >
104
- <HStack justify="flex-start" spacing="0">
105
- <motion.div
106
- className={ clsx(
107
- 'edit-site-site-hub__view-mode-toggle-container',
108
- {
109
- 'has-transparent-background': isTransparent,
110
- }
111
- ) }
112
- layout
113
- transition={ {
114
- type: 'tween',
115
- duration: disableMotion ? 0 : HUB_ANIMATION_DURATION,
116
- ease: 'easeOut',
117
- } }
118
- >
119
- <Button
120
- { ...siteIconButtonProps }
121
- className="edit-site-layout__view-mode-toggle"
49
+ return (
50
+ <div className="edit-site-site-hub">
51
+ <HStack justify="flex-start" spacing="0">
52
+ <div
53
+ className={ clsx(
54
+ 'edit-site-site-hub__view-mode-toggle-container',
55
+ {
56
+ 'has-transparent-background': isTransparent,
57
+ }
58
+ ) }
122
59
  >
123
- <motion.div
124
- initial={ false }
125
- animate={ {
126
- scale: canvasMode === 'view' ? 0.5 : 1,
127
- } }
128
- whileHover={ {
129
- scale: canvasMode === 'view' ? 0.5 : 0.96,
130
- } }
131
- transition={ {
132
- type: 'tween',
133
- duration: disableMotion
134
- ? 0
135
- : HUB_ANIMATION_DURATION,
136
- ease: 'easeOut',
60
+ <Button
61
+ ref={ ref }
62
+ href={ dashboardLink }
63
+ label={ __( 'Go to the Dashboard' ) }
64
+ className="edit-site-layout__view-mode-toggle"
65
+ style={ {
66
+ transform: 'scale(0.5)',
67
+ borderRadius: 4,
137
68
  } }
138
69
  >
139
70
  <SiteIcon className="edit-site-layout__view-mode-toggle-icon" />
140
- </motion.div>
141
- </Button>
142
- </motion.div>
71
+ </Button>
72
+ </div>
143
73
 
144
- <AnimatePresence initial={ false }>
145
- { canvasMode === 'view' && (
74
+ <HStack>
75
+ <div className="edit-site-site-hub__title">
76
+ <Button
77
+ variant="link"
78
+ href={ homeUrl }
79
+ target="_blank"
80
+ label={ __( 'View site (opens in a new tab)' ) }
81
+ >
82
+ { decodeEntities( siteTitle ) }
83
+ </Button>
84
+ </div>
146
85
  <HStack
147
- as={ motion.div }
148
- initial={ { opacity: 0 } }
149
- animate={ {
150
- opacity: isTransparent ? 0 : 1,
151
- } }
152
- exit={ { opacity: 0 } }
153
- transition={ {
154
- type: 'tween',
155
- duration: disableMotion ? 0 : 0.2,
156
- ease: 'easeOut',
157
- delay: canvasMode === 'view' ? 0.1 : 0,
158
- } }
86
+ spacing={ 0 }
87
+ expanded={ false }
88
+ className="edit-site-site-hub__actions"
159
89
  >
160
- <div className="edit-site-site-hub__title">
161
- <Button
162
- variant="link"
163
- href={ homeUrl }
164
- target="_blank"
165
- label={ __(
166
- 'View site (opens in a new tab)'
167
- ) }
168
- aria-label={ __(
169
- 'View site (opens in a new tab)'
170
- ) }
171
- >
172
- { decodeEntities( siteTitle ) }
173
- </Button>
174
- </div>
175
- <HStack
176
- spacing={ 0 }
177
- expanded={ false }
178
- className="edit-site-site-hub__actions"
179
- >
180
- <Button
181
- className="edit-site-site-hub_toggle-command-center"
182
- icon={ search }
183
- onClick={ () => openCommandCenter() }
184
- label={ __( 'Open command palette' ) }
185
- shortcut={ displayShortcut.primary( 'k' ) }
186
- />
187
- </HStack>
90
+ <Button
91
+ className="edit-site-site-hub_toggle-command-center"
92
+ icon={ search }
93
+ onClick={ () => openCommandCenter() }
94
+ label={ __( 'Open command palette' ) }
95
+ shortcut={ displayShortcut.primary( 'k' ) }
96
+ />
188
97
  </HStack>
189
- ) }
190
- </AnimatePresence>
191
- </HStack>
192
- </motion.div>
193
- );
194
- } );
98
+ </HStack>
99
+ </HStack>
100
+ </div>
101
+ );
102
+ } )
103
+ );
195
104
 
196
105
  export default SiteHub;
@@ -3,6 +3,7 @@
3
3
  align-items: center;
4
4
  justify-content: space-between;
5
5
  gap: $grid-unit-10;
6
+ margin-right: $grid-unit-15;
6
7
  }
7
8
 
8
9
  .edit-site-site-hub__actions {
@@ -14,10 +15,6 @@
14
15
  width: $header-height;
15
16
  flex-shrink: 0;
16
17
 
17
- .edit-site-layout__view-mode-toggle-icon {
18
- background: $gray-900;
19
- }
20
-
21
18
  &.has-transparent-background .edit-site-layout__view-mode-toggle-icon {
22
19
  background: transparent;
23
20
  }
@@ -1,8 +1,5 @@
1
1
  .edit-site-site-icon__icon {
2
2
  fill: currentColor;
3
- // Matches SiteIcon motion, smoothing out the transition.
4
- transition: padding 0.3s ease-out;
5
- @include reduce-motion("transition");
6
3
 
7
4
  .edit-site-layout.is-full-canvas & {
8
5
  // Make the WordPress icon not so big in full canvas.
@@ -13,7 +10,6 @@
13
10
  .edit-site-site-icon__image {
14
11
  width: 100%;
15
12
  height: 100%;
16
- border-radius: $radius-block-ui * 2;
17
13
  object-fit: cover;
18
14
  background: #333;
19
15
 
@@ -339,6 +339,7 @@ function PushChangesToGlobalStylesControl( {
339
339
  <Button
340
340
  __next40pxDefaultSize
341
341
  variant="secondary"
342
+ __experimentalIsFocusable
342
343
  disabled={ changes.length === 0 }
343
344
  onClick={ pushChanges }
344
345
  >
@@ -13,39 +13,67 @@ import { store as editorStore } from '@wordpress/editor';
13
13
  export const setCanvasMode =
14
14
  ( mode ) =>
15
15
  ( { registry, dispatch } ) => {
16
- const isMediumOrBigger =
17
- window.matchMedia( '(min-width: 782px)' ).matches;
18
- registry.dispatch( blockEditorStore ).__unstableSetEditorMode( 'edit' );
19
- const isPublishSidebarOpened = registry
20
- .select( editorStore )
21
- .isPublishSidebarOpened();
22
- dispatch( {
23
- type: 'SET_CANVAS_MODE',
24
- mode,
25
- } );
26
- const isEditMode = mode === 'edit';
27
- if ( isPublishSidebarOpened && ! isEditMode ) {
28
- registry.dispatch( editorStore ).closePublishSidebar();
29
- }
16
+ const switchCanvasMode = () => {
17
+ registry.batch( () => {
18
+ const isMediumOrBigger =
19
+ window.matchMedia( '(min-width: 782px)' ).matches;
20
+ registry.dispatch( blockEditorStore ).clearSelectedBlock();
21
+ registry.dispatch( editorStore ).setDeviceType( 'Desktop' );
22
+ registry
23
+ .dispatch( blockEditorStore )
24
+ .__unstableSetEditorMode( 'edit' );
25
+ const isPublishSidebarOpened = registry
26
+ .select( editorStore )
27
+ .isPublishSidebarOpened();
28
+ dispatch( {
29
+ type: 'SET_CANVAS_MODE',
30
+ mode,
31
+ } );
32
+ const isEditMode = mode === 'edit';
33
+ if ( isPublishSidebarOpened && ! isEditMode ) {
34
+ registry.dispatch( editorStore ).closePublishSidebar();
35
+ }
36
+
37
+ // Check if the block list view should be open by default.
38
+ // If `distractionFree` mode is enabled, the block list view should not be open.
39
+ // This behavior is disabled for small viewports.
40
+ if (
41
+ isMediumOrBigger &&
42
+ isEditMode &&
43
+ registry
44
+ .select( preferencesStore )
45
+ .get( 'core', 'showListViewByDefault' ) &&
46
+ ! registry
47
+ .select( preferencesStore )
48
+ .get( 'core', 'distractionFree' )
49
+ ) {
50
+ registry
51
+ .dispatch( editorStore )
52
+ .setIsListViewOpened( true );
53
+ } else {
54
+ registry
55
+ .dispatch( editorStore )
56
+ .setIsListViewOpened( false );
57
+ }
58
+ registry.dispatch( editorStore ).setIsInserterOpened( false );
59
+ } );
60
+ };
30
61
 
31
- // Check if the block list view should be open by default.
32
- // If `distractionFree` mode is enabled, the block list view should not be open.
33
- // This behavior is disabled for small viewports.
34
- if (
35
- isMediumOrBigger &&
36
- isEditMode &&
37
- registry
38
- .select( preferencesStore )
39
- .get( 'core', 'showListViewByDefault' ) &&
40
- ! registry
41
- .select( preferencesStore )
42
- .get( 'core', 'distractionFree' )
43
- ) {
44
- registry.dispatch( editorStore ).setIsListViewOpened( true );
62
+ if ( ! document.startViewTransition ) {
63
+ switchCanvasMode();
45
64
  } else {
46
- registry.dispatch( editorStore ).setIsListViewOpened( false );
65
+ document.documentElement.classList.add(
66
+ `canvas-mode-${ mode }-transition`
67
+ );
68
+ const transition = document.startViewTransition( () =>
69
+ switchCanvasMode()
70
+ );
71
+ transition.finished.finally( () => {
72
+ document.documentElement.classList.remove(
73
+ `canvas-mode-${ mode }-transition`
74
+ );
75
+ } );
47
76
  }
48
- registry.dispatch( editorStore ).setIsInserterOpened( false );
49
77
  };
50
78
 
51
79
  /**