@wordpress/edit-site 5.6.0 → 5.7.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 (122) hide show
  1. package/CHANGELOG.md +2 -0
  2. package/build/components/add-new-template/new-template-part.js +3 -11
  3. package/build/components/add-new-template/new-template-part.js.map +1 -1
  4. package/build/components/add-new-template/new-template.js +7 -7
  5. package/build/components/add-new-template/new-template.js.map +1 -1
  6. package/build/components/add-new-template/utils.js +1 -1
  7. package/build/components/add-new-template/utils.js.map +1 -1
  8. package/build/components/block-editor/editor-canvas.js +7 -10
  9. package/build/components/block-editor/editor-canvas.js.map +1 -1
  10. package/build/components/global-styles/context-menu.js +2 -3
  11. package/build/components/global-styles/context-menu.js.map +1 -1
  12. package/build/components/global-styles/hooks.js +1 -58
  13. package/build/components/global-styles/hooks.js.map +1 -1
  14. package/build/components/global-styles/preview.js +3 -4
  15. package/build/components/global-styles/preview.js.map +1 -1
  16. package/build/components/global-styles/screen-block-list.js +3 -4
  17. package/build/components/global-styles/screen-block-list.js.map +1 -1
  18. package/build/components/global-styles/screen-colors.js +22 -211
  19. package/build/components/global-styles/screen-colors.js.map +1 -1
  20. package/build/components/global-styles/screen-typography-element.js +4 -0
  21. package/build/components/global-styles/screen-typography-element.js.map +1 -1
  22. package/build/components/global-styles/screen-typography.js +5 -0
  23. package/build/components/global-styles/screen-typography.js.map +1 -1
  24. package/build/components/global-styles/ui.js +5 -35
  25. package/build/components/global-styles/ui.js.map +1 -1
  26. package/build/components/global-styles-renderer/index.js +1 -2
  27. package/build/components/global-styles-renderer/index.js.map +1 -1
  28. package/build/components/secondary-sidebar/list-view-sidebar.js +6 -1
  29. package/build/components/secondary-sidebar/list-view-sidebar.js.map +1 -1
  30. package/build/components/start-template-options/index.js +44 -9
  31. package/build/components/start-template-options/index.js.map +1 -1
  32. package/build/components/style-book/index.js +6 -7
  33. package/build/components/style-book/index.js.map +1 -1
  34. package/build/hooks/push-changes-to-global-styles/index.js +1 -0
  35. package/build/hooks/push-changes-to-global-styles/index.js.map +1 -1
  36. package/build-module/components/add-new-template/new-template-part.js +3 -9
  37. package/build-module/components/add-new-template/new-template-part.js.map +1 -1
  38. package/build-module/components/add-new-template/new-template.js +7 -7
  39. package/build-module/components/add-new-template/new-template.js.map +1 -1
  40. package/build-module/components/add-new-template/utils.js +1 -1
  41. package/build-module/components/add-new-template/utils.js.map +1 -1
  42. package/build-module/components/block-editor/editor-canvas.js +8 -11
  43. package/build-module/components/block-editor/editor-canvas.js.map +1 -1
  44. package/build-module/components/global-styles/context-menu.js +2 -2
  45. package/build-module/components/global-styles/context-menu.js.map +1 -1
  46. package/build-module/components/global-styles/hooks.js +1 -52
  47. package/build-module/components/global-styles/hooks.js.map +1 -1
  48. package/build-module/components/global-styles/preview.js +3 -4
  49. package/build-module/components/global-styles/preview.js.map +1 -1
  50. package/build-module/components/global-styles/screen-block-list.js +3 -3
  51. package/build-module/components/global-styles/screen-block-list.js.map +1 -1
  52. package/build-module/components/global-styles/screen-colors.js +23 -208
  53. package/build-module/components/global-styles/screen-colors.js.map +1 -1
  54. package/build-module/components/global-styles/screen-typography-element.js +4 -0
  55. package/build-module/components/global-styles/screen-typography-element.js.map +1 -1
  56. package/build-module/components/global-styles/screen-typography.js +5 -0
  57. package/build-module/components/global-styles/screen-typography.js.map +1 -1
  58. package/build-module/components/global-styles/ui.js +5 -30
  59. package/build-module/components/global-styles/ui.js.map +1 -1
  60. package/build-module/components/global-styles-renderer/index.js +1 -2
  61. package/build-module/components/global-styles-renderer/index.js.map +1 -1
  62. package/build-module/components/secondary-sidebar/list-view-sidebar.js +6 -2
  63. package/build-module/components/secondary-sidebar/list-view-sidebar.js.map +1 -1
  64. package/build-module/components/start-template-options/index.js +45 -10
  65. package/build-module/components/start-template-options/index.js.map +1 -1
  66. package/build-module/components/style-book/index.js +7 -8
  67. package/build-module/components/style-book/index.js.map +1 -1
  68. package/build-module/hooks/push-changes-to-global-styles/index.js +1 -0
  69. package/build-module/hooks/push-changes-to-global-styles/index.js.map +1 -1
  70. package/build-style/style-rtl.css +4 -17
  71. package/build-style/style.css +4 -17
  72. package/package.json +31 -31
  73. package/src/components/add-new-template/new-template-part.js +1 -6
  74. package/src/components/add-new-template/new-template.js +3 -6
  75. package/src/components/add-new-template/utils.js +1 -1
  76. package/src/components/block-editor/editor-canvas.js +13 -23
  77. package/src/components/global-styles/context-menu.js +2 -2
  78. package/src/components/global-styles/hooks.js +1 -78
  79. package/src/components/global-styles/preview.js +1 -1
  80. package/src/components/global-styles/screen-block-list.js +2 -2
  81. package/src/components/global-styles/screen-colors.js +25 -229
  82. package/src/components/global-styles/screen-typography-element.js +4 -0
  83. package/src/components/global-styles/screen-typography.js +6 -0
  84. package/src/components/global-styles/stories/index.js +425 -0
  85. package/src/components/global-styles/style.scss +4 -18
  86. package/src/components/global-styles/ui.js +6 -31
  87. package/src/components/global-styles-renderer/index.js +1 -2
  88. package/src/components/secondary-sidebar/list-view-sidebar.js +4 -3
  89. package/src/components/start-template-options/index.js +40 -8
  90. package/src/components/style-book/index.js +10 -16
  91. package/src/components/style-book/style.scss +1 -1
  92. package/src/hooks/push-changes-to-global-styles/index.js +1 -0
  93. package/build/components/global-styles/color-utils.js +0 -17
  94. package/build/components/global-styles/color-utils.js.map +0 -1
  95. package/build/components/global-styles/screen-background-color.js +0 -114
  96. package/build/components/global-styles/screen-background-color.js.map +0 -1
  97. package/build/components/global-styles/screen-button-color.js +0 -88
  98. package/build/components/global-styles/screen-button-color.js.map +0 -1
  99. package/build/components/global-styles/screen-heading-color.js +0 -165
  100. package/build/components/global-styles/screen-heading-color.js.map +0 -1
  101. package/build/components/global-styles/screen-link-color.js +0 -105
  102. package/build/components/global-styles/screen-link-color.js.map +0 -1
  103. package/build/components/global-styles/screen-text-color.js +0 -71
  104. package/build/components/global-styles/screen-text-color.js.map +0 -1
  105. package/build-module/components/global-styles/color-utils.js +0 -9
  106. package/build-module/components/global-styles/color-utils.js.map +0 -1
  107. package/build-module/components/global-styles/screen-background-color.js +0 -97
  108. package/build-module/components/global-styles/screen-background-color.js.map +0 -1
  109. package/build-module/components/global-styles/screen-button-color.js +0 -73
  110. package/build-module/components/global-styles/screen-button-color.js.map +0 -1
  111. package/build-module/components/global-styles/screen-heading-color.js +0 -149
  112. package/build-module/components/global-styles/screen-heading-color.js.map +0 -1
  113. package/build-module/components/global-styles/screen-link-color.js +0 -89
  114. package/build-module/components/global-styles/screen-link-color.js.map +0 -1
  115. package/build-module/components/global-styles/screen-text-color.js +0 -56
  116. package/build-module/components/global-styles/screen-text-color.js.map +0 -1
  117. package/src/components/global-styles/color-utils.js +0 -14
  118. package/src/components/global-styles/screen-background-color.js +0 -132
  119. package/src/components/global-styles/screen-button-color.js +0 -104
  120. package/src/components/global-styles/screen-heading-color.js +0 -206
  121. package/src/components/global-styles/screen-link-color.js +0 -124
  122. package/src/components/global-styles/screen-text-color.js +0 -62
@@ -20,7 +20,6 @@ import { speak } from '@wordpress/a11y';
20
20
  /**
21
21
  * Internal dependencies
22
22
  */
23
- import { useHasColorPanel } from './color-utils';
24
23
  import { useHasVariationsPanel } from './variations-panel';
25
24
  import ScreenHeader from './header';
26
25
  import { NavigationButtonAsItem } from './navigation-button';
@@ -32,6 +31,7 @@ const {
32
31
  useHasBorderPanel,
33
32
  useGlobalSetting,
34
33
  useSettingsForBlockElement,
34
+ useHasColorPanel,
35
35
  } = unlock( blockEditorPrivateApis );
36
36
 
37
37
  function useSortedBlockTypes() {
@@ -61,7 +61,7 @@ function BlockMenuItem( { block } ) {
61
61
  const [ rawSettings ] = useGlobalSetting( '', block.name );
62
62
  const settings = useSettingsForBlockElement( rawSettings, block.name );
63
63
  const hasTypographyPanel = useHasTypographyPanel( settings );
64
- const hasColorPanel = useHasColorPanel( block.name );
64
+ const hasColorPanel = useHasColorPanel( settings );
65
65
  const hasBorderPanel = useHasBorderPanel( settings );
66
66
  const hasDimensionsPanel = useHasDimensionsPanel( settings );
67
67
  const hasLayoutPanel = hasBorderPanel || hasDimensionsPanel;
@@ -2,14 +2,7 @@
2
2
  * WordPress dependencies
3
3
  */
4
4
  import { __ } from '@wordpress/i18n';
5
- import {
6
- __experimentalItemGroup as ItemGroup,
7
- __experimentalHStack as HStack,
8
- __experimentalVStack as VStack,
9
- __experimentalZStack as ZStack,
10
- FlexItem,
11
- ColorIndicator,
12
- } from '@wordpress/components';
5
+ import { __experimentalVStack as VStack } from '@wordpress/components';
13
6
  import { privateApis as blockEditorPrivateApis } from '@wordpress/block-editor';
14
7
 
15
8
  /**
@@ -17,205 +10,32 @@ import { privateApis as blockEditorPrivateApis } from '@wordpress/block-editor';
17
10
  */
18
11
  import ScreenHeader from './header';
19
12
  import Palette from './palette';
20
- import { NavigationButtonAsItem } from './navigation-button';
21
- import { useSupportedStyles } from './hooks';
22
- import Subtitle from './subtitle';
23
- import ColorIndicatorWrapper from './color-indicator-wrapper';
24
13
  import BlockPreviewPanel from './block-preview-panel';
25
14
  import { getVariationClassName } from './utils';
26
15
  import { unlock } from '../../private-apis';
27
16
 
28
- const { useGlobalStyle } = unlock( blockEditorPrivateApis );
17
+ const {
18
+ useGlobalStyle,
19
+ useGlobalSetting,
20
+ useSettingsForBlockElement,
21
+ ColorPanel: StylesColorPanel,
22
+ } = unlock( blockEditorPrivateApis );
29
23
 
30
- function BackgroundColorItem( { name, parentMenu, variation = '' } ) {
31
- const prefix = variation ? `variations.${ variation }.` : '';
32
- const urlPrefix = variation ? `/variations/${ variation }` : '';
33
- const supports = useSupportedStyles( name );
34
- const hasSupport =
35
- supports.includes( 'backgroundColor' ) ||
36
- supports.includes( 'background' );
37
- const [ backgroundColor ] = useGlobalStyle(
38
- prefix + 'color.background',
39
- name
40
- );
41
- const [ gradientValue ] = useGlobalStyle( prefix + 'color.gradient', name );
42
-
43
- if ( ! hasSupport ) {
44
- return null;
45
- }
46
-
47
- return (
48
- <NavigationButtonAsItem
49
- path={ parentMenu + urlPrefix + '/colors/background' }
50
- aria-label={ __( 'Colors background styles' ) }
51
- >
52
- <HStack justify="flex-start">
53
- <ColorIndicatorWrapper expanded={ false }>
54
- <ColorIndicator
55
- colorValue={ gradientValue ?? backgroundColor }
56
- data-testid="background-color-indicator"
57
- />
58
- </ColorIndicatorWrapper>
59
- <FlexItem className="edit-site-global-styles__color-label">
60
- { __( 'Background' ) }
61
- </FlexItem>
62
- </HStack>
63
- </NavigationButtonAsItem>
64
- );
65
- }
66
-
67
- function TextColorItem( { name, parentMenu, variation = '' } ) {
68
- const prefix = variation ? `variations.${ variation }.` : '';
69
- const urlPrefix = variation ? `/variations/${ variation }` : '';
70
- const supports = useSupportedStyles( name );
71
- const hasSupport = supports.includes( 'color' );
72
- const [ color ] = useGlobalStyle( prefix + 'color.text', name );
73
-
74
- if ( ! hasSupport ) {
75
- return null;
76
- }
77
-
78
- return (
79
- <NavigationButtonAsItem
80
- path={ parentMenu + urlPrefix + '/colors/text' }
81
- aria-label={ __( 'Colors text styles' ) }
82
- >
83
- <HStack justify="flex-start">
84
- <ColorIndicatorWrapper expanded={ false }>
85
- <ColorIndicator
86
- colorValue={ color }
87
- data-testid="text-color-indicator"
88
- />
89
- </ColorIndicatorWrapper>
90
- <FlexItem className="edit-site-global-styles__color-label">
91
- { __( 'Text' ) }
92
- </FlexItem>
93
- </HStack>
94
- </NavigationButtonAsItem>
95
- );
96
- }
97
-
98
- function LinkColorItem( { name, parentMenu, variation = '' } ) {
99
- const prefix = variation ? `variations.${ variation }.` : '';
100
- const urlPrefix = variation ? `/variations/${ variation }` : '';
101
- const supports = useSupportedStyles( name );
102
- const hasSupport = supports.includes( 'linkColor' );
103
- const [ color ] = useGlobalStyle(
104
- prefix + 'elements.link.color.text',
105
- name
106
- );
107
- const [ colorHover ] = useGlobalStyle(
108
- prefix + 'elements.link.:hover.color.text',
109
- name
110
- );
111
-
112
- if ( ! hasSupport ) {
113
- return null;
114
- }
115
-
116
- return (
117
- <NavigationButtonAsItem
118
- path={ parentMenu + urlPrefix + '/colors/link' }
119
- aria-label={ __( 'Colors link styles' ) }
120
- >
121
- <HStack justify="flex-start">
122
- <ZStack isLayered={ false } offset={ -8 }>
123
- <ColorIndicatorWrapper expanded={ false }>
124
- <ColorIndicator colorValue={ color } />
125
- </ColorIndicatorWrapper>
126
- <ColorIndicatorWrapper expanded={ false }>
127
- <ColorIndicator colorValue={ colorHover } />
128
- </ColorIndicatorWrapper>
129
- </ZStack>
130
- <FlexItem className="edit-site-global-styles__color-label">
131
- { __( 'Links' ) }
132
- </FlexItem>
133
- </HStack>
134
- </NavigationButtonAsItem>
135
- );
136
- }
137
-
138
- function HeadingColorItem( { name, parentMenu, variation = '' } ) {
139
- const prefix = variation ? `variations.${ variation }.` : '';
140
- const urlPrefix = variation ? `/variations/${ variation }` : '';
141
- const supports = useSupportedStyles( name );
142
- const hasSupport = supports.includes( 'color' );
143
- const [ color ] = useGlobalStyle(
144
- prefix + 'elements.heading.color.text',
145
- name
146
- );
147
- const [ bgColor ] = useGlobalStyle(
148
- prefix + 'elements.heading.color.background',
149
- name
150
- );
151
-
152
- if ( ! hasSupport ) {
153
- return null;
154
- }
155
-
156
- return (
157
- <NavigationButtonAsItem
158
- path={ parentMenu + urlPrefix + '/colors/heading' }
159
- aria-label={ __( 'Colors heading styles' ) }
160
- >
161
- <HStack justify="flex-start">
162
- <ZStack isLayered={ false } offset={ -8 }>
163
- <ColorIndicatorWrapper expanded={ false }>
164
- <ColorIndicator colorValue={ bgColor } />
165
- </ColorIndicatorWrapper>
166
- <ColorIndicatorWrapper expanded={ false }>
167
- <ColorIndicator colorValue={ color } />
168
- </ColorIndicatorWrapper>
169
- </ZStack>
170
- <FlexItem>{ __( 'Headings' ) }</FlexItem>
171
- </HStack>
172
- </NavigationButtonAsItem>
173
- );
174
- }
175
-
176
- function ButtonColorItem( { name, parentMenu, variation = '' } ) {
177
- const prefix = variation ? `variations.${ variation }.` : '';
178
- const urlPrefix = variation ? `/variations/${ variation }` : '';
179
- const supports = useSupportedStyles( name );
180
- const hasSupport = supports.includes( 'buttonColor' );
181
- const [ color ] = useGlobalStyle(
182
- prefix + 'elements.button.color.text',
183
- name
184
- );
185
- const [ bgColor ] = useGlobalStyle(
186
- prefix + 'elements.button.color.background',
187
- name
188
- );
24
+ function ScreenColors( { name, variation = '' } ) {
25
+ const variationClassName = getVariationClassName( variation );
189
26
 
190
- if ( ! hasSupport ) {
191
- return null;
27
+ let prefixParts = [];
28
+ if ( variation ) {
29
+ prefixParts = [ 'variations', variation ].concat( prefixParts );
192
30
  }
31
+ const prefix = prefixParts.join( '.' );
193
32
 
194
- return (
195
- <NavigationButtonAsItem
196
- path={ parentMenu + urlPrefix + '/colors/button' }
197
- >
198
- <HStack justify="flex-start">
199
- <ZStack isLayered={ false } offset={ -8 }>
200
- <ColorIndicatorWrapper expanded={ false }>
201
- <ColorIndicator colorValue={ bgColor } />
202
- </ColorIndicatorWrapper>
203
- <ColorIndicatorWrapper expanded={ false }>
204
- <ColorIndicator colorValue={ color } />
205
- </ColorIndicatorWrapper>
206
- </ZStack>
207
- <FlexItem className="edit-site-global-styles__color-label">
208
- { __( 'Buttons' ) }
209
- </FlexItem>
210
- </HStack>
211
- </NavigationButtonAsItem>
212
- );
213
- }
214
-
215
- function ScreenColors( { name, variation = '' } ) {
216
- const parentMenu =
217
- name === undefined ? '' : '/blocks/' + encodeURIComponent( name );
218
- const variationClassName = getVariationClassName( variation );
33
+ const [ style ] = useGlobalStyle( prefix, name, 'user', false );
34
+ const [ inheritedStyle, setStyle ] = useGlobalStyle( prefix, name, 'all', {
35
+ shouldDecodeEncode: false,
36
+ } );
37
+ const [ rawSettings ] = useGlobalSetting( '', name );
38
+ const settings = useSettingsForBlockElement( rawSettings, name );
219
39
 
220
40
  return (
221
41
  <>
@@ -232,36 +52,12 @@ function ScreenColors( { name, variation = '' } ) {
232
52
  <VStack spacing={ 10 }>
233
53
  <Palette name={ name } />
234
54
 
235
- <VStack spacing={ 3 }>
236
- <Subtitle level={ 3 }>{ __( 'Elements' ) }</Subtitle>
237
- <ItemGroup isBordered isSeparated>
238
- <BackgroundColorItem
239
- name={ name }
240
- parentMenu={ parentMenu }
241
- variation={ variation }
242
- />
243
- <TextColorItem
244
- name={ name }
245
- parentMenu={ parentMenu }
246
- variation={ variation }
247
- />
248
- <LinkColorItem
249
- name={ name }
250
- parentMenu={ parentMenu }
251
- variation={ variation }
252
- />
253
- <HeadingColorItem
254
- name={ name }
255
- parentMenu={ parentMenu }
256
- variation={ variation }
257
- />
258
- <ButtonColorItem
259
- name={ name }
260
- parentMenu={ parentMenu }
261
- variation={ variation }
262
- />
263
- </ItemGroup>
264
- </VStack>
55
+ <StylesColorPanel
56
+ inheritedValue={ inheritedStyle }
57
+ value={ style }
58
+ onChange={ setStyle }
59
+ settings={ settings }
60
+ />
265
61
  </VStack>
266
62
  </div>
267
63
  </>
@@ -29,6 +29,10 @@ const elements = {
29
29
  description: __( 'Manage the fonts and typography used on headings.' ),
30
30
  title: __( 'Headings' ),
31
31
  },
32
+ caption: {
33
+ description: __( 'Manage the fonts and typography used on captions.' ),
34
+ title: __( 'Captions' ),
35
+ },
32
36
  button: {
33
37
  description: __( 'Manage the fonts and typography used on buttons.' ),
34
38
  title: __( 'Buttons' ),
@@ -129,6 +129,12 @@ function ScreenTypography( { name, variation = '' } ) {
129
129
  element="heading"
130
130
  label={ __( 'Headings' ) }
131
131
  />
132
+ <Item
133
+ name={ name }
134
+ parentMenu={ parentMenu }
135
+ element="caption"
136
+ label={ __( 'Captions' ) }
137
+ />
132
138
  <Item
133
139
  name={ name }
134
140
  parentMenu={ parentMenu }