@wordpress/edit-site 4.2.0 → 4.3.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.
Files changed (93) hide show
  1. package/CHANGELOG.md +2 -0
  2. package/build/components/block-editor/index.js +53 -4
  3. package/build/components/block-editor/index.js.map +1 -1
  4. package/build/components/global-styles/color-indicator-wrapper.js +37 -0
  5. package/build/components/global-styles/color-indicator-wrapper.js.map +1 -0
  6. package/build/components/global-styles/dimensions-panel.js +32 -1
  7. package/build/components/global-styles/dimensions-panel.js.map +1 -1
  8. package/build/components/global-styles/header.js +1 -4
  9. package/build/components/global-styles/header.js.map +1 -1
  10. package/build/components/global-styles/icon-with-current-color.js +34 -0
  11. package/build/components/global-styles/icon-with-current-color.js.map +1 -0
  12. package/build/components/global-styles/navigation-button.js +7 -3
  13. package/build/components/global-styles/navigation-button.js.map +1 -1
  14. package/build/components/global-styles/palette.js +8 -5
  15. package/build/components/global-styles/palette.js.map +1 -1
  16. package/build/components/global-styles/preview.js +142 -26
  17. package/build/components/global-styles/preview.js.map +1 -1
  18. package/build/components/global-styles/screen-block-list.js +2 -2
  19. package/build/components/global-styles/screen-block-list.js.map +1 -1
  20. package/build/components/global-styles/screen-colors.js +11 -3
  21. package/build/components/global-styles/screen-colors.js.map +1 -1
  22. package/build/components/global-styles/screen-root.js +7 -5
  23. package/build/components/global-styles/screen-root.js.map +1 -1
  24. package/build/components/global-styles/screen-style-variations.js +12 -5
  25. package/build/components/global-styles/screen-style-variations.js.map +1 -1
  26. package/build/components/sidebar/index.js +12 -1
  27. package/build/components/sidebar/index.js.map +1 -1
  28. package/build/components/sidebar/navigation-menu-sidebar/index.js +40 -0
  29. package/build/components/sidebar/navigation-menu-sidebar/index.js.map +1 -0
  30. package/build/components/sidebar/navigation-menu-sidebar/navigation-inspector.js +185 -0
  31. package/build/components/sidebar/navigation-menu-sidebar/navigation-inspector.js.map +1 -0
  32. package/build/components/sidebar/navigation-menu-sidebar/navigation-menu.js +54 -0
  33. package/build/components/sidebar/navigation-menu-sidebar/navigation-menu.js.map +1 -0
  34. package/build/components/template-part-converter/convert-to-regular.js +6 -0
  35. package/build/components/template-part-converter/convert-to-regular.js.map +1 -1
  36. package/build-module/components/block-editor/index.js +51 -6
  37. package/build-module/components/block-editor/index.js.map +1 -1
  38. package/build-module/components/global-styles/color-indicator-wrapper.js +25 -0
  39. package/build-module/components/global-styles/color-indicator-wrapper.js.map +1 -0
  40. package/build-module/components/global-styles/dimensions-panel.js +33 -2
  41. package/build-module/components/global-styles/dimensions-panel.js.map +1 -1
  42. package/build-module/components/global-styles/header.js +2 -5
  43. package/build-module/components/global-styles/header.js.map +1 -1
  44. package/build-module/components/global-styles/icon-with-current-color.js +22 -0
  45. package/build-module/components/global-styles/icon-with-current-color.js.map +1 -0
  46. package/build-module/components/global-styles/navigation-button.js +7 -3
  47. package/build-module/components/global-styles/navigation-button.js.map +1 -1
  48. package/build-module/components/global-styles/palette.js +8 -6
  49. package/build-module/components/global-styles/palette.js.map +1 -1
  50. package/build-module/components/global-styles/preview.js +141 -27
  51. package/build-module/components/global-styles/preview.js.map +1 -1
  52. package/build-module/components/global-styles/screen-block-list.js +2 -2
  53. package/build-module/components/global-styles/screen-block-list.js.map +1 -1
  54. package/build-module/components/global-styles/screen-colors.js +10 -3
  55. package/build-module/components/global-styles/screen-colors.js.map +1 -1
  56. package/build-module/components/global-styles/screen-root.js +8 -7
  57. package/build-module/components/global-styles/screen-root.js.map +1 -1
  58. package/build-module/components/global-styles/screen-style-variations.js +13 -6
  59. package/build-module/components/global-styles/screen-style-variations.js.map +1 -1
  60. package/build-module/components/sidebar/index.js +11 -1
  61. package/build-module/components/sidebar/index.js.map +1 -1
  62. package/build-module/components/sidebar/navigation-menu-sidebar/index.js +26 -0
  63. package/build-module/components/sidebar/navigation-menu-sidebar/index.js.map +1 -0
  64. package/build-module/components/sidebar/navigation-menu-sidebar/navigation-inspector.js +168 -0
  65. package/build-module/components/sidebar/navigation-menu-sidebar/navigation-inspector.js.map +1 -0
  66. package/build-module/components/sidebar/navigation-menu-sidebar/navigation-menu.js +45 -0
  67. package/build-module/components/sidebar/navigation-menu-sidebar/navigation-menu.js.map +1 -0
  68. package/build-module/components/template-part-converter/convert-to-regular.js +6 -0
  69. package/build-module/components/template-part-converter/convert-to-regular.js.map +1 -1
  70. package/build-style/style-rtl.css +51 -4
  71. package/build-style/style.css +51 -4
  72. package/package.json +29 -29
  73. package/src/components/block-editor/index.js +79 -9
  74. package/src/components/global-styles/color-indicator-wrapper.js +23 -0
  75. package/src/components/global-styles/dimensions-panel.js +39 -1
  76. package/src/components/global-styles/header.js +2 -7
  77. package/src/components/global-styles/icon-with-current-color.js +21 -0
  78. package/src/components/global-styles/navigation-button.js +6 -4
  79. package/src/components/global-styles/palette.js +8 -11
  80. package/src/components/global-styles/preview.js +186 -29
  81. package/src/components/global-styles/screen-block-list.js +1 -3
  82. package/src/components/global-styles/screen-colors.js +7 -6
  83. package/src/components/global-styles/screen-root.js +15 -17
  84. package/src/components/global-styles/screen-style-variations.js +13 -4
  85. package/src/components/global-styles/style.scss +18 -6
  86. package/src/components/sidebar/index.js +12 -0
  87. package/src/components/sidebar/navigation-menu-sidebar/index.js +34 -0
  88. package/src/components/sidebar/navigation-menu-sidebar/navigation-inspector.js +224 -0
  89. package/src/components/sidebar/navigation-menu-sidebar/navigation-menu.js +62 -0
  90. package/src/components/sidebar/navigation-menu-sidebar/style.scss +42 -0
  91. package/src/components/sidebar/style.scss +1 -1
  92. package/src/components/template-part-converter/convert-to-regular.js +9 -0
  93. package/src/style.scss +1 -0
@@ -5,65 +5,222 @@ import {
5
5
  __unstableIframe as Iframe,
6
6
  __unstableEditorStyles as EditorStyles,
7
7
  } from '@wordpress/block-editor';
8
+ import {
9
+ __unstableMotion as motion,
10
+ __experimentalHStack as HStack,
11
+ __experimentalVStack as VStack,
12
+ } from '@wordpress/components';
13
+ import { useReducedMotion, useResizeObserver } from '@wordpress/compose';
14
+ import { useState } from '@wordpress/element';
8
15
 
9
16
  /**
10
17
  * Internal dependencies
11
18
  */
12
- import { useStyle } from './hooks';
19
+ import { useSetting, useStyle } from './hooks';
13
20
  import { useGlobalStylesOutput } from './use-global-styles-output';
14
21
 
15
- const StylesPreview = ( { height = 150 } ) => {
22
+ const firstFrame = {
23
+ start: {
24
+ opacity: 1,
25
+ display: 'block',
26
+ },
27
+ hover: {
28
+ opacity: 0,
29
+ display: 'none',
30
+ },
31
+ };
32
+
33
+ const secondFrame = {
34
+ hover: {
35
+ opacity: 1,
36
+ display: 'block',
37
+ },
38
+ start: {
39
+ opacity: 0,
40
+ display: 'none',
41
+ },
42
+ };
43
+
44
+ const normalizedWidth = 248;
45
+ const normalizedHeight = 152;
46
+
47
+ const normalizedColorSwatchSize = 32;
48
+
49
+ const StylesPreview = ( { label, isFocused } ) => {
50
+ const [ fontWeight ] = useStyle( 'typography.fontWeight' );
16
51
  const [ fontFamily = 'serif' ] = useStyle( 'typography.fontFamily' );
52
+ const [ headingFontFamily = fontFamily ] = useStyle(
53
+ 'elements.h1.typography.fontFamily'
54
+ );
55
+ const [ headingFontWeight = fontWeight ] = useStyle(
56
+ 'elements.h1.typography.fontWeight'
57
+ );
17
58
  const [ textColor = 'black' ] = useStyle( 'color.text' );
59
+ const [ headingColor = textColor ] = useStyle( 'elements.h1.color.text' );
18
60
  const [ linkColor = 'blue' ] = useStyle( 'elements.link.color.text' );
19
61
  const [ backgroundColor = 'white' ] = useStyle( 'color.background' );
20
62
  const [ gradientValue ] = useStyle( 'color.gradient' );
21
63
  const [ styles ] = useGlobalStylesOutput();
64
+ const disableMotion = useReducedMotion();
65
+ const [ coreColors ] = useSetting( 'color.palette.core' );
66
+ const [ themeColors ] = useSetting( 'color.palette.theme' );
67
+ const [ customColors ] = useSetting( 'color.palette.custom' );
68
+ const [ isHovered, setIsHovered ] = useState( false );
69
+ const [ containerResizeListener, { width } ] = useResizeObserver();
70
+ const ratio = width ? width / normalizedWidth : 1;
71
+
72
+ const paletteColors = ( themeColors ?? [] )
73
+ .concat( customColors ?? [] )
74
+ .concat( coreColors ?? [] );
75
+ const highlightedColors = paletteColors
76
+ .filter(
77
+ // we exclude these two colors because they are already visible in the preview.
78
+ ( { color } ) => color !== backgroundColor && color !== headingColor
79
+ )
80
+ .slice( 0, 2 );
22
81
 
23
82
  return (
24
83
  <Iframe
25
84
  className="edit-site-global-styles-preview__iframe"
26
85
  head={ <EditorStyles styles={ styles } /> }
27
- style={ { height } }
86
+ style={ {
87
+ height: normalizedHeight * ratio,
88
+ visibility: ! width ? 'hidden' : 'visible',
89
+ } }
90
+ onMouseEnter={ () => setIsHovered( true ) }
91
+ onMouseLeave={ () => setIsHovered( false ) }
92
+ tabIndex={ -1 }
28
93
  >
29
- <div
94
+ { containerResizeListener }
95
+ <motion.div
30
96
  style={ {
31
- display: 'flex',
32
- gap: 20,
33
- alignItems: 'center',
34
- justifyContent: 'center',
35
- height: '100%',
36
- transform: `scale(${ height / 150 })`,
97
+ height: normalizedHeight * ratio,
98
+ width: '100%',
37
99
  background: gradientValue ?? backgroundColor,
38
100
  cursor: 'pointer',
39
101
  } }
102
+ initial="start"
103
+ animate={
104
+ ( isHovered || isFocused ) && ! disableMotion
105
+ ? 'hover'
106
+ : 'start'
107
+ }
40
108
  >
41
- <div style={ { fontFamily, fontSize: '80px' } }>Aa</div>
42
- <div
109
+ <motion.div
110
+ variants={ firstFrame }
43
111
  style={ {
44
- display: 'flex',
45
- gap: 20,
46
- flexDirection: 'column',
112
+ height: '100%',
113
+ overflow: 'hidden',
47
114
  } }
48
115
  >
49
- <div
116
+ <HStack
117
+ spacing={ 10 * ratio }
118
+ justify="center"
50
119
  style={ {
51
- height: 40,
52
- width: 40,
53
- background: textColor,
54
- borderRadius: 20,
120
+ height: '100%',
121
+ overflow: 'hidden',
55
122
  } }
56
- />{ ' ' }
57
- <div
123
+ >
124
+ <div
125
+ style={ {
126
+ fontFamily: headingFontFamily,
127
+ fontSize: 65 * ratio,
128
+ color: headingColor,
129
+ fontWeight: headingFontWeight,
130
+ } }
131
+ >
132
+ Aa
133
+ </div>
134
+ <VStack spacing={ 4 * ratio }>
135
+ { highlightedColors.map( ( { slug, color } ) => (
136
+ <div
137
+ key={ slug }
138
+ style={ {
139
+ height:
140
+ normalizedColorSwatchSize * ratio,
141
+ width:
142
+ normalizedColorSwatchSize * ratio,
143
+ background: color,
144
+ borderRadius:
145
+ ( normalizedColorSwatchSize *
146
+ ratio ) /
147
+ 2,
148
+ } }
149
+ />
150
+ ) ) }
151
+ </VStack>
152
+ </HStack>
153
+ </motion.div>
154
+ <motion.div
155
+ variants={ secondFrame }
156
+ style={ {
157
+ height: '100%',
158
+ overflow: 'hidden',
159
+ } }
160
+ >
161
+ <VStack
162
+ spacing={ 3 * ratio }
163
+ justify="center"
58
164
  style={ {
59
- height: 40,
60
- width: 40,
61
- background: linkColor,
62
- borderRadius: 20,
165
+ height: '100%',
166
+ overflow: 'hidden',
167
+ padding: 10 * ratio,
168
+ boxSizing: 'border-box',
63
169
  } }
64
- />
65
- </div>
66
- </div>
170
+ >
171
+ { label && (
172
+ <div
173
+ style={ {
174
+ fontSize: 35 * ratio,
175
+ fontFamily: headingFontFamily,
176
+ color: headingColor,
177
+ fontWeight: headingFontWeight,
178
+ lineHeight: '1em',
179
+ } }
180
+ >
181
+ { label }
182
+ </div>
183
+ ) }
184
+ <HStack spacing={ 2 * ratio } justify="flex-start">
185
+ <div
186
+ style={ {
187
+ fontFamily,
188
+ fontSize: 24 * ratio,
189
+ color: textColor,
190
+ } }
191
+ >
192
+ Aa
193
+ </div>
194
+ <div
195
+ style={ {
196
+ fontFamily,
197
+ fontSize: 24 * ratio,
198
+ color: linkColor,
199
+ } }
200
+ >
201
+ Aa
202
+ </div>
203
+ </HStack>
204
+ { paletteColors && (
205
+ <HStack spacing={ 0 }>
206
+ { paletteColors
207
+ .slice( 0, 4 )
208
+ .map( ( { color }, index ) => (
209
+ <div
210
+ key={ index }
211
+ style={ {
212
+ height: 10 * ratio,
213
+ width: 30 * ratio,
214
+ background: color,
215
+ flexGrow: 1,
216
+ } }
217
+ />
218
+ ) ) }
219
+ </HStack>
220
+ ) }
221
+ </VStack>
222
+ </motion.div>
223
+ </motion.div>
67
224
  </Iframe>
68
225
  );
69
226
  };
@@ -59,9 +59,7 @@ function BlockMenuItem( { block } ) {
59
59
  return (
60
60
  <NavigationButton path={ '/blocks/' + block.name }>
61
61
  <HStack justify="flex-start">
62
- <FlexItem>
63
- <BlockIcon icon={ block.icon } />
64
- </FlexItem>
62
+ <BlockIcon icon={ block.icon } />
65
63
  <FlexItem>{ block.title }</FlexItem>
66
64
  </HStack>
67
65
  </NavigationButton>
@@ -18,6 +18,7 @@ import Palette from './palette';
18
18
  import { NavigationButton } from './navigation-button';
19
19
  import { getSupportedGlobalStylesPanels, useStyle } from './hooks';
20
20
  import Subtitle from './subtitle';
21
+ import ColorIndicatorWrapper from './color-indicator-wrapper';
21
22
 
22
23
  function BackgroundColorItem( { name, parentMenu } ) {
23
24
  const supports = getSupportedGlobalStylesPanels( name );
@@ -34,11 +35,11 @@ function BackgroundColorItem( { name, parentMenu } ) {
34
35
  return (
35
36
  <NavigationButton path={ parentMenu + '/colors/background' }>
36
37
  <HStack justify="flex-start">
37
- <FlexItem>
38
+ <ColorIndicatorWrapper expanded={ false }>
38
39
  <ColorIndicator
39
40
  colorValue={ gradientValue ?? backgroundColor }
40
41
  />
41
- </FlexItem>
42
+ </ColorIndicatorWrapper>
42
43
  <FlexItem>{ __( 'Background' ) }</FlexItem>
43
44
  </HStack>
44
45
  </NavigationButton>
@@ -57,9 +58,9 @@ function TextColorItem( { name, parentMenu } ) {
57
58
  return (
58
59
  <NavigationButton path={ parentMenu + '/colors/text' }>
59
60
  <HStack justify="flex-start">
60
- <FlexItem>
61
+ <ColorIndicatorWrapper expanded={ false }>
61
62
  <ColorIndicator colorValue={ color } />
62
- </FlexItem>
63
+ </ColorIndicatorWrapper>
63
64
  <FlexItem>{ __( 'Text' ) }</FlexItem>
64
65
  </HStack>
65
66
  </NavigationButton>
@@ -78,9 +79,9 @@ function LinkColorItem( { name, parentMenu } ) {
78
79
  return (
79
80
  <NavigationButton path={ parentMenu + '/colors/link' }>
80
81
  <HStack justify="flex-start">
81
- <FlexItem>
82
+ <ColorIndicatorWrapper expanded={ false }>
82
83
  <ColorIndicator colorValue={ color } />
83
- </FlexItem>
84
+ </ColorIndicatorWrapper>
84
85
  <FlexItem>{ __( 'Links' ) }</FlexItem>
85
86
  </HStack>
86
87
  </NavigationButton>
@@ -10,15 +10,17 @@ import {
10
10
  CardBody,
11
11
  Card,
12
12
  CardDivider,
13
+ CardMedia,
13
14
  } from '@wordpress/components';
14
15
  import { isRTL, __ } from '@wordpress/i18n';
15
- import { chevronLeft, chevronRight, Icon } from '@wordpress/icons';
16
+ import { chevronLeft, chevronRight } from '@wordpress/icons';
16
17
  import { useSelect } from '@wordpress/data';
17
18
  import { store as coreStore } from '@wordpress/core-data';
18
19
 
19
20
  /**
20
21
  * Internal dependencies
21
22
  */
23
+ import { IconWithCurrentColor } from './icon-with-current-color';
22
24
  import { NavigationButton } from './navigation-button';
23
25
  import ContextMenu from './context-menu';
24
26
  import StylesPreview from './preview';
@@ -37,19 +39,19 @@ function ScreenRoot() {
37
39
  <CardBody>
38
40
  <VStack spacing={ 2 }>
39
41
  <Card>
40
- <StylesPreview />
42
+ <CardMedia>
43
+ <StylesPreview />
44
+ </CardMedia>
41
45
  </Card>
42
46
  { !! variations?.length && (
43
47
  <NavigationButton path="/variations">
44
48
  <HStack justify="space-between">
45
- <FlexItem>{ __( 'Other styles' ) }</FlexItem>
46
- <FlexItem>
47
- <Icon
48
- icon={
49
- isRTL() ? chevronLeft : chevronRight
50
- }
51
- />
52
- </FlexItem>
49
+ <FlexItem>{ __( 'Browse styles' ) }</FlexItem>
50
+ <IconWithCurrentColor
51
+ icon={
52
+ isRTL() ? chevronLeft : chevronRight
53
+ }
54
+ />
53
55
  </HStack>
54
56
  </NavigationButton>
55
57
  ) }
@@ -72,13 +74,9 @@ function ScreenRoot() {
72
74
  <NavigationButton path="/blocks">
73
75
  <HStack justify="space-between">
74
76
  <FlexItem>{ __( 'Blocks' ) }</FlexItem>
75
- <FlexItem>
76
- <Icon
77
- icon={
78
- isRTL() ? chevronLeft : chevronRight
79
- }
80
- />
81
- </FlexItem>
77
+ <IconWithCurrentColor
78
+ icon={ isRTL() ? chevronLeft : chevronRight }
79
+ />
82
80
  </HStack>
83
81
  </NavigationButton>
84
82
  </ItemGroup>
@@ -9,7 +9,7 @@ import classnames from 'classnames';
9
9
  */
10
10
  import { store as coreStore } from '@wordpress/core-data';
11
11
  import { useSelect } from '@wordpress/data';
12
- import { useMemo, useContext } from '@wordpress/element';
12
+ import { useMemo, useContext, useState } from '@wordpress/element';
13
13
  import { ENTER } from '@wordpress/keycodes';
14
14
  import {
15
15
  __experimentalGrid as Grid,
@@ -31,6 +31,7 @@ function compareVariations( a, b ) {
31
31
  }
32
32
 
33
33
  function Variation( { variation } ) {
34
+ const [ isFocused, setIsFocused ] = useState( false );
34
35
  const { base, user, setUserConfig } = useContext( GlobalStylesContext );
35
36
  const context = useMemo( () => {
36
37
  return {
@@ -77,8 +78,16 @@ function Variation( { variation } ) {
77
78
  onClick={ selectVariation }
78
79
  onKeyDown={ selectOnEnter }
79
80
  tabIndex="0"
81
+ aria-label={ variation?.title }
82
+ onFocus={ () => setIsFocused( true ) }
83
+ onBlur={ () => setIsFocused( false ) }
80
84
  >
81
- <StylesPreview height={ 100 } />
85
+ <div className="edit-site-global-styles-variations_item-preview">
86
+ <StylesPreview
87
+ label={ variation?.title }
88
+ isFocused={ isFocused }
89
+ />
90
+ </div>
82
91
  </div>
83
92
  </GlobalStylesContext.Provider>
84
93
  );
@@ -96,7 +105,7 @@ function ScreenStyleVariations() {
96
105
  const withEmptyVariation = useMemo( () => {
97
106
  return [
98
107
  {
99
- name: __( 'Default' ),
108
+ title: __( 'Default' ),
100
109
  settings: {},
101
110
  styles: {},
102
111
  },
@@ -108,7 +117,7 @@ function ScreenStyleVariations() {
108
117
  <>
109
118
  <ScreenHeader
110
119
  back="/"
111
- title={ __( 'Other styles' ) }
120
+ title={ __( 'Browse styles' ) }
112
121
  description={ __(
113
122
  'Choose a different style combination for the theme styles'
114
123
  ) }
@@ -73,19 +73,31 @@
73
73
 
74
74
  .edit-site-global-styles-variations_item {
75
75
  box-sizing: border-box;
76
- padding: $border-width * 2;
77
- border-radius: $radius-block-ui;
78
- border: $gray-200 $border-width solid;
79
76
 
80
- &.is-active {
77
+ .edit-site-global-styles-variations_item-preview {
78
+ padding: $border-width * 2;
79
+ border-radius: $radius-block-ui;
80
+ border: $gray-200 $border-width solid;
81
+ }
82
+
83
+ &.is-active .edit-site-global-styles-variations_item-preview {
81
84
  border: $gray-900 $border-width solid;
82
85
  }
83
86
 
84
- &:hover {
87
+ &:hover .edit-site-global-styles-variations_item-preview {
85
88
  border: var(--wp-admin-theme-color) $border-width solid;
86
89
  }
87
90
 
88
- &:focus {
91
+ &:focus .edit-site-global-styles-variations_item-preview {
89
92
  border: var(--wp-admin-theme-color) $border-width solid;
90
93
  }
91
94
  }
95
+
96
+ .edit-site-global-styles-icon-with-current-color {
97
+ fill: currentColor;
98
+ }
99
+
100
+ .edit-site-global-styles__color-indicator-wrapper {
101
+ // Match the height of the rest of the icons (24px).
102
+ height: $grid-unit * 3;
103
+ }
@@ -14,6 +14,7 @@ import { store as blockEditorStore } from '@wordpress/block-editor';
14
14
  */
15
15
  import DefaultSidebar from './default-sidebar';
16
16
  import GlobalStylesSidebar from './global-styles-sidebar';
17
+ import NavigationMenuSidebar from './navigation-menu-sidebar';
17
18
  import { STORE_NAME } from '../../store/constants';
18
19
  import SettingsHeader from './settings-header';
19
20
  import TemplateCard from './template-card';
@@ -57,6 +58,16 @@ export function SidebarComplementaryAreaFills() {
57
58
  if ( ! isEditorSidebarOpened ) {
58
59
  sidebarName = hasBlockSelection ? SIDEBAR_BLOCK : SIDEBAR_TEMPLATE;
59
60
  }
61
+
62
+ // Conditionally include NavMenu sidebar in Plugin only.
63
+ // Optimise for dead code elimination.
64
+ // See https://github.com/WordPress/gutenberg/blob/trunk/docs/how-to-guides/feature-flags.md#dead-code-elimination.
65
+ let MaybeNavigationMenuSidebar = 'Fragment';
66
+
67
+ if ( process.env.IS_GUTENBERG_PLUGIN ) {
68
+ MaybeNavigationMenuSidebar = NavigationMenuSidebar;
69
+ }
70
+
60
71
  return (
61
72
  <>
62
73
  <DefaultSidebar
@@ -77,6 +88,7 @@ export function SidebarComplementaryAreaFills() {
77
88
  ) }
78
89
  </DefaultSidebar>
79
90
  <GlobalStylesSidebar />
91
+ <MaybeNavigationMenuSidebar />
80
92
  </>
81
93
  );
82
94
  }
@@ -0,0 +1,34 @@
1
+ /**
2
+ * WordPress dependencies
3
+ */
4
+ import { FlexBlock, Flex } from '@wordpress/components';
5
+ import { __ } from '@wordpress/i18n';
6
+ import { navigation } from '@wordpress/icons';
7
+
8
+ /**
9
+ * Internal dependencies
10
+ */
11
+ import DefaultSidebar from '../default-sidebar';
12
+ import NavigationInspector from './navigation-inspector';
13
+
14
+ export default function NavigationMenuSidebar() {
15
+ return (
16
+ <DefaultSidebar
17
+ className="edit-site-navigation-menu-sidebar"
18
+ identifier="edit-site/navigation-menu"
19
+ title={ __( 'Navigation Menus' ) }
20
+ icon={ navigation }
21
+ closeLabel={ __( 'Close navigation menu sidebar' ) }
22
+ panelClassName="edit-site-navigation-menu-sidebar__panel"
23
+ header={
24
+ <Flex>
25
+ <FlexBlock>
26
+ <strong>{ __( 'Navigation Menus' ) }</strong>
27
+ </FlexBlock>
28
+ </Flex>
29
+ }
30
+ >
31
+ <NavigationInspector />
32
+ </DefaultSidebar>
33
+ );
34
+ }