@wordpress/edit-site 3.0.11 → 3.0.12
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/new-template-part.js +34 -17
- package/build/components/add-new-template/new-template-part.js.map +1 -1
- package/build/components/add-new-template/new-template.js +41 -22
- package/build/components/add-new-template/new-template.js.map +1 -1
- package/build/components/block-editor/index.js +3 -1
- package/build/components/block-editor/index.js.map +1 -1
- package/build/components/global-styles/color-palette-panel.js +4 -4
- package/build/components/global-styles/color-palette-panel.js.map +1 -1
- package/build/components/global-styles/gradients-palette-panel.js +56 -0
- package/build/components/global-styles/gradients-palette-panel.js.map +1 -0
- package/build/components/global-styles/hooks.js +5 -5
- package/build/components/global-styles/hooks.js.map +1 -1
- package/build/components/global-styles/palette.js +11 -5
- package/build/components/global-styles/palette.js.map +1 -1
- package/build/components/global-styles/screen-background-color.js +2 -1
- package/build/components/global-styles/screen-background-color.js.map +1 -1
- package/build/components/global-styles/screen-color-palette.js +23 -3
- package/build/components/global-styles/screen-color-palette.js.map +1 -1
- package/build/components/global-styles/screen-link-color.js +2 -1
- package/build/components/global-styles/screen-link-color.js.map +1 -1
- package/build/components/global-styles/screen-text-color.js +2 -1
- package/build/components/global-styles/screen-text-color.js.map +1 -1
- package/build/components/global-styles/screen-typography-element.js +54 -0
- package/build/components/global-styles/screen-typography-element.js.map +1 -0
- package/build/components/global-styles/screen-typography.js +74 -6
- package/build/components/global-styles/screen-typography.js.map +1 -1
- package/build/components/global-styles/typography-panel.js +28 -8
- package/build/components/global-styles/typography-panel.js.map +1 -1
- package/build/components/global-styles/ui.js +12 -0
- package/build/components/global-styles/ui.js.map +1 -1
- package/build/components/global-styles/use-global-styles-output.js +2 -2
- package/build/components/global-styles/use-global-styles-output.js.map +1 -1
- package/build/components/global-styles/utils.js +1 -1
- package/build/components/global-styles/utils.js.map +1 -1
- package/build/components/list/actions/index.js +104 -0
- package/build/components/list/actions/index.js.map +1 -0
- package/build/components/list/actions/rename-menu-item.js +112 -0
- package/build/components/list/actions/rename-menu-item.js.map +1 -0
- package/build/components/list/added-by.js +180 -0
- package/build/components/list/added-by.js.map +1 -0
- package/build/components/list/index.js +18 -3
- package/build/components/list/index.js.map +1 -1
- package/build/components/list/table.js +54 -67
- package/build/components/list/table.js.map +1 -1
- package/build/components/navigation-sidebar/index.js +12 -11
- package/build/components/navigation-sidebar/index.js.map +1 -1
- package/build/components/navigation-sidebar/navigation-panel/index.js +28 -11
- package/build/components/navigation-sidebar/navigation-panel/index.js.map +1 -1
- package/build/components/navigation-sidebar/navigation-toggle/index.js +14 -5
- package/build/components/navigation-sidebar/navigation-toggle/index.js.map +1 -1
- package/build/index.js +8 -2
- package/build/index.js.map +1 -1
- package/build/store/actions.js +47 -18
- package/build/store/actions.js.map +1 -1
- package/build/store/selectors.js +25 -5
- package/build/store/selectors.js.map +1 -1
- package/build-module/components/add-new-template/new-template-part.js +30 -16
- package/build-module/components/add-new-template/new-template-part.js.map +1 -1
- package/build-module/components/add-new-template/new-template.js +40 -23
- package/build-module/components/add-new-template/new-template.js.map +1 -1
- package/build-module/components/block-editor/index.js +2 -1
- package/build-module/components/block-editor/index.js.map +1 -1
- package/build-module/components/global-styles/color-palette-panel.js +5 -5
- package/build-module/components/global-styles/color-palette-panel.js.map +1 -1
- package/build-module/components/global-styles/gradients-palette-panel.js +46 -0
- package/build-module/components/global-styles/gradients-palette-panel.js.map +1 -0
- package/build-module/components/global-styles/hooks.js +5 -5
- package/build-module/components/global-styles/hooks.js.map +1 -1
- package/build-module/components/global-styles/palette.js +12 -5
- package/build-module/components/global-styles/palette.js.map +1 -1
- package/build-module/components/global-styles/screen-background-color.js +2 -1
- package/build-module/components/global-styles/screen-background-color.js.map +1 -1
- package/build-module/components/global-styles/screen-color-palette.js +22 -3
- package/build-module/components/global-styles/screen-color-palette.js.map +1 -1
- package/build-module/components/global-styles/screen-link-color.js +2 -1
- package/build-module/components/global-styles/screen-link-color.js.map +1 -1
- package/build-module/components/global-styles/screen-text-color.js +2 -1
- package/build-module/components/global-styles/screen-text-color.js.map +1 -1
- package/build-module/components/global-styles/screen-typography-element.js +41 -0
- package/build-module/components/global-styles/screen-typography-element.js.map +1 -0
- package/build-module/components/global-styles/screen-typography.js +70 -6
- package/build-module/components/global-styles/screen-typography.js.map +1 -1
- package/build-module/components/global-styles/typography-panel.js +28 -8
- package/build-module/components/global-styles/typography-panel.js.map +1 -1
- package/build-module/components/global-styles/ui.js +11 -0
- package/build-module/components/global-styles/ui.js.map +1 -1
- package/build-module/components/global-styles/use-global-styles-output.js +2 -2
- package/build-module/components/global-styles/use-global-styles-output.js.map +1 -1
- package/build-module/components/global-styles/utils.js +1 -1
- package/build-module/components/global-styles/utils.js.map +1 -1
- package/build-module/components/list/actions/index.js +85 -0
- package/build-module/components/list/actions/index.js.map +1 -0
- package/build-module/components/list/actions/rename-menu-item.js +101 -0
- package/build-module/components/list/actions/rename-menu-item.js.map +1 -0
- package/build-module/components/list/added-by.js +166 -0
- package/build-module/components/list/added-by.js.map +1 -0
- package/build-module/components/list/index.js +15 -3
- package/build-module/components/list/index.js.map +1 -1
- package/build-module/components/list/table.js +56 -69
- package/build-module/components/list/table.js.map +1 -1
- package/build-module/components/navigation-sidebar/index.js +11 -12
- package/build-module/components/navigation-sidebar/index.js.map +1 -1
- package/build-module/components/navigation-sidebar/navigation-panel/index.js +26 -12
- package/build-module/components/navigation-sidebar/navigation-panel/index.js.map +1 -1
- package/build-module/components/navigation-sidebar/navigation-toggle/index.js +14 -6
- package/build-module/components/navigation-sidebar/navigation-toggle/index.js.map +1 -1
- package/build-module/index.js +8 -3
- package/build-module/index.js.map +1 -1
- package/build-module/store/actions.js +48 -19
- package/build-module/store/actions.js.map +1 -1
- package/build-module/store/selectors.js +21 -3
- package/build-module/store/selectors.js.map +1 -1
- package/build-style/style-rtl.css +136 -17
- package/build-style/style.css +136 -17
- package/package.json +10 -8
- package/src/components/add-new-template/new-template-part.js +32 -17
- package/src/components/add-new-template/new-template.js +39 -19
- package/src/components/block-editor/index.js +2 -0
- package/src/components/global-styles/color-palette-panel.js +5 -5
- package/src/components/global-styles/gradients-palette-panel.js +79 -0
- package/src/components/global-styles/hooks.js +4 -4
- package/src/components/global-styles/palette.js +30 -10
- package/src/components/global-styles/screen-background-color.js +1 -0
- package/src/components/global-styles/screen-color-palette.js +30 -3
- package/src/components/global-styles/screen-link-color.js +1 -0
- package/src/components/global-styles/screen-text-color.js +1 -0
- package/src/components/global-styles/screen-typography-element.js +39 -0
- package/src/components/global-styles/screen-typography.js +84 -3
- package/src/components/global-styles/style.scss +33 -0
- package/src/components/global-styles/test/use-global-styles-output.js +1 -1
- package/src/components/global-styles/test/utils.js +1 -1
- package/src/components/global-styles/typography-panel.js +37 -7
- package/src/components/global-styles/ui.js +9 -0
- package/src/components/global-styles/use-global-styles-output.js +2 -2
- package/src/components/global-styles/utils.js +1 -1
- package/src/components/list/actions/index.js +95 -0
- package/src/components/list/actions/rename-menu-item.js +134 -0
- package/src/components/list/added-by.js +179 -0
- package/src/components/list/index.js +27 -11
- package/src/components/list/style.scss +106 -11
- package/src/components/list/table.js +64 -75
- package/src/components/navigation-sidebar/index.js +9 -16
- package/src/components/navigation-sidebar/navigation-panel/index.js +25 -9
- package/src/components/navigation-sidebar/navigation-toggle/index.js +29 -17
- package/src/components/navigation-sidebar/navigation-toggle/test/index.js +2 -0
- package/src/components/sidebar/style.scss +2 -1
- package/src/index.js +10 -2
- package/src/store/actions.js +82 -34
- package/src/store/selectors.js +22 -4
- package/src/store/test/actions.js +0 -24
- package/src/store/test/selectors.js +24 -0
|
@@ -61,12 +61,14 @@
|
|
|
61
61
|
|
|
62
62
|
.edit-site-list-table {
|
|
63
63
|
width: 100%;
|
|
64
|
-
border: $border-width solid $gray-
|
|
64
|
+
border: $border-width solid $gray-300;
|
|
65
65
|
border-radius: 2px;
|
|
66
66
|
margin: 0;
|
|
67
67
|
overflow: hidden;
|
|
68
|
+
border-spacing: 0;
|
|
69
|
+
max-width: 960px;
|
|
68
70
|
|
|
69
|
-
|
|
71
|
+
tr {
|
|
70
72
|
display: flex;
|
|
71
73
|
align-items: center;
|
|
72
74
|
padding: $grid-unit-20;
|
|
@@ -74,40 +76,133 @@
|
|
|
74
76
|
border-top: $border-width solid $gray-100;
|
|
75
77
|
margin: 0;
|
|
76
78
|
|
|
79
|
+
&:first-child {
|
|
80
|
+
border-top: 0;
|
|
81
|
+
}
|
|
82
|
+
|
|
77
83
|
@include break-medium() {
|
|
78
84
|
padding: $grid-unit-30 $grid-unit-40;
|
|
79
85
|
}
|
|
80
86
|
|
|
87
|
+
// Template.
|
|
81
88
|
.edit-site-list-table-column:nth-child(1) {
|
|
82
|
-
width: calc(60% -
|
|
89
|
+
width: calc(60% - 18px);
|
|
90
|
+
padding-right: $grid-unit-30;
|
|
83
91
|
|
|
84
92
|
a {
|
|
85
|
-
display: block;
|
|
93
|
+
display: inline-block;
|
|
86
94
|
text-decoration: none;
|
|
87
95
|
font-weight: 500;
|
|
88
96
|
margin-bottom: $grid-unit-05;
|
|
89
97
|
}
|
|
90
98
|
}
|
|
91
99
|
|
|
100
|
+
// Added by.
|
|
92
101
|
.edit-site-list-table-column:nth-child(2) {
|
|
93
|
-
width: calc(40% -
|
|
102
|
+
width: calc(40% - 18px);
|
|
94
103
|
}
|
|
95
104
|
|
|
105
|
+
// Actions.
|
|
96
106
|
.edit-site-list-table-column:nth-child(3) {
|
|
97
107
|
min-width: $button-size;
|
|
108
|
+
flex-shrink: 0;
|
|
98
109
|
}
|
|
99
110
|
}
|
|
100
111
|
|
|
101
|
-
|
|
102
|
-
border-bottom: $border-width solid $gray-200;
|
|
112
|
+
tr.edit-site-list-table-head {
|
|
103
113
|
font-size: 16px;
|
|
104
|
-
font-weight:
|
|
114
|
+
font-weight: 600;
|
|
105
115
|
text-align: left;
|
|
106
|
-
color: $
|
|
116
|
+
color: $gray-900;
|
|
107
117
|
border-top: none;
|
|
118
|
+
border-bottom: $border-width solid $gray-300;
|
|
108
119
|
|
|
109
|
-
|
|
110
|
-
|
|
120
|
+
th {
|
|
121
|
+
font-weight: inherit;
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
.edit-site-list.is-navigation-open .components-snackbar-list {
|
|
127
|
+
@include break-medium() {
|
|
128
|
+
margin-left: $nav-sidebar-width;
|
|
129
|
+
}
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
.edit-site-list__rename-modal {
|
|
133
|
+
.components-base-control {
|
|
134
|
+
@include break-medium() {
|
|
135
|
+
width: $grid-unit * 40;
|
|
136
|
+
}
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
.components-modal__header {
|
|
140
|
+
border-bottom: none;
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
.components-modal__content::before {
|
|
144
|
+
margin-bottom: $grid-unit-05;
|
|
145
|
+
}
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
.edit-site-list__rename-modal-actions {
|
|
149
|
+
margin-top: $grid-unit-15;
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
.edit-site-template__actions {
|
|
153
|
+
button:not(:last-child) {
|
|
154
|
+
margin-right: $grid-unit-10;
|
|
155
|
+
}
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
.edit-site-list-added-by__icon {
|
|
159
|
+
display: flex;
|
|
160
|
+
flex-shrink: 0;
|
|
161
|
+
position: relative;
|
|
162
|
+
align-items: center;
|
|
163
|
+
justify-content: center;
|
|
164
|
+
width: $grid-unit-40;
|
|
165
|
+
height: $grid-unit-40;
|
|
166
|
+
background: $gray-800;
|
|
167
|
+
border-radius: 100%;
|
|
168
|
+
|
|
169
|
+
svg {
|
|
170
|
+
fill: $white;
|
|
171
|
+
}
|
|
172
|
+
|
|
173
|
+
&.is-customized::after {
|
|
174
|
+
position: absolute;
|
|
175
|
+
content: "";
|
|
176
|
+
background: var(--wp-admin-theme-color);
|
|
177
|
+
height: $grid-unit-10;
|
|
178
|
+
width: $grid-unit-10;
|
|
179
|
+
outline: 2px solid $white;
|
|
180
|
+
border-radius: 100%;
|
|
181
|
+
top: -1px;
|
|
182
|
+
right: -1px;
|
|
183
|
+
}
|
|
184
|
+
}
|
|
185
|
+
|
|
186
|
+
.edit-site-list-added-by__avatar {
|
|
187
|
+
flex-shrink: 0;
|
|
188
|
+
overflow: hidden;
|
|
189
|
+
border-radius: 100%;
|
|
190
|
+
background: $gray-800;
|
|
191
|
+
width: $grid-unit-40;
|
|
192
|
+
height: $grid-unit-40;
|
|
193
|
+
|
|
194
|
+
img {
|
|
195
|
+
width: $grid-unit-40;
|
|
196
|
+
height: $grid-unit-40;
|
|
197
|
+
object-fit: cover;
|
|
198
|
+
opacity: 0;
|
|
199
|
+
transition: opacity 0.1s linear;
|
|
200
|
+
@include reduce-motion("transition");
|
|
201
|
+
}
|
|
202
|
+
|
|
203
|
+
&.is-loaded {
|
|
204
|
+
img {
|
|
205
|
+
opacity: 1;
|
|
111
206
|
}
|
|
112
207
|
}
|
|
113
208
|
}
|
|
@@ -1,43 +1,20 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* WordPress dependencies
|
|
3
3
|
*/
|
|
4
|
-
import { useSelect
|
|
4
|
+
import { useSelect } from '@wordpress/data';
|
|
5
5
|
import { store as coreStore } from '@wordpress/core-data';
|
|
6
6
|
import { __, sprintf } from '@wordpress/i18n';
|
|
7
7
|
import {
|
|
8
8
|
VisuallyHidden,
|
|
9
|
-
FlexItem,
|
|
10
|
-
__experimentalHStack as HStack,
|
|
11
9
|
__experimentalHeading as Heading,
|
|
12
|
-
DropdownMenu,
|
|
13
|
-
MenuGroup,
|
|
14
|
-
MenuItem,
|
|
15
10
|
} from '@wordpress/components';
|
|
16
|
-
import { moreVertical } from '@wordpress/icons';
|
|
17
11
|
import { addQueryArgs } from '@wordpress/url';
|
|
18
12
|
|
|
19
13
|
/**
|
|
20
14
|
* Internal dependencies
|
|
21
15
|
*/
|
|
22
|
-
import
|
|
23
|
-
import
|
|
24
|
-
|
|
25
|
-
function Actions( { template, onClose } ) {
|
|
26
|
-
const { removeTemplate } = useDispatch( editSiteStore );
|
|
27
|
-
|
|
28
|
-
return (
|
|
29
|
-
<MenuGroup>
|
|
30
|
-
<MenuItem
|
|
31
|
-
onClick={ () => {
|
|
32
|
-
removeTemplate( template );
|
|
33
|
-
onClose();
|
|
34
|
-
} }
|
|
35
|
-
>
|
|
36
|
-
{ __( 'Remove template' ) }
|
|
37
|
-
</MenuItem>
|
|
38
|
-
</MenuGroup>
|
|
39
|
-
);
|
|
40
|
-
}
|
|
16
|
+
import Actions from './actions';
|
|
17
|
+
import AddedBy from './added-by';
|
|
41
18
|
|
|
42
19
|
export default function Table( { templateType } ) {
|
|
43
20
|
const { templates, isLoading, postType } = useSelect(
|
|
@@ -49,10 +26,13 @@ export default function Table( { templateType } ) {
|
|
|
49
26
|
} = select( coreStore );
|
|
50
27
|
|
|
51
28
|
return {
|
|
52
|
-
templates: getEntityRecords( 'postType', templateType
|
|
29
|
+
templates: getEntityRecords( 'postType', templateType, {
|
|
30
|
+
per_page: -1,
|
|
31
|
+
} ),
|
|
53
32
|
isLoading: ! hasFinishedResolution( 'getEntityRecords', [
|
|
54
33
|
'postType',
|
|
55
34
|
templateType,
|
|
35
|
+
{ per_page: -1 },
|
|
56
36
|
] ),
|
|
57
37
|
postType: getPostType( templateType ),
|
|
58
38
|
};
|
|
@@ -77,56 +57,65 @@ export default function Table( { templateType } ) {
|
|
|
77
57
|
}
|
|
78
58
|
|
|
79
59
|
return (
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
60
|
+
// These explicit aria roles are needed for Safari.
|
|
61
|
+
// See https://developer.mozilla.org/en-US/docs/Web/CSS/display#tables
|
|
62
|
+
<table className="edit-site-list-table" role="table">
|
|
63
|
+
<thead>
|
|
64
|
+
<tr className="edit-site-list-table-head" role="row">
|
|
65
|
+
<th
|
|
66
|
+
className="edit-site-list-table-column"
|
|
67
|
+
role="columnheader"
|
|
68
|
+
>
|
|
69
|
+
{ __( 'Template' ) }
|
|
70
|
+
</th>
|
|
71
|
+
<th
|
|
72
|
+
className="edit-site-list-table-column"
|
|
73
|
+
role="columnheader"
|
|
74
|
+
>
|
|
75
|
+
{ __( 'Added by' ) }
|
|
76
|
+
</th>
|
|
77
|
+
<th
|
|
78
|
+
className="edit-site-list-table-column"
|
|
79
|
+
role="columnheader"
|
|
80
|
+
>
|
|
81
|
+
<VisuallyHidden>{ __( 'Actions' ) }</VisuallyHidden>
|
|
82
|
+
</th>
|
|
83
|
+
</tr>
|
|
84
|
+
</thead>
|
|
92
85
|
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
<
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
86
|
+
<tbody>
|
|
87
|
+
{ templates.map( ( template ) => (
|
|
88
|
+
<tr
|
|
89
|
+
key={ template.id }
|
|
90
|
+
className="edit-site-list-table-row"
|
|
91
|
+
role="row"
|
|
92
|
+
>
|
|
93
|
+
<td className="edit-site-list-table-column" role="cell">
|
|
94
|
+
<Heading level={ 4 }>
|
|
95
|
+
<a
|
|
96
|
+
href={ addQueryArgs( window.location.href, {
|
|
97
|
+
postId: template.id,
|
|
98
|
+
postType: template.type,
|
|
99
|
+
} ) }
|
|
100
|
+
>
|
|
101
|
+
{ template.title.rendered }
|
|
102
|
+
</a>
|
|
103
|
+
</Heading>
|
|
105
104
|
{ template.description }
|
|
106
|
-
</
|
|
105
|
+
</td>
|
|
107
106
|
|
|
108
|
-
<
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
onClose={ onClose }
|
|
122
|
-
/>
|
|
123
|
-
) }
|
|
124
|
-
</DropdownMenu>
|
|
125
|
-
) }
|
|
126
|
-
</FlexItem>
|
|
127
|
-
</HStack>
|
|
128
|
-
</li>
|
|
129
|
-
) ) }
|
|
130
|
-
</ul>
|
|
107
|
+
<td className="edit-site-list-table-column" role="cell">
|
|
108
|
+
<AddedBy
|
|
109
|
+
templateType={ templateType }
|
|
110
|
+
template={ template }
|
|
111
|
+
/>
|
|
112
|
+
</td>
|
|
113
|
+
<td className="edit-site-list-table-column" role="cell">
|
|
114
|
+
<Actions template={ template } />
|
|
115
|
+
</td>
|
|
116
|
+
</tr>
|
|
117
|
+
) ) }
|
|
118
|
+
</tbody>
|
|
119
|
+
</table>
|
|
131
120
|
);
|
|
132
121
|
}
|
|
@@ -1,13 +1,15 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* WordPress dependencies
|
|
3
3
|
*/
|
|
4
|
-
import { useEffect
|
|
4
|
+
import { useEffect } from '@wordpress/element';
|
|
5
5
|
import { createSlotFill } from '@wordpress/components';
|
|
6
6
|
import { useViewportMatch } from '@wordpress/compose';
|
|
7
|
+
import { useDispatch } from '@wordpress/data';
|
|
7
8
|
|
|
8
9
|
/**
|
|
9
10
|
* Internal dependencies
|
|
10
11
|
*/
|
|
12
|
+
import { store as editSiteStore } from '../../store';
|
|
11
13
|
import NavigationPanel from './navigation-panel';
|
|
12
14
|
import NavigationToggle from './navigation-toggle';
|
|
13
15
|
|
|
@@ -21,33 +23,24 @@ export default function NavigationSidebar( {
|
|
|
21
23
|
activeTemplateType,
|
|
22
24
|
} ) {
|
|
23
25
|
const isDesktopViewport = useViewportMatch( 'medium' );
|
|
24
|
-
const
|
|
25
|
-
isDefaultOpen && isDesktopViewport
|
|
26
|
-
);
|
|
26
|
+
const { setIsNavigationPanelOpened } = useDispatch( editSiteStore );
|
|
27
27
|
|
|
28
28
|
useEffect( () => {
|
|
29
29
|
// When transitioning to desktop open the navigation if `isDefaultOpen` is true.
|
|
30
30
|
if ( isDefaultOpen && isDesktopViewport ) {
|
|
31
|
-
|
|
31
|
+
setIsNavigationPanelOpened( true );
|
|
32
32
|
}
|
|
33
33
|
|
|
34
34
|
// When transitioning to mobile/tablet, close the navigation.
|
|
35
35
|
if ( ! isDesktopViewport ) {
|
|
36
|
-
|
|
36
|
+
setIsNavigationPanelOpened( false );
|
|
37
37
|
}
|
|
38
|
-
}, [ isDefaultOpen, isDesktopViewport ] );
|
|
38
|
+
}, [ isDefaultOpen, isDesktopViewport, setIsNavigationPanelOpened ] );
|
|
39
39
|
|
|
40
40
|
return (
|
|
41
41
|
<>
|
|
42
|
-
<NavigationToggle
|
|
43
|
-
|
|
44
|
-
setIsOpen={ setIsNavigationOpen }
|
|
45
|
-
/>
|
|
46
|
-
<NavigationPanel
|
|
47
|
-
isOpen={ isNavigationOpen }
|
|
48
|
-
setIsOpen={ setIsNavigationOpen }
|
|
49
|
-
activeTemplateType={ activeTemplateType }
|
|
50
|
-
/>
|
|
42
|
+
<NavigationToggle />
|
|
43
|
+
<NavigationPanel activeItem={ activeTemplateType } />
|
|
51
44
|
<NavigationPanelPreviewSlot />
|
|
52
45
|
</>
|
|
53
46
|
);
|
|
@@ -14,41 +14,53 @@ import {
|
|
|
14
14
|
__experimentalNavigationMenu as NavigationMenu,
|
|
15
15
|
} from '@wordpress/components';
|
|
16
16
|
import { store as coreDataStore } from '@wordpress/core-data';
|
|
17
|
-
import { useSelect } from '@wordpress/data';
|
|
17
|
+
import { useSelect, useDispatch } from '@wordpress/data';
|
|
18
18
|
import { useEffect, useRef } from '@wordpress/element';
|
|
19
19
|
import { __ } from '@wordpress/i18n';
|
|
20
20
|
import { ESCAPE } from '@wordpress/keycodes';
|
|
21
21
|
import { decodeEntities } from '@wordpress/html-entities';
|
|
22
22
|
import { addQueryArgs } from '@wordpress/url';
|
|
23
|
+
import {
|
|
24
|
+
home as siteIcon,
|
|
25
|
+
layout as templateIcon,
|
|
26
|
+
symbolFilled as templatePartIcon,
|
|
27
|
+
} from '@wordpress/icons';
|
|
23
28
|
|
|
24
29
|
/**
|
|
25
30
|
* Internal dependencies
|
|
26
31
|
*/
|
|
27
32
|
import MainDashboardButton from '../../main-dashboard-button';
|
|
33
|
+
import { store as editSiteStore } from '../../../store';
|
|
34
|
+
|
|
35
|
+
const SITE_EDITOR_KEY = 'site-editor';
|
|
28
36
|
|
|
29
|
-
const NavigationPanel = ( {
|
|
30
|
-
const siteTitle = useSelect( ( select ) => {
|
|
37
|
+
const NavigationPanel = ( { activeItem = SITE_EDITOR_KEY } ) => {
|
|
38
|
+
const { isNavigationOpen, siteTitle } = useSelect( ( select ) => {
|
|
31
39
|
const { getEntityRecord } = select( coreDataStore );
|
|
32
40
|
|
|
33
41
|
const siteData =
|
|
34
42
|
getEntityRecord( 'root', '__unstableBase', undefined ) || {};
|
|
35
43
|
|
|
36
|
-
return
|
|
44
|
+
return {
|
|
45
|
+
siteTitle: siteData.name,
|
|
46
|
+
isNavigationOpen: select( editSiteStore ).isNavigationOpened(),
|
|
47
|
+
};
|
|
37
48
|
}, [] );
|
|
49
|
+
const { setIsNavigationPanelOpened } = useDispatch( editSiteStore );
|
|
38
50
|
|
|
39
51
|
// Ensures focus is moved to the panel area when it is activated
|
|
40
52
|
// from a separate component (such as document actions in the header).
|
|
41
53
|
const panelRef = useRef();
|
|
42
54
|
useEffect( () => {
|
|
43
|
-
if (
|
|
55
|
+
if ( isNavigationOpen ) {
|
|
44
56
|
panelRef.current.focus();
|
|
45
57
|
}
|
|
46
|
-
}, [
|
|
58
|
+
}, [ activeItem, isNavigationOpen ] );
|
|
47
59
|
|
|
48
60
|
const closeOnEscape = ( event ) => {
|
|
49
61
|
if ( event.keyCode === ESCAPE && ! event.defaultPrevented ) {
|
|
50
62
|
event.preventDefault();
|
|
51
|
-
|
|
63
|
+
setIsNavigationPanelOpened( false );
|
|
52
64
|
}
|
|
53
65
|
};
|
|
54
66
|
|
|
@@ -56,7 +68,7 @@ const NavigationPanel = ( { isOpen, setIsOpen, activeTemplateType } ) => {
|
|
|
56
68
|
// eslint-disable-next-line jsx-a11y/no-static-element-interactions
|
|
57
69
|
<div
|
|
58
70
|
className={ classnames( `edit-site-navigation-panel`, {
|
|
59
|
-
'is-open':
|
|
71
|
+
'is-open': isNavigationOpen,
|
|
60
72
|
} ) }
|
|
61
73
|
ref={ panelRef }
|
|
62
74
|
tabIndex="-1"
|
|
@@ -69,7 +81,7 @@ const NavigationPanel = ( { isOpen, setIsOpen, activeTemplateType } ) => {
|
|
|
69
81
|
</div>
|
|
70
82
|
</div>
|
|
71
83
|
<div className="edit-site-navigation-panel__scroll-container">
|
|
72
|
-
<Navigation activeItem={
|
|
84
|
+
<Navigation activeItem={ activeItem }>
|
|
73
85
|
<MainDashboardButton.Slot>
|
|
74
86
|
<NavigationBackButton
|
|
75
87
|
backButtonLabel={ __( 'Dashboard' ) }
|
|
@@ -81,13 +93,16 @@ const NavigationPanel = ( { isOpen, setIsOpen, activeTemplateType } ) => {
|
|
|
81
93
|
<NavigationMenu>
|
|
82
94
|
<NavigationGroup title={ __( 'Editor' ) }>
|
|
83
95
|
<NavigationItem
|
|
96
|
+
icon={ siteIcon }
|
|
84
97
|
title={ __( 'Site' ) }
|
|
98
|
+
item={ SITE_EDITOR_KEY }
|
|
85
99
|
href={ addQueryArgs( window.location.href, {
|
|
86
100
|
postId: undefined,
|
|
87
101
|
postType: undefined,
|
|
88
102
|
} ) }
|
|
89
103
|
/>
|
|
90
104
|
<NavigationItem
|
|
105
|
+
icon={ templateIcon }
|
|
91
106
|
title={ __( 'Templates' ) }
|
|
92
107
|
item="wp_template"
|
|
93
108
|
href={ addQueryArgs( window.location.href, {
|
|
@@ -96,6 +111,7 @@ const NavigationPanel = ( { isOpen, setIsOpen, activeTemplateType } ) => {
|
|
|
96
111
|
} ) }
|
|
97
112
|
/>
|
|
98
113
|
<NavigationItem
|
|
114
|
+
icon={ templatePartIcon }
|
|
99
115
|
title={ __( 'Template Parts' ) }
|
|
100
116
|
item="wp_template_part"
|
|
101
117
|
href={ addQueryArgs( window.location.href, {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* WordPress dependencies
|
|
3
3
|
*/
|
|
4
|
-
import { useSelect } from '@wordpress/data';
|
|
4
|
+
import { useSelect, useDispatch } from '@wordpress/data';
|
|
5
5
|
import {
|
|
6
6
|
Button,
|
|
7
7
|
Icon,
|
|
@@ -12,25 +12,36 @@ import { wordpress } from '@wordpress/icons';
|
|
|
12
12
|
import { store as coreDataStore } from '@wordpress/core-data';
|
|
13
13
|
import { useReducedMotion } from '@wordpress/compose';
|
|
14
14
|
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
15
|
+
/**
|
|
16
|
+
* Internal dependencies
|
|
17
|
+
*/
|
|
18
|
+
import { store as editSiteStore } from '../../../store';
|
|
19
|
+
|
|
20
|
+
function NavigationToggle( { icon } ) {
|
|
21
|
+
const { isNavigationOpen, isRequestingSiteIcon, siteIconUrl } = useSelect(
|
|
22
|
+
( select ) => {
|
|
23
|
+
const { getEntityRecord, isResolving } = select( coreDataStore );
|
|
24
|
+
const siteData =
|
|
25
|
+
getEntityRecord( 'root', '__unstableBase', undefined ) || {};
|
|
20
26
|
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
'
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
27
|
+
return {
|
|
28
|
+
isNavigationOpen: select( editSiteStore ).isNavigationOpened(),
|
|
29
|
+
isRequestingSiteIcon: isResolving( 'core', 'getEntityRecord', [
|
|
30
|
+
'root',
|
|
31
|
+
'__unstableBase',
|
|
32
|
+
undefined,
|
|
33
|
+
] ),
|
|
34
|
+
siteIconUrl: siteData.site_icon_url,
|
|
35
|
+
};
|
|
36
|
+
},
|
|
37
|
+
[]
|
|
38
|
+
);
|
|
39
|
+
const { setIsNavigationPanelOpened } = useDispatch( editSiteStore );
|
|
30
40
|
|
|
31
41
|
const disableMotion = useReducedMotion();
|
|
32
42
|
|
|
33
|
-
const toggleNavigationPanel = () =>
|
|
43
|
+
const toggleNavigationPanel = () =>
|
|
44
|
+
setIsNavigationPanelOpened( ! isNavigationOpen );
|
|
34
45
|
|
|
35
46
|
let buttonIcon = <Icon size="36px" icon={ wordpress } />;
|
|
36
47
|
|
|
@@ -60,7 +71,8 @@ function NavigationToggle( { icon, isOpen, setIsOpen } ) {
|
|
|
60
71
|
return (
|
|
61
72
|
<motion.div
|
|
62
73
|
className={
|
|
63
|
-
'edit-site-navigation-toggle' +
|
|
74
|
+
'edit-site-navigation-toggle' +
|
|
75
|
+
( isNavigationOpen ? ' is-open' : '' )
|
|
64
76
|
}
|
|
65
77
|
whileHover="expand"
|
|
66
78
|
>
|
|
@@ -34,6 +34,7 @@ describe( 'NavigationToggle', () => {
|
|
|
34
34
|
site_icon_url: 'https://fakeUrl.com',
|
|
35
35
|
} ),
|
|
36
36
|
isResolving: () => false,
|
|
37
|
+
isNavigationOpened: () => false,
|
|
37
38
|
} ) );
|
|
38
39
|
} );
|
|
39
40
|
|
|
@@ -53,6 +54,7 @@ describe( 'NavigationToggle', () => {
|
|
|
53
54
|
site_icon_url: '',
|
|
54
55
|
} ),
|
|
55
56
|
isResolving: () => false,
|
|
57
|
+
isNavigationOpened: () => false,
|
|
56
58
|
} ) );
|
|
57
59
|
} );
|
|
58
60
|
|
package/src/index.js
CHANGED
|
@@ -6,20 +6,21 @@ import {
|
|
|
6
6
|
registerCoreBlocks,
|
|
7
7
|
__experimentalRegisterExperimentalCoreBlocks,
|
|
8
8
|
} from '@wordpress/block-library';
|
|
9
|
-
import { dispatch } from '@wordpress/data';
|
|
9
|
+
import { dispatch, select } from '@wordpress/data';
|
|
10
10
|
import { render, unmountComponentAtNode } from '@wordpress/element';
|
|
11
11
|
import {
|
|
12
12
|
__experimentalFetchLinkSuggestions as fetchLinkSuggestions,
|
|
13
13
|
__experimentalFetchUrlData as fetchUrlData,
|
|
14
14
|
} from '@wordpress/core-data';
|
|
15
15
|
import { store as editorStore } from '@wordpress/editor';
|
|
16
|
+
import { store as viewportStore } from '@wordpress/viewport';
|
|
16
17
|
|
|
17
18
|
/**
|
|
18
19
|
* Internal dependencies
|
|
19
20
|
*/
|
|
20
21
|
import './plugins';
|
|
21
22
|
import './hooks';
|
|
22
|
-
import './store';
|
|
23
|
+
import { store as editSiteStore } from './store';
|
|
23
24
|
import Editor from './components/editor';
|
|
24
25
|
import List from './components/list';
|
|
25
26
|
|
|
@@ -84,6 +85,13 @@ export function initializeList( id, templateType, settings ) {
|
|
|
84
85
|
defaultTemplatePartAreas: settings.defaultTemplatePartAreas,
|
|
85
86
|
} );
|
|
86
87
|
|
|
88
|
+
// Default the navigation panel to be opened when we're in a bigger screen.
|
|
89
|
+
// We update the store synchronously before rendering so that we won't
|
|
90
|
+
// trigger an unnecessary re-render with useEffect.
|
|
91
|
+
dispatch( editSiteStore ).setIsNavigationPanelOpened(
|
|
92
|
+
select( viewportStore ).isViewportMatch( 'medium' )
|
|
93
|
+
);
|
|
94
|
+
|
|
87
95
|
render( <List templateType={ templateType } />, target );
|
|
88
96
|
}
|
|
89
97
|
|