@wordpress/edit-site 5.1.0 → 5.2.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 (180) hide show
  1. package/CHANGELOG.md +2 -0
  2. package/LICENSE.md +1 -1
  3. package/build/components/add-new-template/new-template-part.js +21 -1
  4. package/build/components/add-new-template/new-template-part.js.map +1 -1
  5. package/build/components/add-new-template/utils.js +9 -1
  6. package/build/components/add-new-template/utils.js.map +1 -1
  7. package/build/components/block-editor/editor-canvas.js +0 -1
  8. package/build/components/block-editor/editor-canvas.js.map +1 -1
  9. package/build/components/block-editor/index.js +15 -51
  10. package/build/components/block-editor/index.js.map +1 -1
  11. package/build/components/block-editor/resize-handle.js +2 -1
  12. package/build/components/block-editor/resize-handle.js.map +1 -1
  13. package/build/components/editor/index.js +1 -1
  14. package/build/components/editor/index.js.map +1 -1
  15. package/build/components/global-styles/block-preview-panel.js +8 -2
  16. package/build/components/global-styles/block-preview-panel.js.map +1 -1
  17. package/build/components/global-styles/border-panel.js +5 -4
  18. package/build/components/global-styles/border-panel.js.map +1 -1
  19. package/build/components/global-styles/context-menu.js +9 -1
  20. package/build/components/global-styles/context-menu.js.map +1 -1
  21. package/build/components/global-styles/dimensions-panel.js +16 -11
  22. package/build/components/global-styles/dimensions-panel.js.map +1 -1
  23. package/build/components/global-styles/screen-background-color.js +6 -5
  24. package/build/components/global-styles/screen-background-color.js.map +1 -1
  25. package/build/components/global-styles/screen-block-list.js +4 -1
  26. package/build/components/global-styles/screen-block-list.js.map +1 -1
  27. package/build/components/global-styles/screen-border.js +9 -3
  28. package/build/components/global-styles/screen-border.js.map +1 -1
  29. package/build/components/global-styles/screen-button-color.js +3 -2
  30. package/build/components/global-styles/screen-button-color.js.map +1 -1
  31. package/build/components/global-styles/screen-colors.js +50 -26
  32. package/build/components/global-styles/screen-colors.js.map +1 -1
  33. package/build/components/global-styles/screen-heading-color.js +8 -7
  34. package/build/components/global-styles/screen-heading-color.js.map +1 -1
  35. package/build/components/global-styles/screen-layout.js +9 -3
  36. package/build/components/global-styles/screen-layout.js.map +1 -1
  37. package/build/components/global-styles/screen-link-color.js +8 -7
  38. package/build/components/global-styles/screen-link-color.js.map +1 -1
  39. package/build/components/global-styles/screen-text-color.js +4 -3
  40. package/build/components/global-styles/screen-text-color.js.map +1 -1
  41. package/build/components/global-styles/screen-typography.js +8 -2
  42. package/build/components/global-styles/screen-typography.js.map +1 -1
  43. package/build/components/global-styles/screen-variations.js +71 -0
  44. package/build/components/global-styles/screen-variations.js.map +1 -0
  45. package/build/components/global-styles/typography-panel.js +9 -8
  46. package/build/components/global-styles/typography-panel.js.map +1 -1
  47. package/build/components/global-styles/ui.js +85 -18
  48. package/build/components/global-styles/ui.js.map +1 -1
  49. package/build/components/global-styles/use-global-styles-output.js +119 -33
  50. package/build/components/global-styles/use-global-styles-output.js.map +1 -1
  51. package/build/components/global-styles/utils.js +49 -2
  52. package/build/components/global-styles/utils.js.map +1 -1
  53. package/build/components/global-styles/variations-panel.js +85 -0
  54. package/build/components/global-styles/variations-panel.js.map +1 -0
  55. package/build/components/layout/index.js +81 -8
  56. package/build/components/layout/index.js.map +1 -1
  57. package/build/components/sidebar-edit-mode/navigation-menu-sidebar/navigation-inspector.js +2 -0
  58. package/build/components/sidebar-edit-mode/navigation-menu-sidebar/navigation-inspector.js.map +1 -1
  59. package/build/components/site-hub/index.js +9 -9
  60. package/build/components/site-hub/index.js.map +1 -1
  61. package/build/components/sync-state-with-url/use-sync-canvas-mode-with-url.js +54 -0
  62. package/build/components/sync-state-with-url/use-sync-canvas-mode-with-url.js.map +1 -0
  63. package/build/components/template-details/edit-template-title.js +1 -0
  64. package/build/components/template-details/edit-template-title.js.map +1 -1
  65. package/build/components/template-details/template-part-area-selector.js +1 -0
  66. package/build/components/template-details/template-part-area-selector.js.map +1 -1
  67. package/build/hooks/push-changes-to-global-styles/index.js +3 -3
  68. package/build/hooks/push-changes-to-global-styles/index.js.map +1 -1
  69. package/build/store/reducer.js +1 -1
  70. package/build/store/reducer.js.map +1 -1
  71. package/build-module/components/add-new-template/new-template-part.js +20 -1
  72. package/build-module/components/add-new-template/new-template-part.js.map +1 -1
  73. package/build-module/components/add-new-template/utils.js +5 -0
  74. package/build-module/components/add-new-template/utils.js.map +1 -1
  75. package/build-module/components/block-editor/editor-canvas.js +0 -1
  76. package/build-module/components/block-editor/editor-canvas.js.map +1 -1
  77. package/build-module/components/block-editor/index.js +17 -49
  78. package/build-module/components/block-editor/index.js.map +1 -1
  79. package/build-module/components/block-editor/resize-handle.js +2 -1
  80. package/build-module/components/block-editor/resize-handle.js.map +1 -1
  81. package/build-module/components/editor/index.js +1 -1
  82. package/build-module/components/editor/index.js.map +1 -1
  83. package/build-module/components/global-styles/block-preview-panel.js +8 -2
  84. package/build-module/components/global-styles/block-preview-panel.js.map +1 -1
  85. package/build-module/components/global-styles/border-panel.js +5 -4
  86. package/build-module/components/global-styles/border-panel.js.map +1 -1
  87. package/build-module/components/global-styles/context-menu.js +7 -1
  88. package/build-module/components/global-styles/context-menu.js.map +1 -1
  89. package/build-module/components/global-styles/dimensions-panel.js +16 -11
  90. package/build-module/components/global-styles/dimensions-panel.js.map +1 -1
  91. package/build-module/components/global-styles/screen-background-color.js +6 -5
  92. package/build-module/components/global-styles/screen-background-color.js.map +1 -1
  93. package/build-module/components/global-styles/screen-block-list.js +3 -1
  94. package/build-module/components/global-styles/screen-block-list.js.map +1 -1
  95. package/build-module/components/global-styles/screen-border.js +8 -3
  96. package/build-module/components/global-styles/screen-border.js.map +1 -1
  97. package/build-module/components/global-styles/screen-button-color.js +3 -2
  98. package/build-module/components/global-styles/screen-button-color.js.map +1 -1
  99. package/build-module/components/global-styles/screen-colors.js +49 -26
  100. package/build-module/components/global-styles/screen-colors.js.map +1 -1
  101. package/build-module/components/global-styles/screen-heading-color.js +8 -7
  102. package/build-module/components/global-styles/screen-heading-color.js.map +1 -1
  103. package/build-module/components/global-styles/screen-layout.js +8 -3
  104. package/build-module/components/global-styles/screen-layout.js.map +1 -1
  105. package/build-module/components/global-styles/screen-link-color.js +8 -7
  106. package/build-module/components/global-styles/screen-link-color.js.map +1 -1
  107. package/build-module/components/global-styles/screen-text-color.js +4 -3
  108. package/build-module/components/global-styles/screen-text-color.js.map +1 -1
  109. package/build-module/components/global-styles/screen-typography.js +7 -2
  110. package/build-module/components/global-styles/screen-typography.js.map +1 -1
  111. package/build-module/components/global-styles/screen-variations.js +54 -0
  112. package/build-module/components/global-styles/screen-variations.js.map +1 -0
  113. package/build-module/components/global-styles/typography-panel.js +9 -8
  114. package/build-module/components/global-styles/typography-panel.js.map +1 -1
  115. package/build-module/components/global-styles/ui.js +84 -19
  116. package/build-module/components/global-styles/ui.js.map +1 -1
  117. package/build-module/components/global-styles/use-global-styles-output.js +121 -35
  118. package/build-module/components/global-styles/use-global-styles-output.js.map +1 -1
  119. package/build-module/components/global-styles/utils.js +47 -2
  120. package/build-module/components/global-styles/utils.js.map +1 -1
  121. package/build-module/components/global-styles/variations-panel.js +68 -0
  122. package/build-module/components/global-styles/variations-panel.js.map +1 -0
  123. package/build-module/components/layout/index.js +81 -10
  124. package/build-module/components/layout/index.js.map +1 -1
  125. package/build-module/components/sidebar-edit-mode/navigation-menu-sidebar/navigation-inspector.js +2 -0
  126. package/build-module/components/sidebar-edit-mode/navigation-menu-sidebar/navigation-inspector.js.map +1 -1
  127. package/build-module/components/site-hub/index.js +10 -9
  128. package/build-module/components/site-hub/index.js.map +1 -1
  129. package/build-module/components/sync-state-with-url/use-sync-canvas-mode-with-url.js +43 -0
  130. package/build-module/components/sync-state-with-url/use-sync-canvas-mode-with-url.js.map +1 -0
  131. package/build-module/components/template-details/edit-template-title.js +1 -0
  132. package/build-module/components/template-details/edit-template-title.js.map +1 -1
  133. package/build-module/components/template-details/template-part-area-selector.js +1 -0
  134. package/build-module/components/template-details/template-part-area-selector.js.map +1 -1
  135. package/build-module/hooks/push-changes-to-global-styles/index.js +3 -3
  136. package/build-module/hooks/push-changes-to-global-styles/index.js.map +1 -1
  137. package/build-module/store/reducer.js +1 -1
  138. package/build-module/store/reducer.js.map +1 -1
  139. package/build-style/style-rtl.css +93 -21
  140. package/build-style/style.css +93 -21
  141. package/package.json +30 -30
  142. package/src/components/add-new-template/new-template-part.js +23 -1
  143. package/src/components/add-new-template/utils.js +14 -0
  144. package/src/components/block-editor/editor-canvas.js +0 -1
  145. package/src/components/block-editor/index.js +11 -54
  146. package/src/components/block-editor/resize-handle.js +6 -2
  147. package/src/components/block-editor/style.scss +43 -7
  148. package/src/components/editor/index.js +1 -1
  149. package/src/components/global-styles/block-preview-panel.js +14 -2
  150. package/src/components/global-styles/border-panel.js +8 -4
  151. package/src/components/global-styles/context-menu.js +6 -0
  152. package/src/components/global-styles/dimensions-panel.js +32 -15
  153. package/src/components/global-styles/screen-background-color.js +12 -5
  154. package/src/components/global-styles/screen-block-list.js +6 -1
  155. package/src/components/global-styles/screen-border.js +7 -4
  156. package/src/components/global-styles/screen-button-color.js +2 -2
  157. package/src/components/global-styles/screen-colors.js +82 -21
  158. package/src/components/global-styles/screen-heading-color.js +7 -7
  159. package/src/components/global-styles/screen-layout.js +10 -4
  160. package/src/components/global-styles/screen-link-color.js +19 -7
  161. package/src/components/global-styles/screen-text-color.js +7 -3
  162. package/src/components/global-styles/screen-typography.js +11 -4
  163. package/src/components/global-styles/screen-variations.js +47 -0
  164. package/src/components/global-styles/style.scss +9 -0
  165. package/src/components/global-styles/test/use-global-styles-output.js +1 -1
  166. package/src/components/global-styles/typography-panel.js +31 -8
  167. package/src/components/global-styles/ui.js +101 -13
  168. package/src/components/global-styles/use-global-styles-output.js +137 -14
  169. package/src/components/global-styles/utils.js +46 -2
  170. package/src/components/global-styles/variations-panel.js +78 -0
  171. package/src/components/layout/index.js +107 -19
  172. package/src/components/layout/style.scss +30 -5
  173. package/src/components/sidebar-edit-mode/navigation-menu-sidebar/navigation-inspector.js +2 -0
  174. package/src/components/sidebar-edit-mode/navigation-menu-sidebar/style.scss +4 -0
  175. package/src/components/site-hub/index.js +120 -109
  176. package/src/components/sync-state-with-url/use-sync-canvas-mode-with-url.js +40 -0
  177. package/src/components/template-details/edit-template-title.js +1 -0
  178. package/src/components/template-details/template-part-area-selector.js +1 -0
  179. package/src/hooks/push-changes-to-global-styles/index.js +3 -3
  180. package/src/store/reducer.js +1 -1
@@ -21,14 +21,29 @@ import { getSupportedGlobalStylesPanels, useStyle } from './hooks';
21
21
  import Subtitle from './subtitle';
22
22
  import ColorIndicatorWrapper from './color-indicator-wrapper';
23
23
  import BlockPreviewPanel from './block-preview-panel';
24
+ import { getVariationClassNameFromPath } from './utils';
24
25
 
25
- function BackgroundColorItem( { name, parentMenu } ) {
26
+ function variationPathToURL( variationPath ) {
27
+ if ( ! variationPath ) {
28
+ return '';
29
+ }
30
+ // Replace the dots with slashes, add slash at the beginning and remove the last slash.
31
+ return '/' + variationPath.replace( /\./g, '/' ).slice( 0, -1 );
32
+ }
33
+
34
+ function BackgroundColorItem( { name, parentMenu, variationPath = '' } ) {
26
35
  const supports = getSupportedGlobalStylesPanels( name );
27
36
  const hasSupport =
28
37
  supports.includes( 'backgroundColor' ) ||
29
38
  supports.includes( 'background' );
30
- const [ backgroundColor ] = useStyle( 'color.background', name );
31
- const [ gradientValue ] = useStyle( 'color.gradient', name );
39
+ const [ backgroundColor ] = useStyle(
40
+ variationPath + 'color.background',
41
+ name
42
+ );
43
+ const [ gradientValue ] = useStyle(
44
+ variationPath + 'color.gradient',
45
+ name
46
+ );
32
47
 
33
48
  if ( ! hasSupport ) {
34
49
  return null;
@@ -36,7 +51,11 @@ function BackgroundColorItem( { name, parentMenu } ) {
36
51
 
37
52
  return (
38
53
  <NavigationButtonAsItem
39
- path={ parentMenu + '/colors/background' }
54
+ path={
55
+ parentMenu +
56
+ variationPathToURL( variationPath ) +
57
+ '/colors/background'
58
+ }
40
59
  aria-label={ __( 'Colors background styles' ) }
41
60
  >
42
61
  <HStack justify="flex-start">
@@ -54,10 +73,10 @@ function BackgroundColorItem( { name, parentMenu } ) {
54
73
  );
55
74
  }
56
75
 
57
- function TextColorItem( { name, parentMenu } ) {
76
+ function TextColorItem( { name, parentMenu, variationPath = '' } ) {
58
77
  const supports = getSupportedGlobalStylesPanels( name );
59
78
  const hasSupport = supports.includes( 'color' );
60
- const [ color ] = useStyle( 'color.text', name );
79
+ const [ color ] = useStyle( variationPath + 'color.text', name );
61
80
 
62
81
  if ( ! hasSupport ) {
63
82
  return null;
@@ -65,7 +84,11 @@ function TextColorItem( { name, parentMenu } ) {
65
84
 
66
85
  return (
67
86
  <NavigationButtonAsItem
68
- path={ parentMenu + '/colors/text' }
87
+ path={
88
+ parentMenu +
89
+ variationPathToURL( variationPath ) +
90
+ '/colors/text'
91
+ }
69
92
  aria-label={ __( 'Colors text styles' ) }
70
93
  >
71
94
  <HStack justify="flex-start">
@@ -83,11 +106,17 @@ function TextColorItem( { name, parentMenu } ) {
83
106
  );
84
107
  }
85
108
 
86
- function LinkColorItem( { name, parentMenu } ) {
109
+ function LinkColorItem( { name, parentMenu, variationPath = '' } ) {
87
110
  const supports = getSupportedGlobalStylesPanels( name );
88
111
  const hasSupport = supports.includes( 'linkColor' );
89
- const [ color ] = useStyle( 'elements.link.color.text', name );
90
- const [ colorHover ] = useStyle( 'elements.link.:hover.color.text', name );
112
+ const [ color ] = useStyle(
113
+ variationPath + 'elements.link.color.text',
114
+ name
115
+ );
116
+ const [ colorHover ] = useStyle(
117
+ variationPath + 'elements.link.:hover.color.text',
118
+ name
119
+ );
91
120
 
92
121
  if ( ! hasSupport ) {
93
122
  return null;
@@ -95,7 +124,11 @@ function LinkColorItem( { name, parentMenu } ) {
95
124
 
96
125
  return (
97
126
  <NavigationButtonAsItem
98
- path={ parentMenu + '/colors/link' }
127
+ path={
128
+ parentMenu +
129
+ variationPathToURL( variationPath ) +
130
+ '/colors/link'
131
+ }
99
132
  aria-label={ __( 'Colors link styles' ) }
100
133
  >
101
134
  <HStack justify="flex-start">
@@ -115,11 +148,17 @@ function LinkColorItem( { name, parentMenu } ) {
115
148
  );
116
149
  }
117
150
 
118
- function HeadingColorItem( { name, parentMenu } ) {
151
+ function HeadingColorItem( { name, parentMenu, variationPath = '' } ) {
119
152
  const supports = getSupportedGlobalStylesPanels( name );
120
153
  const hasSupport = supports.includes( 'color' );
121
- const [ color ] = useStyle( 'elements.heading.color.text', name );
122
- const [ bgColor ] = useStyle( 'elements.heading.color.background', name );
154
+ const [ color ] = useStyle(
155
+ variationPath + 'elements.heading.color.text',
156
+ name
157
+ );
158
+ const [ bgColor ] = useStyle(
159
+ variationPath + 'elements.heading.color.background',
160
+ name
161
+ );
123
162
 
124
163
  if ( ! hasSupport ) {
125
164
  return null;
@@ -127,7 +166,11 @@ function HeadingColorItem( { name, parentMenu } ) {
127
166
 
128
167
  return (
129
168
  <NavigationButtonAsItem
130
- path={ parentMenu + '/colors/heading' }
169
+ path={
170
+ parentMenu +
171
+ variationPathToURL( variationPath ) +
172
+ '/colors/heading'
173
+ }
131
174
  aria-label={ __( 'Colors heading styles' ) }
132
175
  >
133
176
  <HStack justify="flex-start">
@@ -145,18 +188,30 @@ function HeadingColorItem( { name, parentMenu } ) {
145
188
  );
146
189
  }
147
190
 
148
- function ButtonColorItem( { name, parentMenu } ) {
191
+ function ButtonColorItem( { name, parentMenu, variationPath = '' } ) {
149
192
  const supports = getSupportedGlobalStylesPanels( name );
150
193
  const hasSupport = supports.includes( 'buttonColor' );
151
- const [ color ] = useStyle( 'elements.button.color.text', name );
152
- const [ bgColor ] = useStyle( 'elements.button.color.background', name );
194
+ const [ color ] = useStyle(
195
+ variationPath + 'elements.button.color.text',
196
+ name
197
+ );
198
+ const [ bgColor ] = useStyle(
199
+ variationPath + 'elements.button.color.background',
200
+ name
201
+ );
153
202
 
154
203
  if ( ! hasSupport ) {
155
204
  return null;
156
205
  }
157
206
 
158
207
  return (
159
- <NavigationButtonAsItem path={ parentMenu + '/colors/button' }>
208
+ <NavigationButtonAsItem
209
+ path={
210
+ parentMenu +
211
+ variationPathToURL( variationPath ) +
212
+ '/colors/button'
213
+ }
214
+ >
160
215
  <HStack justify="flex-start">
161
216
  <ZStack isLayered={ false } offset={ -8 }>
162
217
  <ColorIndicatorWrapper expanded={ false }>
@@ -174,9 +229,10 @@ function ButtonColorItem( { name, parentMenu } ) {
174
229
  );
175
230
  }
176
231
 
177
- function ScreenColors( { name } ) {
232
+ function ScreenColors( { name, variationPath = '' } ) {
178
233
  const parentMenu =
179
234
  name === undefined ? '' : '/blocks/' + encodeURIComponent( name );
235
+ const variationClassName = getVariationClassNameFromPath( variationPath );
180
236
 
181
237
  return (
182
238
  <>
@@ -187,7 +243,7 @@ function ScreenColors( { name } ) {
187
243
  ) }
188
244
  />
189
245
 
190
- <BlockPreviewPanel name={ name } />
246
+ <BlockPreviewPanel name={ name } variation={ variationClassName } />
191
247
 
192
248
  <div className="edit-site-global-styles-screen-colors">
193
249
  <VStack spacing={ 10 }>
@@ -199,22 +255,27 @@ function ScreenColors( { name } ) {
199
255
  <BackgroundColorItem
200
256
  name={ name }
201
257
  parentMenu={ parentMenu }
258
+ variationPath={ variationPath }
202
259
  />
203
260
  <TextColorItem
204
261
  name={ name }
205
262
  parentMenu={ parentMenu }
263
+ variationPath={ variationPath }
206
264
  />
207
265
  <LinkColorItem
208
266
  name={ name }
209
267
  parentMenu={ parentMenu }
268
+ variationPath={ variationPath }
210
269
  />
211
270
  <HeadingColorItem
212
271
  name={ name }
213
272
  parentMenu={ parentMenu }
273
+ variationPath={ variationPath }
214
274
  />
215
275
  <ButtonColorItem
216
276
  name={ name }
217
277
  parentMenu={ parentMenu }
278
+ variationPath={ variationPath }
218
279
  />
219
280
  </ItemGroup>
220
281
  </VStack>
@@ -21,7 +21,7 @@ import {
21
21
  useGradientsPerOrigin,
22
22
  } from './hooks';
23
23
 
24
- function ScreenHeadingColor( { name } ) {
24
+ function ScreenHeadingColor( { name, variationPath = '' } ) {
25
25
  const [ selectedLevel, setCurrentTab ] = useState( 'heading' );
26
26
 
27
27
  const supports = getSupportedGlobalStylesPanels( name );
@@ -52,30 +52,30 @@ function ScreenHeadingColor( { name } ) {
52
52
  ( gradients.length > 0 || areCustomGradientsEnabled );
53
53
 
54
54
  const [ color, setColor ] = useStyle(
55
- 'elements.' + selectedLevel + '.color.text',
55
+ variationPath + 'elements.' + selectedLevel + '.color.text',
56
56
  name
57
57
  );
58
58
  const [ userColor ] = useStyle(
59
- 'elements.' + selectedLevel + '.color.text',
59
+ variationPath + 'elements.' + selectedLevel + '.color.text',
60
60
  name,
61
61
  'user'
62
62
  );
63
63
 
64
64
  const [ backgroundColor, setBackgroundColor ] = useStyle(
65
- 'elements.' + selectedLevel + '.color.background',
65
+ variationPath + 'elements.' + selectedLevel + '.color.background',
66
66
  name
67
67
  );
68
68
  const [ userBackgroundColor ] = useStyle(
69
- 'elements.' + selectedLevel + '.color.background',
69
+ variationPath + 'elements.' + selectedLevel + '.color.background',
70
70
  name,
71
71
  'user'
72
72
  );
73
73
  const [ gradient, setGradient ] = useStyle(
74
- 'elements.' + selectedLevel + '.color.gradient',
74
+ variationPath + 'elements.' + selectedLevel + '.color.gradient',
75
75
  name
76
76
  );
77
77
  const [ userGradient ] = useStyle(
78
- 'elements.' + selectedLevel + '.color.gradient',
78
+ variationPath + 'elements.' + selectedLevel + '.color.gradient',
79
79
  name,
80
80
  'user'
81
81
  );
@@ -9,15 +9,21 @@ import { __ } from '@wordpress/i18n';
9
9
  import DimensionsPanel, { useHasDimensionsPanel } from './dimensions-panel';
10
10
  import ScreenHeader from './header';
11
11
  import BlockPreviewPanel from './block-preview-panel';
12
+ import { getVariationClassNameFromPath } from './utils';
12
13
 
13
- function ScreenLayout( { name } ) {
14
+ function ScreenLayout( { name, variationPath = '' } ) {
14
15
  const hasDimensionsPanel = useHasDimensionsPanel( name );
15
-
16
+ const variationClassName = getVariationClassNameFromPath( variationPath );
16
17
  return (
17
18
  <>
18
19
  <ScreenHeader title={ __( 'Layout' ) } />
19
- <BlockPreviewPanel name={ name } />
20
- { hasDimensionsPanel && <DimensionsPanel name={ name } /> }
20
+ <BlockPreviewPanel name={ name } variation={ variationClassName } />
21
+ { hasDimensionsPanel && (
22
+ <DimensionsPanel
23
+ name={ name }
24
+ variationPath={ variationPath }
25
+ />
26
+ ) }
21
27
  </>
22
28
  );
23
29
  }
@@ -15,7 +15,7 @@ import {
15
15
  useColorsPerOrigin,
16
16
  } from './hooks';
17
17
 
18
- function ScreenLinkColor( { name } ) {
18
+ function ScreenLinkColor( { name, variationPath = '' } ) {
19
19
  const supports = getSupportedGlobalStylesPanels( name );
20
20
  const [ solids ] = useSetting( 'color.palette', name );
21
21
  const [ areCustomSolidsEnabled ] = useSetting( 'color.custom', name );
@@ -32,20 +32,32 @@ function ScreenLinkColor( { name } ) {
32
32
  const pseudoStates = {
33
33
  default: {
34
34
  label: __( 'Default' ),
35
- value: useStyle( 'elements.link.color.text', name )[ 0 ],
36
- handler: useStyle( 'elements.link.color.text', name )[ 1 ],
35
+ value: useStyle(
36
+ variationPath + 'elements.link.color.text',
37
+ name
38
+ )[ 0 ],
39
+ handler: useStyle(
40
+ variationPath + 'elements.link.color.text',
41
+ name
42
+ )[ 1 ],
37
43
  userValue: useStyle(
38
- 'elements.link.color.text',
44
+ variationPath + 'elements.link.color.text',
39
45
  name,
40
46
  'user'
41
47
  )[ 0 ],
42
48
  },
43
49
  hover: {
44
50
  label: __( 'Hover' ),
45
- value: useStyle( 'elements.link.:hover.color.text', name )[ 0 ],
46
- handler: useStyle( 'elements.link.:hover.color.text', name )[ 1 ],
51
+ value: useStyle(
52
+ variationPath + 'elements.link.:hover.color.text',
53
+ name
54
+ )[ 0 ],
55
+ handler: useStyle(
56
+ variationPath + 'elements.link.:hover.color.text',
57
+ name
58
+ )[ 1 ],
47
59
  userValue: useStyle(
48
- 'elements.link.:hover.color.text',
60
+ variationPath + 'elements.link.:hover.color.text',
49
61
  name,
50
62
  'user'
51
63
  )[ 0 ],
@@ -15,7 +15,7 @@ import {
15
15
  useColorsPerOrigin,
16
16
  } from './hooks';
17
17
 
18
- function ScreenTextColor( { name } ) {
18
+ function ScreenTextColor( { name, variationPath = '' } ) {
19
19
  const supports = getSupportedGlobalStylesPanels( name );
20
20
  const [ solids ] = useSetting( 'color.palette', name );
21
21
  const [ areCustomSolidsEnabled ] = useSetting( 'color.custom', name );
@@ -28,8 +28,12 @@ function ScreenTextColor( { name } ) {
28
28
  isTextEnabled &&
29
29
  ( solids.length > 0 || areCustomSolidsEnabled );
30
30
 
31
- const [ color, setColor ] = useStyle( 'color.text', name );
32
- const [ userColor ] = useStyle( 'color.text', name, 'user' );
31
+ const [ color, setColor ] = useStyle( variationPath + 'color.text', name );
32
+ const [ userColor ] = useStyle(
33
+ variationPath + 'color.text',
34
+ name,
35
+ 'user'
36
+ );
33
37
 
34
38
  if ( ! hasTextColor ) {
35
39
  return null;
@@ -18,6 +18,7 @@ import { useStyle } from './hooks';
18
18
  import Subtitle from './subtitle';
19
19
  import TypographyPanel from './typography-panel';
20
20
  import BlockPreviewPanel from './block-preview-panel';
21
+ import { getVariationClassNameFromPath } from './utils';
21
22
 
22
23
  function Item( { name, parentMenu, element, label } ) {
23
24
  const hasSupport = ! name;
@@ -76,9 +77,9 @@ function Item( { name, parentMenu, element, label } ) {
76
77
  );
77
78
  }
78
79
 
79
- function ScreenTypography( { name } ) {
80
+ function ScreenTypography( { name, variationPath = '' } ) {
80
81
  const parentMenu = name === undefined ? '' : '/blocks/' + name;
81
-
82
+ const variationClassName = getVariationClassNameFromPath( variationPath );
82
83
  return (
83
84
  <>
84
85
  <ScreenHeader
@@ -88,7 +89,7 @@ function ScreenTypography( { name } ) {
88
89
  ) }
89
90
  />
90
91
 
91
- <BlockPreviewPanel name={ name } />
92
+ <BlockPreviewPanel name={ name } variation={ variationClassName } />
92
93
 
93
94
  { ! name && (
94
95
  <div className="edit-site-global-styles-screen-typography">
@@ -124,7 +125,13 @@ function ScreenTypography( { name } ) {
124
125
  </div>
125
126
  ) }
126
127
  { /* No typography elements support yet for blocks. */ }
127
- { !! name && <TypographyPanel name={ name } element="text" /> }
128
+ { !! name && (
129
+ <TypographyPanel
130
+ name={ name }
131
+ variationPath={ variationPath }
132
+ element="text"
133
+ />
134
+ ) }
128
135
  </>
129
136
  );
130
137
  }
@@ -0,0 +1,47 @@
1
+ /**
2
+ * WordPress dependencies
3
+ */
4
+ import { __ } from '@wordpress/i18n';
5
+ import { __experimentalVStack as VStack } from '@wordpress/components';
6
+ /**
7
+ * Internal dependencies
8
+ */
9
+ import {
10
+ VariationPanel,
11
+ VariationsPanel,
12
+ useHasVariationsPanel,
13
+ } from './variations-panel';
14
+ import ScreenHeader from './header';
15
+ import BlockPreviewPanel from './block-preview-panel';
16
+ import Subtitle from './subtitle';
17
+
18
+ export function ScreenVariations( { name, path = '' } ) {
19
+ const hasVariationsPanel = useHasVariationsPanel( name, path );
20
+
21
+ if ( ! hasVariationsPanel ) {
22
+ return null;
23
+ }
24
+ return (
25
+ <div className="edit-site-global-styles-screen-variations">
26
+ <VStack spacing={ 3 }>
27
+ <p>Manage style variations, saved block appearence presets.</p>
28
+ <Subtitle>{ __( 'Style Variations' ) }</Subtitle>
29
+ <VariationsPanel name={ name } />
30
+ </VStack>
31
+ </div>
32
+ );
33
+ }
34
+
35
+ export function ScreenVariation( { blockName, style } ) {
36
+ const { name: styleName, label: styleLabel } = style;
37
+ return (
38
+ <>
39
+ <ScreenHeader title={ styleLabel } />
40
+ <BlockPreviewPanel
41
+ name={ blockName }
42
+ variation={ `is-style-${ styleName }` }
43
+ />
44
+ <VariationPanel blockName={ blockName } styleName={ styleName } />
45
+ </>
46
+ );
47
+ }
@@ -146,3 +146,12 @@ $block-preview-height: 150px;
146
146
  max-height: 200px;
147
147
  overflow-y: scroll;
148
148
  }
149
+
150
+ .edit-site-global-styles-screen-variations {
151
+ margin-top: $grid-unit-20;
152
+ border-top: 1px solid $gray-300;
153
+
154
+ & > * {
155
+ margin: $grid-unit-30 $grid-unit-20;
156
+ }
157
+ }
@@ -681,7 +681,7 @@ describe( 'global styles renderer', () => {
681
681
  const imageBlock = { name: 'core/image', supports: imageSupports };
682
682
  const blockTypes = [ imageBlock ];
683
683
 
684
- expect( getBlockSelectors( blockTypes ) ).toEqual( {
684
+ expect( getBlockSelectors( blockTypes, () => {} ) ).toEqual( {
685
685
  'core/image': {
686
686
  name: imageBlock.name,
687
687
  selector: imageSupports.__experimentalSelector,
@@ -171,7 +171,12 @@ function useFontAppearance( prefix, name ) {
171
171
  };
172
172
  }
173
173
 
174
- export default function TypographyPanel( { name, element, headingLevel } ) {
174
+ export default function TypographyPanel( {
175
+ name,
176
+ element,
177
+ headingLevel,
178
+ variationPath = '',
179
+ } ) {
175
180
  const supports = getSupportedGlobalStylesPanels( name );
176
181
  let prefix = '';
177
182
  if ( element === 'heading' ) {
@@ -210,9 +215,15 @@ export default function TypographyPanel( { name, element, headingLevel } ) {
210
215
  }
211
216
 
212
217
  const [ fontFamily, setFontFamily, hasFontFamily, resetFontFamily ] =
213
- useStyleWithReset( prefix + 'typography.fontFamily', name );
218
+ useStyleWithReset(
219
+ variationPath + prefix + 'typography.fontFamily',
220
+ name
221
+ );
214
222
  const { fontSize, setFontSize, hasFontSize, resetFontSize } =
215
- useFontSizeWithReset( prefix + 'typography.fontSize', name );
223
+ useFontSizeWithReset(
224
+ variationPath + prefix + 'typography.fontSize',
225
+ name
226
+ );
216
227
  const {
217
228
  fontStyle,
218
229
  setFontStyle,
@@ -220,27 +231,39 @@ export default function TypographyPanel( { name, element, headingLevel } ) {
220
231
  setFontWeight,
221
232
  hasFontAppearance,
222
233
  resetFontAppearance,
223
- } = useFontAppearance( prefix, name );
234
+ } = useFontAppearance( variationPath + prefix, name );
224
235
  const [ lineHeight, setLineHeight, hasLineHeight, resetLineHeight ] =
225
- useStyleWithReset( prefix + 'typography.lineHeight', name );
236
+ useStyleWithReset(
237
+ variationPath + prefix + 'typography.lineHeight',
238
+ name
239
+ );
226
240
  const [
227
241
  letterSpacing,
228
242
  setLetterSpacing,
229
243
  hasLetterSpacing,
230
244
  resetLetterSpacing,
231
- ] = useStyleWithReset( prefix + 'typography.letterSpacing', name );
245
+ ] = useStyleWithReset(
246
+ variationPath + prefix + 'typography.letterSpacing',
247
+ name
248
+ );
232
249
  const [
233
250
  textTransform,
234
251
  setTextTransform,
235
252
  hasTextTransform,
236
253
  resetTextTransform,
237
- ] = useStyleWithReset( prefix + 'typography.textTransform', name );
254
+ ] = useStyleWithReset(
255
+ variationPath + prefix + 'typography.textTransform',
256
+ name
257
+ );
238
258
  const [
239
259
  textDecoration,
240
260
  setTextDecoration,
241
261
  hasTextDecoration,
242
262
  resetTextDecoration,
243
- ] = useStyleWithReset( prefix + 'typography.textDecoration', name );
263
+ ] = useStyleWithReset(
264
+ variationPath + prefix + 'typography.textDecoration',
265
+ name
266
+ );
244
267
 
245
268
  const resetAll = () => {
246
269
  resetFontFamily();