@wordpress/edit-site 5.3.4 → 5.3.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.
- package/build/components/add-new-template/add-custom-template-modal.js +12 -3
- package/build/components/add-new-template/add-custom-template-modal.js.map +1 -1
- package/build/components/add-new-template/new-template-part.js +8 -7
- package/build/components/add-new-template/new-template-part.js.map +1 -1
- package/build/components/add-new-template/new-template.js +3 -6
- package/build/components/add-new-template/new-template.js.map +1 -1
- package/build/components/editor/index.js +3 -3
- package/build/components/editor/index.js.map +1 -1
- package/build/components/global-styles/screen-border.js +1 -1
- package/build/components/global-styles/screen-border.js.map +1 -1
- package/build/components/global-styles/screen-variations.js +1 -1
- package/build/components/global-styles/screen-variations.js.map +1 -1
- package/build/components/global-styles/shadow-panel.js +6 -4
- package/build/components/global-styles/shadow-panel.js.map +1 -1
- package/build/components/global-styles/ui.js +1 -1
- package/build/components/global-styles/ui.js.map +1 -1
- package/build/components/keyboard-shortcuts/edit-mode.js +124 -0
- package/build/components/keyboard-shortcuts/edit-mode.js.map +1 -0
- package/build/components/keyboard-shortcuts/global.js +48 -0
- package/build/components/keyboard-shortcuts/global.js.map +1 -0
- package/build/components/keyboard-shortcuts/register.js +153 -0
- package/build/components/keyboard-shortcuts/register.js.map +1 -0
- package/build/components/layout/index.js +5 -1
- package/build/components/layout/index.js.map +1 -1
- package/build/components/list/added-by.js +41 -42
- package/build/components/list/added-by.js.map +1 -1
- package/build/components/list/table.js +3 -2
- package/build/components/list/table.js.map +1 -1
- package/build/components/navigation-inspector/navigation-menu.js +4 -2
- package/build/components/navigation-inspector/navigation-menu.js.map +1 -1
- package/build/components/save-button/index.js +5 -2
- package/build/components/save-button/index.js.map +1 -1
- package/build/components/save-panel/index.js +11 -1
- package/build/components/save-panel/index.js.map +1 -1
- package/build/components/sidebar/index.js +28 -35
- package/build/components/sidebar/index.js.map +1 -1
- package/build/components/sidebar-button/index.js +30 -0
- package/build/components/sidebar-button/index.js.map +1 -0
- package/build/components/sidebar-edit-mode/global-styles-sidebar.js +8 -2
- package/build/components/sidebar-edit-mode/global-styles-sidebar.js.map +1 -1
- package/build/components/sidebar-navigation-screen/index.js +10 -10
- package/build/components/sidebar-navigation-screen/index.js.map +1 -1
- package/build/components/sidebar-navigation-screen-main/index.js +3 -3
- package/build/components/sidebar-navigation-screen-main/index.js.map +1 -1
- package/build/components/sidebar-navigation-screen-navigation-item/index.js +17 -16
- package/build/components/sidebar-navigation-screen-navigation-item/index.js.map +1 -1
- package/build/components/sidebar-navigation-screen-navigation-menus/index.js +1 -3
- package/build/components/sidebar-navigation-screen-navigation-menus/index.js.map +1 -1
- package/build/components/sidebar-navigation-screen-template/index.js +9 -19
- package/build/components/sidebar-navigation-screen-template/index.js.map +1 -1
- package/build/components/sidebar-navigation-screen-templates/index.js +25 -15
- package/build/components/sidebar-navigation-screen-templates/index.js.map +1 -1
- package/build/components/sidebar-navigation-screen-templates-browse/index.js +8 -7
- package/build/components/sidebar-navigation-screen-templates-browse/index.js.map +1 -1
- package/build/components/style-book/index.js +17 -2
- package/build/components/style-book/index.js.map +1 -1
- package/build/components/sync-state-with-url/use-init-edited-entity-from-url.js +36 -34
- package/build/components/sync-state-with-url/use-init-edited-entity-from-url.js.map +1 -1
- package/build/components/sync-state-with-url/use-sync-path-with-url.js +65 -18
- package/build/components/sync-state-with-url/use-sync-path-with-url.js.map +1 -1
- package/build/components/template-details/index.js +7 -9
- package/build/components/template-details/index.js.map +1 -1
- package/build/index.js +10 -22
- package/build/index.js.map +1 -1
- package/build/utils/get-is-list-page.js +1 -1
- package/build/utils/get-is-list-page.js.map +1 -1
- package/build-module/components/add-new-template/add-custom-template-modal.js +13 -4
- package/build-module/components/add-new-template/add-custom-template-modal.js.map +1 -1
- package/build-module/components/add-new-template/new-template-part.js +8 -7
- package/build-module/components/add-new-template/new-template-part.js.map +1 -1
- package/build-module/components/add-new-template/new-template.js +3 -6
- package/build-module/components/add-new-template/new-template.js.map +1 -1
- package/build-module/components/editor/index.js +3 -3
- package/build-module/components/editor/index.js.map +1 -1
- package/build-module/components/global-styles/screen-border.js +1 -1
- package/build-module/components/global-styles/screen-border.js.map +1 -1
- package/build-module/components/global-styles/screen-variations.js +1 -1
- package/build-module/components/global-styles/screen-variations.js.map +1 -1
- package/build-module/components/global-styles/shadow-panel.js +6 -4
- package/build-module/components/global-styles/shadow-panel.js.map +1 -1
- package/build-module/components/global-styles/ui.js +1 -1
- package/build-module/components/global-styles/ui.js.map +1 -1
- package/build-module/components/keyboard-shortcuts/edit-mode.js +108 -0
- package/build-module/components/keyboard-shortcuts/edit-mode.js.map +1 -0
- package/build-module/components/keyboard-shortcuts/global.js +37 -0
- package/build-module/components/keyboard-shortcuts/global.js.map +1 -0
- package/build-module/components/keyboard-shortcuts/register.js +141 -0
- package/build-module/components/keyboard-shortcuts/register.js.map +1 -0
- package/build-module/components/layout/index.js +3 -1
- package/build-module/components/layout/index.js.map +1 -1
- package/build-module/components/list/added-by.js +43 -44
- package/build-module/components/list/added-by.js.map +1 -1
- package/build-module/components/list/table.js +3 -2
- package/build-module/components/list/table.js.map +1 -1
- package/build-module/components/navigation-inspector/navigation-menu.js +4 -2
- package/build-module/components/navigation-inspector/navigation-menu.js.map +1 -1
- package/build-module/components/save-button/index.js +5 -2
- package/build-module/components/save-button/index.js.map +1 -1
- package/build-module/components/save-panel/index.js +8 -1
- package/build-module/components/save-panel/index.js.map +1 -1
- package/build-module/components/sidebar/index.js +25 -35
- package/build-module/components/sidebar/index.js.map +1 -1
- package/build-module/components/sidebar-button/index.js +18 -0
- package/build-module/components/sidebar-button/index.js.map +1 -0
- package/build-module/components/sidebar-edit-mode/global-styles-sidebar.js +8 -2
- package/build-module/components/sidebar-edit-mode/global-styles-sidebar.js.map +1 -1
- package/build-module/components/sidebar-navigation-screen/index.js +8 -11
- package/build-module/components/sidebar-navigation-screen/index.js.map +1 -1
- package/build-module/components/sidebar-navigation-screen-main/index.js +3 -3
- package/build-module/components/sidebar-navigation-screen-main/index.js.map +1 -1
- package/build-module/components/sidebar-navigation-screen-navigation-item/index.js +16 -17
- package/build-module/components/sidebar-navigation-screen-navigation-item/index.js.map +1 -1
- package/build-module/components/sidebar-navigation-screen-navigation-menus/index.js +1 -3
- package/build-module/components/sidebar-navigation-screen-navigation-menus/index.js.map +1 -1
- package/build-module/components/sidebar-navigation-screen-template/index.js +8 -18
- package/build-module/components/sidebar-navigation-screen-template/index.js.map +1 -1
- package/build-module/components/sidebar-navigation-screen-templates/index.js +23 -16
- package/build-module/components/sidebar-navigation-screen-templates/index.js.map +1 -1
- package/build-module/components/sidebar-navigation-screen-templates-browse/index.js +7 -7
- package/build-module/components/sidebar-navigation-screen-templates-browse/index.js.map +1 -1
- package/build-module/components/style-book/index.js +17 -3
- package/build-module/components/style-book/index.js.map +1 -1
- package/build-module/components/sync-state-with-url/use-init-edited-entity-from-url.js +36 -34
- package/build-module/components/sync-state-with-url/use-init-edited-entity-from-url.js.map +1 -1
- package/build-module/components/sync-state-with-url/use-sync-path-with-url.js +63 -18
- package/build-module/components/sync-state-with-url/use-sync-path-with-url.js.map +1 -1
- package/build-module/components/template-details/index.js +7 -8
- package/build-module/components/template-details/index.js.map +1 -1
- package/build-module/index.js +12 -22
- package/build-module/index.js.map +1 -1
- package/build-module/utils/get-is-list-page.js +1 -1
- package/build-module/utils/get-is-list-page.js.map +1 -1
- package/build-style/style-rtl.css +41 -38
- package/build-style/style.css +41 -38
- package/package.json +21 -21
- package/src/components/add-new-template/add-custom-template-modal.js +14 -10
- package/src/components/add-new-template/new-template-part.js +7 -9
- package/src/components/add-new-template/new-template.js +3 -6
- package/src/components/add-new-template/style.scss +0 -5
- package/src/components/block-editor/style.scss +1 -1
- package/src/components/editor/index.js +4 -3
- package/src/components/editor/style.scss +0 -6
- package/src/components/global-styles/screen-border.js +1 -1
- package/src/components/global-styles/screen-variations.js +0 -1
- package/src/components/global-styles/shadow-panel.js +4 -3
- package/src/components/global-styles/ui.js +1 -1
- package/src/components/keyboard-shortcuts/edit-mode.js +116 -0
- package/src/components/keyboard-shortcuts/global.js +35 -0
- package/src/components/keyboard-shortcuts/register.js +157 -0
- package/src/components/layout/index.js +4 -0
- package/src/components/layout/style.scss +8 -1
- package/src/components/list/added-by.js +48 -55
- package/src/components/list/style.scss +5 -13
- package/src/components/list/table.js +4 -5
- package/src/components/navigation-inspector/navigation-menu.js +8 -2
- package/src/components/save-button/index.js +2 -2
- package/src/components/save-panel/index.js +8 -1
- package/src/components/sidebar/index.js +34 -29
- package/src/components/sidebar-button/index.js +21 -0
- package/src/components/sidebar-button/style.scss +23 -0
- package/src/components/sidebar-edit-mode/global-styles-sidebar.js +3 -7
- package/src/components/sidebar-edit-mode/style.scss +16 -0
- package/src/components/sidebar-navigation-screen/index.js +31 -38
- package/src/components/sidebar-navigation-screen/style.scss +1 -9
- package/src/components/sidebar-navigation-screen-main/index.js +3 -3
- package/src/components/sidebar-navigation-screen-navigation-item/index.js +24 -20
- package/src/components/sidebar-navigation-screen-navigation-menus/index.js +0 -2
- package/src/components/sidebar-navigation-screen-template/index.js +7 -19
- package/src/components/sidebar-navigation-screen-templates/index.js +22 -14
- package/src/components/sidebar-navigation-screen-templates/style.scss +0 -5
- package/src/components/sidebar-navigation-screen-templates-browse/index.js +6 -11
- package/src/components/style-book/index.js +25 -1
- package/src/components/sync-state-with-url/use-init-edited-entity-from-url.js +28 -23
- package/src/components/sync-state-with-url/use-sync-path-with-url.js +72 -17
- package/src/components/template-details/index.js +5 -6
- package/src/index.js +6 -21
- package/src/style.scss +1 -0
- package/src/utils/get-is-list-page.js +1 -1
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* WordPress dependencies
|
|
3
3
|
*/
|
|
4
|
-
import { memo } from '@wordpress/element';
|
|
5
|
-
import {
|
|
6
|
-
|
|
7
|
-
|
|
4
|
+
import { memo, useRef } from '@wordpress/element';
|
|
5
|
+
import {
|
|
6
|
+
__experimentalNavigatorProvider as NavigatorProvider,
|
|
7
|
+
__experimentalNavigatorScreen as NavigatorScreen,
|
|
8
|
+
} from '@wordpress/components';
|
|
8
9
|
|
|
9
10
|
/**
|
|
10
11
|
* Internal dependencies
|
|
@@ -12,54 +13,58 @@ import { store as coreStore } from '@wordpress/core-data';
|
|
|
12
13
|
import SidebarNavigationScreenMain from '../sidebar-navigation-screen-main';
|
|
13
14
|
import SidebarNavigationScreenTemplates from '../sidebar-navigation-screen-templates';
|
|
14
15
|
import SidebarNavigationScreenTemplate from '../sidebar-navigation-screen-template';
|
|
15
|
-
import useSyncPathWithURL
|
|
16
|
+
import useSyncPathWithURL, {
|
|
17
|
+
getPathFromURL,
|
|
18
|
+
} from '../sync-state-with-url/use-sync-path-with-url';
|
|
16
19
|
import SidebarNavigationScreenNavigationMenus from '../sidebar-navigation-screen-navigation-menus';
|
|
17
20
|
import SidebarNavigationScreenTemplatesBrowse from '../sidebar-navigation-screen-templates-browse';
|
|
18
21
|
import SaveButton from '../save-button';
|
|
19
22
|
import SidebarNavigationScreenNavigationItem from '../sidebar-navigation-screen-navigation-item';
|
|
23
|
+
import { useLocation } from '../routes';
|
|
20
24
|
|
|
21
25
|
function SidebarScreens() {
|
|
22
26
|
useSyncPathWithURL();
|
|
23
27
|
|
|
24
28
|
return (
|
|
25
29
|
<>
|
|
26
|
-
<
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
<
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
<
|
|
33
|
-
|
|
34
|
-
|
|
30
|
+
<NavigatorScreen path="/">
|
|
31
|
+
<SidebarNavigationScreenMain />
|
|
32
|
+
</NavigatorScreen>
|
|
33
|
+
<NavigatorScreen path="/navigation">
|
|
34
|
+
<SidebarNavigationScreenNavigationMenus />
|
|
35
|
+
</NavigatorScreen>
|
|
36
|
+
<NavigatorScreen path="/navigation/:postType/:postId">
|
|
37
|
+
<SidebarNavigationScreenNavigationItem />
|
|
38
|
+
</NavigatorScreen>
|
|
39
|
+
<NavigatorScreen path="/:postType(wp_template|wp_template_part)">
|
|
40
|
+
<SidebarNavigationScreenTemplates />
|
|
41
|
+
</NavigatorScreen>
|
|
42
|
+
<NavigatorScreen path="/:postType(wp_template|wp_template_part)/all">
|
|
43
|
+
<SidebarNavigationScreenTemplatesBrowse />
|
|
44
|
+
</NavigatorScreen>
|
|
45
|
+
<NavigatorScreen path="/:postType(wp_template|wp_template_part)/:postId">
|
|
46
|
+
<SidebarNavigationScreenTemplate />
|
|
47
|
+
</NavigatorScreen>
|
|
35
48
|
</>
|
|
36
49
|
);
|
|
37
50
|
}
|
|
38
51
|
|
|
39
52
|
function Sidebar() {
|
|
40
|
-
const {
|
|
41
|
-
|
|
42
|
-
const dirtyEntityRecords = __experimentalGetDirtyEntityRecords();
|
|
43
|
-
// The currently selected entity to display.
|
|
44
|
-
// Typically template or template part in the site editor.
|
|
45
|
-
return {
|
|
46
|
-
isDirty: dirtyEntityRecords.length > 0,
|
|
47
|
-
};
|
|
48
|
-
}, [] );
|
|
53
|
+
const { params: urlParams } = useLocation();
|
|
54
|
+
const initialPath = useRef( getPathFromURL( urlParams ) );
|
|
49
55
|
|
|
50
56
|
return (
|
|
51
57
|
<>
|
|
52
58
|
<NavigatorProvider
|
|
53
59
|
className="edit-site-sidebar__content"
|
|
54
|
-
initialPath=
|
|
60
|
+
initialPath={ initialPath.current }
|
|
55
61
|
>
|
|
56
62
|
<SidebarScreens />
|
|
57
63
|
</NavigatorProvider>
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
) }
|
|
64
|
+
|
|
65
|
+
<div className="edit-site-sidebar__footer">
|
|
66
|
+
<SaveButton showTooltip={ false } />
|
|
67
|
+
</div>
|
|
63
68
|
</>
|
|
64
69
|
);
|
|
65
70
|
}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* External dependencies
|
|
3
|
+
*/
|
|
4
|
+
import classnames from 'classnames';
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* WordPress dependencies
|
|
8
|
+
*/
|
|
9
|
+
import { Button } from '@wordpress/components';
|
|
10
|
+
|
|
11
|
+
export default function SidebarButton( props ) {
|
|
12
|
+
return (
|
|
13
|
+
<Button
|
|
14
|
+
{ ...props }
|
|
15
|
+
className={ classnames(
|
|
16
|
+
'edit-site-sidebar-button',
|
|
17
|
+
props.className
|
|
18
|
+
) }
|
|
19
|
+
/>
|
|
20
|
+
);
|
|
21
|
+
}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
.edit-site-sidebar-button {
|
|
2
|
+
color: $gray-200;
|
|
3
|
+
flex-shrink: 0;
|
|
4
|
+
|
|
5
|
+
// Focus (resets default button focus and use focus-visible).
|
|
6
|
+
&:focus:not(:disabled) {
|
|
7
|
+
box-shadow: none;
|
|
8
|
+
outline: none;
|
|
9
|
+
}
|
|
10
|
+
&:focus-visible:not(:disabled) {
|
|
11
|
+
box-shadow:
|
|
12
|
+
0 0 0 var(--wp-admin-border-width-focus)
|
|
13
|
+
var(--wp-components-color-accent, var(--wp-admin-theme-color, #007cba));
|
|
14
|
+
outline: 3px solid transparent;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
&:hover,
|
|
18
|
+
&:focus-visible,
|
|
19
|
+
&:focus,
|
|
20
|
+
&:not([aria-disabled="true"]):active {
|
|
21
|
+
color: $white;
|
|
22
|
+
}
|
|
23
|
+
}
|
|
@@ -37,18 +37,14 @@ export default function GlobalStylesSidebar() {
|
|
|
37
37
|
closeLabel={ __( 'Close Styles sidebar' ) }
|
|
38
38
|
panelClassName="edit-site-global-styles-sidebar__panel"
|
|
39
39
|
header={
|
|
40
|
-
<Flex>
|
|
41
|
-
<FlexBlock>
|
|
40
|
+
<Flex className="edit-site-global-styles-sidebar__header">
|
|
41
|
+
<FlexBlock style={ { minWidth: 'min-content' } }>
|
|
42
42
|
<strong>{ __( 'Styles' ) }</strong>
|
|
43
43
|
</FlexBlock>
|
|
44
44
|
<FlexItem>
|
|
45
45
|
<Button
|
|
46
46
|
icon={ seen }
|
|
47
|
-
label={
|
|
48
|
-
isStyleBookOpened
|
|
49
|
-
? __( 'Close Style Book' )
|
|
50
|
-
: __( 'Open Style Book' )
|
|
51
|
-
}
|
|
47
|
+
label={ __( 'Style Book' ) }
|
|
52
48
|
isPressed={ isStyleBookOpened }
|
|
53
49
|
disabled={ editorMode !== 'visual' }
|
|
54
50
|
onClick={ () => {
|
|
@@ -83,3 +83,19 @@
|
|
|
83
83
|
.edit-site-global-styles-sidebar hr {
|
|
84
84
|
margin: 0;
|
|
85
85
|
}
|
|
86
|
+
|
|
87
|
+
.show-icon-labels {
|
|
88
|
+
.edit-site-global-styles-sidebar__header {
|
|
89
|
+
.components-button.has-icon {
|
|
90
|
+
// Hide the button icons when labels are set to display...
|
|
91
|
+
svg {
|
|
92
|
+
display: none;
|
|
93
|
+
}
|
|
94
|
+
// ... and display labels.
|
|
95
|
+
&::after {
|
|
96
|
+
content: attr(aria-label);
|
|
97
|
+
font-size: $helptext-font-size;
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
}
|
|
@@ -5,8 +5,6 @@ import {
|
|
|
5
5
|
__experimentalHStack as HStack,
|
|
6
6
|
__experimentalVStack as VStack,
|
|
7
7
|
__experimentalNavigatorToParentButton as NavigatorToParentButton,
|
|
8
|
-
Button,
|
|
9
|
-
__experimentalNavigatorScreen as NavigatorScreen,
|
|
10
8
|
} from '@wordpress/components';
|
|
11
9
|
import { isRTL, __ } from '@wordpress/i18n';
|
|
12
10
|
import { chevronRight, chevronLeft } from '@wordpress/icons';
|
|
@@ -17,9 +15,10 @@ import { useSelect } from '@wordpress/data';
|
|
|
17
15
|
*/
|
|
18
16
|
import { store as editSiteStore } from '../../store';
|
|
19
17
|
import { unlock } from '../../private-apis';
|
|
18
|
+
import SidebarButton from '../sidebar-button';
|
|
20
19
|
|
|
21
20
|
export default function SidebarNavigationScreen( {
|
|
22
|
-
|
|
21
|
+
isRoot,
|
|
23
22
|
title,
|
|
24
23
|
actions,
|
|
25
24
|
content,
|
|
@@ -32,41 +31,35 @@ export default function SidebarNavigationScreen( {
|
|
|
32
31
|
}, [] );
|
|
33
32
|
|
|
34
33
|
return (
|
|
35
|
-
<
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
<h2 className="edit-site-sidebar-navigation-screen__title">
|
|
61
|
-
{ title }
|
|
62
|
-
</h2>
|
|
63
|
-
{ actions }
|
|
64
|
-
</HStack>
|
|
34
|
+
<VStack spacing={ 2 }>
|
|
35
|
+
<HStack
|
|
36
|
+
spacing={ 4 }
|
|
37
|
+
justify="flex-start"
|
|
38
|
+
className="edit-site-sidebar-navigation-screen__title-icon"
|
|
39
|
+
>
|
|
40
|
+
{ ! isRoot ? (
|
|
41
|
+
<NavigatorToParentButton
|
|
42
|
+
as={ SidebarButton }
|
|
43
|
+
icon={ isRTL() ? chevronRight : chevronLeft }
|
|
44
|
+
aria-label={ __( 'Back' ) }
|
|
45
|
+
/>
|
|
46
|
+
) : (
|
|
47
|
+
<SidebarButton
|
|
48
|
+
icon={ isRTL() ? chevronRight : chevronLeft }
|
|
49
|
+
aria-label={ __( 'Navigate to the Dashboard' ) }
|
|
50
|
+
href={ dashboardLink || 'index.php' }
|
|
51
|
+
label={ __( 'Dashboard' ) }
|
|
52
|
+
/>
|
|
53
|
+
) }
|
|
54
|
+
<h2 className="edit-site-sidebar-navigation-screen__title">
|
|
55
|
+
{ title }
|
|
56
|
+
</h2>
|
|
57
|
+
{ actions }
|
|
58
|
+
</HStack>
|
|
65
59
|
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
</NavigatorScreen>
|
|
60
|
+
<nav className="edit-site-sidebar-navigation-screen__content">
|
|
61
|
+
{ content }
|
|
62
|
+
</nav>
|
|
63
|
+
</VStack>
|
|
71
64
|
);
|
|
72
65
|
}
|
|
@@ -23,17 +23,9 @@
|
|
|
23
23
|
|
|
24
24
|
.edit-site-sidebar-navigation-screen__title {
|
|
25
25
|
font-size: calc(1.56 * 13px);
|
|
26
|
+
line-height: normal;
|
|
26
27
|
font-weight: 500;
|
|
27
28
|
flex-grow: 1;
|
|
28
29
|
color: $white;
|
|
29
30
|
margin: 0;
|
|
30
31
|
}
|
|
31
|
-
|
|
32
|
-
.edit-site-sidebar-navigation-screen__back {
|
|
33
|
-
color: $gray-200;
|
|
34
|
-
|
|
35
|
-
&:hover,
|
|
36
|
-
&:not([aria-disabled="true"]):active {
|
|
37
|
-
color: $white;
|
|
38
|
-
}
|
|
39
|
-
}
|
|
@@ -29,7 +29,7 @@ export default function SidebarNavigationScreenMain() {
|
|
|
29
29
|
|
|
30
30
|
return (
|
|
31
31
|
<SidebarNavigationScreen
|
|
32
|
-
|
|
32
|
+
isRoot
|
|
33
33
|
title={ __( 'Design' ) }
|
|
34
34
|
content={
|
|
35
35
|
<ItemGroup>
|
|
@@ -45,7 +45,7 @@ export default function SidebarNavigationScreenMain() {
|
|
|
45
45
|
) }
|
|
46
46
|
<NavigatorButton
|
|
47
47
|
as={ SidebarNavigationItem }
|
|
48
|
-
path="/
|
|
48
|
+
path="/wp_template"
|
|
49
49
|
withChevron
|
|
50
50
|
icon={ layout }
|
|
51
51
|
>
|
|
@@ -53,7 +53,7 @@ export default function SidebarNavigationScreenMain() {
|
|
|
53
53
|
</NavigatorButton>
|
|
54
54
|
<NavigatorButton
|
|
55
55
|
as={ SidebarNavigationItem }
|
|
56
|
-
path="/
|
|
56
|
+
path="/wp_template_part"
|
|
57
57
|
withChevron
|
|
58
58
|
icon={ symbolFilled }
|
|
59
59
|
>
|
|
@@ -3,9 +3,10 @@
|
|
|
3
3
|
*/
|
|
4
4
|
import { __ } from '@wordpress/i18n';
|
|
5
5
|
import { useDispatch, useSelect } from '@wordpress/data';
|
|
6
|
-
import {
|
|
6
|
+
import { __experimentalUseNavigator as useNavigator } from '@wordpress/components';
|
|
7
7
|
import { store as coreStore } from '@wordpress/core-data';
|
|
8
8
|
import { decodeEntities } from '@wordpress/html-entities';
|
|
9
|
+
import { pencil } from '@wordpress/icons';
|
|
9
10
|
|
|
10
11
|
/**
|
|
11
12
|
* Internal dependencies
|
|
@@ -13,36 +14,39 @@ import { decodeEntities } from '@wordpress/html-entities';
|
|
|
13
14
|
import SidebarNavigationScreen from '../sidebar-navigation-screen';
|
|
14
15
|
import { unlock } from '../../private-apis';
|
|
15
16
|
import { store as editSiteStore } from '../../store';
|
|
17
|
+
import SidebarButton from '../sidebar-button';
|
|
16
18
|
|
|
17
19
|
export default function SidebarNavigationScreenNavigationItem() {
|
|
18
20
|
const { setCanvasMode } = unlock( useDispatch( editSiteStore ) );
|
|
21
|
+
const {
|
|
22
|
+
params: { postType, postId },
|
|
23
|
+
} = useNavigator();
|
|
19
24
|
|
|
20
|
-
const { post } = useSelect(
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
const { postType, postId } = getEditedPostContext() ?? {};
|
|
25
|
+
const { post } = useSelect(
|
|
26
|
+
( select ) => {
|
|
27
|
+
const { getEntityRecord } = select( coreStore );
|
|
24
28
|
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
29
|
+
// The currently selected entity to display.
|
|
30
|
+
// Typically template or template part in the site editor.
|
|
31
|
+
return {
|
|
32
|
+
post:
|
|
33
|
+
postId && postType
|
|
34
|
+
? getEntityRecord( 'postType', postType, postId )
|
|
35
|
+
: null,
|
|
36
|
+
};
|
|
37
|
+
},
|
|
38
|
+
[ postType, postId ]
|
|
39
|
+
);
|
|
34
40
|
|
|
35
41
|
return (
|
|
36
42
|
<SidebarNavigationScreen
|
|
37
|
-
path="/navigation/single"
|
|
38
43
|
title={ post ? decodeEntities( post?.title?.rendered ) : null }
|
|
39
44
|
actions={
|
|
40
|
-
<
|
|
41
|
-
variant="primary"
|
|
45
|
+
<SidebarButton
|
|
42
46
|
onClick={ () => setCanvasMode( 'edit' ) }
|
|
43
|
-
|
|
44
|
-
{
|
|
45
|
-
|
|
47
|
+
label={ __( 'Edit' ) }
|
|
48
|
+
icon={ pencil }
|
|
49
|
+
/>
|
|
46
50
|
}
|
|
47
51
|
content={
|
|
48
52
|
post ? decodeEntities( post?.description?.rendered ) : null
|
|
@@ -25,7 +25,6 @@ export default function SidebarNavigationScreenNavigationMenus() {
|
|
|
25
25
|
history.push( {
|
|
26
26
|
postType: attributes.type,
|
|
27
27
|
postId: attributes.id,
|
|
28
|
-
path: '/navigation/single',
|
|
29
28
|
} );
|
|
30
29
|
}
|
|
31
30
|
},
|
|
@@ -33,7 +32,6 @@ export default function SidebarNavigationScreenNavigationMenus() {
|
|
|
33
32
|
);
|
|
34
33
|
return (
|
|
35
34
|
<SidebarNavigationScreen
|
|
36
|
-
path="/navigation"
|
|
37
35
|
title={ __( 'Navigation' ) }
|
|
38
36
|
content={
|
|
39
37
|
<div className="edit-site-sidebar-navigation-screen-navigation-menus">
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
*/
|
|
4
4
|
import { __ } from '@wordpress/i18n';
|
|
5
5
|
import { useDispatch } from '@wordpress/data';
|
|
6
|
-
import {
|
|
6
|
+
import { pencil } from '@wordpress/icons';
|
|
7
7
|
|
|
8
8
|
/**
|
|
9
9
|
* Internal dependencies
|
|
@@ -12,19 +12,9 @@ import SidebarNavigationScreen from '../sidebar-navigation-screen';
|
|
|
12
12
|
import useEditedEntityRecord from '../use-edited-entity-record';
|
|
13
13
|
import { unlock } from '../../private-apis';
|
|
14
14
|
import { store as editSiteStore } from '../../store';
|
|
15
|
+
import SidebarButton from '../sidebar-button';
|
|
15
16
|
|
|
16
|
-
|
|
17
|
-
wp_template: {
|
|
18
|
-
path: '/templates/single',
|
|
19
|
-
},
|
|
20
|
-
wp_template_part: {
|
|
21
|
-
path: '/template-parts/single',
|
|
22
|
-
},
|
|
23
|
-
};
|
|
24
|
-
|
|
25
|
-
export default function SidebarNavigationScreenTemplate( {
|
|
26
|
-
postType = 'wp_template',
|
|
27
|
-
} ) {
|
|
17
|
+
export default function SidebarNavigationScreenTemplate() {
|
|
28
18
|
const { setCanvasMode } = unlock( useDispatch( editSiteStore ) );
|
|
29
19
|
const { getDescription, getTitle, record } = useEditedEntityRecord();
|
|
30
20
|
let description = getDescription();
|
|
@@ -36,15 +26,13 @@ export default function SidebarNavigationScreenTemplate( {
|
|
|
36
26
|
|
|
37
27
|
return (
|
|
38
28
|
<SidebarNavigationScreen
|
|
39
|
-
path={ config[ postType ].path }
|
|
40
29
|
title={ getTitle() }
|
|
41
30
|
actions={
|
|
42
|
-
<
|
|
43
|
-
variant="primary"
|
|
31
|
+
<SidebarButton
|
|
44
32
|
onClick={ () => setCanvasMode( 'edit' ) }
|
|
45
|
-
|
|
46
|
-
{
|
|
47
|
-
|
|
33
|
+
label={ __( 'Edit' ) }
|
|
34
|
+
icon={ pencil }
|
|
35
|
+
/>
|
|
48
36
|
}
|
|
49
37
|
content={ description ? <p>{ description }</p> : undefined }
|
|
50
38
|
/>
|
|
@@ -4,9 +4,11 @@
|
|
|
4
4
|
import {
|
|
5
5
|
__experimentalItemGroup as ItemGroup,
|
|
6
6
|
__experimentalItem as Item,
|
|
7
|
+
__experimentalUseNavigator as useNavigator,
|
|
7
8
|
} from '@wordpress/components';
|
|
8
9
|
import { __ } from '@wordpress/i18n';
|
|
9
10
|
import { useEntityRecords } from '@wordpress/core-data';
|
|
11
|
+
import { useSelect } from '@wordpress/data';
|
|
10
12
|
import { decodeEntities } from '@wordpress/html-entities';
|
|
11
13
|
import { useViewportMatch } from '@wordpress/compose';
|
|
12
14
|
|
|
@@ -17,10 +19,11 @@ import SidebarNavigationScreen from '../sidebar-navigation-screen';
|
|
|
17
19
|
import { useLink } from '../routes/link';
|
|
18
20
|
import SidebarNavigationItem from '../sidebar-navigation-item';
|
|
19
21
|
import AddNewTemplate from '../add-new-template';
|
|
22
|
+
import { store as editSiteStore } from '../../store';
|
|
23
|
+
import SidebarButton from '../sidebar-button';
|
|
20
24
|
|
|
21
25
|
const config = {
|
|
22
26
|
wp_template: {
|
|
23
|
-
path: '/templates',
|
|
24
27
|
labels: {
|
|
25
28
|
title: __( 'Templates' ),
|
|
26
29
|
loading: __( 'Loading templates' ),
|
|
@@ -29,7 +32,6 @@ const config = {
|
|
|
29
32
|
},
|
|
30
33
|
},
|
|
31
34
|
wp_template_part: {
|
|
32
|
-
path: '/template-parts',
|
|
33
35
|
labels: {
|
|
34
36
|
title: __( 'Template parts' ),
|
|
35
37
|
loading: __( 'Loading template parts' ),
|
|
@@ -43,15 +45,20 @@ const TemplateItem = ( { postType, postId, ...props } ) => {
|
|
|
43
45
|
const linkInfo = useLink( {
|
|
44
46
|
postType,
|
|
45
47
|
postId,
|
|
46
|
-
path: config[ postType ].path + '/single',
|
|
47
48
|
} );
|
|
48
49
|
return <SidebarNavigationItem { ...linkInfo } { ...props } />;
|
|
49
50
|
};
|
|
50
51
|
|
|
51
|
-
export default function SidebarNavigationScreenTemplates( {
|
|
52
|
-
|
|
53
|
-
|
|
52
|
+
export default function SidebarNavigationScreenTemplates() {
|
|
53
|
+
const {
|
|
54
|
+
params: { postType },
|
|
55
|
+
} = useNavigator();
|
|
54
56
|
const isMobileViewport = useViewportMatch( 'medium', '<' );
|
|
57
|
+
const isTemplatePartsMode = useSelect( ( select ) => {
|
|
58
|
+
const settings = select( editSiteStore ).getSettings();
|
|
59
|
+
|
|
60
|
+
return !! settings.supportsTemplatePartsMode;
|
|
61
|
+
}, [] );
|
|
55
62
|
|
|
56
63
|
const { records: templates, isResolving: isLoading } = useEntityRecords(
|
|
57
64
|
'postType',
|
|
@@ -60,24 +67,25 @@ export default function SidebarNavigationScreenTemplates( {
|
|
|
60
67
|
per_page: -1,
|
|
61
68
|
}
|
|
62
69
|
);
|
|
70
|
+
const sortedTemplates = templates ? [ ...templates ] : [];
|
|
71
|
+
sortedTemplates.sort( ( a, b ) => a.slug.localeCompare( b.slug ) );
|
|
63
72
|
|
|
64
73
|
const browseAllLink = useLink( {
|
|
65
|
-
postType,
|
|
66
|
-
postId: undefined,
|
|
67
|
-
path: config[ postType ].path + '/all',
|
|
74
|
+
path: '/' + postType + '/all',
|
|
68
75
|
} );
|
|
69
76
|
|
|
77
|
+
const canCreate = ! isMobileViewport && ! isTemplatePartsMode;
|
|
78
|
+
|
|
70
79
|
return (
|
|
71
80
|
<SidebarNavigationScreen
|
|
72
|
-
|
|
81
|
+
isRoot={ isTemplatePartsMode }
|
|
73
82
|
title={ config[ postType ].labels.title }
|
|
74
83
|
actions={
|
|
75
|
-
|
|
84
|
+
canCreate && (
|
|
76
85
|
<AddNewTemplate
|
|
77
86
|
templateType={ postType }
|
|
78
87
|
toggleProps={ {
|
|
79
|
-
|
|
80
|
-
'edit-site-sidebar-navigation-screen-templates__add-button',
|
|
88
|
+
as: SidebarButton,
|
|
81
89
|
} }
|
|
82
90
|
/>
|
|
83
91
|
)
|
|
@@ -92,7 +100,7 @@ export default function SidebarNavigationScreenTemplates( {
|
|
|
92
100
|
{ config[ postType ].labels.notFound }
|
|
93
101
|
</Item>
|
|
94
102
|
) }
|
|
95
|
-
{
|
|
103
|
+
{ sortedTemplates.map( ( template ) => (
|
|
96
104
|
<TemplateItem
|
|
97
105
|
postType={ postType }
|
|
98
106
|
postId={ template.id }
|
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
* WordPress dependencies
|
|
3
3
|
*/
|
|
4
4
|
import { __ } from '@wordpress/i18n';
|
|
5
|
+
import { __experimentalUseNavigator as useNavigator } from '@wordpress/components';
|
|
5
6
|
|
|
6
7
|
/**
|
|
7
8
|
* Internal dependencies
|
|
@@ -10,22 +11,16 @@ import SidebarNavigationScreen from '../sidebar-navigation-screen';
|
|
|
10
11
|
|
|
11
12
|
const config = {
|
|
12
13
|
wp_template: {
|
|
13
|
-
path: '/templates/all',
|
|
14
14
|
title: __( 'All templates' ),
|
|
15
15
|
},
|
|
16
16
|
wp_template_part: {
|
|
17
|
-
path: '/template-parts/all',
|
|
18
17
|
title: __( 'All template parts' ),
|
|
19
18
|
},
|
|
20
19
|
};
|
|
21
20
|
|
|
22
|
-
export default function SidebarNavigationScreenTemplatesBrowse( {
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
path={ config[ postType ].path }
|
|
28
|
-
title={ config[ postType ].title }
|
|
29
|
-
/>
|
|
30
|
-
);
|
|
21
|
+
export default function SidebarNavigationScreenTemplatesBrowse() {
|
|
22
|
+
const {
|
|
23
|
+
params: { postType },
|
|
24
|
+
} = useNavigator();
|
|
25
|
+
return <SidebarNavigationScreen title={ config[ postType ].title } />;
|
|
31
26
|
}
|
|
@@ -24,8 +24,14 @@ import {
|
|
|
24
24
|
privateApis as blockEditorPrivateApis,
|
|
25
25
|
} from '@wordpress/block-editor';
|
|
26
26
|
import { closeSmall } from '@wordpress/icons';
|
|
27
|
-
import {
|
|
27
|
+
import {
|
|
28
|
+
useResizeObserver,
|
|
29
|
+
useFocusOnMount,
|
|
30
|
+
useFocusReturn,
|
|
31
|
+
useMergeRefs,
|
|
32
|
+
} from '@wordpress/compose';
|
|
28
33
|
import { useMemo, memo } from '@wordpress/element';
|
|
34
|
+
import { ESCAPE } from '@wordpress/keycodes';
|
|
29
35
|
|
|
30
36
|
/**
|
|
31
37
|
* Internal dependencies
|
|
@@ -90,6 +96,9 @@ function getExamples() {
|
|
|
90
96
|
|
|
91
97
|
function StyleBook( { isSelected, onSelect, onClose } ) {
|
|
92
98
|
const [ resizeObserver, sizes ] = useResizeObserver();
|
|
99
|
+
const focusOnMountRef = useFocusOnMount( 'firstElement' );
|
|
100
|
+
const sectionFocusReturnRef = useFocusReturn();
|
|
101
|
+
|
|
93
102
|
const [ textColor ] = useGlobalStyle( 'color.text' );
|
|
94
103
|
const [ backgroundColor ] = useGlobalStyle( 'color.background' );
|
|
95
104
|
const examples = useMemo( getExamples, [] );
|
|
@@ -108,8 +117,17 @@ function StyleBook( { isSelected, onSelect, onClose } ) {
|
|
|
108
117
|
} ) ),
|
|
109
118
|
[ examples ]
|
|
110
119
|
);
|
|
120
|
+
|
|
121
|
+
function closeOnEscape( event ) {
|
|
122
|
+
if ( event.keyCode === ESCAPE && ! event.defaultPrevented ) {
|
|
123
|
+
event.preventDefault();
|
|
124
|
+
onClose();
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
|
|
111
128
|
return (
|
|
112
129
|
<StyleBookFill>
|
|
130
|
+
{ /* eslint-disable-next-line jsx-a11y/no-noninteractive-element-interactions */ }
|
|
113
131
|
<section
|
|
114
132
|
className={ classnames( 'edit-site-style-book', {
|
|
115
133
|
'is-wide': sizes.width > 600,
|
|
@@ -119,6 +137,11 @@ function StyleBook( { isSelected, onSelect, onClose } ) {
|
|
|
119
137
|
background: backgroundColor,
|
|
120
138
|
} }
|
|
121
139
|
aria-label={ __( 'Style Book' ) }
|
|
140
|
+
onKeyDown={ closeOnEscape }
|
|
141
|
+
ref={ useMergeRefs( [
|
|
142
|
+
sectionFocusReturnRef,
|
|
143
|
+
focusOnMountRef,
|
|
144
|
+
] ) }
|
|
122
145
|
>
|
|
123
146
|
{ resizeObserver }
|
|
124
147
|
<Button
|
|
@@ -126,6 +149,7 @@ function StyleBook( { isSelected, onSelect, onClose } ) {
|
|
|
126
149
|
icon={ closeSmall }
|
|
127
150
|
label={ __( 'Close Style Book' ) }
|
|
128
151
|
onClick={ onClose }
|
|
152
|
+
showTooltip={ false }
|
|
129
153
|
/>
|
|
130
154
|
<TabPanel
|
|
131
155
|
className="edit-site-style-book__tab-panel"
|