@wordpress/boot 0.3.1-next.738bb1424.0 → 0.4.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/build-module/components/app/index.js +3 -3
- package/build-module/components/app/router.js +39 -42
- package/build-module/components/app/router.js.map +2 -2
- package/build-module/components/app/use-route-title.js +1 -1
- package/build-module/components/canvas/back-button.js +1 -1
- package/build-module/components/canvas/index.js +1 -1
- package/build-module/components/canvas-renderer/index.js +1 -1
- package/build-module/components/navigation/drilldown-item/index.js +1 -1
- package/build-module/components/navigation/dropdown-item/index.js +3 -3
- package/build-module/components/navigation/index.js +6 -6
- package/build-module/components/navigation/navigation-item/index.js +2 -2
- package/build-module/components/navigation/router-link-item.js +1 -1
- package/build-module/components/navigation/use-sidebar-parent.js +3 -3
- package/build-module/components/root/index.js +112 -102
- package/build-module/components/root/index.js.map +2 -2
- package/build-module/components/root/single-page.js +17 -11
- package/build-module/components/root/single-page.js.map +2 -2
- package/build-module/components/save-button/index.js +1 -1
- package/build-module/components/save-panel/index.js +1 -1
- package/build-module/components/sidebar/index.js +3 -3
- package/build-module/components/site-hub/index.js +10 -28
- package/build-module/components/site-hub/index.js.map +2 -2
- package/build-module/components/site-icon-link/index.js +2 -2
- package/build-module/index.js +62 -20
- package/build-module/index.js.map +2 -2
- package/build-module/store/index.js +3 -3
- package/build-style/style-rtl.css +59 -17
- package/build-style/style.css +59 -17
- package/build-types/components/app/router.d.ts.map +1 -1
- package/build-types/components/root/index.d.ts.map +1 -1
- package/build-types/components/root/single-page.d.ts.map +1 -1
- package/build-types/components/site-hub/index.d.ts.map +1 -1
- package/package.json +22 -30
- package/src/components/app/router.tsx +51 -54
- package/src/components/root/index.tsx +46 -44
- package/src/components/root/single-page.tsx +19 -18
- package/src/components/root/style.scss +0 -1
- package/src/components/site-hub/index.tsx +1 -6
- package/src/components/site-hub/style.scss +6 -21
- package/src/style.scss +34 -19
- package/tsconfig.json +27 -0
- package/tsconfig.tsbuildinfo +1 -0
- package/build-module/components/user-theme-provider/index.js +0 -33
- package/build-module/components/user-theme-provider/index.js.map +0 -7
- package/build-types/components/user-theme-provider/index.d.ts +0 -6
- package/build-types/components/user-theme-provider/index.d.ts.map +0 -1
- package/src/components/user-theme-provider/index.tsx +0 -35
- package/src/components/user-theme-provider/test/index.test.ts +0 -11
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
// packages/boot/src/store/index.ts
|
|
2
2
|
import { createReduxStore, register } from "@wordpress/data";
|
|
3
|
-
import { reducer } from "./reducer
|
|
4
|
-
import * as actions from "./actions
|
|
5
|
-
import * as selectors from "./selectors
|
|
3
|
+
import { reducer } from "./reducer";
|
|
4
|
+
import * as actions from "./actions";
|
|
5
|
+
import * as selectors from "./selectors";
|
|
6
6
|
var STORE_NAME = "wordpress/boot";
|
|
7
7
|
var store = createReduxStore(STORE_NAME, {
|
|
8
8
|
reducer,
|
|
@@ -450,27 +450,69 @@
|
|
|
450
450
|
/**
|
|
451
451
|
* Reset the WP Admin page styles for Gutenberg-like pages.
|
|
452
452
|
*/
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
453
|
+
.boot-layout-container .boot-layout {
|
|
454
|
+
height: calc(100vh - 32px);
|
|
455
|
+
}
|
|
456
|
+
|
|
457
|
+
body:has(.boot-layout-container) {
|
|
458
|
+
background: #1d2327;
|
|
459
|
+
overflow: hidden;
|
|
460
|
+
background: #fff;
|
|
461
|
+
}
|
|
462
|
+
body:has(.boot-layout-container) #wpcontent {
|
|
463
|
+
padding-right: 0;
|
|
464
|
+
}
|
|
465
|
+
body:has(.boot-layout-container) #wpbody-content {
|
|
466
|
+
padding-bottom: 0;
|
|
467
|
+
}
|
|
468
|
+
body:has(.boot-layout-container) {
|
|
469
|
+
/* We hide legacy notices in Gutenberg Based Pages, because they were not designed in a way that scaled well.
|
|
470
|
+
Plugins can use Gutenberg notices if they need to pass on information to the user when they are editing. */
|
|
462
471
|
}
|
|
472
|
+
body:has(.boot-layout-container) #wpbody-content > div:not(.boot-layout-container):not(#screen-meta) {
|
|
473
|
+
display: none;
|
|
474
|
+
}
|
|
475
|
+
body:has(.boot-layout-container) #wpfooter {
|
|
476
|
+
display: none;
|
|
477
|
+
}
|
|
478
|
+
body:has(.boot-layout-container) .a11y-speak-region {
|
|
479
|
+
right: -1px;
|
|
480
|
+
top: -1px;
|
|
481
|
+
}
|
|
482
|
+
body:has(.boot-layout-container) ul#adminmenu a.wp-has-current-submenu::after,
|
|
483
|
+
body:has(.boot-layout-container) ul#adminmenu > li.current > a.current::after {
|
|
484
|
+
border-left-color: #fff;
|
|
485
|
+
}
|
|
486
|
+
body:has(.boot-layout-container) .media-frame select.attachment-filters:last-of-type {
|
|
487
|
+
width: auto;
|
|
488
|
+
max-width: 100%;
|
|
489
|
+
}
|
|
490
|
+
|
|
491
|
+
#wpcontent {
|
|
492
|
+
padding-right: 0;
|
|
493
|
+
}
|
|
494
|
+
|
|
495
|
+
#wpbody-content {
|
|
496
|
+
padding-bottom: 0;
|
|
497
|
+
}
|
|
498
|
+
|
|
499
|
+
#wpfooter {
|
|
500
|
+
display: none;
|
|
501
|
+
}
|
|
502
|
+
|
|
463
503
|
@media (min-width: 782px) {
|
|
464
|
-
.boot-layout
|
|
465
|
-
|
|
504
|
+
body:has(.boot-layout.has-full-canvas) {
|
|
505
|
+
margin-top: -32px;
|
|
506
|
+
height: calc(100% + 32px);
|
|
466
507
|
}
|
|
467
|
-
body:has(.boot-layout.has-full-canvas)
|
|
468
|
-
|
|
508
|
+
body:has(.boot-layout.has-full-canvas) #adminmenumain,
|
|
509
|
+
body:has(.boot-layout.has-full-canvas) #wpadminbar {
|
|
510
|
+
display: none;
|
|
511
|
+
}
|
|
512
|
+
body:has(.boot-layout.has-full-canvas) #wpcontent,
|
|
513
|
+
body:has(.boot-layout.has-full-canvas) #wpfooter {
|
|
514
|
+
margin-right: 0;
|
|
469
515
|
}
|
|
470
|
-
}
|
|
471
|
-
.boot-layout-container .boot-layout img {
|
|
472
|
-
max-width: 100%;
|
|
473
|
-
height: auto;
|
|
474
516
|
}
|
|
475
517
|
|
|
476
518
|
.boot-layout .components-editor-notices__snackbar {
|
package/build-style/style.css
CHANGED
|
@@ -450,27 +450,69 @@
|
|
|
450
450
|
/**
|
|
451
451
|
* Reset the WP Admin page styles for Gutenberg-like pages.
|
|
452
452
|
*/
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
453
|
+
.boot-layout-container .boot-layout {
|
|
454
|
+
height: calc(100vh - 32px);
|
|
455
|
+
}
|
|
456
|
+
|
|
457
|
+
body:has(.boot-layout-container) {
|
|
458
|
+
background: #1d2327;
|
|
459
|
+
overflow: hidden;
|
|
460
|
+
background: #fff;
|
|
461
|
+
}
|
|
462
|
+
body:has(.boot-layout-container) #wpcontent {
|
|
463
|
+
padding-left: 0;
|
|
464
|
+
}
|
|
465
|
+
body:has(.boot-layout-container) #wpbody-content {
|
|
466
|
+
padding-bottom: 0;
|
|
467
|
+
}
|
|
468
|
+
body:has(.boot-layout-container) {
|
|
469
|
+
/* We hide legacy notices in Gutenberg Based Pages, because they were not designed in a way that scaled well.
|
|
470
|
+
Plugins can use Gutenberg notices if they need to pass on information to the user when they are editing. */
|
|
462
471
|
}
|
|
472
|
+
body:has(.boot-layout-container) #wpbody-content > div:not(.boot-layout-container):not(#screen-meta) {
|
|
473
|
+
display: none;
|
|
474
|
+
}
|
|
475
|
+
body:has(.boot-layout-container) #wpfooter {
|
|
476
|
+
display: none;
|
|
477
|
+
}
|
|
478
|
+
body:has(.boot-layout-container) .a11y-speak-region {
|
|
479
|
+
left: -1px;
|
|
480
|
+
top: -1px;
|
|
481
|
+
}
|
|
482
|
+
body:has(.boot-layout-container) ul#adminmenu a.wp-has-current-submenu::after,
|
|
483
|
+
body:has(.boot-layout-container) ul#adminmenu > li.current > a.current::after {
|
|
484
|
+
border-right-color: #fff;
|
|
485
|
+
}
|
|
486
|
+
body:has(.boot-layout-container) .media-frame select.attachment-filters:last-of-type {
|
|
487
|
+
width: auto;
|
|
488
|
+
max-width: 100%;
|
|
489
|
+
}
|
|
490
|
+
|
|
491
|
+
#wpcontent {
|
|
492
|
+
padding-left: 0;
|
|
493
|
+
}
|
|
494
|
+
|
|
495
|
+
#wpbody-content {
|
|
496
|
+
padding-bottom: 0;
|
|
497
|
+
}
|
|
498
|
+
|
|
499
|
+
#wpfooter {
|
|
500
|
+
display: none;
|
|
501
|
+
}
|
|
502
|
+
|
|
463
503
|
@media (min-width: 782px) {
|
|
464
|
-
.boot-layout
|
|
465
|
-
|
|
504
|
+
body:has(.boot-layout.has-full-canvas) {
|
|
505
|
+
margin-top: -32px;
|
|
506
|
+
height: calc(100% + 32px);
|
|
466
507
|
}
|
|
467
|
-
body:has(.boot-layout.has-full-canvas)
|
|
468
|
-
|
|
508
|
+
body:has(.boot-layout.has-full-canvas) #adminmenumain,
|
|
509
|
+
body:has(.boot-layout.has-full-canvas) #wpadminbar {
|
|
510
|
+
display: none;
|
|
511
|
+
}
|
|
512
|
+
body:has(.boot-layout.has-full-canvas) #wpcontent,
|
|
513
|
+
body:has(.boot-layout.has-full-canvas) #wpfooter {
|
|
514
|
+
margin-left: 0;
|
|
469
515
|
}
|
|
470
|
-
}
|
|
471
|
-
.boot-layout-container .boot-layout img {
|
|
472
|
-
max-width: 100%;
|
|
473
|
-
height: auto;
|
|
474
516
|
}
|
|
475
517
|
|
|
476
518
|
.boot-layout .components-editor-notices__snackbar {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"router.d.ts","sourceRoot":"","sources":["../../../src/components/app/router.tsx"],"names":[],"mappings":"AAAA;;GAEG;AACH,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,OAAO,CAAC;AAmB3C,OAAO,KAAK,EAAE,KAAK,EAAmC,MAAM,mBAAmB,CAAC;
|
|
1
|
+
{"version":3,"file":"router.d.ts","sourceRoot":"","sources":["../../../src/components/app/router.tsx"],"names":[],"mappings":"AAAA;;GAEG;AACH,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,OAAO,CAAC;AAmB3C,OAAO,KAAK,EAAE,KAAK,EAAmC,MAAM,mBAAmB,CAAC;AAwKhF,UAAU,WAAW;IACpB,MAAM,EAAE,KAAK,EAAE,CAAC;IAChB,aAAa,CAAC,EAAE,aAAa,CAAC;CAC9B;AAED,MAAM,CAAC,OAAO,UAAU,MAAM,CAAE,EAC/B,MAAM,EACN,aAAoB,GACpB,EAAE,WAAW,+BAkCb"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/components/root/index.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/components/root/index.tsx"],"names":[],"mappings":"AAkCA,OAAO,cAAc,CAAC;AAKtB,MAAM,CAAC,OAAO,UAAU,IAAI,gCAyJ3B"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"single-page.d.ts","sourceRoot":"","sources":["../../../src/components/root/single-page.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"single-page.d.ts","sourceRoot":"","sources":["../../../src/components/root/single-page.tsx"],"names":[],"mappings":"AAqBA,OAAO,cAAc,CAAC;AAMtB;;;GAGG;AACH,MAAM,CAAC,OAAO,UAAU,cAAc,gCA6CrC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/components/site-hub/index.tsx"],"names":[],"mappings":"AAwBA,OAAO,cAAc,CAAC;AAEtB,iBAAS,OAAO,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/components/site-hub/index.tsx"],"names":[],"mappings":"AAwBA,OAAO,cAAc,CAAC;AAEtB,iBAAS,OAAO,gCAsCf;AAED,eAAe,OAAO,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@wordpress/boot",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.4.0",
|
|
4
4
|
"description": "Minimal boot package for WordPress admin pages.",
|
|
5
5
|
"author": "The WordPress Contributors",
|
|
6
6
|
"license": "GPL-2.0-or-later",
|
|
@@ -22,14 +22,6 @@
|
|
|
22
22
|
"node": ">=18.12.0",
|
|
23
23
|
"npm": ">=8.19.2"
|
|
24
24
|
},
|
|
25
|
-
"files": [
|
|
26
|
-
"src",
|
|
27
|
-
"build-module",
|
|
28
|
-
"build-style",
|
|
29
|
-
"build-types",
|
|
30
|
-
"*.md"
|
|
31
|
-
],
|
|
32
|
-
"type": "module",
|
|
33
25
|
"module": "build-module/index.js",
|
|
34
26
|
"exports": {
|
|
35
27
|
".": {
|
|
@@ -42,26 +34,26 @@
|
|
|
42
34
|
"wpScriptModuleExports": "./build-module/index.js",
|
|
43
35
|
"types": "build-types",
|
|
44
36
|
"dependencies": {
|
|
45
|
-
"@wordpress/a11y": "^4.
|
|
46
|
-
"@wordpress/admin-ui": "^1.
|
|
47
|
-
"@wordpress/commands": "^1.
|
|
48
|
-
"@wordpress/components": "^31.0.
|
|
49
|
-
"@wordpress/compose": "^7.
|
|
50
|
-
"@wordpress/core-data": "^7.
|
|
51
|
-
"@wordpress/data": "^10.
|
|
52
|
-
"@wordpress/editor": "^14.
|
|
53
|
-
"@wordpress/element": "^6.
|
|
54
|
-
"@wordpress/html-entities": "^4.
|
|
55
|
-
"@wordpress/i18n": "^6.
|
|
56
|
-
"@wordpress/icons": "^11.
|
|
57
|
-
"@wordpress/keyboard-shortcuts": "^5.
|
|
58
|
-
"@wordpress/keycodes": "^4.
|
|
59
|
-
"@wordpress/lazy-editor": "^1.
|
|
60
|
-
"@wordpress/primitives": "^4.
|
|
61
|
-
"@wordpress/private-apis": "^1.
|
|
62
|
-
"@wordpress/route": "^0.
|
|
63
|
-
"@wordpress/theme": "^0.4.
|
|
64
|
-
"@wordpress/url": "^4.
|
|
37
|
+
"@wordpress/a11y": "^4.37.0",
|
|
38
|
+
"@wordpress/admin-ui": "^1.5.0",
|
|
39
|
+
"@wordpress/commands": "^1.37.0",
|
|
40
|
+
"@wordpress/components": "^31.0.0",
|
|
41
|
+
"@wordpress/compose": "^7.37.0",
|
|
42
|
+
"@wordpress/core-data": "^7.37.0",
|
|
43
|
+
"@wordpress/data": "^10.37.0",
|
|
44
|
+
"@wordpress/editor": "^14.37.0",
|
|
45
|
+
"@wordpress/element": "^6.37.0",
|
|
46
|
+
"@wordpress/html-entities": "^4.37.0",
|
|
47
|
+
"@wordpress/i18n": "^6.10.0",
|
|
48
|
+
"@wordpress/icons": "^11.4.0",
|
|
49
|
+
"@wordpress/keyboard-shortcuts": "^5.37.0",
|
|
50
|
+
"@wordpress/keycodes": "^4.37.0",
|
|
51
|
+
"@wordpress/lazy-editor": "^1.3.0",
|
|
52
|
+
"@wordpress/primitives": "^4.37.0",
|
|
53
|
+
"@wordpress/private-apis": "^1.37.0",
|
|
54
|
+
"@wordpress/route": "^0.3.0",
|
|
55
|
+
"@wordpress/theme": "^0.4.0",
|
|
56
|
+
"@wordpress/url": "^4.37.0",
|
|
65
57
|
"clsx": "^2.1.1"
|
|
66
58
|
},
|
|
67
59
|
"peerDependencies": {
|
|
@@ -71,5 +63,5 @@
|
|
|
71
63
|
"publishConfig": {
|
|
72
64
|
"access": "public"
|
|
73
65
|
},
|
|
74
|
-
"gitHead": "
|
|
66
|
+
"gitHead": "2cf13ec6cf86153c9b3cf369bf5c59046f5cd950"
|
|
75
67
|
}
|
|
@@ -7,7 +7,7 @@ import type { ComponentType } from 'react';
|
|
|
7
7
|
* WordPress dependencies
|
|
8
8
|
*/
|
|
9
9
|
import { __ } from '@wordpress/i18n';
|
|
10
|
-
import {
|
|
10
|
+
import { useState, useEffect } from '@wordpress/element';
|
|
11
11
|
import { Page } from '@wordpress/admin-ui';
|
|
12
12
|
import {
|
|
13
13
|
privateApis as routePrivateApis,
|
|
@@ -52,33 +52,29 @@ function NotFoundComponent() {
|
|
|
52
52
|
* @param parentRoute Parent route.
|
|
53
53
|
* @return Tanstack Route.
|
|
54
54
|
*/
|
|
55
|
-
function createRouteFromDefinition(
|
|
55
|
+
async function createRouteFromDefinition(
|
|
56
|
+
route: Route,
|
|
57
|
+
parentRoute: AnyRoute
|
|
58
|
+
) {
|
|
59
|
+
let routeConfig: RouteConfig = {};
|
|
60
|
+
|
|
61
|
+
if ( route.route_module ) {
|
|
62
|
+
const module = await import( route.route_module );
|
|
63
|
+
routeConfig = module.route || {};
|
|
64
|
+
}
|
|
65
|
+
|
|
56
66
|
// Create route without component initially
|
|
57
67
|
let tanstackRoute = createRoute( {
|
|
58
68
|
getParentRoute: () => parentRoute,
|
|
59
69
|
path: route.path,
|
|
60
|
-
beforeLoad:
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
const module = await import( route.route_module );
|
|
64
|
-
const routeConfig = module.route || {};
|
|
65
|
-
|
|
66
|
-
if ( routeConfig.beforeLoad ) {
|
|
67
|
-
return routeConfig.beforeLoad( {
|
|
70
|
+
beforeLoad: routeConfig.beforeLoad
|
|
71
|
+
? ( opts: any ) =>
|
|
72
|
+
routeConfig.beforeLoad!( {
|
|
68
73
|
params: opts.params || {},
|
|
69
74
|
search: opts.search || {},
|
|
70
|
-
} )
|
|
71
|
-
|
|
72
|
-
}
|
|
73
|
-
},
|
|
75
|
+
} )
|
|
76
|
+
: undefined,
|
|
74
77
|
loader: async ( opts: any ) => {
|
|
75
|
-
// Import route module here (lazy)
|
|
76
|
-
let routeConfig: RouteConfig = {};
|
|
77
|
-
if ( route.route_module ) {
|
|
78
|
-
const module = await import( route.route_module );
|
|
79
|
-
routeConfig = module.route || {};
|
|
80
|
-
}
|
|
81
|
-
|
|
82
78
|
const context: RouteLoaderContext = {
|
|
83
79
|
params: opts.params || {},
|
|
84
80
|
search: opts.deps || {},
|
|
@@ -158,7 +154,7 @@ function createRouteFromDefinition( route: Route, parentRoute: AnyRoute ) {
|
|
|
158
154
|
* @param rootComponent Root component to use for the router.
|
|
159
155
|
* @return Router tree.
|
|
160
156
|
*/
|
|
161
|
-
function createRouteTree(
|
|
157
|
+
async function createRouteTree(
|
|
162
158
|
routes: Route[],
|
|
163
159
|
rootComponent: ComponentType = Root
|
|
164
160
|
) {
|
|
@@ -167,9 +163,9 @@ function createRouteTree(
|
|
|
167
163
|
context: () => ( {} ),
|
|
168
164
|
} );
|
|
169
165
|
|
|
170
|
-
// Create routes from definitions
|
|
171
|
-
const dynamicRoutes =
|
|
172
|
-
createRouteFromDefinition( route, rootRoute )
|
|
166
|
+
// Create routes from definitions
|
|
167
|
+
const dynamicRoutes = await Promise.all(
|
|
168
|
+
routes.map( ( route ) => createRouteFromDefinition( route, rootRoute ) )
|
|
173
169
|
);
|
|
174
170
|
|
|
175
171
|
return rootRoute.addChildren( dynamicRoutes );
|
|
@@ -201,36 +197,37 @@ export default function Router( {
|
|
|
201
197
|
routes,
|
|
202
198
|
rootComponent = Root,
|
|
203
199
|
}: RouterProps ) {
|
|
204
|
-
const router =
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
},
|
|
231
|
-
},
|
|
232
|
-
} );
|
|
200
|
+
const [ router, setRouter ] = useState< any >( null );
|
|
201
|
+
|
|
202
|
+
useEffect( () => {
|
|
203
|
+
let cancelled = false;
|
|
204
|
+
|
|
205
|
+
async function initializeRouter() {
|
|
206
|
+
const history = createPathHistory();
|
|
207
|
+
const routeTree = await createRouteTree( routes, rootComponent );
|
|
208
|
+
|
|
209
|
+
if ( ! cancelled ) {
|
|
210
|
+
const newRouter = createRouter( {
|
|
211
|
+
history,
|
|
212
|
+
routeTree,
|
|
213
|
+
defaultPreload: 'intent',
|
|
214
|
+
defaultNotFoundComponent: NotFoundComponent,
|
|
215
|
+
defaultViewTransition: true,
|
|
216
|
+
} );
|
|
217
|
+
setRouter( newRouter );
|
|
218
|
+
}
|
|
219
|
+
}
|
|
220
|
+
|
|
221
|
+
initializeRouter();
|
|
222
|
+
|
|
223
|
+
return () => {
|
|
224
|
+
cancelled = true;
|
|
225
|
+
};
|
|
233
226
|
}, [ routes, rootComponent ] );
|
|
234
227
|
|
|
228
|
+
if ( ! router ) {
|
|
229
|
+
return <div>Loading routes...</div>;
|
|
230
|
+
}
|
|
231
|
+
|
|
235
232
|
return <RouterProvider router={ router } />;
|
|
236
233
|
}
|
|
@@ -9,6 +9,7 @@ import clsx from 'clsx';
|
|
|
9
9
|
import { privateApis as routePrivateApis } from '@wordpress/route';
|
|
10
10
|
// @ts-expect-error Commands is not typed properly.
|
|
11
11
|
import { CommandMenu } from '@wordpress/commands';
|
|
12
|
+
import { privateApis as themePrivateApis } from '@wordpress/theme';
|
|
12
13
|
import { EditorSnackbars } from '@wordpress/editor';
|
|
13
14
|
import { useViewportMatch, useReducedMotion } from '@wordpress/compose';
|
|
14
15
|
import {
|
|
@@ -32,8 +33,8 @@ import useRouteTitle from '../app/use-route-title';
|
|
|
32
33
|
import { unlock } from '../../lock-unlock';
|
|
33
34
|
import type { CanvasData } from '../../store/types';
|
|
34
35
|
import './style.scss';
|
|
35
|
-
import { UserThemeProvider } from '../user-theme-provider';
|
|
36
36
|
|
|
37
|
+
const { ThemeProvider } = unlock( themePrivateApis );
|
|
37
38
|
const { useLocation, useMatches, Outlet } = unlock( routePrivateApis );
|
|
38
39
|
|
|
39
40
|
export default function Root() {
|
|
@@ -61,8 +62,11 @@ export default function Root() {
|
|
|
61
62
|
|
|
62
63
|
return (
|
|
63
64
|
<SlotFillProvider>
|
|
64
|
-
<
|
|
65
|
-
|
|
65
|
+
<ThemeProvider
|
|
66
|
+
isRoot
|
|
67
|
+
color={ { bg: '#f8f8f8', primary: '#3858e9' } }
|
|
68
|
+
>
|
|
69
|
+
<ThemeProvider color={ { bg: '#1d2327', primary: '#3858e9' } }>
|
|
66
70
|
<div
|
|
67
71
|
className={ clsx( 'boot-layout', {
|
|
68
72
|
'has-canvas': !! canvas || canvas === null,
|
|
@@ -142,50 +146,48 @@ export default function Root() {
|
|
|
142
146
|
</div>
|
|
143
147
|
) }
|
|
144
148
|
<div className="boot-layout__surfaces">
|
|
145
|
-
<
|
|
149
|
+
<ThemeProvider
|
|
150
|
+
color={ { bg: '#ffffff', primary: '#3858e9' } }
|
|
151
|
+
>
|
|
146
152
|
<Outlet />
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
/>
|
|
182
|
-
</div>
|
|
183
|
-
) }
|
|
184
|
-
</UserThemeProvider>
|
|
153
|
+
</ThemeProvider>
|
|
154
|
+
{ /* Render Canvas in Root to prevent remounting on route changes */ }
|
|
155
|
+
{ ( canvas || canvas === null ) && (
|
|
156
|
+
<div
|
|
157
|
+
className={ clsx( 'boot-layout__canvas', {
|
|
158
|
+
'has-mobile-drawer':
|
|
159
|
+
canvas?.isPreview &&
|
|
160
|
+
isMobileViewport,
|
|
161
|
+
} ) }
|
|
162
|
+
>
|
|
163
|
+
{ canvas?.isPreview && isMobileViewport && (
|
|
164
|
+
<div className="boot-layout__mobile-sidebar-drawer">
|
|
165
|
+
<Button
|
|
166
|
+
icon={ menu }
|
|
167
|
+
onClick={ () =>
|
|
168
|
+
setIsMobileSidebarOpen(
|
|
169
|
+
true
|
|
170
|
+
)
|
|
171
|
+
}
|
|
172
|
+
label={ __(
|
|
173
|
+
'Open navigation panel'
|
|
174
|
+
) }
|
|
175
|
+
size="compact"
|
|
176
|
+
/>
|
|
177
|
+
</div>
|
|
178
|
+
) }
|
|
179
|
+
<CanvasRenderer
|
|
180
|
+
canvas={ canvas }
|
|
181
|
+
routeContentModule={
|
|
182
|
+
routeContentModule
|
|
183
|
+
}
|
|
184
|
+
/>
|
|
185
|
+
</div>
|
|
186
|
+
) }
|
|
185
187
|
</div>
|
|
186
188
|
</div>
|
|
187
|
-
</
|
|
188
|
-
</
|
|
189
|
+
</ThemeProvider>
|
|
190
|
+
</ThemeProvider>
|
|
189
191
|
</SlotFillProvider>
|
|
190
192
|
);
|
|
191
193
|
}
|
|
@@ -9,6 +9,7 @@ import clsx from 'clsx';
|
|
|
9
9
|
import { privateApis as routePrivateApis } from '@wordpress/route';
|
|
10
10
|
// @ts-expect-error Commands is not typed properly.
|
|
11
11
|
import { CommandMenu } from '@wordpress/commands';
|
|
12
|
+
import { privateApis as themePrivateApis } from '@wordpress/theme';
|
|
12
13
|
import { EditorSnackbars } from '@wordpress/editor';
|
|
13
14
|
|
|
14
15
|
/**
|
|
@@ -20,9 +21,9 @@ import { unlock } from '../../lock-unlock';
|
|
|
20
21
|
import type { CanvasData } from '../../store/types';
|
|
21
22
|
import './style.scss';
|
|
22
23
|
import useRouteTitle from '../app/use-route-title';
|
|
23
|
-
import { UserThemeProvider } from '../user-theme-provider';
|
|
24
24
|
|
|
25
25
|
const { useMatches, Outlet } = unlock( routePrivateApis );
|
|
26
|
+
const { ThemeProvider } = unlock( themePrivateApis );
|
|
26
27
|
|
|
27
28
|
/**
|
|
28
29
|
* Root component for single page mode (no sidebar).
|
|
@@ -42,8 +43,8 @@ export default function RootSinglePage() {
|
|
|
42
43
|
useRouteTitle();
|
|
43
44
|
|
|
44
45
|
return (
|
|
45
|
-
<
|
|
46
|
-
<
|
|
46
|
+
<ThemeProvider isRoot color={ { bg: '#f8f8f8', primary: '#3858e9' } }>
|
|
47
|
+
<ThemeProvider color={ { bg: '#1d2327', primary: '#3858e9' } }>
|
|
47
48
|
<div
|
|
48
49
|
className={ clsx( 'boot-layout boot-layout--single-page', {
|
|
49
50
|
'has-canvas': !! canvas || canvas === null,
|
|
@@ -54,23 +55,23 @@ export default function RootSinglePage() {
|
|
|
54
55
|
<SavePanel />
|
|
55
56
|
<EditorSnackbars />
|
|
56
57
|
<div className="boot-layout__surfaces">
|
|
57
|
-
<
|
|
58
|
+
<ThemeProvider
|
|
59
|
+
color={ { bg: '#ffffff', primary: '#3858e9' } }
|
|
60
|
+
>
|
|
58
61
|
<Outlet />
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
) }
|
|
70
|
-
</UserThemeProvider>
|
|
62
|
+
</ThemeProvider>
|
|
63
|
+
{ /* Render Canvas in Root to prevent remounting on route changes */ }
|
|
64
|
+
{ ( canvas || canvas === null ) && (
|
|
65
|
+
<div className="boot-layout__canvas">
|
|
66
|
+
<CanvasRenderer
|
|
67
|
+
canvas={ canvas }
|
|
68
|
+
routeContentModule={ routeContentModule }
|
|
69
|
+
/>
|
|
70
|
+
</div>
|
|
71
|
+
) }
|
|
71
72
|
</div>
|
|
72
73
|
</div>
|
|
73
|
-
</
|
|
74
|
-
</
|
|
74
|
+
</ThemeProvider>
|
|
75
|
+
</ThemeProvider>
|
|
75
76
|
);
|
|
76
77
|
}
|
|
@@ -48,12 +48,7 @@ function SiteHub() {
|
|
|
48
48
|
href={ homeUrl ?? '/' }
|
|
49
49
|
className="boot-site-hub__title"
|
|
50
50
|
>
|
|
51
|
-
|
|
52
|
-
{ siteTitle && decodeEntities( siteTitle ) }
|
|
53
|
-
</div>
|
|
54
|
-
<div className="boot-site-hub__url">
|
|
55
|
-
{ filterURLForDisplay( homeUrl ?? '' ) }
|
|
56
|
-
</div>
|
|
51
|
+
{ siteTitle && decodeEntities( siteTitle ) }
|
|
57
52
|
</ExternalLink>
|
|
58
53
|
<HStack className="boot-site-hub__actions">
|
|
59
54
|
<Button
|