@wordpress/edit-site 4.12.0 → 4.12.1-next.d6164808d3.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 (98) hide show
  1. package/build/components/add-new-template/new-template.js +7 -2
  2. package/build/components/add-new-template/new-template.js.map +1 -1
  3. package/build/components/block-editor/resizable-editor.js +26 -12
  4. package/build/components/block-editor/resizable-editor.js.map +1 -1
  5. package/build/components/global-styles/border-panel.js +3 -3
  6. package/build/components/global-styles/border-panel.js.map +1 -1
  7. package/build/components/global-styles/dimensions-panel.js +92 -6
  8. package/build/components/global-styles/dimensions-panel.js.map +1 -1
  9. package/build/components/global-styles/hooks.js +3 -3
  10. package/build/components/global-styles/hooks.js.map +1 -1
  11. package/build/components/global-styles/typography-panel.js +28 -21
  12. package/build/components/global-styles/typography-panel.js.map +1 -1
  13. package/build/components/global-styles/use-global-styles-output.js +42 -10
  14. package/build/components/global-styles/use-global-styles-output.js.map +1 -1
  15. package/build/components/global-styles/utils.js +39 -5
  16. package/build/components/global-styles/utils.js.map +1 -1
  17. package/build/components/header/document-actions/index.js +1 -0
  18. package/build/components/header/document-actions/index.js.map +1 -1
  19. package/build/components/header/index.js +5 -2
  20. package/build/components/header/index.js.map +1 -1
  21. package/build/components/header/mode-switcher/index.js +0 -4
  22. package/build/components/header/mode-switcher/index.js.map +1 -1
  23. package/build/components/header/more-menu/index.js +13 -3
  24. package/build/components/header/more-menu/index.js.map +1 -1
  25. package/build/components/sidebar/default-sidebar.js +11 -1
  26. package/build/components/sidebar/default-sidebar.js.map +1 -1
  27. package/build/components/sidebar/plugin-sidebar/index.js +11 -1
  28. package/build/components/sidebar/plugin-sidebar/index.js.map +1 -1
  29. package/build/components/template-details/edit-template-title.js +1 -1
  30. package/build/components/template-details/edit-template-title.js.map +1 -1
  31. package/build/components/template-details/index.js +18 -8
  32. package/build/components/template-details/index.js.map +1 -1
  33. package/build/components/template-details/template-part-area-selector.js +47 -0
  34. package/build/components/template-details/template-part-area-selector.js.map +1 -0
  35. package/build/index.js +1 -1
  36. package/build/index.js.map +1 -1
  37. package/build-module/components/add-new-template/new-template.js +8 -3
  38. package/build-module/components/add-new-template/new-template.js.map +1 -1
  39. package/build-module/components/block-editor/resizable-editor.js +26 -12
  40. package/build-module/components/block-editor/resizable-editor.js.map +1 -1
  41. package/build-module/components/global-styles/border-panel.js +3 -3
  42. package/build-module/components/global-styles/border-panel.js.map +1 -1
  43. package/build-module/components/global-styles/dimensions-panel.js +90 -7
  44. package/build-module/components/global-styles/dimensions-panel.js.map +1 -1
  45. package/build-module/components/global-styles/hooks.js +3 -3
  46. package/build-module/components/global-styles/hooks.js.map +1 -1
  47. package/build-module/components/global-styles/typography-panel.js +29 -22
  48. package/build-module/components/global-styles/typography-panel.js.map +1 -1
  49. package/build-module/components/global-styles/use-global-styles-output.js +42 -10
  50. package/build-module/components/global-styles/use-global-styles-output.js.map +1 -1
  51. package/build-module/components/global-styles/utils.js +39 -5
  52. package/build-module/components/global-styles/utils.js.map +1 -1
  53. package/build-module/components/header/document-actions/index.js +1 -0
  54. package/build-module/components/header/document-actions/index.js.map +1 -1
  55. package/build-module/components/header/index.js +5 -2
  56. package/build-module/components/header/index.js.map +1 -1
  57. package/build-module/components/header/mode-switcher/index.js +0 -4
  58. package/build-module/components/header/mode-switcher/index.js.map +1 -1
  59. package/build-module/components/header/more-menu/index.js +13 -3
  60. package/build-module/components/header/more-menu/index.js.map +1 -1
  61. package/build-module/components/sidebar/default-sidebar.js +9 -1
  62. package/build-module/components/sidebar/default-sidebar.js.map +1 -1
  63. package/build-module/components/sidebar/plugin-sidebar/index.js +9 -1
  64. package/build-module/components/sidebar/plugin-sidebar/index.js.map +1 -1
  65. package/build-module/components/template-details/edit-template-title.js +1 -1
  66. package/build-module/components/template-details/edit-template-title.js.map +1 -1
  67. package/build-module/components/template-details/index.js +18 -9
  68. package/build-module/components/template-details/index.js.map +1 -1
  69. package/build-module/components/template-details/template-part-area-selector.js +35 -0
  70. package/build-module/components/template-details/template-part-area-selector.js.map +1 -0
  71. package/build-module/index.js +1 -1
  72. package/build-module/index.js.map +1 -1
  73. package/build-style/style-rtl.css +4 -6
  74. package/build-style/style.css +4 -6
  75. package/package.json +29 -29
  76. package/src/components/add-new-template/new-template.js +13 -4
  77. package/src/components/block-editor/resizable-editor.js +28 -18
  78. package/src/components/editor/style.scss +1 -0
  79. package/src/components/global-styles/border-panel.js +3 -3
  80. package/src/components/global-styles/dimensions-panel.js +134 -30
  81. package/src/components/global-styles/hooks.js +3 -3
  82. package/src/components/global-styles/style.scss +3 -2
  83. package/src/components/global-styles/test/use-global-styles-output.js +16 -3
  84. package/src/components/global-styles/test/utils.js +68 -8
  85. package/src/components/global-styles/typography-panel.js +96 -94
  86. package/src/components/global-styles/use-global-styles-output.js +41 -14
  87. package/src/components/global-styles/utils.js +29 -4
  88. package/src/components/header/document-actions/index.js +3 -0
  89. package/src/components/header/index.js +4 -1
  90. package/src/components/header/mode-switcher/index.js +0 -3
  91. package/src/components/header/more-menu/index.js +7 -2
  92. package/src/components/sidebar/default-sidebar.js +12 -0
  93. package/src/components/sidebar/plugin-sidebar/index.js +12 -0
  94. package/src/components/template-details/edit-template-title.js +7 -3
  95. package/src/components/template-details/index.js +20 -7
  96. package/src/components/template-details/style.scss +0 -5
  97. package/src/components/template-details/template-part-area-selector.js +38 -0
  98. package/src/index.js +1 -1
@@ -1,3 +1,8 @@
1
+ /**
2
+ * External dependencies
3
+ */
4
+ import classnames from 'classnames';
5
+
1
6
  /**
2
7
  * WordPress dependencies
3
8
  */
@@ -11,7 +16,10 @@ import {
11
16
  __experimentalUseCustomUnits as useCustomUnits,
12
17
  __experimentalView as View,
13
18
  } from '@wordpress/components';
14
- import { __experimentalUseCustomSides as useCustomSides } from '@wordpress/block-editor';
19
+ import {
20
+ __experimentalUseCustomSides as useCustomSides,
21
+ __experimentalSpacingSizesControl as SpacingSizesControl,
22
+ } from '@wordpress/block-editor';
15
23
  import { Icon, positionCenter, stretchWide } from '@wordpress/icons';
16
24
 
17
25
  /**
@@ -66,6 +74,12 @@ function useHasGap( name ) {
66
74
  return settings && supports.includes( 'blockGap' );
67
75
  }
68
76
 
77
+ function useHasSpacingPresets() {
78
+ const [ settings ] = useSetting( 'spacing.spacingSizes' );
79
+
80
+ return settings && settings.length > 0;
81
+ }
82
+
69
83
  function filterValuesBySides( values, sides ) {
70
84
  if ( ! sides ) {
71
85
  // If no custom side configuration all sides are opted into by default.
@@ -90,7 +104,7 @@ function filterValuesBySides( values, sides ) {
90
104
  }
91
105
 
92
106
  function splitStyleValue( value ) {
93
- // Check for shorthand value ( a string value ).
107
+ // Check for shorthand value (a string value).
94
108
  if ( value && typeof value === 'string' ) {
95
109
  // Convert to value for individual sides for BoxControl.
96
110
  return {
@@ -104,6 +118,25 @@ function splitStyleValue( value ) {
104
118
  return value;
105
119
  }
106
120
 
121
+ function splitGapValue( value ) {
122
+ // Check for shorthand value (a string value).
123
+ if ( value && typeof value === 'string' ) {
124
+ // Convert to value for individual sides for BoxControl.
125
+ return {
126
+ top: value,
127
+ right: value,
128
+ bottom: value,
129
+ left: value,
130
+ };
131
+ }
132
+
133
+ return {
134
+ ...value,
135
+ right: value?.left,
136
+ bottom: value?.top,
137
+ };
138
+ }
139
+
107
140
  // Props for managing `layout.contentSize`.
108
141
  function useContentSizeProps( name ) {
109
142
  const [ contentSizeValue, setContentSizeValue ] = useSetting(
@@ -204,12 +237,29 @@ function useMarginProps( name ) {
204
237
  // Props for managing `spacing.blockGap`.
205
238
  function useBlockGapProps( name ) {
206
239
  const [ gapValue, setGapValue ] = useStyle( 'spacing.blockGap', name );
240
+ const gapValues = splitGapValue( gapValue );
241
+ const setGapValues = ( nextBoxGapValue ) => {
242
+ if ( ! nextBoxGapValue ) {
243
+ setGapValue( null );
244
+ }
245
+ setGapValue( {
246
+ top: nextBoxGapValue?.top,
247
+ left: nextBoxGapValue?.left,
248
+ } );
249
+ };
250
+ const gapSides = useCustomSides( name, 'blockGap' );
251
+ const isAxialGap =
252
+ gapSides && gapSides.some( ( side ) => AXIAL_SIDES.includes( side ) );
207
253
  const resetGapValue = () => setGapValue( undefined );
208
254
  const [ userSetGapValue ] = useStyle( 'spacing.blockGap', name, 'user' );
209
255
  const hasGapValue = () => !! userSetGapValue;
210
256
  return {
211
257
  gapValue,
258
+ gapValues,
259
+ gapSides,
260
+ isAxialGap,
212
261
  setGapValue,
262
+ setGapValues,
213
263
  resetGapValue,
214
264
  hasGapValue,
215
265
  };
@@ -221,6 +271,7 @@ export default function DimensionsPanel( { name } ) {
221
271
  const showPaddingControl = useHasPadding( name );
222
272
  const showMarginControl = useHasMargin( name );
223
273
  const showGapControl = useHasGap( name );
274
+ const showSpacingPresetsControl = useHasSpacingPresets();
224
275
  const units = useCustomUnits( {
225
276
  availableUnits: useSetting( 'spacing.units', name )[ 0 ] || [
226
277
  '%',
@@ -268,8 +319,16 @@ export default function DimensionsPanel( { name } ) {
268
319
  } = useMarginProps( name );
269
320
 
270
321
  // Props for managing `spacing.blockGap`.
271
- const { gapValue, setGapValue, resetGapValue, hasGapValue } =
272
- useBlockGapProps( name );
322
+ const {
323
+ gapValue,
324
+ gapValues,
325
+ gapSides,
326
+ isAxialGap,
327
+ setGapValue,
328
+ setGapValues,
329
+ resetGapValue,
330
+ hasGapValue,
331
+ } = useBlockGapProps( name );
273
332
 
274
333
  const resetAll = () => {
275
334
  resetPaddingValue();
@@ -342,16 +401,32 @@ export default function DimensionsPanel( { name } ) {
342
401
  label={ __( 'Padding' ) }
343
402
  onDeselect={ resetPaddingValue }
344
403
  isShownByDefault={ true }
404
+ className={ classnames( {
405
+ 'tools-panel-item-spacing': showSpacingPresetsControl,
406
+ } ) }
345
407
  >
346
- <BoxControl
347
- values={ paddingValues }
348
- onChange={ setPaddingValues }
349
- label={ __( 'Padding' ) }
350
- sides={ paddingSides }
351
- units={ units }
352
- allowReset={ false }
353
- splitOnAxis={ isAxialPadding }
354
- />
408
+ { ! showSpacingPresetsControl && (
409
+ <BoxControl
410
+ values={ paddingValues }
411
+ onChange={ setPaddingValues }
412
+ label={ __( 'Padding' ) }
413
+ sides={ paddingSides }
414
+ units={ units }
415
+ allowReset={ false }
416
+ splitOnAxis={ isAxialPadding }
417
+ />
418
+ ) }
419
+ { showSpacingPresetsControl && (
420
+ <SpacingSizesControl
421
+ values={ paddingValues }
422
+ onChange={ setPaddingValues }
423
+ label={ __( 'Padding' ) }
424
+ sides={ paddingSides }
425
+ units={ units }
426
+ allowReset={ false }
427
+ splitOnAxis={ isAxialPadding }
428
+ />
429
+ ) }
355
430
  </ToolsPanelItem>
356
431
  ) }
357
432
  { showMarginControl && (
@@ -360,16 +435,32 @@ export default function DimensionsPanel( { name } ) {
360
435
  label={ __( 'Margin' ) }
361
436
  onDeselect={ resetMarginValue }
362
437
  isShownByDefault={ true }
438
+ className={ classnames( {
439
+ 'tools-panel-item-spacing': showSpacingPresetsControl,
440
+ } ) }
363
441
  >
364
- <BoxControl
365
- values={ marginValues }
366
- onChange={ setMarginValues }
367
- label={ __( 'Margin' ) }
368
- sides={ marginSides }
369
- units={ units }
370
- allowReset={ false }
371
- splitOnAxis={ isAxialMargin }
372
- />
442
+ { ! showSpacingPresetsControl && (
443
+ <BoxControl
444
+ values={ marginValues }
445
+ onChange={ setMarginValues }
446
+ label={ __( 'Margin' ) }
447
+ sides={ marginSides }
448
+ units={ units }
449
+ allowReset={ false }
450
+ splitOnAxis={ isAxialMargin }
451
+ />
452
+ ) }
453
+ { showSpacingPresetsControl && (
454
+ <SpacingSizesControl
455
+ values={ marginValues }
456
+ onChange={ setMarginValues }
457
+ label={ __( 'Margin' ) }
458
+ sides={ marginSides }
459
+ units={ units }
460
+ allowReset={ false }
461
+ splitOnAxis={ isAxialMargin }
462
+ />
463
+ ) }
373
464
  </ToolsPanelItem>
374
465
  ) }
375
466
  { showGapControl && (
@@ -379,14 +470,27 @@ export default function DimensionsPanel( { name } ) {
379
470
  onDeselect={ resetGapValue }
380
471
  isShownByDefault={ true }
381
472
  >
382
- <UnitControl
383
- label={ __( 'Block spacing' ) }
384
- __unstableInputWidth="80px"
385
- min={ 0 }
386
- onChange={ setGapValue }
387
- units={ units }
388
- value={ gapValue }
389
- />
473
+ { isAxialGap ? (
474
+ <BoxControl
475
+ label={ __( 'Block spacing' ) }
476
+ min={ 0 }
477
+ onChange={ setGapValues }
478
+ units={ units }
479
+ sides={ gapSides }
480
+ values={ gapValues }
481
+ allowReset={ false }
482
+ splitOnAxis={ isAxialGap }
483
+ />
484
+ ) : (
485
+ <UnitControl
486
+ label={ __( 'Block spacing' ) }
487
+ __unstableInputWidth="80px"
488
+ min={ 0 }
489
+ onChange={ setGapValue }
490
+ units={ units }
491
+ value={ gapValue }
492
+ />
493
+ ) }
390
494
  </ToolsPanelItem>
391
495
  ) }
392
496
  </ToolsPanel>
@@ -128,21 +128,21 @@ export function useStyle( path, blockName, source = 'all' ) {
128
128
  switch ( source ) {
129
129
  case 'all':
130
130
  result = getValueFromVariable(
131
- mergedConfig.settings,
131
+ mergedConfig,
132
132
  blockName,
133
133
  get( userConfig, finalPath ) ?? get( baseConfig, finalPath )
134
134
  );
135
135
  break;
136
136
  case 'user':
137
137
  result = getValueFromVariable(
138
- mergedConfig.settings,
138
+ mergedConfig,
139
139
  blockName,
140
140
  get( userConfig, finalPath )
141
141
  );
142
142
  break;
143
143
  case 'base':
144
144
  result = getValueFromVariable(
145
- baseConfig.settings,
145
+ baseConfig,
146
146
  blockName,
147
147
  get( baseConfig, finalPath )
148
148
  );
@@ -21,8 +21,9 @@
21
21
  border-radius: $radius-block-ui;
22
22
  }
23
23
 
24
- .edit-site-typography-panel__half-width-control {
25
- width: calc((100% - #{$grid-unit-30}) / 2);
24
+ .edit-site-typography-panel__full-width-control {
25
+ grid-column: 1 / -1;
26
+ max-width: 100%;
26
27
  }
27
28
 
28
29
  .edit-site-global-styles-screen-heading-color,
@@ -484,6 +484,19 @@ describe( 'global styles renderer', () => {
484
484
  '.has-white-color{color: var(--wp--preset--color--white) !important;}.has-white-background-color{background-color: var(--wp--preset--color--white) !important;}.has-white-border-color{border-color: var(--wp--preset--color--white) !important;}.has-black-color{color: var(--wp--preset--color--black) !important;}.has-black-background-color{background-color: var(--wp--preset--color--black) !important;}.has-black-border-color{border-color: var(--wp--preset--color--black) !important;}h1.has-blue-color,h2.has-blue-color,h3.has-blue-color,h4.has-blue-color,h5.has-blue-color,h6.has-blue-color{color: var(--wp--preset--color--blue) !important;}h1.has-blue-background-color,h2.has-blue-background-color,h3.has-blue-background-color,h4.has-blue-background-color,h5.has-blue-background-color,h6.has-blue-background-color{background-color: var(--wp--preset--color--blue) !important;}h1.has-blue-border-color,h2.has-blue-border-color,h3.has-blue-border-color,h4.has-blue-border-color,h5.has-blue-border-color,h6.has-blue-border-color{border-color: var(--wp--preset--color--blue) !important;}'
485
485
  );
486
486
  } );
487
+ it( 'should output content and wide size variables if values are specified', () => {
488
+ const tree = {
489
+ settings: {
490
+ layout: {
491
+ contentSize: '840px',
492
+ wideSize: '1100px',
493
+ },
494
+ },
495
+ };
496
+ expect( toStyles( tree, 'body' ) ).toEqual(
497
+ 'body {margin: 0; --wp--style--global--content-size: 840px; --wp--style--global--wide-size: 1100px;}.wp-site-blocks > .alignleft { float: left; margin-right: 2em; }.wp-site-blocks > .alignright { float: right; margin-left: 2em; }.wp-site-blocks > .aligncenter { justify-content: center; margin-left: auto; margin-right: auto; }'
498
+ );
499
+ } );
487
500
  } );
488
501
 
489
502
  describe( 'getLayoutStyles', () => {
@@ -705,12 +718,12 @@ describe( 'global styles renderer', () => {
705
718
  expect(
706
719
  getStylesDeclarations( blockStyles, 'body', true )
707
720
  ).toEqual( [
708
- 'font-family: sans-serif',
709
721
  '--wp--style--root--padding-top: 33px',
710
722
  '--wp--style--root--padding-right: 33px',
711
723
  '--wp--style--root--padding-bottom: 33px',
712
724
  '--wp--style--root--padding-left: 33px',
713
725
  'background-color: var(--wp--preset--color--light-green-cyan)',
726
+ 'font-family: sans-serif',
714
727
  ] );
715
728
  } );
716
729
 
@@ -718,12 +731,12 @@ describe( 'global styles renderer', () => {
718
731
  expect(
719
732
  getStylesDeclarations( blockStyles, 'body', false )
720
733
  ).toEqual( [
721
- 'font-family: sans-serif',
722
734
  'background-color: var(--wp--preset--color--light-green-cyan)',
723
735
  'padding-top: 33px',
724
736
  'padding-right: 33px',
725
737
  'padding-bottom: 33px',
726
738
  'padding-left: 33px',
739
+ 'font-family: sans-serif',
727
740
  ] );
728
741
  } );
729
742
 
@@ -735,12 +748,12 @@ describe( 'global styles renderer', () => {
735
748
  true
736
749
  )
737
750
  ).toEqual( [
738
- 'font-family: sans-serif',
739
751
  'background-color: var(--wp--preset--color--light-green-cyan)',
740
752
  'padding-top: 33px',
741
753
  'padding-right: 33px',
742
754
  'padding-bottom: 33px',
743
755
  'padding-left: 33px',
756
+ 'font-family: sans-serif',
744
757
  ] );
745
758
  } );
746
759
  } );
@@ -4,7 +4,7 @@
4
4
  import { getPresetVariableFromValue, getValueFromVariable } from '../utils';
5
5
 
6
6
  describe( 'editor utils', () => {
7
- const styles = {
7
+ const themeJson = {
8
8
  version: 1,
9
9
  settings: {
10
10
  color: {
@@ -57,7 +57,7 @@ describe( 'editor utils', () => {
57
57
  describe( 'when a provided global style (e.g. fontFamily, color,etc.) does not exist', () => {
58
58
  it( 'returns the originally provided value', () => {
59
59
  const actual = getPresetVariableFromValue(
60
- styles.settings,
60
+ themeJson.settings,
61
61
  context,
62
62
  'fakePropertyName',
63
63
  value
@@ -69,7 +69,7 @@ describe( 'editor utils', () => {
69
69
  describe( 'when a global style is cleared by the user', () => {
70
70
  it( 'returns an undefined preset variable', () => {
71
71
  const actual = getPresetVariableFromValue(
72
- styles.settings,
72
+ themeJson.settings,
73
73
  context,
74
74
  propertyName,
75
75
  undefined
@@ -83,7 +83,7 @@ describe( 'editor utils', () => {
83
83
  it( 'returns the originally provided value', () => {
84
84
  const customValue = '#6e4545';
85
85
  const actual = getPresetVariableFromValue(
86
- styles.settings,
86
+ themeJson.settings,
87
87
  context,
88
88
  propertyName,
89
89
  customValue
@@ -95,7 +95,7 @@ describe( 'editor utils', () => {
95
95
  describe( 'and it is a preset value', () => {
96
96
  it( 'returns the preset variable', () => {
97
97
  const actual = getPresetVariableFromValue(
98
- styles.settings,
98
+ themeJson.settings,
99
99
  context,
100
100
  propertyName,
101
101
  value
@@ -110,7 +110,7 @@ describe( 'editor utils', () => {
110
110
  describe( 'when provided an invalid variable', () => {
111
111
  it( 'returns the originally provided value', () => {
112
112
  const actual = getValueFromVariable(
113
- styles.settings,
113
+ themeJson,
114
114
  'root',
115
115
  undefined
116
116
  );
@@ -122,7 +122,7 @@ describe( 'editor utils', () => {
122
122
  describe( 'when provided a preset variable', () => {
123
123
  it( 'retrieves the correct preset value', () => {
124
124
  const actual = getValueFromVariable(
125
- styles.settings,
125
+ themeJson,
126
126
  'root',
127
127
  'var:preset|color|primary'
128
128
  );
@@ -134,7 +134,7 @@ describe( 'editor utils', () => {
134
134
  describe( 'when provided a custom variable', () => {
135
135
  it( 'retrieves the correct custom value', () => {
136
136
  const actual = getValueFromVariable(
137
- styles.settings,
137
+ themeJson,
138
138
  'root',
139
139
  'var(--wp--custom--color--secondary)'
140
140
  );
@@ -142,5 +142,65 @@ describe( 'editor utils', () => {
142
142
  expect( actual ).toBe( '#a65555' );
143
143
  } );
144
144
  } );
145
+
146
+ describe( 'when provided a dynamic reference', () => {
147
+ it( 'retrieves the referenced value', () => {
148
+ const stylesWithRefs = {
149
+ ...themeJson,
150
+ styles: {
151
+ color: {
152
+ background: {
153
+ ref: 'styles.color.text',
154
+ },
155
+ text: 'purple-rain',
156
+ },
157
+ },
158
+ };
159
+ const actual = getValueFromVariable( stylesWithRefs, 'root', {
160
+ ref: 'styles.color.text',
161
+ } );
162
+
163
+ expect( actual ).toBe( stylesWithRefs.styles.color.text );
164
+ } );
165
+
166
+ it( 'returns the originally provided value where value is dynamic reference and reference does not exist', () => {
167
+ const stylesWithRefs = {
168
+ ...themeJson,
169
+ styles: {
170
+ color: {
171
+ text: {
172
+ ref: 'styles.background.text',
173
+ },
174
+ },
175
+ },
176
+ };
177
+ const actual = getValueFromVariable( stylesWithRefs, 'root', {
178
+ ref: 'styles.color.text',
179
+ } );
180
+
181
+ expect( actual ).toBe( stylesWithRefs.styles.color.text );
182
+ } );
183
+
184
+ it( 'returns the originally provided value where value is dynamic reference', () => {
185
+ const stylesWithRefs = {
186
+ ...themeJson,
187
+ styles: {
188
+ color: {
189
+ background: {
190
+ ref: 'styles.color.text',
191
+ },
192
+ text: {
193
+ ref: 'styles.background.text',
194
+ },
195
+ },
196
+ },
197
+ };
198
+ const actual = getValueFromVariable( stylesWithRefs, 'root', {
199
+ ref: 'styles.color.text',
200
+ } );
201
+
202
+ expect( actual ).toBe( stylesWithRefs.styles.color.text );
203
+ } );
204
+ } );
145
205
  } );
146
206
  } );