@wordpress/edit-site 4.1.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 (170) hide show
  1. package/CHANGELOG.md +4 -0
  2. package/build/components/add-new-template/new-template-part.js +2 -9
  3. package/build/components/add-new-template/new-template-part.js.map +1 -1
  4. package/build/components/add-new-template/new-template.js +28 -12
  5. package/build/components/add-new-template/new-template.js.map +1 -1
  6. package/build/components/block-editor/index.js +53 -4
  7. package/build/components/block-editor/index.js.map +1 -1
  8. package/build/components/editor/index.js +9 -3
  9. package/build/components/editor/index.js.map +1 -1
  10. package/build/components/global-styles/border-panel.js +25 -24
  11. package/build/components/global-styles/border-panel.js.map +1 -1
  12. package/build/components/global-styles/color-indicator-wrapper.js +37 -0
  13. package/build/components/global-styles/color-indicator-wrapper.js.map +1 -0
  14. package/build/components/global-styles/dimensions-panel.js +6 -2
  15. package/build/components/global-styles/dimensions-panel.js.map +1 -1
  16. package/build/components/global-styles/header.js +1 -4
  17. package/build/components/global-styles/header.js.map +1 -1
  18. package/build/components/global-styles/icon-with-current-color.js +34 -0
  19. package/build/components/global-styles/icon-with-current-color.js.map +1 -0
  20. package/build/components/global-styles/navigation-button.js +7 -3
  21. package/build/components/global-styles/navigation-button.js.map +1 -1
  22. package/build/components/global-styles/palette.js +8 -5
  23. package/build/components/global-styles/palette.js.map +1 -1
  24. package/build/components/global-styles/preview.js +142 -26
  25. package/build/components/global-styles/preview.js.map +1 -1
  26. package/build/components/global-styles/screen-block-list.js +2 -2
  27. package/build/components/global-styles/screen-block-list.js.map +1 -1
  28. package/build/components/global-styles/screen-colors.js +11 -3
  29. package/build/components/global-styles/screen-colors.js.map +1 -1
  30. package/build/components/global-styles/screen-root.js +7 -5
  31. package/build/components/global-styles/screen-root.js.map +1 -1
  32. package/build/components/global-styles/screen-style-variations.js +12 -5
  33. package/build/components/global-styles/screen-style-variations.js.map +1 -1
  34. package/build/components/header/document-actions/index.js +13 -11
  35. package/build/components/header/document-actions/index.js.map +1 -1
  36. package/build/components/header/index.js +5 -3
  37. package/build/components/header/index.js.map +1 -1
  38. package/build/components/header/more-menu/index.js +9 -1
  39. package/build/components/header/more-menu/index.js.map +1 -1
  40. package/build/components/header/more-menu/site-export.js +5 -2
  41. package/build/components/header/more-menu/site-export.js.map +1 -1
  42. package/build/components/header/plugin-more-menu-item/index.js +5 -0
  43. package/build/components/header/plugin-more-menu-item/index.js.map +1 -1
  44. package/build/components/list/actions/rename-menu-item.js +3 -10
  45. package/build/components/list/actions/rename-menu-item.js.map +1 -1
  46. package/build/components/preferences-modal/enable-feature.js +40 -0
  47. package/build/components/preferences-modal/enable-feature.js.map +1 -0
  48. package/build/components/preferences-modal/index.js +68 -0
  49. package/build/components/preferences-modal/index.js.map +1 -0
  50. package/build/components/sidebar/index.js +12 -1
  51. package/build/components/sidebar/index.js.map +1 -1
  52. package/build/components/sidebar/navigation-menu-sidebar/index.js +40 -0
  53. package/build/components/sidebar/navigation-menu-sidebar/index.js.map +1 -0
  54. package/build/components/sidebar/navigation-menu-sidebar/navigation-inspector.js +185 -0
  55. package/build/components/sidebar/navigation-menu-sidebar/navigation-inspector.js.map +1 -0
  56. package/build/components/sidebar/navigation-menu-sidebar/navigation-menu.js +54 -0
  57. package/build/components/sidebar/navigation-menu-sidebar/navigation-menu.js.map +1 -0
  58. package/build/components/template-part-converter/convert-to-regular.js +6 -0
  59. package/build/components/template-part-converter/convert-to-regular.js.map +1 -1
  60. package/build/index.js +1 -0
  61. package/build/index.js.map +1 -1
  62. package/build/store/actions.js +3 -3
  63. package/build/store/actions.js.map +1 -1
  64. package/build/store/selectors.js +3 -1
  65. package/build/store/selectors.js.map +1 -1
  66. package/build-module/components/add-new-template/new-template-part.js +3 -10
  67. package/build-module/components/add-new-template/new-template-part.js.map +1 -1
  68. package/build-module/components/add-new-template/new-template.js +27 -12
  69. package/build-module/components/add-new-template/new-template.js.map +1 -1
  70. package/build-module/components/block-editor/index.js +51 -6
  71. package/build-module/components/block-editor/index.js.map +1 -1
  72. package/build-module/components/editor/index.js +8 -3
  73. package/build-module/components/editor/index.js.map +1 -1
  74. package/build-module/components/global-styles/border-panel.js +27 -26
  75. package/build-module/components/global-styles/border-panel.js.map +1 -1
  76. package/build-module/components/global-styles/color-indicator-wrapper.js +25 -0
  77. package/build-module/components/global-styles/color-indicator-wrapper.js.map +1 -0
  78. package/build-module/components/global-styles/dimensions-panel.js +6 -2
  79. package/build-module/components/global-styles/dimensions-panel.js.map +1 -1
  80. package/build-module/components/global-styles/header.js +2 -5
  81. package/build-module/components/global-styles/header.js.map +1 -1
  82. package/build-module/components/global-styles/icon-with-current-color.js +22 -0
  83. package/build-module/components/global-styles/icon-with-current-color.js.map +1 -0
  84. package/build-module/components/global-styles/navigation-button.js +7 -3
  85. package/build-module/components/global-styles/navigation-button.js.map +1 -1
  86. package/build-module/components/global-styles/palette.js +8 -6
  87. package/build-module/components/global-styles/palette.js.map +1 -1
  88. package/build-module/components/global-styles/preview.js +141 -27
  89. package/build-module/components/global-styles/preview.js.map +1 -1
  90. package/build-module/components/global-styles/screen-block-list.js +2 -2
  91. package/build-module/components/global-styles/screen-block-list.js.map +1 -1
  92. package/build-module/components/global-styles/screen-colors.js +10 -3
  93. package/build-module/components/global-styles/screen-colors.js.map +1 -1
  94. package/build-module/components/global-styles/screen-root.js +8 -7
  95. package/build-module/components/global-styles/screen-root.js.map +1 -1
  96. package/build-module/components/global-styles/screen-style-variations.js +13 -6
  97. package/build-module/components/global-styles/screen-style-variations.js.map +1 -1
  98. package/build-module/components/header/document-actions/index.js +13 -11
  99. package/build-module/components/header/document-actions/index.js.map +1 -1
  100. package/build-module/components/header/index.js +5 -3
  101. package/build-module/components/header/index.js.map +1 -1
  102. package/build-module/components/header/more-menu/index.js +8 -1
  103. package/build-module/components/header/more-menu/index.js.map +1 -1
  104. package/build-module/components/header/more-menu/site-export.js +5 -2
  105. package/build-module/components/header/more-menu/site-export.js.map +1 -1
  106. package/build-module/components/header/plugin-more-menu-item/index.js +4 -0
  107. package/build-module/components/header/plugin-more-menu-item/index.js.map +1 -1
  108. package/build-module/components/list/actions/rename-menu-item.js +4 -11
  109. package/build-module/components/list/actions/rename-menu-item.js.map +1 -1
  110. package/build-module/components/preferences-modal/enable-feature.js +27 -0
  111. package/build-module/components/preferences-modal/enable-feature.js.map +1 -0
  112. package/build-module/components/preferences-modal/index.js +57 -0
  113. package/build-module/components/preferences-modal/index.js.map +1 -0
  114. package/build-module/components/sidebar/index.js +11 -1
  115. package/build-module/components/sidebar/index.js.map +1 -1
  116. package/build-module/components/sidebar/navigation-menu-sidebar/index.js +26 -0
  117. package/build-module/components/sidebar/navigation-menu-sidebar/index.js.map +1 -0
  118. package/build-module/components/sidebar/navigation-menu-sidebar/navigation-inspector.js +168 -0
  119. package/build-module/components/sidebar/navigation-menu-sidebar/navigation-inspector.js.map +1 -0
  120. package/build-module/components/sidebar/navigation-menu-sidebar/navigation-menu.js +45 -0
  121. package/build-module/components/sidebar/navigation-menu-sidebar/navigation-menu.js.map +1 -0
  122. package/build-module/components/template-part-converter/convert-to-regular.js +6 -0
  123. package/build-module/components/template-part-converter/convert-to-regular.js.map +1 -1
  124. package/build-module/index.js +1 -0
  125. package/build-module/index.js.map +1 -1
  126. package/build-module/store/actions.js +3 -3
  127. package/build-module/store/actions.js.map +1 -1
  128. package/build-module/store/selectors.js +3 -1
  129. package/build-module/store/selectors.js.map +1 -1
  130. package/build-style/style-rtl.css +86 -5
  131. package/build-style/style.css +86 -5
  132. package/package.json +29 -29
  133. package/src/components/add-new-template/new-template-part.js +3 -12
  134. package/src/components/add-new-template/new-template.js +49 -12
  135. package/src/components/block-editor/index.js +79 -9
  136. package/src/components/editor/index.js +13 -0
  137. package/src/components/global-styles/border-panel.js +32 -26
  138. package/src/components/global-styles/color-indicator-wrapper.js +23 -0
  139. package/src/components/global-styles/dimensions-panel.js +7 -2
  140. package/src/components/global-styles/header.js +2 -7
  141. package/src/components/global-styles/icon-with-current-color.js +21 -0
  142. package/src/components/global-styles/navigation-button.js +6 -4
  143. package/src/components/global-styles/palette.js +8 -11
  144. package/src/components/global-styles/preview.js +186 -29
  145. package/src/components/global-styles/screen-block-list.js +1 -3
  146. package/src/components/global-styles/screen-colors.js +7 -6
  147. package/src/components/global-styles/screen-root.js +15 -17
  148. package/src/components/global-styles/screen-style-variations.js +13 -4
  149. package/src/components/global-styles/style.scss +18 -6
  150. package/src/components/header/document-actions/index.js +14 -10
  151. package/src/components/header/index.js +6 -1
  152. package/src/components/header/more-menu/index.js +15 -0
  153. package/src/components/header/more-menu/site-export.js +13 -2
  154. package/src/components/header/plugin-more-menu-item/index.js +2 -0
  155. package/src/components/header/style.scss +45 -0
  156. package/src/components/list/actions/rename-menu-item.js +3 -13
  157. package/src/components/preferences-modal/enable-feature.js +24 -0
  158. package/src/components/preferences-modal/index.js +76 -0
  159. package/src/components/sidebar/index.js +12 -0
  160. package/src/components/sidebar/navigation-menu-sidebar/index.js +34 -0
  161. package/src/components/sidebar/navigation-menu-sidebar/navigation-inspector.js +224 -0
  162. package/src/components/sidebar/navigation-menu-sidebar/navigation-menu.js +62 -0
  163. package/src/components/sidebar/navigation-menu-sidebar/style.scss +42 -0
  164. package/src/components/sidebar/style.scss +1 -1
  165. package/src/components/template-part-converter/convert-to-regular.js +9 -0
  166. package/src/index.js +1 -0
  167. package/src/store/actions.js +4 -4
  168. package/src/store/selectors.js +10 -0
  169. package/src/store/test/selectors.js +4 -0
  170. package/src/style.scss +1 -0
@@ -4,7 +4,7 @@
4
4
  import {
5
5
  __experimentalBorderRadiusControl as BorderRadiusControl,
6
6
  __experimentalBorderStyleControl as BorderStyleControl,
7
- __experimentalColorGradientControl as ColorGradientControl,
7
+ __experimentalColorGradientSettingsDropdown as ColorGradientSettingsDropdown,
8
8
  } from '@wordpress/block-editor';
9
9
  import {
10
10
  __experimentalToolsPanel as ToolsPanel,
@@ -17,14 +17,15 @@ import { __ } from '@wordpress/i18n';
17
17
  /**
18
18
  * Internal dependencies
19
19
  */
20
- import { getSupportedGlobalStylesPanels, useSetting, useStyle } from './hooks';
20
+ import {
21
+ getSupportedGlobalStylesPanels,
22
+ useColorsPerOrigin,
23
+ useSetting,
24
+ useStyle,
25
+ } from './hooks';
21
26
 
22
27
  const MIN_BORDER_WIDTH = 0;
23
28
 
24
- // Defining empty array here instead of inline avoids unnecessary re-renders of
25
- // color control.
26
- const EMPTY_ARRAY = [];
27
-
28
29
  export function useHasBorderPanel( name ) {
29
30
  const controls = [
30
31
  useHasBorderColorControl( name ),
@@ -100,13 +101,32 @@ export default function BorderPanel( { name } ) {
100
101
  const showBorderStyle = useHasBorderStyleControl( name );
101
102
  const [ borderStyle, setBorderStyle ] = useStyle( 'border.style', name );
102
103
 
104
+ // When we set a border color or width ensure we have a style so the user
105
+ // can see a visible border.
106
+ const handleOnChangeWithStyle = ( setStyle ) => ( value ) => {
107
+ if ( !! value && ! borderStyle ) {
108
+ setBorderStyle( 'solid' );
109
+ }
110
+
111
+ setStyle( value || undefined );
112
+ };
113
+
103
114
  // Border color.
104
115
  const showBorderColor = useHasBorderColorControl( name );
105
116
  const [ borderColor, setBorderColor ] = useStyle( 'border.color', name );
106
- const [ colors = EMPTY_ARRAY ] = useSetting( 'color.palette' );
107
117
  const disableCustomColors = ! useSetting( 'color.custom' )[ 0 ];
108
118
  const disableCustomGradients = ! useSetting( 'color.customGradient' )[ 0 ];
109
119
 
120
+ const borderColorSettings = [
121
+ {
122
+ label: __( 'Color' ),
123
+ colors: useColorsPerOrigin( name ),
124
+ colorValue: borderColor,
125
+ onColorChange: handleOnChangeWithStyle( setBorderColor ),
126
+ clearable: false,
127
+ },
128
+ ];
129
+
110
130
  // Border radius.
111
131
  const showBorderRadius = useHasBorderRadiusControl( name );
112
132
  const [ borderRadiusValues, setBorderRadius ] = useStyle(
@@ -128,16 +148,6 @@ export default function BorderPanel( { name } ) {
128
148
  setBorderWidth( undefined );
129
149
  };
130
150
 
131
- // When we set a border color or width ensure we have a style so the user
132
- // can see a visible border.
133
- const handleOnChangeWithStyle = ( setStyle ) => ( value ) => {
134
- if ( !! value && ! borderStyle ) {
135
- setBorderStyle( 'solid' );
136
- }
137
-
138
- setStyle( value || undefined );
139
- };
140
-
141
151
  return (
142
152
  <ToolsPanel label={ __( 'Border' ) } resetAll={ resetAll }>
143
153
  { showBorderWidth && (
@@ -178,17 +188,13 @@ export default function BorderPanel( { name } ) {
178
188
  onDeselect={ createResetCallback( setBorderColor ) }
179
189
  isShownByDefault={ true }
180
190
  >
181
- <ColorGradientControl
182
- label={ __( 'Color' ) }
183
- colorValue={ borderColor }
184
- colors={ colors }
185
- gradients={ undefined }
191
+ <ColorGradientSettingsDropdown
192
+ __experimentalHasMultipleOrigins
193
+ __experimentalIsRenderedInSidebar
186
194
  disableCustomColors={ disableCustomColors }
187
195
  disableCustomGradients={ disableCustomGradients }
188
- onColorChange={ handleOnChangeWithStyle(
189
- setBorderColor
190
- ) }
191
- clearable={ false }
196
+ enableAlpha
197
+ settings={ borderColorSettings }
192
198
  />
193
199
  </ToolsPanelItem>
194
200
  ) }
@@ -0,0 +1,23 @@
1
+ /**
2
+ * External dependencies
3
+ */
4
+ import classnames from 'classnames';
5
+
6
+ /**
7
+ * WordPress dependencies
8
+ */
9
+ import { Flex } from '@wordpress/components';
10
+
11
+ function ColorIndicatorWrapper( { className, ...props } ) {
12
+ return (
13
+ <Flex
14
+ className={ classnames(
15
+ 'edit-site-global-styles__color-indicator-wrapper',
16
+ className
17
+ ) }
18
+ { ...props }
19
+ />
20
+ );
21
+ }
22
+
23
+ export default ColorIndicatorWrapper;
@@ -43,8 +43,13 @@ function useHasMargin( name ) {
43
43
  function useHasGap( name ) {
44
44
  const supports = getSupportedGlobalStylesPanels( name );
45
45
  const [ settings ] = useSetting( 'spacing.blockGap', name );
46
-
47
- return settings && supports.includes( '--wp--style--block-gap' );
46
+ // Do not show the gap control panel for block-level global styles
47
+ // as they do not work on the frontend.
48
+ // See: https://github.com/WordPress/gutenberg/pull/39845.
49
+ // We can revert this condition when they're working again.
50
+ return !! name
51
+ ? false
52
+ : settings && supports.includes( '--wp--style--block-gap' );
48
53
  }
49
54
 
50
55
  function filterValuesBySides( values, sides ) {
@@ -9,7 +9,7 @@ import {
9
9
  __experimentalView as View,
10
10
  } from '@wordpress/components';
11
11
  import { isRTL, __ } from '@wordpress/i18n';
12
- import { chevronRight, chevronLeft, Icon } from '@wordpress/icons';
12
+ import { chevronRight, chevronLeft } from '@wordpress/icons';
13
13
 
14
14
  /**
15
15
  * Internal dependencies
@@ -22,12 +22,7 @@ function ScreenHeader( { title, description } ) {
22
22
  <HStack spacing={ 2 }>
23
23
  <View>
24
24
  <NavigationBackButton
25
- icon={
26
- <Icon
27
- icon={ isRTL() ? chevronRight : chevronLeft }
28
- variant="muted"
29
- />
30
- }
25
+ icon={ isRTL() ? chevronRight : chevronLeft }
31
26
  size="small"
32
27
  aria-label={ __( 'Navigate to the previous view' ) }
33
28
  />
@@ -0,0 +1,21 @@
1
+ /**
2
+ * External dependencies
3
+ */
4
+ import classnames from 'classnames';
5
+
6
+ /**
7
+ * WordPress dependencies
8
+ */
9
+ import { Icon } from '@wordpress/components';
10
+
11
+ export function IconWithCurrentColor( { className, ...props } ) {
12
+ return (
13
+ <Icon
14
+ className={ classnames(
15
+ className,
16
+ 'edit-site-global-styles-icon-with-current-color'
17
+ ) }
18
+ { ...props }
19
+ />
20
+ );
21
+ }
@@ -8,16 +8,18 @@ import {
8
8
  FlexItem,
9
9
  __experimentalHStack as HStack,
10
10
  } from '@wordpress/components';
11
- import { Icon } from '@wordpress/icons';
11
+
12
+ /**
13
+ * Internal dependencies
14
+ */
15
+ import { IconWithCurrentColor } from './icon-with-current-color';
12
16
 
13
17
  function GenericNavigationButton( { icon, children, ...props } ) {
14
18
  return (
15
19
  <Item { ...props }>
16
20
  { icon && (
17
21
  <HStack justify="flex-start">
18
- <FlexItem>
19
- <Icon icon={ icon } size={ 24 } />
20
- </FlexItem>
22
+ <IconWithCurrentColor icon={ icon } size={ 24 } />
21
23
  <FlexItem>{ children }</FlexItem>
22
24
  </HStack>
23
25
  ) }
@@ -7,7 +7,6 @@ import {
7
7
  __experimentalHStack as HStack,
8
8
  __experimentalZStack as ZStack,
9
9
  __experimentalVStack as VStack,
10
- FlexBlock,
11
10
  ColorIndicator,
12
11
  } from '@wordpress/components';
13
12
  import { __, _n, sprintf } from '@wordpress/i18n';
@@ -19,6 +18,7 @@ import { useMemo } from '@wordpress/element';
19
18
  import Subtitle from './subtitle';
20
19
  import { NavigationButton } from './navigation-button';
21
20
  import { useSetting } from './hooks';
21
+ import ColorIndicatorWrapper from './color-indicator-wrapper';
22
22
 
23
23
  const EMPTY_COLORS = [];
24
24
 
@@ -64,16 +64,13 @@ function Palette( { name } ) {
64
64
  colors.length === 0 ? 'row-reverse' : 'row'
65
65
  }
66
66
  >
67
- <FlexBlock>
68
- <ZStack isLayered={ false } offset={ -8 }>
69
- { colors.slice( 0, 5 ).map( ( { color } ) => (
70
- <ColorIndicator
71
- key={ color }
72
- colorValue={ color }
73
- />
74
- ) ) }
75
- </ZStack>
76
- </FlexBlock>
67
+ <ZStack isLayered={ false } offset={ -8 }>
68
+ { colors.slice( 0, 5 ).map( ( { color } ) => (
69
+ <ColorIndicatorWrapper key={ color }>
70
+ <ColorIndicator colorValue={ color } />
71
+ </ColorIndicatorWrapper>
72
+ ) ) }
73
+ </ZStack>
77
74
  <FlexItem>{ paletteButtonText }</FlexItem>
78
75
  </HStack>
79
76
  </NavigationButton>
@@ -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
  ) }