@wordpress/edit-site 6.0.5 → 6.0.6

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.
@@ -56,6 +56,18 @@
56
56
  position: relative;
57
57
  width: 100%;
58
58
  z-index: z-index(".edit-site-layout__canvas-container");
59
+
60
+ /*
61
+ * The SiteHubMobile component is displayed
62
+ * for pages that do not have a sidebar,
63
+ * yet it needs the Sidebar component for the React context.
64
+ *
65
+ * This removes the padding in this scenario.
66
+ * See https://github.com/WordPress/gutenberg/pull/63118
67
+ */
68
+ .edit-site-sidebar__screen-wrapper {
69
+ padding: 0;
70
+ }
59
71
  }
60
72
 
61
73
  .edit-site-layout__canvas-container {
@@ -1,6 +1,12 @@
1
1
  .edit-site-sidebar__content {
2
2
  flex-grow: 1;
3
3
  overflow-y: auto;
4
+ // Prevents horizontal overflow while animating screen transitions
5
+ overflow-x: hidden;
6
+ // Mark this section of the DOM as isolated, providing performance benefits
7
+ // by limiting calculations of layout, style and paint to a DOM subtree rather
8
+ // than the entire page.
9
+ contain: content;
4
10
  }
5
11
 
6
12
  @keyframes slide-from-right {
@@ -11,11 +11,12 @@ import { Button, __experimentalHStack as HStack } from '@wordpress/components';
11
11
  import { __ } from '@wordpress/i18n';
12
12
  import { store as coreStore } from '@wordpress/core-data';
13
13
  import { decodeEntities } from '@wordpress/html-entities';
14
- import { memo, forwardRef } from '@wordpress/element';
14
+ import { memo, forwardRef, useContext } from '@wordpress/element';
15
15
  import { search } from '@wordpress/icons';
16
16
  import { store as commandsStore } from '@wordpress/commands';
17
17
  import { displayShortcut } from '@wordpress/keycodes';
18
18
  import { filterURLForDisplay } from '@wordpress/url';
19
+ import { privateApis as routerPrivateApis } from '@wordpress/router';
19
20
 
20
21
  /**
21
22
  * Internal dependencies
@@ -23,6 +24,8 @@ import { filterURLForDisplay } from '@wordpress/url';
23
24
  import { store as editSiteStore } from '../../store';
24
25
  import SiteIcon from '../site-icon';
25
26
  import { unlock } from '../../lock-unlock';
27
+ const { useHistory } = unlock( routerPrivateApis );
28
+ import { SidebarNavigationContext } from '../sidebar';
26
29
 
27
30
  const SiteHub = memo(
28
31
  forwardRef( ( { isTransparent }, ref ) => {
@@ -103,3 +106,83 @@ const SiteHub = memo(
103
106
  );
104
107
 
105
108
  export default SiteHub;
109
+
110
+ export const SiteHubMobile = memo(
111
+ forwardRef( ( { isTransparent }, ref ) => {
112
+ const history = useHistory();
113
+ const { navigate } = useContext( SidebarNavigationContext );
114
+
115
+ const { homeUrl, siteTitle } = useSelect( ( select ) => {
116
+ const {
117
+ getSite,
118
+ getUnstableBase, // Site index.
119
+ } = select( coreStore );
120
+ const _site = getSite();
121
+ return {
122
+ homeUrl: getUnstableBase()?.home,
123
+ siteTitle:
124
+ ! _site?.title && !! _site?.url
125
+ ? filterURLForDisplay( _site?.url )
126
+ : _site?.title,
127
+ };
128
+ }, [] );
129
+ const { open: openCommandCenter } = useDispatch( commandsStore );
130
+
131
+ return (
132
+ <div className="edit-site-site-hub">
133
+ <HStack justify="flex-start" spacing="0">
134
+ <div
135
+ className={ clsx(
136
+ 'edit-site-site-hub__view-mode-toggle-container',
137
+ {
138
+ 'has-transparent-background': isTransparent,
139
+ }
140
+ ) }
141
+ >
142
+ <Button
143
+ ref={ ref }
144
+ label={ __( 'Go to Site Editor' ) }
145
+ className="edit-site-layout__view-mode-toggle"
146
+ style={ {
147
+ transform: 'scale(0.5)',
148
+ borderRadius: 4,
149
+ } }
150
+ onClick={ () => {
151
+ history.push( {} );
152
+ navigate( 'back' );
153
+ } }
154
+ >
155
+ <SiteIcon className="edit-site-layout__view-mode-toggle-icon" />
156
+ </Button>
157
+ </div>
158
+
159
+ <HStack>
160
+ <div className="edit-site-site-hub__title">
161
+ <Button
162
+ variant="link"
163
+ href={ homeUrl }
164
+ target="_blank"
165
+ label={ __( 'View site (opens in a new tab)' ) }
166
+ >
167
+ { decodeEntities( siteTitle ) }
168
+ </Button>
169
+ </div>
170
+ <HStack
171
+ spacing={ 0 }
172
+ expanded={ false }
173
+ className="edit-site-site-hub__actions"
174
+ >
175
+ <Button
176
+ className="edit-site-site-hub_toggle-command-center"
177
+ icon={ search }
178
+ onClick={ () => openCommandCenter() }
179
+ label={ __( 'Open command palette' ) }
180
+ shortcut={ displayShortcut.primary( 'k' ) }
181
+ />
182
+ </HStack>
183
+ </HStack>
184
+ </HStack>
185
+ </div>
186
+ );
187
+ } )
188
+ );