@wordpress/edit-site 4.12.0 → 4.13.1-next.957ca95e4c.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.
- package/CHANGELOG.md +2 -0
- package/build/components/add-new-template/new-template.js +8 -3
- package/build/components/add-new-template/new-template.js.map +1 -1
- package/build/components/add-new-template/utils.js +90 -52
- package/build/components/add-new-template/utils.js.map +1 -1
- package/build/components/block-editor/resizable-editor.js +26 -12
- package/build/components/block-editor/resizable-editor.js.map +1 -1
- package/build/components/global-styles/border-panel.js +3 -3
- package/build/components/global-styles/border-panel.js.map +1 -1
- package/build/components/global-styles/dimensions-panel.js +110 -7
- package/build/components/global-styles/dimensions-panel.js.map +1 -1
- package/build/components/global-styles/hooks.js +4 -4
- package/build/components/global-styles/hooks.js.map +1 -1
- package/build/components/global-styles/preview.js +2 -2
- package/build/components/global-styles/preview.js.map +1 -1
- package/build/components/global-styles/typography-panel.js +28 -21
- package/build/components/global-styles/typography-panel.js.map +1 -1
- package/build/components/global-styles/use-global-styles-output.js +42 -10
- package/build/components/global-styles/use-global-styles-output.js.map +1 -1
- package/build/components/global-styles/utils.js +39 -5
- package/build/components/global-styles/utils.js.map +1 -1
- package/build/components/header/document-actions/index.js +1 -0
- package/build/components/header/document-actions/index.js.map +1 -1
- package/build/components/header/index.js +5 -2
- package/build/components/header/index.js.map +1 -1
- package/build/components/header/mode-switcher/index.js +0 -4
- package/build/components/header/mode-switcher/index.js.map +1 -1
- package/build/components/header/more-menu/index.js +13 -3
- package/build/components/header/more-menu/index.js.map +1 -1
- package/build/components/sidebar/default-sidebar.js +11 -1
- package/build/components/sidebar/default-sidebar.js.map +1 -1
- package/build/components/sidebar/plugin-sidebar/index.js +11 -1
- package/build/components/sidebar/plugin-sidebar/index.js.map +1 -1
- package/build/components/template-details/edit-template-title.js +1 -1
- package/build/components/template-details/edit-template-title.js.map +1 -1
- package/build/components/template-details/index.js +18 -8
- package/build/components/template-details/index.js.map +1 -1
- package/build/components/template-details/template-part-area-selector.js +47 -0
- package/build/components/template-details/template-part-area-selector.js.map +1 -0
- package/build/index.js +1 -1
- package/build/index.js.map +1 -1
- package/build-module/components/add-new-template/new-template.js +10 -5
- package/build-module/components/add-new-template/new-template.js.map +1 -1
- package/build-module/components/add-new-template/utils.js +87 -52
- package/build-module/components/add-new-template/utils.js.map +1 -1
- package/build-module/components/block-editor/resizable-editor.js +26 -12
- package/build-module/components/block-editor/resizable-editor.js.map +1 -1
- package/build-module/components/global-styles/border-panel.js +3 -3
- package/build-module/components/global-styles/border-panel.js.map +1 -1
- package/build-module/components/global-styles/dimensions-panel.js +108 -8
- package/build-module/components/global-styles/dimensions-panel.js.map +1 -1
- package/build-module/components/global-styles/hooks.js +5 -5
- package/build-module/components/global-styles/hooks.js.map +1 -1
- package/build-module/components/global-styles/preview.js +2 -2
- package/build-module/components/global-styles/preview.js.map +1 -1
- package/build-module/components/global-styles/typography-panel.js +29 -22
- package/build-module/components/global-styles/typography-panel.js.map +1 -1
- package/build-module/components/global-styles/use-global-styles-output.js +42 -10
- package/build-module/components/global-styles/use-global-styles-output.js.map +1 -1
- package/build-module/components/global-styles/utils.js +39 -5
- package/build-module/components/global-styles/utils.js.map +1 -1
- package/build-module/components/header/document-actions/index.js +1 -0
- package/build-module/components/header/document-actions/index.js.map +1 -1
- package/build-module/components/header/index.js +5 -2
- package/build-module/components/header/index.js.map +1 -1
- package/build-module/components/header/mode-switcher/index.js +0 -4
- package/build-module/components/header/mode-switcher/index.js.map +1 -1
- package/build-module/components/header/more-menu/index.js +13 -3
- package/build-module/components/header/more-menu/index.js.map +1 -1
- package/build-module/components/sidebar/default-sidebar.js +9 -1
- package/build-module/components/sidebar/default-sidebar.js.map +1 -1
- package/build-module/components/sidebar/plugin-sidebar/index.js +9 -1
- package/build-module/components/sidebar/plugin-sidebar/index.js.map +1 -1
- package/build-module/components/template-details/edit-template-title.js +1 -1
- package/build-module/components/template-details/edit-template-title.js.map +1 -1
- package/build-module/components/template-details/index.js +18 -9
- package/build-module/components/template-details/index.js.map +1 -1
- package/build-module/components/template-details/template-part-area-selector.js +35 -0
- package/build-module/components/template-details/template-part-area-selector.js.map +1 -0
- package/build-module/index.js +1 -1
- package/build-module/index.js.map +1 -1
- package/build-style/style-rtl.css +4 -6
- package/build-style/style.css +4 -6
- package/package.json +29 -29
- package/src/components/add-new-template/new-template.js +15 -4
- package/src/components/add-new-template/utils.js +82 -20
- package/src/components/block-editor/resizable-editor.js +28 -18
- package/src/components/editor/style.scss +1 -0
- package/src/components/global-styles/border-panel.js +3 -3
- package/src/components/global-styles/dimensions-panel.js +155 -30
- package/src/components/global-styles/hooks.js +6 -8
- package/src/components/global-styles/preview.js +2 -2
- package/src/components/global-styles/style.scss +3 -2
- package/src/components/global-styles/test/use-global-styles-output.js +16 -3
- package/src/components/global-styles/test/utils.js +68 -8
- package/src/components/global-styles/typography-panel.js +96 -94
- package/src/components/global-styles/use-global-styles-output.js +41 -14
- package/src/components/global-styles/utils.js +29 -4
- package/src/components/header/document-actions/index.js +3 -0
- package/src/components/header/index.js +4 -1
- package/src/components/header/mode-switcher/index.js +0 -3
- package/src/components/header/more-menu/index.js +7 -2
- package/src/components/sidebar/default-sidebar.js +12 -0
- package/src/components/sidebar/plugin-sidebar/index.js +12 -0
- package/src/components/template-details/edit-template-title.js +7 -3
- package/src/components/template-details/index.js +20 -7
- package/src/components/template-details/style.scss +0 -5
- package/src/components/template-details/template-part-area-selector.js +38 -0
- 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 {
|
|
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 (
|
|
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,26 @@ 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
|
+
// If the value is a string, treat it as a single side (top) for the spacing controls.
|
|
125
|
+
return {
|
|
126
|
+
top: value,
|
|
127
|
+
};
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
if ( value ) {
|
|
131
|
+
return {
|
|
132
|
+
...value,
|
|
133
|
+
right: value?.left,
|
|
134
|
+
bottom: value?.top,
|
|
135
|
+
};
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
return value;
|
|
139
|
+
}
|
|
140
|
+
|
|
107
141
|
// Props for managing `layout.contentSize`.
|
|
108
142
|
function useContentSizeProps( name ) {
|
|
109
143
|
const [ contentSizeValue, setContentSizeValue ] = useSetting(
|
|
@@ -204,12 +238,34 @@ function useMarginProps( name ) {
|
|
|
204
238
|
// Props for managing `spacing.blockGap`.
|
|
205
239
|
function useBlockGapProps( name ) {
|
|
206
240
|
const [ gapValue, setGapValue ] = useStyle( 'spacing.blockGap', name );
|
|
241
|
+
const gapValues = splitGapValue( gapValue );
|
|
242
|
+
const gapSides = useCustomSides( name, 'blockGap' );
|
|
243
|
+
const isAxialGap =
|
|
244
|
+
gapSides && gapSides.some( ( side ) => AXIAL_SIDES.includes( side ) );
|
|
207
245
|
const resetGapValue = () => setGapValue( undefined );
|
|
208
246
|
const [ userSetGapValue ] = useStyle( 'spacing.blockGap', name, 'user' );
|
|
209
247
|
const hasGapValue = () => !! userSetGapValue;
|
|
248
|
+
const setGapValues = ( nextBoxGapValue ) => {
|
|
249
|
+
if ( ! nextBoxGapValue ) {
|
|
250
|
+
setGapValue( null );
|
|
251
|
+
}
|
|
252
|
+
// If axial gap is not enabled, treat the 'top' value as the shorthand gap value.
|
|
253
|
+
if ( ! isAxialGap && nextBoxGapValue?.hasOwnProperty( 'top' ) ) {
|
|
254
|
+
setGapValue( nextBoxGapValue.top );
|
|
255
|
+
} else {
|
|
256
|
+
setGapValue( {
|
|
257
|
+
top: nextBoxGapValue?.top,
|
|
258
|
+
left: nextBoxGapValue?.left,
|
|
259
|
+
} );
|
|
260
|
+
}
|
|
261
|
+
};
|
|
210
262
|
return {
|
|
211
263
|
gapValue,
|
|
264
|
+
gapValues,
|
|
265
|
+
gapSides,
|
|
266
|
+
isAxialGap,
|
|
212
267
|
setGapValue,
|
|
268
|
+
setGapValues,
|
|
213
269
|
resetGapValue,
|
|
214
270
|
hasGapValue,
|
|
215
271
|
};
|
|
@@ -221,6 +277,7 @@ export default function DimensionsPanel( { name } ) {
|
|
|
221
277
|
const showPaddingControl = useHasPadding( name );
|
|
222
278
|
const showMarginControl = useHasMargin( name );
|
|
223
279
|
const showGapControl = useHasGap( name );
|
|
280
|
+
const showSpacingPresetsControl = useHasSpacingPresets();
|
|
224
281
|
const units = useCustomUnits( {
|
|
225
282
|
availableUnits: useSetting( 'spacing.units', name )[ 0 ] || [
|
|
226
283
|
'%',
|
|
@@ -268,8 +325,16 @@ export default function DimensionsPanel( { name } ) {
|
|
|
268
325
|
} = useMarginProps( name );
|
|
269
326
|
|
|
270
327
|
// Props for managing `spacing.blockGap`.
|
|
271
|
-
const {
|
|
272
|
-
|
|
328
|
+
const {
|
|
329
|
+
gapValue,
|
|
330
|
+
gapValues,
|
|
331
|
+
gapSides,
|
|
332
|
+
isAxialGap,
|
|
333
|
+
setGapValue,
|
|
334
|
+
setGapValues,
|
|
335
|
+
resetGapValue,
|
|
336
|
+
hasGapValue,
|
|
337
|
+
} = useBlockGapProps( name );
|
|
273
338
|
|
|
274
339
|
const resetAll = () => {
|
|
275
340
|
resetPaddingValue();
|
|
@@ -342,16 +407,32 @@ export default function DimensionsPanel( { name } ) {
|
|
|
342
407
|
label={ __( 'Padding' ) }
|
|
343
408
|
onDeselect={ resetPaddingValue }
|
|
344
409
|
isShownByDefault={ true }
|
|
410
|
+
className={ classnames( {
|
|
411
|
+
'tools-panel-item-spacing': showSpacingPresetsControl,
|
|
412
|
+
} ) }
|
|
345
413
|
>
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
414
|
+
{ ! showSpacingPresetsControl && (
|
|
415
|
+
<BoxControl
|
|
416
|
+
values={ paddingValues }
|
|
417
|
+
onChange={ setPaddingValues }
|
|
418
|
+
label={ __( 'Padding' ) }
|
|
419
|
+
sides={ paddingSides }
|
|
420
|
+
units={ units }
|
|
421
|
+
allowReset={ false }
|
|
422
|
+
splitOnAxis={ isAxialPadding }
|
|
423
|
+
/>
|
|
424
|
+
) }
|
|
425
|
+
{ showSpacingPresetsControl && (
|
|
426
|
+
<SpacingSizesControl
|
|
427
|
+
values={ paddingValues }
|
|
428
|
+
onChange={ setPaddingValues }
|
|
429
|
+
label={ __( 'Padding' ) }
|
|
430
|
+
sides={ paddingSides }
|
|
431
|
+
units={ units }
|
|
432
|
+
allowReset={ false }
|
|
433
|
+
splitOnAxis={ isAxialPadding }
|
|
434
|
+
/>
|
|
435
|
+
) }
|
|
355
436
|
</ToolsPanelItem>
|
|
356
437
|
) }
|
|
357
438
|
{ showMarginControl && (
|
|
@@ -360,16 +441,32 @@ export default function DimensionsPanel( { name } ) {
|
|
|
360
441
|
label={ __( 'Margin' ) }
|
|
361
442
|
onDeselect={ resetMarginValue }
|
|
362
443
|
isShownByDefault={ true }
|
|
444
|
+
className={ classnames( {
|
|
445
|
+
'tools-panel-item-spacing': showSpacingPresetsControl,
|
|
446
|
+
} ) }
|
|
363
447
|
>
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
448
|
+
{ ! showSpacingPresetsControl && (
|
|
449
|
+
<BoxControl
|
|
450
|
+
values={ marginValues }
|
|
451
|
+
onChange={ setMarginValues }
|
|
452
|
+
label={ __( 'Margin' ) }
|
|
453
|
+
sides={ marginSides }
|
|
454
|
+
units={ units }
|
|
455
|
+
allowReset={ false }
|
|
456
|
+
splitOnAxis={ isAxialMargin }
|
|
457
|
+
/>
|
|
458
|
+
) }
|
|
459
|
+
{ showSpacingPresetsControl && (
|
|
460
|
+
<SpacingSizesControl
|
|
461
|
+
values={ marginValues }
|
|
462
|
+
onChange={ setMarginValues }
|
|
463
|
+
label={ __( 'Margin' ) }
|
|
464
|
+
sides={ marginSides }
|
|
465
|
+
units={ units }
|
|
466
|
+
allowReset={ false }
|
|
467
|
+
splitOnAxis={ isAxialMargin }
|
|
468
|
+
/>
|
|
469
|
+
) }
|
|
373
470
|
</ToolsPanelItem>
|
|
374
471
|
) }
|
|
375
472
|
{ showGapControl && (
|
|
@@ -378,15 +475,43 @@ export default function DimensionsPanel( { name } ) {
|
|
|
378
475
|
label={ __( 'Block spacing' ) }
|
|
379
476
|
onDeselect={ resetGapValue }
|
|
380
477
|
isShownByDefault={ true }
|
|
478
|
+
className={ classnames( {
|
|
479
|
+
'tools-panel-item-spacing': showSpacingPresetsControl,
|
|
480
|
+
} ) }
|
|
381
481
|
>
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
482
|
+
{ ! showSpacingPresetsControl &&
|
|
483
|
+
( isAxialGap ? (
|
|
484
|
+
<BoxControl
|
|
485
|
+
label={ __( 'Block spacing' ) }
|
|
486
|
+
min={ 0 }
|
|
487
|
+
onChange={ setGapValues }
|
|
488
|
+
units={ units }
|
|
489
|
+
sides={ gapSides }
|
|
490
|
+
values={ gapValues }
|
|
491
|
+
allowReset={ false }
|
|
492
|
+
splitOnAxis={ isAxialGap }
|
|
493
|
+
/>
|
|
494
|
+
) : (
|
|
495
|
+
<UnitControl
|
|
496
|
+
label={ __( 'Block spacing' ) }
|
|
497
|
+
__unstableInputWidth="80px"
|
|
498
|
+
min={ 0 }
|
|
499
|
+
onChange={ setGapValue }
|
|
500
|
+
units={ units }
|
|
501
|
+
value={ gapValue }
|
|
502
|
+
/>
|
|
503
|
+
) ) }
|
|
504
|
+
{ showSpacingPresetsControl && (
|
|
505
|
+
<SpacingSizesControl
|
|
506
|
+
label={ __( 'Block spacing' ) }
|
|
507
|
+
min={ 0 }
|
|
508
|
+
onChange={ setGapValues }
|
|
509
|
+
sides={ isAxialGap ? gapSides : [ 'top' ] } // Use 'top' as the shorthand property in non-axial configurations.
|
|
510
|
+
values={ gapValues }
|
|
511
|
+
allowReset={ false }
|
|
512
|
+
splitOnAxis={ isAxialGap }
|
|
513
|
+
/>
|
|
514
|
+
) }
|
|
390
515
|
</ToolsPanelItem>
|
|
391
516
|
) }
|
|
392
517
|
</ToolsPanel>
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* External dependencies
|
|
3
3
|
*/
|
|
4
|
-
import { get, cloneDeep, set, isEqual
|
|
4
|
+
import { get, cloneDeep, set, isEqual } from 'lodash';
|
|
5
5
|
|
|
6
6
|
/**
|
|
7
7
|
* WordPress dependencies
|
|
@@ -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
|
|
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
|
|
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
|
|
145
|
+
baseConfig,
|
|
146
146
|
blockName,
|
|
147
147
|
get( baseConfig, finalPath )
|
|
148
148
|
);
|
|
@@ -210,10 +210,8 @@ export function getSupportedGlobalStylesPanels( name ) {
|
|
|
210
210
|
// unset, we still enable it.
|
|
211
211
|
if ( STYLE_PROPERTY[ styleName ].requiresOptOut ) {
|
|
212
212
|
if (
|
|
213
|
-
|
|
214
|
-
blockType.supports
|
|
215
|
-
STYLE_PROPERTY[ styleName ].support[ 0 ]
|
|
216
|
-
) &&
|
|
213
|
+
STYLE_PROPERTY[ styleName ].support[ 0 ] in
|
|
214
|
+
blockType.supports &&
|
|
217
215
|
get(
|
|
218
216
|
blockType.supports,
|
|
219
217
|
STYLE_PROPERTY[ styleName ].support
|
|
@@ -79,13 +79,13 @@ const StylesPreview = ( { label, isFocused } ) => {
|
|
|
79
79
|
)
|
|
80
80
|
.slice( 0, 2 );
|
|
81
81
|
|
|
82
|
-
// Reset leaked styles from WP common.css.
|
|
82
|
+
// Reset leaked styles from WP common.css and remove main content layout padding.
|
|
83
83
|
const editorStyles = useMemo( () => {
|
|
84
84
|
if ( styles ) {
|
|
85
85
|
return [
|
|
86
86
|
...styles,
|
|
87
87
|
{
|
|
88
|
-
css: 'body{min-width: 0;}',
|
|
88
|
+
css: 'body{min-width: 0;padding: 0;}',
|
|
89
89
|
isGlobalStyles: true,
|
|
90
90
|
},
|
|
91
91
|
];
|
|
@@ -21,8 +21,9 @@
|
|
|
21
21
|
border-radius: $radius-block-ui;
|
|
22
22
|
}
|
|
23
23
|
|
|
24
|
-
.edit-site-typography-
|
|
25
|
-
|
|
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
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
} );
|