@wordpress/boot 0.20.0 → 0.21.2-next.v.202608281122.0
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/CHANGELOG.md +38 -0
- package/README.md +4 -0
- package/build-module/components/app/router.mjs +100 -4
- package/build-module/components/app/router.mjs.map +3 -3
- package/build-module/components/canvas/index.mjs +72 -13
- package/build-module/components/canvas/index.mjs.map +2 -2
- package/build-module/components/canvas/site-preview.mjs +50 -0
- package/build-module/components/canvas/site-preview.mjs.map +7 -0
- package/build-module/components/canvas/use-navigate-to-entity-record.mjs +122 -0
- package/build-module/components/canvas/use-navigate-to-entity-record.mjs.map +7 -0
- package/build-module/components/canvas/viewport.mjs +18 -0
- package/build-module/components/canvas/viewport.mjs.map +7 -0
- package/build-module/components/error-boundary/index.mjs +129 -0
- package/build-module/components/error-boundary/index.mjs.map +7 -0
- package/build-module/components/navigation/drilldown-item/index.mjs +91 -1
- package/build-module/components/navigation/drilldown-item/index.mjs.map +3 -3
- package/build-module/components/navigation/dropdown-item/index.mjs +98 -11
- package/build-module/components/navigation/dropdown-item/index.mjs.map +4 -4
- package/build-module/components/navigation/index.mjs +0 -1
- package/build-module/components/navigation/index.mjs.map +2 -2
- package/build-module/components/navigation/navigation-item/index.mjs +88 -15
- package/build-module/components/navigation/navigation-item/index.mjs.map +3 -3
- package/build-module/components/navigation/navigation-screen/index.mjs +111 -38
- package/build-module/components/navigation/navigation-screen/index.mjs.map +3 -3
- package/build-module/components/plugin-area/index.mjs +29 -0
- package/build-module/components/plugin-area/index.mjs.map +7 -0
- package/build-module/components/root/index.mjs +220 -122
- package/build-module/components/root/index.mjs.map +3 -3
- package/build-module/components/root/single-page.mjs +139 -47
- package/build-module/components/root/single-page.mjs.map +3 -3
- package/build-module/components/root/use-sync-body-background.mjs.map +1 -1
- package/build-module/components/save-button/index.mjs +127 -16
- package/build-module/components/save-button/index.mjs.map +3 -3
- package/build-module/components/save-panel/index.mjs +91 -1
- package/build-module/components/save-panel/index.mjs.map +3 -3
- package/build-module/components/sidebar/index.mjs +90 -10
- package/build-module/components/sidebar/index.mjs.map +3 -3
- package/build-module/index.mjs +0 -16
- package/build-module/index.mjs.map +3 -3
- package/build-module/store/actions.mjs +8 -0
- package/build-module/store/actions.mjs.map +2 -2
- package/build-module/store/reducer.mjs +16 -1
- package/build-module/store/reducer.mjs.map +2 -2
- package/build-module/store/selectors.mjs +9 -0
- package/build-module/store/selectors.mjs.map +2 -2
- package/build-types/components/app/router.d.ts.map +1 -1
- package/build-types/components/canvas/index.d.ts.map +1 -1
- package/build-types/components/canvas/site-preview.d.ts +10 -0
- package/build-types/components/canvas/site-preview.d.ts.map +1 -0
- package/build-types/components/canvas/use-navigate-to-entity-record.d.ts +40 -0
- package/build-types/components/canvas/use-navigate-to-entity-record.d.ts.map +1 -0
- package/build-types/components/canvas/viewport.d.ts +15 -0
- package/build-types/components/canvas/viewport.d.ts.map +1 -0
- package/build-types/components/error-boundary/index.d.ts +22 -0
- package/build-types/components/error-boundary/index.d.ts.map +1 -0
- package/build-types/components/navigation/drilldown-item/index.d.ts.map +1 -1
- package/build-types/components/navigation/dropdown-item/index.d.ts +0 -1
- package/build-types/components/navigation/dropdown-item/index.d.ts.map +1 -1
- package/build-types/components/navigation/index.d.ts.map +1 -1
- package/build-types/components/navigation/navigation-item/index.d.ts +0 -1
- package/build-types/components/navigation/navigation-item/index.d.ts.map +1 -1
- package/build-types/components/navigation/navigation-screen/index.d.ts +0 -1
- package/build-types/components/navigation/navigation-screen/index.d.ts.map +1 -1
- package/build-types/components/plugin-area/index.d.ts +12 -0
- package/build-types/components/plugin-area/index.d.ts.map +1 -0
- package/build-types/components/root/index.d.ts +0 -1
- package/build-types/components/root/index.d.ts.map +1 -1
- package/build-types/components/root/single-page.d.ts +0 -1
- package/build-types/components/root/single-page.d.ts.map +1 -1
- package/build-types/components/root/use-sync-body-background.d.ts +1 -1
- package/build-types/components/save-button/index.d.ts +0 -1
- package/build-types/components/save-button/index.d.ts.map +1 -1
- package/build-types/components/save-panel/index.d.ts.map +1 -1
- package/build-types/components/sidebar/index.d.ts +0 -1
- package/build-types/components/sidebar/index.d.ts.map +1 -1
- package/build-types/index.d.ts +0 -2
- package/build-types/index.d.ts.map +1 -1
- package/build-types/store/actions.d.ts +15 -2
- package/build-types/store/actions.d.ts.map +1 -1
- package/build-types/store/reducer.d.ts.map +1 -1
- package/build-types/store/selectors.d.ts +12 -0
- package/build-types/store/selectors.d.ts.map +1 -1
- package/build-types/store/types.d.ts +34 -3
- package/build-types/store/types.d.ts.map +1 -1
- package/package.json +27 -25
- package/src/components/app/router.tsx +19 -7
- package/src/components/canvas/index.tsx +117 -15
- package/src/components/canvas/site-preview.tsx +64 -0
- package/src/components/canvas/use-navigate-to-entity-record.ts +220 -0
- package/src/components/canvas/viewport.ts +34 -0
- package/src/components/error-boundary/index.tsx +71 -0
- package/src/components/error-boundary/style.module.scss +13 -0
- package/src/components/navigation/drilldown-item/index.tsx +2 -1
- package/src/components/navigation/dropdown-item/index.tsx +10 -6
- package/src/components/navigation/dropdown-item/{style.scss → style.module.scss} +6 -2
- package/src/components/navigation/index.tsx +0 -1
- package/src/components/navigation/navigation-item/index.tsx +3 -6
- package/src/components/navigation/navigation-item/{style.scss → style.module.scss} +7 -14
- package/src/components/navigation/navigation-screen/index.tsx +6 -15
- package/src/components/navigation/navigation-screen/{style.scss → style.module.scss} +10 -9
- package/src/components/plugin-area/index.tsx +34 -0
- package/src/components/root/{style.scss → _layout.module.scss} +71 -40
- package/src/components/root/_view-transitions.module.scss +205 -0
- package/src/components/root/index.tsx +44 -24
- package/src/components/root/single-page.tsx +15 -7
- package/src/components/root/style.module.scss +2 -0
- package/src/components/root/use-sync-body-background.ts +1 -1
- package/src/components/save-button/index.tsx +36 -14
- package/src/components/save-button/style.module.scss +10 -0
- package/src/components/save-panel/index.tsx +2 -1
- package/src/components/save-panel/style.module.scss +7 -0
- package/src/components/sidebar/index.tsx +5 -5
- package/src/components/sidebar/style.module.scss +29 -0
- package/src/index.tsx +0 -2
- package/src/store/actions.ts +18 -1
- package/src/store/reducer.ts +19 -0
- package/src/store/selectors.ts +28 -0
- package/src/store/types.ts +37 -3
- package/build-style/style-rtl.css +0 -133
- package/build-style/style.css +0 -133
- package/build-style/view-transitions-rtl.css +0 -189
- package/build-style/view-transitions.css +0 -189
- package/src/components/save-button/style.scss +0 -9
- package/src/components/sidebar/style.scss +0 -23
- package/src/style.scss +0 -34
- package/src/view-transitions.scss +0 -221
|
@@ -0,0 +1,220 @@
|
|
|
1
|
+
import { useCallback, useMemo } from '@wordpress/element';
|
|
2
|
+
import { useDispatch, useRegistry, useSelect } from '@wordpress/data';
|
|
3
|
+
import { store as coreStore } from '@wordpress/core-data';
|
|
4
|
+
import { store as editorStore } from '@wordpress/editor';
|
|
5
|
+
import { store as noticesStore } from '@wordpress/notices';
|
|
6
|
+
import { decodeEntities } from '@wordpress/html-entities';
|
|
7
|
+
import { __, sprintf } from '@wordpress/i18n';
|
|
8
|
+
import {
|
|
9
|
+
useNavigate,
|
|
10
|
+
useSearch,
|
|
11
|
+
privateApis as routePrivateApis,
|
|
12
|
+
} from '@wordpress/route';
|
|
13
|
+
import { store as bootStore } from '../../store';
|
|
14
|
+
import { isValidViewport } from './viewport';
|
|
15
|
+
import { unlock } from '../../lock-unlock';
|
|
16
|
+
|
|
17
|
+
const { useCanGoBack, useRouter } = unlock( routePrivateApis );
|
|
18
|
+
|
|
19
|
+
/*
|
|
20
|
+
* The route tree is assembled from routes registered at runtime, so TanStack has
|
|
21
|
+
* no search schema to infer and types `search` against a placeholder. Describe
|
|
22
|
+
* the two calls this module makes instead.
|
|
23
|
+
*/
|
|
24
|
+
type Navigate = ( options: {
|
|
25
|
+
to?: string;
|
|
26
|
+
replace?: boolean;
|
|
27
|
+
search?: (
|
|
28
|
+
previous: Record< string, unknown >
|
|
29
|
+
) => Record< string, unknown >;
|
|
30
|
+
} ) => void;
|
|
31
|
+
|
|
32
|
+
interface NavigateParams {
|
|
33
|
+
postType: string;
|
|
34
|
+
postId: string;
|
|
35
|
+
viewport?: string;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
/**
|
|
39
|
+
* Builds the editor's entity navigation callbacks.
|
|
40
|
+
*
|
|
41
|
+
* The editor uses these to move between an entity and one nested inside it —
|
|
42
|
+
* a template part or a synced pattern reached from the block inspector. They
|
|
43
|
+
* are passed through the editor settings, where `onNavigateToEntityRecord`
|
|
44
|
+
* gates the inspector's edit affordance and `onNavigateToPreviousEntityRecord`
|
|
45
|
+
* gates the document bar's back button.
|
|
46
|
+
*
|
|
47
|
+
* @return The two callbacks, for spreading into the editor settings.
|
|
48
|
+
*/
|
|
49
|
+
export default function useNavigateToEntityRecord() {
|
|
50
|
+
const navigate = useNavigate() as Navigate;
|
|
51
|
+
const search = useSearch( { strict: false } ) as { focusMode?: unknown };
|
|
52
|
+
const registry = useRegistry();
|
|
53
|
+
const getEntityLink = useSelect(
|
|
54
|
+
( select ) => select( bootStore ).getEntityLink,
|
|
55
|
+
[]
|
|
56
|
+
);
|
|
57
|
+
const router = useRouter();
|
|
58
|
+
const canGoBack = useCanGoBack();
|
|
59
|
+
|
|
60
|
+
const onNavigateToEntityRecord = useCallback(
|
|
61
|
+
( params: NavigateParams ) => {
|
|
62
|
+
/*
|
|
63
|
+
* Stash the block selected in the entity being left, so returning to
|
|
64
|
+
* it can restore the user's place. The edits hold the external
|
|
65
|
+
* client ID, which `onChangeSelection` has already resolved.
|
|
66
|
+
*/
|
|
67
|
+
const currentPostType = (
|
|
68
|
+
registry.select( editorStore ) as any
|
|
69
|
+
).getCurrentPostType();
|
|
70
|
+
const currentPostId = (
|
|
71
|
+
registry.select( editorStore ) as any
|
|
72
|
+
).getCurrentPostId();
|
|
73
|
+
const edits = registry
|
|
74
|
+
.select( coreStore )
|
|
75
|
+
.getEntityRecordEdits(
|
|
76
|
+
'postType',
|
|
77
|
+
currentPostType,
|
|
78
|
+
currentPostId
|
|
79
|
+
) as { selection?: { selectionStart?: { clientId?: string } } };
|
|
80
|
+
const selectedBlock = edits?.selection?.selectionStart?.clientId;
|
|
81
|
+
|
|
82
|
+
if ( selectedBlock ) {
|
|
83
|
+
navigate( {
|
|
84
|
+
search: ( previous: Record< string, unknown > ) => ( {
|
|
85
|
+
...previous,
|
|
86
|
+
selectedBlock,
|
|
87
|
+
} ),
|
|
88
|
+
replace: true,
|
|
89
|
+
} );
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
/*
|
|
93
|
+
* An entity can ask to be edited at a particular width — a
|
|
94
|
+
* navigation overlay meant for mobile. The width is where the entity
|
|
95
|
+
* opens, not something the entity being left carries away: a width
|
|
96
|
+
* set from the device preview is view state, and an entity that asks
|
|
97
|
+
* for none opens at the default.
|
|
98
|
+
*/
|
|
99
|
+
const requestedViewport = params.viewport?.toLowerCase();
|
|
100
|
+
const hasRequestedViewport = isValidViewport( requestedViewport );
|
|
101
|
+
|
|
102
|
+
/*
|
|
103
|
+
* `focusMode` marks the entity as one navigated into rather than
|
|
104
|
+
* opened directly, which is what offers the way back out. The search
|
|
105
|
+
* is replaced rather than extended so the block stashed above stays
|
|
106
|
+
* with the entity it belongs to.
|
|
107
|
+
*/
|
|
108
|
+
const to = getEntityLink( params.postType, params.postId );
|
|
109
|
+
|
|
110
|
+
if ( to ) {
|
|
111
|
+
navigate( {
|
|
112
|
+
to,
|
|
113
|
+
search: () => ( {
|
|
114
|
+
focusMode: true,
|
|
115
|
+
...( hasRequestedViewport
|
|
116
|
+
? { viewport: requestedViewport }
|
|
117
|
+
: {} ),
|
|
118
|
+
} ),
|
|
119
|
+
} );
|
|
120
|
+
}
|
|
121
|
+
},
|
|
122
|
+
[ navigate, registry, getEntityLink ]
|
|
123
|
+
);
|
|
124
|
+
|
|
125
|
+
/*
|
|
126
|
+
* Only entities navigated into offer a way back out. The editor reads this
|
|
127
|
+
* as the entity being a focused one, giving it the document bar's back
|
|
128
|
+
* button and the surrounding padding, so an entity opened directly — from a
|
|
129
|
+
* list, say — must not have it. `canGoBack` covers reloading such a URL,
|
|
130
|
+
* where the marker survives but the history to return to does not.
|
|
131
|
+
*/
|
|
132
|
+
const isFocusMode = !! search.focusMode;
|
|
133
|
+
const onNavigateToPreviousEntityRecord = useMemo(
|
|
134
|
+
() =>
|
|
135
|
+
isFocusMode && canGoBack ? () => router.history.back() : undefined,
|
|
136
|
+
[ isFocusMode, canGoBack, router ]
|
|
137
|
+
);
|
|
138
|
+
|
|
139
|
+
return { onNavigateToEntityRecord, onNavigateToPreviousEntityRecord };
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
interface ActionItem {
|
|
143
|
+
id: string | number;
|
|
144
|
+
type: string;
|
|
145
|
+
title?: string | { rendered?: string };
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
/**
|
|
149
|
+
* Builds the callback the editor runs after a post action.
|
|
150
|
+
*
|
|
151
|
+
* Actions taken from inside the editor act on the entity being edited, so
|
|
152
|
+
* trashing or deleting one leaves the canvas showing something that is no
|
|
153
|
+
* longer there, and duplicating one gives no way to reach the copy.
|
|
154
|
+
*
|
|
155
|
+
* @param postType Post type rendered in the canvas.
|
|
156
|
+
* @return The callback, for passing to the editor.
|
|
157
|
+
*/
|
|
158
|
+
export function useActionPerformed( postType?: string ) {
|
|
159
|
+
const navigate = useNavigate() as Navigate;
|
|
160
|
+
const { createSuccessNotice } = useDispatch( noticesStore );
|
|
161
|
+
const getEntityLink = useSelect(
|
|
162
|
+
( select ) => select( bootStore ).getEntityLink,
|
|
163
|
+
[]
|
|
164
|
+
);
|
|
165
|
+
|
|
166
|
+
return useCallback(
|
|
167
|
+
( actionId: string, items: ActionItem[] ) => {
|
|
168
|
+
switch ( actionId ) {
|
|
169
|
+
case 'move-to-trash':
|
|
170
|
+
case 'delete-post': {
|
|
171
|
+
const to = postType && getEntityLink( postType );
|
|
172
|
+
|
|
173
|
+
if ( to ) {
|
|
174
|
+
navigate( { to, search: () => ( {} ) } );
|
|
175
|
+
}
|
|
176
|
+
break;
|
|
177
|
+
}
|
|
178
|
+
|
|
179
|
+
case 'duplicate-post': {
|
|
180
|
+
const newItem = items[ 0 ];
|
|
181
|
+
const to = getEntityLink( newItem.type, newItem.id );
|
|
182
|
+
|
|
183
|
+
if ( ! to ) {
|
|
184
|
+
break;
|
|
185
|
+
}
|
|
186
|
+
|
|
187
|
+
const title =
|
|
188
|
+
typeof newItem.title === 'string'
|
|
189
|
+
? newItem.title
|
|
190
|
+
: newItem.title?.rendered;
|
|
191
|
+
|
|
192
|
+
/*
|
|
193
|
+
* The action has already announced the copy under this id.
|
|
194
|
+
* Reissuing it under the same id replaces that notice rather
|
|
195
|
+
* than stacking a second one, and adds the way to reach it.
|
|
196
|
+
*/
|
|
197
|
+
createSuccessNotice(
|
|
198
|
+
sprintf(
|
|
199
|
+
// translators: %s: Title of the created post, e.g: "Hello world".
|
|
200
|
+
__( '"%s" successfully created.' ),
|
|
201
|
+
decodeEntities( title ?? '' ) || __( '(no title)' )
|
|
202
|
+
),
|
|
203
|
+
{
|
|
204
|
+
type: 'snackbar',
|
|
205
|
+
id: 'duplicate-post-action',
|
|
206
|
+
actions: [
|
|
207
|
+
{
|
|
208
|
+
label: __( 'Edit' ),
|
|
209
|
+
onClick: () => navigate( { to } ),
|
|
210
|
+
},
|
|
211
|
+
],
|
|
212
|
+
}
|
|
213
|
+
);
|
|
214
|
+
break;
|
|
215
|
+
}
|
|
216
|
+
}
|
|
217
|
+
},
|
|
218
|
+
[ navigate, createSuccessNotice, getEntityLink, postType ]
|
|
219
|
+
);
|
|
220
|
+
}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
const DEFAULT_DEVICE_TYPE = 'Desktop';
|
|
2
|
+
|
|
3
|
+
/*
|
|
4
|
+
* Lowercase in the URL, PascalCase in the editor store. Duplicated in
|
|
5
|
+
* packages/edit-site/src/components/block-editor/viewport.js, in the editor's
|
|
6
|
+
* preview-dropdown choices, and in the block editor's block-visibility
|
|
7
|
+
* constants. Update all four when adding a viewport type.
|
|
8
|
+
*/
|
|
9
|
+
const VALID_VIEWPORTS = [ 'desktop', 'tablet', 'mobile' ];
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* Whether a viewport is one an entity can be asked to be edited at.
|
|
13
|
+
*
|
|
14
|
+
* @param viewport Viewport, as written in the URL.
|
|
15
|
+
* @return Whether the editor has a width for it.
|
|
16
|
+
*/
|
|
17
|
+
export function isValidViewport( viewport?: string ): viewport is string {
|
|
18
|
+
return !! viewport && VALID_VIEWPORTS.includes( viewport.toLowerCase() );
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
/**
|
|
22
|
+
* The device type a `viewport` search param names.
|
|
23
|
+
*
|
|
24
|
+
* @param viewport Viewport, as written in the URL.
|
|
25
|
+
* @return Device type, Desktop for a viewport the editor has no width for.
|
|
26
|
+
*/
|
|
27
|
+
export function getDeviceType( viewport?: string ) {
|
|
28
|
+
if ( ! isValidViewport( viewport ) ) {
|
|
29
|
+
return DEFAULT_DEVICE_TYPE;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
const value = viewport.toLowerCase();
|
|
33
|
+
return value.charAt( 0 ).toUpperCase() + value.slice( 1 );
|
|
34
|
+
}
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
import type { ReactNode } from 'react';
|
|
2
|
+
import { Component } from '@wordpress/element';
|
|
3
|
+
import { __ } from '@wordpress/i18n';
|
|
4
|
+
import { Button } from '@wordpress/components';
|
|
5
|
+
import { EmptyState } from '@wordpress/ui';
|
|
6
|
+
import { useCopyToClipboard } from '@wordpress/compose';
|
|
7
|
+
import { caution } from '@wordpress/icons';
|
|
8
|
+
import styles from './style.module.scss';
|
|
9
|
+
|
|
10
|
+
interface Props {
|
|
11
|
+
children: ReactNode;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
interface State {
|
|
15
|
+
error: Error | null;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
function CopyErrorButton( { error }: { error: Error } ) {
|
|
19
|
+
const ref = useCopyToClipboard( () => error.stack ?? String( error ) );
|
|
20
|
+
|
|
21
|
+
return (
|
|
22
|
+
<Button __next40pxDefaultSize variant="secondary" ref={ ref }>
|
|
23
|
+
{ __( 'Copy error' ) }
|
|
24
|
+
</Button>
|
|
25
|
+
);
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
/**
|
|
29
|
+
* Contains a failure to one surface, so a screen keeps working around it.
|
|
30
|
+
*
|
|
31
|
+
* Wrapping each surface separately means a stage that throws leaves the
|
|
32
|
+
* navigation, the canvas and the way to save reachable, rather than taking the
|
|
33
|
+
* whole screen down with it.
|
|
34
|
+
*/
|
|
35
|
+
export default class ErrorBoundary extends Component< Props, State > {
|
|
36
|
+
constructor( props: Props ) {
|
|
37
|
+
super( props );
|
|
38
|
+
this.state = { error: null };
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
static getDerivedStateFromError( error: Error ): State {
|
|
42
|
+
return { error };
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
render() {
|
|
46
|
+
const { error } = this.state;
|
|
47
|
+
|
|
48
|
+
if ( ! error ) {
|
|
49
|
+
return this.props.children;
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
return (
|
|
53
|
+
<div className={ styles[ 'error-boundary' ] }>
|
|
54
|
+
<EmptyState.Root>
|
|
55
|
+
<EmptyState.Icon icon={ caution } />
|
|
56
|
+
<EmptyState.Title>
|
|
57
|
+
{ __( 'Something went wrong' ) }
|
|
58
|
+
</EmptyState.Title>
|
|
59
|
+
<EmptyState.Description>
|
|
60
|
+
{ __(
|
|
61
|
+
'This part of the screen could not be displayed. Reloading the page may help.'
|
|
62
|
+
) }
|
|
63
|
+
</EmptyState.Description>
|
|
64
|
+
<EmptyState.Actions>
|
|
65
|
+
<CopyErrorButton error={ error } />
|
|
66
|
+
</EmptyState.Actions>
|
|
67
|
+
</EmptyState.Root>
|
|
68
|
+
</div>
|
|
69
|
+
);
|
|
70
|
+
}
|
|
71
|
+
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
@use "@wordpress/base-styles/variables";
|
|
2
|
+
|
|
3
|
+
// The surfaces this sits in are sized by their container, so fill the height
|
|
4
|
+
// available and centre the message in it rather than leaving it at the top of
|
|
5
|
+
// an otherwise empty area.
|
|
6
|
+
.error-boundary {
|
|
7
|
+
display: flex;
|
|
8
|
+
align-items: center;
|
|
9
|
+
justify-content: center;
|
|
10
|
+
box-sizing: border-box;
|
|
11
|
+
min-height: 100%;
|
|
12
|
+
padding: variables.$grid-unit-20;
|
|
13
|
+
}
|
|
@@ -10,6 +10,7 @@ import { isRTL } from '@wordpress/i18n';
|
|
|
10
10
|
import { chevronRightSmall, chevronLeftSmall } from '@wordpress/icons';
|
|
11
11
|
import { wrapIcon } from '../items';
|
|
12
12
|
import type { IconType } from '../../../store/types';
|
|
13
|
+
import styles from '../navigation-item/style.module.scss';
|
|
13
14
|
|
|
14
15
|
interface DrilldownItemProps {
|
|
15
16
|
/**
|
|
@@ -59,7 +60,7 @@ export default function DrilldownItem( {
|
|
|
59
60
|
|
|
60
61
|
return (
|
|
61
62
|
<Item
|
|
62
|
-
className={ clsx(
|
|
63
|
+
className={ clsx( styles.item, className ) }
|
|
63
64
|
onClick={ handleClick }
|
|
64
65
|
>
|
|
65
66
|
<HStack
|
|
@@ -15,7 +15,8 @@ import { STORE_NAME } from '../../../store';
|
|
|
15
15
|
import NavigationItem from '../navigation-item';
|
|
16
16
|
import { wrapIcon } from '../items';
|
|
17
17
|
import type { IconType, MenuItem } from '../../../store/types';
|
|
18
|
-
import '
|
|
18
|
+
import navigationItemStyles from '../navigation-item/style.module.scss';
|
|
19
|
+
import styles from './style.module.scss';
|
|
19
20
|
|
|
20
21
|
const ANIMATION_DURATION = 0.2;
|
|
21
22
|
|
|
@@ -67,9 +68,9 @@ export default function DropdownItem( {
|
|
|
67
68
|
const items = menuItems.filter( ( item ) => item.parent === id );
|
|
68
69
|
const disableMotion = useReducedMotion();
|
|
69
70
|
return (
|
|
70
|
-
<div className=
|
|
71
|
+
<div className={ styles.dropdown }>
|
|
71
72
|
<Item
|
|
72
|
-
className={ clsx(
|
|
73
|
+
className={ clsx( navigationItemStyles.item, className ) }
|
|
73
74
|
onClick={ ( e ) => {
|
|
74
75
|
e.preventDefault();
|
|
75
76
|
e.stopPropagation();
|
|
@@ -86,8 +87,8 @@ export default function DropdownItem( {
|
|
|
86
87
|
<FlexBlock>{ children }</FlexBlock>
|
|
87
88
|
<WCIcon
|
|
88
89
|
icon={ chevronDownSmall }
|
|
89
|
-
className={ clsx(
|
|
90
|
-
'is-up': isExpanded,
|
|
90
|
+
className={ clsx( styles.chevron, {
|
|
91
|
+
[ styles[ 'is-up' ] ]: isExpanded,
|
|
91
92
|
} ) }
|
|
92
93
|
/>
|
|
93
94
|
</HStack>
|
|
@@ -103,11 +104,14 @@ export default function DropdownItem( {
|
|
|
103
104
|
duration: disableMotion ? 0 : ANIMATION_DURATION,
|
|
104
105
|
ease: 'easeOut',
|
|
105
106
|
} }
|
|
106
|
-
className=
|
|
107
|
+
className={ styles[ 'dropdown-children' ] }
|
|
107
108
|
>
|
|
108
109
|
{ items.map( ( item, index ) => (
|
|
109
110
|
<NavigationItem
|
|
110
111
|
key={ index }
|
|
112
|
+
className={
|
|
113
|
+
navigationItemStyles[ 'is-compact' ]
|
|
114
|
+
}
|
|
111
115
|
to={ item.to }
|
|
112
116
|
shouldShowPlaceholder={ false }
|
|
113
117
|
>
|
|
@@ -1,6 +1,10 @@
|
|
|
1
1
|
@use "@wordpress/base-styles/variables";
|
|
2
2
|
|
|
3
|
-
.
|
|
3
|
+
.dropdown {
|
|
4
|
+
display: block;
|
|
5
|
+
}
|
|
6
|
+
|
|
7
|
+
.dropdown-children {
|
|
4
8
|
display: flex;
|
|
5
9
|
flex-direction: column;
|
|
6
10
|
|
|
@@ -18,6 +22,6 @@
|
|
|
18
22
|
overflow: hidden;
|
|
19
23
|
}
|
|
20
24
|
|
|
21
|
-
.
|
|
25
|
+
.chevron.is-up {
|
|
22
26
|
transform: rotate(180deg);
|
|
23
27
|
}
|
|
@@ -8,7 +8,7 @@ import {
|
|
|
8
8
|
import RouterLinkItem from '../router-link-item';
|
|
9
9
|
import { wrapIcon } from '../items';
|
|
10
10
|
import type { IconType } from '../../../store/types';
|
|
11
|
-
import './style.scss';
|
|
11
|
+
import styles from './style.module.scss';
|
|
12
12
|
|
|
13
13
|
interface NavigationItemProps {
|
|
14
14
|
/**
|
|
@@ -58,7 +58,7 @@ export default function NavigationItem( {
|
|
|
58
58
|
<Item
|
|
59
59
|
as="a"
|
|
60
60
|
href={ to }
|
|
61
|
-
className={ clsx(
|
|
61
|
+
className={ clsx( styles.item, className ) }
|
|
62
62
|
>
|
|
63
63
|
{ content }
|
|
64
64
|
</Item>
|
|
@@ -66,10 +66,7 @@ export default function NavigationItem( {
|
|
|
66
66
|
}
|
|
67
67
|
|
|
68
68
|
return (
|
|
69
|
-
<RouterLinkItem
|
|
70
|
-
to={ to }
|
|
71
|
-
className={ clsx( 'boot-navigation-item', className ) }
|
|
72
|
-
>
|
|
69
|
+
<RouterLinkItem to={ to } className={ clsx( styles.item, className ) }>
|
|
73
70
|
{ content }
|
|
74
71
|
</RouterLinkItem>
|
|
75
72
|
);
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
@use "@wordpress/base-styles/variables";
|
|
2
2
|
@use "@wordpress/base-styles/mixins";
|
|
3
3
|
|
|
4
|
-
.
|
|
4
|
+
// Override Item's default styles without depending on its class names.
|
|
5
|
+
.item.item {
|
|
5
6
|
color: var(--wpds-color-foreground-interactive-neutral);
|
|
6
7
|
padding-inline: variables.$grid-unit-05;
|
|
7
8
|
padding-block: 0;
|
|
@@ -14,29 +15,21 @@
|
|
|
14
15
|
align-items: center;
|
|
15
16
|
@include mixins.body-medium();
|
|
16
17
|
|
|
17
|
-
.boot-dropdown-item__children & {
|
|
18
|
-
min-height: variables.$grid-unit-30;
|
|
19
|
-
}
|
|
20
|
-
|
|
21
18
|
// Rounded focus ring
|
|
22
19
|
border-radius: var(--wpds-border-radius-sm);
|
|
23
20
|
|
|
24
|
-
&.active,
|
|
25
21
|
&:hover,
|
|
26
22
|
&:focus,
|
|
27
23
|
&[aria-current="true"] {
|
|
28
24
|
color: var(--wpds-color-foreground-interactive-brand-active);
|
|
29
25
|
}
|
|
30
26
|
|
|
31
|
-
&.active {
|
|
32
|
-
font-weight: var(--wpds-typography-font-weight-emphasis);
|
|
33
|
-
}
|
|
34
|
-
|
|
35
27
|
svg:last-child {
|
|
36
28
|
padding: variables.$grid-unit-05;
|
|
37
29
|
}
|
|
38
30
|
|
|
39
|
-
&[aria-current="
|
|
31
|
+
&[aria-current="page"],
|
|
32
|
+
&[data-status="active"] {
|
|
40
33
|
color: var(--wpds-color-foreground-interactive-brand-active);
|
|
41
34
|
font-weight: var(--wpds-typography-font-weight-emphasis);
|
|
42
35
|
}
|
|
@@ -45,8 +38,8 @@
|
|
|
45
38
|
&:focus-visible {
|
|
46
39
|
transform: translateZ(0);
|
|
47
40
|
}
|
|
41
|
+
}
|
|
48
42
|
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
}
|
|
43
|
+
.item.is-compact {
|
|
44
|
+
min-height: variables.$grid-unit-30;
|
|
52
45
|
}
|
|
@@ -9,7 +9,7 @@ import {
|
|
|
9
9
|
import { isRTL, __ } from '@wordpress/i18n';
|
|
10
10
|
import { chevronRight, chevronLeft } from '@wordpress/icons';
|
|
11
11
|
import { useReducedMotion } from '@wordpress/compose';
|
|
12
|
-
import './style.scss';
|
|
12
|
+
import styles from './style.module.scss';
|
|
13
13
|
|
|
14
14
|
const ANIMATION_DURATION = 0.3;
|
|
15
15
|
const slideVariants = {
|
|
@@ -66,7 +66,7 @@ export default function NavigationScreen( {
|
|
|
66
66
|
|
|
67
67
|
return (
|
|
68
68
|
<div
|
|
69
|
-
className=
|
|
69
|
+
className={ styles.screen }
|
|
70
70
|
style={ {
|
|
71
71
|
overflow: 'hidden',
|
|
72
72
|
position: 'relative',
|
|
@@ -94,10 +94,7 @@ export default function NavigationScreen( {
|
|
|
94
94
|
gridRow: '1',
|
|
95
95
|
} }
|
|
96
96
|
>
|
|
97
|
-
<HStack
|
|
98
|
-
spacing={ 2 }
|
|
99
|
-
className="boot-navigation-screen__title-icon"
|
|
100
|
-
>
|
|
97
|
+
<HStack spacing={ 2 } className={ styles[ 'title-icon' ] }>
|
|
101
98
|
{ ! isRoot && (
|
|
102
99
|
<Button
|
|
103
100
|
ref={ backButtonRef }
|
|
@@ -109,24 +106,18 @@ export default function NavigationScreen( {
|
|
|
109
106
|
/>
|
|
110
107
|
) }
|
|
111
108
|
<Heading
|
|
112
|
-
className=
|
|
109
|
+
className={ styles.title }
|
|
113
110
|
level={ 1 }
|
|
114
111
|
size="15px"
|
|
115
112
|
>
|
|
116
113
|
{ title }
|
|
117
114
|
</Heading>
|
|
118
115
|
{ actions && (
|
|
119
|
-
<div className=
|
|
120
|
-
{ actions }
|
|
121
|
-
</div>
|
|
116
|
+
<div className={ styles.actions }>{ actions }</div>
|
|
122
117
|
) }
|
|
123
118
|
</HStack>
|
|
124
119
|
|
|
125
|
-
{ description &&
|
|
126
|
-
<div className="boot-navigation-screen__description">
|
|
127
|
-
{ description }
|
|
128
|
-
</div>
|
|
129
|
-
) }
|
|
120
|
+
{ description && <div>{ description }</div> }
|
|
130
121
|
|
|
131
122
|
{ content }
|
|
132
123
|
</motion.div>
|
|
@@ -1,34 +1,35 @@
|
|
|
1
1
|
@use "@wordpress/base-styles/variables";
|
|
2
2
|
|
|
3
|
-
.
|
|
3
|
+
.screen {
|
|
4
4
|
// Avoid cutting off focus ring of the last menu item
|
|
5
5
|
padding-block-end: variables.$grid-unit-05;
|
|
6
6
|
}
|
|
7
7
|
|
|
8
|
-
.
|
|
8
|
+
.screen :global(.components-text) {
|
|
9
9
|
color: var(--wpds-color-foreground-content-neutral);
|
|
10
10
|
}
|
|
11
11
|
|
|
12
|
-
.
|
|
12
|
+
.title-icon {
|
|
13
13
|
position: sticky;
|
|
14
14
|
top: 0;
|
|
15
|
-
padding:
|
|
16
|
-
|
|
17
|
-
|
|
15
|
+
padding-block-start: variables.$grid-unit-15;
|
|
16
|
+
padding-inline-end: variables.$grid-unit-20;
|
|
17
|
+
padding-block-end: variables.$grid-unit-10;
|
|
18
|
+
padding-inline-start: variables.$grid-unit-20;
|
|
18
19
|
}
|
|
19
20
|
|
|
20
|
-
.
|
|
21
|
+
.title {
|
|
21
22
|
flex-grow: 1;
|
|
22
23
|
overflow-wrap: break-word;
|
|
23
24
|
|
|
24
25
|
&#{&},
|
|
25
|
-
&#{&} .
|
|
26
|
+
&#{&} .title {
|
|
26
27
|
line-height: variables.$font-line-height-x-large;
|
|
27
28
|
color: var(--wpds-color-foreground-content-neutral);
|
|
28
29
|
}
|
|
29
30
|
}
|
|
30
31
|
|
|
31
|
-
.
|
|
32
|
+
.actions {
|
|
32
33
|
display: flex;
|
|
33
34
|
flex-shrink: 0;
|
|
34
35
|
}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { useDispatch } from '@wordpress/data';
|
|
2
|
+
import { __, sprintf } from '@wordpress/i18n';
|
|
3
|
+
import { store as noticesStore } from '@wordpress/notices';
|
|
4
|
+
import { PluginArea as WPPluginArea } from '@wordpress/plugins';
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* Mounts every plugin registered with `registerPlugin`, so the fills they
|
|
8
|
+
* render reach their slots.
|
|
9
|
+
*
|
|
10
|
+
* Sits at the root rather than with the editor: a plugin's fills mostly target
|
|
11
|
+
* editor slots, but the component holding them is also where it registers
|
|
12
|
+
* commands and extends a list, which the routes without a canvas need too.
|
|
13
|
+
*
|
|
14
|
+
* @return The mount point. Renders whatever the plugins do, and nothing itself.
|
|
15
|
+
*/
|
|
16
|
+
export default function PluginArea() {
|
|
17
|
+
const { createErrorNotice } = useDispatch( noticesStore );
|
|
18
|
+
|
|
19
|
+
return (
|
|
20
|
+
<WPPluginArea
|
|
21
|
+
onError={ ( name ) => {
|
|
22
|
+
createErrorNotice(
|
|
23
|
+
sprintf(
|
|
24
|
+
/* translators: %s: plugin name */
|
|
25
|
+
__(
|
|
26
|
+
'The "%s" plugin has encountered an error and cannot be rendered.'
|
|
27
|
+
),
|
|
28
|
+
name
|
|
29
|
+
)
|
|
30
|
+
);
|
|
31
|
+
} }
|
|
32
|
+
/>
|
|
33
|
+
);
|
|
34
|
+
}
|