@wordpress/boot 0.14.1 → 0.15.1

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.
Files changed (34) hide show
  1. package/CHANGELOG.md +11 -0
  2. package/build-module/components/canvas/back-button.mjs +3 -3
  3. package/build-module/components/canvas/back-button.mjs.map +2 -2
  4. package/build-module/components/navigation/index.mjs +2 -2
  5. package/build-module/components/navigation/index.mjs.map +2 -2
  6. package/build-module/components/root/index.mjs +121 -100
  7. package/build-module/components/root/index.mjs.map +2 -2
  8. package/build-module/components/root/single-page.mjs +45 -25
  9. package/build-module/components/root/single-page.mjs.map +2 -2
  10. package/build-module/components/save-button/index.mjs +33 -27
  11. package/build-module/components/save-button/index.mjs.map +2 -2
  12. package/build-module/components/site-icon-link/index.mjs +25 -17
  13. package/build-module/components/site-icon-link/index.mjs.map +2 -2
  14. package/build-module/index.mjs +3 -3
  15. package/build-module/index.mjs.map +2 -2
  16. package/build-style/style-rtl.css +23 -114
  17. package/build-style/style.css +23 -114
  18. package/build-style/view-transitions-rtl.css +6 -3
  19. package/build-style/view-transitions.css +6 -3
  20. package/build-types/components/root/index.d.ts.map +1 -1
  21. package/build-types/components/root/single-page.d.ts.map +1 -1
  22. package/build-types/components/save-button/index.d.ts.map +1 -1
  23. package/build-types/components/site-icon-link/index.d.ts.map +1 -1
  24. package/package.json +26 -25
  25. package/src/components/navigation/index.tsx +2 -2
  26. package/src/components/root/index.tsx +141 -120
  27. package/src/components/root/single-page.tsx +20 -7
  28. package/src/components/save-button/index.tsx +31 -20
  29. package/src/components/save-button/style.scss +6 -0
  30. package/src/components/site-icon-link/index.tsx +27 -18
  31. package/build-module/components/user-theme-provider/index.mjs +0 -33
  32. package/build-module/components/user-theme-provider/index.mjs.map +0 -7
  33. package/src/components/user-theme-provider/index.tsx +0 -35
  34. package/src/components/user-theme-provider/test/index.test.ts +0 -11
@@ -9,6 +9,9 @@ import clsx from 'clsx';
9
9
  import { privateApis as routePrivateApis } from '@wordpress/route';
10
10
  import { SnackbarNotices } from '@wordpress/notices';
11
11
  import { SlotFillProvider } from '@wordpress/components';
12
+ import { useMemo } from '@wordpress/element';
13
+ import { getAdminThemeColors } from '@wordpress/admin-ui';
14
+ import { privateApis as themePrivateApis } from '@wordpress/theme';
12
15
 
13
16
  /**
14
17
  * Internal dependencies
@@ -19,9 +22,9 @@ import { unlock } from '../../lock-unlock';
19
22
  import type { CanvasData } from '../../store/types';
20
23
  import './style.scss';
21
24
  import useRouteTitle from '../app/use-route-title';
22
- import { UserThemeProvider } from '../user-theme-provider';
23
25
 
24
26
  const { useMatches, Outlet } = unlock( routePrivateApis );
27
+ const { ThemeProvider } = unlock( themePrivateApis );
25
28
 
26
29
  /**
27
30
  * Root component for single page mode (no sidebar).
@@ -40,10 +43,15 @@ export default function RootSinglePage() {
40
43
 
41
44
  useRouteTitle();
42
45
 
46
+ const themeColors = useMemo( getAdminThemeColors, [] );
47
+
43
48
  return (
44
49
  <SlotFillProvider>
45
- <UserThemeProvider isRoot color={ { bg: '#f8f8f8' } }>
46
- <UserThemeProvider color={ { bg: '#1d2327' } }>
50
+ <ThemeProvider
51
+ isRoot
52
+ color={ { ...themeColors, background: '#f8f8f8' } }
53
+ >
54
+ <ThemeProvider color={ themeColors }>
47
55
  <div
48
56
  className={ clsx(
49
57
  'boot-layout boot-layout--single-page',
@@ -56,7 +64,12 @@ export default function RootSinglePage() {
56
64
  <SavePanel />
57
65
  <SnackbarNotices className="boot-notices__snackbar" />
58
66
  <div className="boot-layout__surfaces">
59
- <UserThemeProvider color={ { bg: '#ffffff' } }>
67
+ <ThemeProvider
68
+ color={ {
69
+ ...themeColors,
70
+ background: '#ffffff',
71
+ } }
72
+ >
60
73
  <Outlet />
61
74
  { /* Render Canvas in Root to prevent remounting on route changes */ }
62
75
  { ( canvas || canvas === null ) && (
@@ -69,11 +82,11 @@ export default function RootSinglePage() {
69
82
  />
70
83
  </div>
71
84
  ) }
72
- </UserThemeProvider>
85
+ </ThemeProvider>
73
86
  </div>
74
87
  </div>
75
- </UserThemeProvider>
76
- </UserThemeProvider>
88
+ </ThemeProvider>
89
+ </ThemeProvider>
77
90
  </SlotFillProvider>
78
91
  );
79
92
  }
@@ -8,7 +8,9 @@ import { store as coreStore } from '@wordpress/core-data';
8
8
  import { displayShortcut, rawShortcut } from '@wordpress/keycodes';
9
9
  import { check } from '@wordpress/icons';
10
10
  import { EntitiesSavedStates } from '@wordpress/editor';
11
- import { Button, Modal, Tooltip as WCTooltip } from '@wordpress/components';
11
+ import { Button, Modal } from '@wordpress/components';
12
+ // eslint-disable-next-line @wordpress/use-recommended-components -- `Tooltip` is not yet on the recommended `@wordpress/ui` allow-list; landing as a migration step ahead of the wider rollout.
13
+ import { Tooltip } from '@wordpress/ui';
12
14
 
13
15
  /**
14
16
  * Internal dependencies
@@ -82,28 +84,37 @@ export default function SaveButton() {
82
84
  );
83
85
  };
84
86
  const label = getLabel();
87
+ const shortcut = displayShortcut.primary( 's' );
85
88
 
86
89
  return (
87
90
  <>
88
- <WCTooltip
89
- text={ hasChanges ? label : undefined }
90
- shortcut={ displayShortcut.primary( 's' ) }
91
- >
92
- <Button
93
- variant="primary"
94
- size="compact"
95
- onClick={ () => setIsSaveViewOpened( true ) }
96
- onBlur={ hideSavedState }
97
- disabled={ disabled }
98
- accessibleWhenDisabled
99
- isBusy={ isSaving }
100
- aria-keyshortcuts={ rawShortcut.primary( 's' ) }
101
- className="boot-save-button"
102
- icon={ isInSavedState ? check : undefined }
103
- >
104
- { label }
105
- </Button>
106
- </WCTooltip>
91
+ <Tooltip.Root>
92
+ <Tooltip.Trigger
93
+ render={
94
+ <Button
95
+ variant="primary"
96
+ size="compact"
97
+ onClick={ () => setIsSaveViewOpened( true ) }
98
+ onBlur={ hideSavedState }
99
+ disabled={ disabled }
100
+ accessibleWhenDisabled
101
+ isBusy={ isSaving }
102
+ aria-keyshortcuts={ rawShortcut.primary( 's' ) }
103
+ className="boot-save-button"
104
+ icon={ isInSavedState ? check : undefined }
105
+ >
106
+ { label }
107
+ </Button>
108
+ }
109
+ />
110
+ <Tooltip.Popup>
111
+ { hasChanges && <span>{ label }</span> }
112
+ { /* TODO: replace with a future `@wordpress/ui` `Shortcut` primitive once available */ }
113
+ <span className="boot-save-button__shortcut">
114
+ { shortcut }
115
+ </span>
116
+ </Tooltip.Popup>
117
+ </Tooltip.Root>
107
118
  { isSaveViewOpen && (
108
119
  <Modal
109
120
  title={ __( 'Review changes' ) }
@@ -1,3 +1,9 @@
1
+ @use "@wordpress/base-styles/variables" as *;
2
+
1
3
  .boot-save-button {
2
4
  width: 100%;
3
5
  }
6
+
7
+ .boot-save-button__shortcut:not(:first-child) {
8
+ margin-left: $grid-unit-10;
9
+ }
@@ -2,12 +2,14 @@
2
2
  * WordPress dependencies
3
3
  */
4
4
  import { Link, privateApis as routePrivateApis } from '@wordpress/route';
5
- import { Tooltip as WCTooltip } from '@wordpress/components';
5
+ // eslint-disable-next-line @wordpress/use-recommended-components -- `Tooltip` is not yet on the recommended `@wordpress/ui` allow-list; landing as a migration step ahead of the wider rollout.
6
+ import { Tooltip } from '@wordpress/ui';
6
7
 
7
8
  /**
8
9
  * Internal dependencies
9
10
  */
10
11
  import { unlock } from '../../lock-unlock';
12
+
11
13
  import SiteIcon from '../site-icon';
12
14
  import './style.scss';
13
15
 
@@ -26,23 +28,30 @@ function SiteIconLink( {
26
28
  const canGoBack = useCanGoBack();
27
29
 
28
30
  return (
29
- <WCTooltip text={ props[ 'aria-label' ] } placement="right">
30
- <Link
31
- to={ to }
32
- aria-label={ props[ 'aria-label' ] }
33
- className="boot-site-icon-link"
34
- onClick={ ( event ) => {
35
- // If possible, restore the previous page with
36
- // filters etc.
37
- if ( canGoBack && isBackButton ) {
38
- event.preventDefault();
39
- router.history.back();
40
- }
41
- } }
42
- >
43
- <SiteIcon />
44
- </Link>
45
- </WCTooltip>
31
+ <Tooltip.Root>
32
+ <Tooltip.Trigger
33
+ render={
34
+ <Link
35
+ to={ to }
36
+ aria-label={ props[ 'aria-label' ] }
37
+ className="boot-site-icon-link"
38
+ onClick={ ( event ) => {
39
+ // If possible, restore the previous page with
40
+ // filters etc.
41
+ if ( canGoBack && isBackButton ) {
42
+ event.preventDefault();
43
+ router.history.back();
44
+ }
45
+ } }
46
+ >
47
+ <SiteIcon />
48
+ </Link>
49
+ }
50
+ />
51
+ <Tooltip.Popup positioner={ <Tooltip.Positioner side="right" /> }>
52
+ { props[ 'aria-label' ] }
53
+ </Tooltip.Popup>
54
+ </Tooltip.Root>
46
55
  );
47
56
  }
48
57
 
@@ -1,33 +0,0 @@
1
- // packages/boot/src/components/user-theme-provider/index.tsx
2
- import {
3
- privateApis as themePrivateApis
4
- } from "@wordpress/theme";
5
- import { unlock } from "../../lock-unlock.mjs";
6
- import { jsx } from "react/jsx-runtime";
7
- var ThemeProvider = unlock(themePrivateApis).ThemeProvider;
8
- var THEME_PRIMARY_COLORS = /* @__PURE__ */ new Map([
9
- ["light", "#0085ba"],
10
- ["modern", "#3858e9"],
11
- ["blue", "#096484"],
12
- ["coffee", "#46403c"],
13
- ["ectoplasm", "#523f6d"],
14
- ["midnight", "#e14d43"],
15
- ["ocean", "#627c83"],
16
- ["sunrise", "#dd823b"]
17
- ]);
18
- function getAdminThemePrimaryColor() {
19
- const theme = document.body.className.match(/admin-color-([a-z]+)/)?.[1];
20
- return theme && THEME_PRIMARY_COLORS.get(theme);
21
- }
22
- function UserThemeProvider({
23
- color,
24
- ...restProps
25
- }) {
26
- const primary = getAdminThemePrimaryColor();
27
- return /* @__PURE__ */ jsx(ThemeProvider, { ...restProps, color: { primary, ...color } });
28
- }
29
- export {
30
- UserThemeProvider,
31
- getAdminThemePrimaryColor
32
- };
33
- //# sourceMappingURL=index.mjs.map
@@ -1,7 +0,0 @@
1
- {
2
- "version": 3,
3
- "sources": ["../../../src/components/user-theme-provider/index.tsx"],
4
- "sourcesContent": ["import {\n\ttype ThemeProvider as ThemeProviderType,\n\tprivateApis as themePrivateApis,\n} from '@wordpress/theme';\nimport { unlock } from '../../lock-unlock';\n\nconst ThemeProvider: typeof ThemeProviderType =\n\tunlock( themePrivateApis ).ThemeProvider;\n\nconst THEME_PRIMARY_COLORS = new Map< string, string >( [\n\t[ 'light', '#0085ba' ],\n\t[ 'modern', '#3858e9' ],\n\t[ 'blue', '#096484' ],\n\t[ 'coffee', '#46403c' ],\n\t[ 'ectoplasm', '#523f6d' ],\n\t[ 'midnight', '#e14d43' ],\n\t[ 'ocean', '#627c83' ],\n\t[ 'sunrise', '#dd823b' ],\n] );\n\nexport function getAdminThemePrimaryColor(): string | undefined {\n\tconst theme =\n\t\tdocument.body.className.match( /admin-color-([a-z]+)/ )?.[ 1 ];\n\n\treturn theme && THEME_PRIMARY_COLORS.get( theme );\n}\n\nexport function UserThemeProvider( {\n\tcolor,\n\t...restProps\n}: React.ComponentProps< typeof ThemeProvider > ) {\n\tconst primary = getAdminThemePrimaryColor();\n\n\treturn <ThemeProvider { ...restProps } color={ { primary, ...color } } />;\n}\n"],
5
- "mappings": ";AAAA;AAAA,EAEC,eAAe;AAAA,OACT;AACP,SAAS,cAAc;AA6Bf;AA3BR,IAAM,gBACL,OAAQ,gBAAiB,EAAE;AAE5B,IAAM,uBAAuB,oBAAI,IAAuB;AAAA,EACvD,CAAE,SAAS,SAAU;AAAA,EACrB,CAAE,UAAU,SAAU;AAAA,EACtB,CAAE,QAAQ,SAAU;AAAA,EACpB,CAAE,UAAU,SAAU;AAAA,EACtB,CAAE,aAAa,SAAU;AAAA,EACzB,CAAE,YAAY,SAAU;AAAA,EACxB,CAAE,SAAS,SAAU;AAAA,EACrB,CAAE,WAAW,SAAU;AACxB,CAAE;AAEK,SAAS,4BAAgD;AAC/D,QAAM,QACL,SAAS,KAAK,UAAU,MAAO,sBAAuB,IAAK,CAAE;AAE9D,SAAO,SAAS,qBAAqB,IAAK,KAAM;AACjD;AAEO,SAAS,kBAAmB;AAAA,EAClC;AAAA,EACA,GAAG;AACJ,GAAkD;AACjD,QAAM,UAAU,0BAA0B;AAE1C,SAAO,oBAAC,iBAAgB,GAAG,WAAY,OAAQ,EAAE,SAAS,GAAG,MAAM,GAAI;AACxE;",
6
- "names": []
7
- }
@@ -1,35 +0,0 @@
1
- import {
2
- type ThemeProvider as ThemeProviderType,
3
- privateApis as themePrivateApis,
4
- } from '@wordpress/theme';
5
- import { unlock } from '../../lock-unlock';
6
-
7
- const ThemeProvider: typeof ThemeProviderType =
8
- unlock( themePrivateApis ).ThemeProvider;
9
-
10
- const THEME_PRIMARY_COLORS = new Map< string, string >( [
11
- [ 'light', '#0085ba' ],
12
- [ 'modern', '#3858e9' ],
13
- [ 'blue', '#096484' ],
14
- [ 'coffee', '#46403c' ],
15
- [ 'ectoplasm', '#523f6d' ],
16
- [ 'midnight', '#e14d43' ],
17
- [ 'ocean', '#627c83' ],
18
- [ 'sunrise', '#dd823b' ],
19
- ] );
20
-
21
- export function getAdminThemePrimaryColor(): string | undefined {
22
- const theme =
23
- document.body.className.match( /admin-color-([a-z]+)/ )?.[ 1 ];
24
-
25
- return theme && THEME_PRIMARY_COLORS.get( theme );
26
- }
27
-
28
- export function UserThemeProvider( {
29
- color,
30
- ...restProps
31
- }: React.ComponentProps< typeof ThemeProvider > ) {
32
- const primary = getAdminThemePrimaryColor();
33
-
34
- return <ThemeProvider { ...restProps } color={ { primary, ...color } } />;
35
- }
@@ -1,11 +0,0 @@
1
- import { getAdminThemePrimaryColor } from '../index';
2
-
3
- describe( 'getAdminThemePrimaryColor', () => {
4
- it( 'should return the primary color for the admin theme from the body class', () => {
5
- document.body.className = 'foo admin-color-coffee bar';
6
-
7
- const primaryColor = getAdminThemePrimaryColor();
8
-
9
- expect( primaryColor ).toBe( '#46403c' );
10
- } );
11
- } );