@wordpress/edit-site 4.9.0 → 4.10.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/add-custom-generic-template-modal.js +84 -0
- package/build/components/add-new-template/add-custom-generic-template-modal.js.map +1 -0
- package/build/components/add-new-template/add-custom-template-modal.js +92 -53
- package/build/components/add-new-template/add-custom-template-modal.js.map +1 -1
- package/build/components/add-new-template/new-template.js +77 -81
- package/build/components/add-new-template/new-template.js.map +1 -1
- package/build/components/add-new-template/utils.js +310 -44
- package/build/components/add-new-template/utils.js.map +1 -1
- package/build/components/code-editor/index.js +17 -4
- package/build/components/code-editor/index.js.map +1 -1
- package/build/components/editor/index.js +16 -0
- package/build/components/editor/index.js.map +1 -1
- package/build/components/error-boundary/index.js +6 -0
- package/build/components/error-boundary/index.js.map +1 -1
- package/build/components/global-styles/dimensions-panel.js +2 -6
- package/build/components/global-styles/dimensions-panel.js.map +1 -1
- package/build/components/global-styles/global-styles-provider.js +4 -2
- package/build/components/global-styles/global-styles-provider.js.map +1 -1
- package/build/components/global-styles/hooks.js +10 -1
- package/build/components/global-styles/hooks.js.map +1 -1
- package/build/components/global-styles/screen-color-palette.js +13 -17
- package/build/components/global-styles/screen-color-palette.js.map +1 -1
- package/build/components/global-styles/screen-colors.js +9 -1
- package/build/components/global-styles/screen-colors.js.map +1 -1
- package/build/components/global-styles/screen-link-color.js +48 -14
- package/build/components/global-styles/screen-link-color.js.map +1 -1
- package/build/components/global-styles/use-global-styles-output.js +171 -33
- package/build/components/global-styles/use-global-styles-output.js.map +1 -1
- package/build/components/global-styles/utils.js +1 -1
- package/build/components/global-styles/utils.js.map +1 -1
- package/build/components/keyboard-shortcut-help-modal/index.js +1 -3
- package/build/components/keyboard-shortcut-help-modal/index.js.map +1 -1
- package/build/components/template-details/edit-template-title.js +11 -3
- package/build/components/template-details/edit-template-title.js.map +1 -1
- package/build/components/template-details/index.js +1 -20
- package/build/components/template-details/index.js.map +1 -1
- package/build/store/selectors.js +4 -1
- package/build/store/selectors.js.map +1 -1
- package/build-module/components/add-new-template/add-custom-generic-template-modal.js +77 -0
- package/build-module/components/add-new-template/add-custom-generic-template-modal.js.map +1 -0
- package/build-module/components/add-new-template/add-custom-template-modal.js +92 -53
- package/build-module/components/add-new-template/add-custom-template-modal.js.map +1 -1
- package/build-module/components/add-new-template/new-template.js +80 -83
- package/build-module/components/add-new-template/new-template.js.map +1 -1
- package/build-module/components/add-new-template/utils.js +286 -40
- package/build-module/components/add-new-template/utils.js.map +1 -1
- package/build-module/components/code-editor/index.js +18 -5
- package/build-module/components/code-editor/index.js.map +1 -1
- package/build-module/components/editor/index.js +16 -0
- package/build-module/components/editor/index.js.map +1 -1
- package/build-module/components/error-boundary/index.js +5 -0
- package/build-module/components/error-boundary/index.js.map +1 -1
- package/build-module/components/global-styles/dimensions-panel.js +2 -6
- package/build-module/components/global-styles/dimensions-panel.js.map +1 -1
- package/build-module/components/global-styles/global-styles-provider.js +4 -2
- package/build-module/components/global-styles/global-styles-provider.js.map +1 -1
- package/build-module/components/global-styles/hooks.js +10 -1
- package/build-module/components/global-styles/hooks.js.map +1 -1
- package/build-module/components/global-styles/screen-color-palette.js +14 -19
- package/build-module/components/global-styles/screen-color-palette.js.map +1 -1
- package/build-module/components/global-styles/screen-colors.js +9 -1
- package/build-module/components/global-styles/screen-colors.js.map +1 -1
- package/build-module/components/global-styles/screen-link-color.js +47 -14
- package/build-module/components/global-styles/screen-link-color.js.map +1 -1
- package/build-module/components/global-styles/use-global-styles-output.js +171 -35
- package/build-module/components/global-styles/use-global-styles-output.js.map +1 -1
- package/build-module/components/global-styles/utils.js +2 -2
- package/build-module/components/global-styles/utils.js.map +1 -1
- package/build-module/components/keyboard-shortcut-help-modal/index.js +1 -2
- package/build-module/components/keyboard-shortcut-help-modal/index.js.map +1 -1
- package/build-module/components/template-details/edit-template-title.js +12 -3
- package/build-module/components/template-details/edit-template-title.js.map +1 -1
- package/build-module/components/template-details/index.js +2 -21
- package/build-module/components/template-details/index.js.map +1 -1
- package/build-module/store/selectors.js +5 -2
- package/build-module/store/selectors.js.map +1 -1
- package/build-style/style-rtl.css +21 -23
- package/build-style/style.css +21 -23
- package/package.json +29 -29
- package/src/components/add-new-template/add-custom-generic-template-modal.js +97 -0
- package/src/components/add-new-template/add-custom-template-modal.js +92 -58
- package/src/components/add-new-template/new-template.js +142 -94
- package/src/components/add-new-template/style.scss +21 -0
- package/src/components/add-new-template/utils.js +290 -46
- package/src/components/code-editor/index.js +15 -5
- package/src/components/editor/index.js +11 -0
- package/src/components/error-boundary/index.js +5 -0
- package/src/components/global-styles/dimensions-panel.js +2 -7
- package/src/components/global-styles/global-styles-provider.js +8 -9
- package/src/components/global-styles/hooks.js +15 -0
- package/src/components/global-styles/screen-color-palette.js +25 -27
- package/src/components/global-styles/screen-colors.js +9 -3
- package/src/components/global-styles/screen-link-color.js +65 -23
- package/src/components/global-styles/style.scss +7 -11
- package/src/components/global-styles/test/use-global-styles-output.js +168 -0
- package/src/components/global-styles/use-global-styles-output.js +234 -59
- package/src/components/global-styles/utils.js +2 -2
- package/src/components/keyboard-shortcut-help-modal/index.js +1 -2
- package/src/components/keyboard-shortcut-help-modal/style.scss +0 -5
- package/src/components/list/style.scss +0 -8
- package/src/components/template-details/edit-template-title.js +10 -2
- package/src/components/template-details/index.js +4 -21
- package/src/components/test/error-boundary.js +38 -0
- package/src/store/selectors.js +11 -5
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
*/
|
|
4
4
|
import { __ } from '@wordpress/i18n';
|
|
5
5
|
import { __experimentalColorGradientControl as ColorGradientControl } from '@wordpress/block-editor';
|
|
6
|
-
|
|
6
|
+
import { TabPanel } from '@wordpress/components';
|
|
7
7
|
/**
|
|
8
8
|
* Internal dependencies
|
|
9
9
|
*/
|
|
@@ -29,40 +29,82 @@ function ScreenLinkColor( { name } ) {
|
|
|
29
29
|
isLinkEnabled &&
|
|
30
30
|
( solids.length > 0 || areCustomSolidsEnabled );
|
|
31
31
|
|
|
32
|
-
const
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
32
|
+
const pseudoStates = {
|
|
33
|
+
default: {
|
|
34
|
+
label: __( 'Default' ),
|
|
35
|
+
value: useStyle( 'elements.link.color.text', name )[ 0 ],
|
|
36
|
+
handler: useStyle( 'elements.link.color.text', name )[ 1 ],
|
|
37
|
+
userValue: useStyle(
|
|
38
|
+
'elements.link.color.text',
|
|
39
|
+
name,
|
|
40
|
+
'user'
|
|
41
|
+
)[ 0 ],
|
|
42
|
+
},
|
|
43
|
+
hover: {
|
|
44
|
+
label: __( 'Hover' ),
|
|
45
|
+
value: useStyle( 'elements.link.:hover.color.text', name )[ 0 ],
|
|
46
|
+
handler: useStyle( 'elements.link.:hover.color.text', name )[ 1 ],
|
|
47
|
+
userValue: useStyle(
|
|
48
|
+
'elements.link.:hover.color.text',
|
|
49
|
+
name,
|
|
50
|
+
'user'
|
|
51
|
+
)[ 0 ],
|
|
52
|
+
},
|
|
53
|
+
};
|
|
41
54
|
|
|
42
55
|
if ( ! hasLinkColor ) {
|
|
43
56
|
return null;
|
|
44
57
|
}
|
|
45
58
|
|
|
59
|
+
const tabs = Object.entries( pseudoStates ).map(
|
|
60
|
+
( [ selector, config ] ) => {
|
|
61
|
+
return {
|
|
62
|
+
name: selector,
|
|
63
|
+
title: config.label,
|
|
64
|
+
className: `color-text-${ selector }`,
|
|
65
|
+
};
|
|
66
|
+
}
|
|
67
|
+
);
|
|
68
|
+
|
|
46
69
|
return (
|
|
47
70
|
<>
|
|
48
71
|
<ScreenHeader
|
|
49
72
|
title={ __( 'Links' ) }
|
|
50
73
|
description={ __(
|
|
51
|
-
'Set the
|
|
74
|
+
'Set the colors used for links across the site.'
|
|
52
75
|
) }
|
|
53
76
|
/>
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
77
|
+
|
|
78
|
+
<TabPanel tabs={ tabs }>
|
|
79
|
+
{ ( tab ) => {
|
|
80
|
+
const pseudoSelectorConfig =
|
|
81
|
+
pseudoStates[ tab.name ] ?? null;
|
|
82
|
+
|
|
83
|
+
if ( ! pseudoSelectorConfig ) {
|
|
84
|
+
return null;
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
return (
|
|
88
|
+
<>
|
|
89
|
+
<ColorGradientControl
|
|
90
|
+
className="edit-site-screen-link-color__control"
|
|
91
|
+
colors={ colorsPerOrigin }
|
|
92
|
+
disableCustomColors={ ! areCustomSolidsEnabled }
|
|
93
|
+
__experimentalHasMultipleOrigins
|
|
94
|
+
showTitle={ false }
|
|
95
|
+
enableAlpha
|
|
96
|
+
__experimentalIsRenderedInSidebar
|
|
97
|
+
colorValue={ pseudoSelectorConfig.value }
|
|
98
|
+
onColorChange={ pseudoSelectorConfig.handler }
|
|
99
|
+
clearable={
|
|
100
|
+
pseudoSelectorConfig.value ===
|
|
101
|
+
pseudoSelectorConfig.userValue
|
|
102
|
+
}
|
|
103
|
+
/>
|
|
104
|
+
</>
|
|
105
|
+
);
|
|
106
|
+
} }
|
|
107
|
+
</TabPanel>
|
|
66
108
|
</>
|
|
67
109
|
);
|
|
68
110
|
}
|
|
@@ -66,22 +66,18 @@
|
|
|
66
66
|
margin: 0;
|
|
67
67
|
}
|
|
68
68
|
|
|
69
|
-
.edit-site-screen-color-palette-toggle.edit-site-screen-color-palette-toggle {
|
|
70
|
-
margin-right: $grid-unit-20;
|
|
71
|
-
margin-left: $grid-unit-20;
|
|
72
|
-
width: unset;
|
|
73
|
-
.components-toggle-group-control {
|
|
74
|
-
min-height: $grid-unit-40;
|
|
75
|
-
}
|
|
76
|
-
}
|
|
77
|
-
|
|
78
69
|
.edit-site-screen-text-color__control,
|
|
79
70
|
.edit-site-screen-link-color__control,
|
|
80
|
-
.edit-site-screen-button-color__control
|
|
81
|
-
.edit-site-screen-background-color__control {
|
|
71
|
+
.edit-site-screen-button-color__control {
|
|
82
72
|
padding: $grid-unit-20;
|
|
83
73
|
}
|
|
84
74
|
|
|
75
|
+
.edit-site-screen-background-color__control {
|
|
76
|
+
.block-editor-color-gradient-control__tab-panel {
|
|
77
|
+
padding: $grid-unit-20;
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
|
|
85
81
|
.edit-site-global-styles-variations_item {
|
|
86
82
|
box-sizing: border-box;
|
|
87
83
|
|
|
@@ -7,6 +7,7 @@ import { __EXPERIMENTAL_ELEMENTS as ELEMENTS } from '@wordpress/blocks';
|
|
|
7
7
|
* Internal dependencies
|
|
8
8
|
*/
|
|
9
9
|
import {
|
|
10
|
+
getLayoutStyles,
|
|
10
11
|
getNodesWithSettings,
|
|
11
12
|
getNodesWithStyles,
|
|
12
13
|
toCustomProperties,
|
|
@@ -450,4 +451,171 @@ describe( 'global styles renderer', () => {
|
|
|
450
451
|
);
|
|
451
452
|
} );
|
|
452
453
|
} );
|
|
454
|
+
|
|
455
|
+
describe( 'getLayoutStyles', () => {
|
|
456
|
+
const layoutDefinitionsTree = {
|
|
457
|
+
settings: {
|
|
458
|
+
layout: {
|
|
459
|
+
definitions: {
|
|
460
|
+
default: {
|
|
461
|
+
name: 'default',
|
|
462
|
+
slug: 'flow',
|
|
463
|
+
className: 'is-layout-flow',
|
|
464
|
+
baseStyles: [
|
|
465
|
+
{
|
|
466
|
+
selector: ' > .alignleft',
|
|
467
|
+
rules: {
|
|
468
|
+
float: 'left',
|
|
469
|
+
'margin-inline-start': '0',
|
|
470
|
+
'margin-inline-end': '2em',
|
|
471
|
+
},
|
|
472
|
+
},
|
|
473
|
+
{
|
|
474
|
+
selector: ' > .alignright',
|
|
475
|
+
rules: {
|
|
476
|
+
float: 'right',
|
|
477
|
+
'margin-inline-start': '2em',
|
|
478
|
+
'margin-inline-end': '0',
|
|
479
|
+
},
|
|
480
|
+
},
|
|
481
|
+
{
|
|
482
|
+
selector: ' > .aligncenter',
|
|
483
|
+
rules: {
|
|
484
|
+
'margin-left': 'auto !important',
|
|
485
|
+
'margin-right': 'auto !important',
|
|
486
|
+
},
|
|
487
|
+
},
|
|
488
|
+
],
|
|
489
|
+
spacingStyles: [
|
|
490
|
+
{
|
|
491
|
+
selector: ' > *',
|
|
492
|
+
rules: {
|
|
493
|
+
'margin-block-start': '0',
|
|
494
|
+
'margin-block-end': '0',
|
|
495
|
+
},
|
|
496
|
+
},
|
|
497
|
+
{
|
|
498
|
+
selector: ' > * + *',
|
|
499
|
+
rules: {
|
|
500
|
+
'margin-block-start': null,
|
|
501
|
+
'margin-block-end': '0',
|
|
502
|
+
},
|
|
503
|
+
},
|
|
504
|
+
],
|
|
505
|
+
},
|
|
506
|
+
flex: {
|
|
507
|
+
name: 'flex',
|
|
508
|
+
slug: 'flex',
|
|
509
|
+
className: 'is-layout-flex',
|
|
510
|
+
displayMode: 'flex',
|
|
511
|
+
baseStyles: [
|
|
512
|
+
{
|
|
513
|
+
selector: '',
|
|
514
|
+
rules: {
|
|
515
|
+
'flex-wrap': 'wrap',
|
|
516
|
+
'align-items': 'center',
|
|
517
|
+
},
|
|
518
|
+
},
|
|
519
|
+
{
|
|
520
|
+
selector: ' > *',
|
|
521
|
+
rules: {
|
|
522
|
+
margin: '0',
|
|
523
|
+
},
|
|
524
|
+
},
|
|
525
|
+
],
|
|
526
|
+
spacingStyles: [
|
|
527
|
+
{
|
|
528
|
+
selector: '',
|
|
529
|
+
rules: {
|
|
530
|
+
gap: null,
|
|
531
|
+
},
|
|
532
|
+
},
|
|
533
|
+
],
|
|
534
|
+
},
|
|
535
|
+
},
|
|
536
|
+
},
|
|
537
|
+
},
|
|
538
|
+
};
|
|
539
|
+
|
|
540
|
+
it( 'should return fallback gap flex layout style, and all base styles, if block styles are enabled and blockGap is disabled', () => {
|
|
541
|
+
const style = { spacing: { blockGap: '12px' } };
|
|
542
|
+
|
|
543
|
+
const layoutStyles = getLayoutStyles( {
|
|
544
|
+
tree: layoutDefinitionsTree,
|
|
545
|
+
style,
|
|
546
|
+
selector: 'body',
|
|
547
|
+
hasBlockGapSupport: false,
|
|
548
|
+
hasFallbackGapSupport: true,
|
|
549
|
+
} );
|
|
550
|
+
|
|
551
|
+
expect( layoutStyles ).toEqual(
|
|
552
|
+
'body .is-layout-flex { gap: 0.5em; }body .is-layout-flow > .alignleft { float: left; margin-inline-start: 0; margin-inline-end: 2em; }body .is-layout-flow > .alignright { float: right; margin-inline-start: 2em; margin-inline-end: 0; }body .is-layout-flow > .aligncenter { margin-left: auto !important; margin-right: auto !important; }body .is-layout-flex { display:flex; }body .is-layout-flex { flex-wrap: wrap; align-items: center; }body .is-layout-flex > * { margin: 0; }'
|
|
553
|
+
);
|
|
554
|
+
} );
|
|
555
|
+
|
|
556
|
+
it( 'should return fallback gap layout styles, and base styles, if blockGap is enabled, but there is no blockGap value', () => {
|
|
557
|
+
const style = {};
|
|
558
|
+
|
|
559
|
+
const layoutStyles = getLayoutStyles( {
|
|
560
|
+
tree: layoutDefinitionsTree,
|
|
561
|
+
style,
|
|
562
|
+
selector: 'body',
|
|
563
|
+
hasBlockGapSupport: true,
|
|
564
|
+
hasFallbackGapSupport: true,
|
|
565
|
+
} );
|
|
566
|
+
|
|
567
|
+
expect( layoutStyles ).toEqual(
|
|
568
|
+
'body .is-layout-flow > * { margin-block-start: 0; margin-block-end: 0; }body .is-layout-flow > * + * { margin-block-start: 0.5em; margin-block-end: 0; }body .is-layout-flex { gap: 0.5em; }body { --wp--style--block-gap: 0.5em; }body .is-layout-flow > .alignleft { float: left; margin-inline-start: 0; margin-inline-end: 2em; }body .is-layout-flow > .alignright { float: right; margin-inline-start: 2em; margin-inline-end: 0; }body .is-layout-flow > .aligncenter { margin-left: auto !important; margin-right: auto !important; }body .is-layout-flex { display:flex; }body .is-layout-flex { flex-wrap: wrap; align-items: center; }body .is-layout-flex > * { margin: 0; }'
|
|
569
|
+
);
|
|
570
|
+
} );
|
|
571
|
+
|
|
572
|
+
it( 'should return real gap layout style if blockGap is enabled, and base styles', () => {
|
|
573
|
+
const style = { spacing: { blockGap: '12px' } };
|
|
574
|
+
|
|
575
|
+
const layoutStyles = getLayoutStyles( {
|
|
576
|
+
tree: layoutDefinitionsTree,
|
|
577
|
+
style,
|
|
578
|
+
selector: 'body',
|
|
579
|
+
hasBlockGapSupport: true,
|
|
580
|
+
hasFallbackGapSupport: true,
|
|
581
|
+
} );
|
|
582
|
+
|
|
583
|
+
expect( layoutStyles ).toEqual(
|
|
584
|
+
'body .is-layout-flow > * { margin-block-start: 0; margin-block-end: 0; }body .is-layout-flow > * + * { margin-block-start: 12px; margin-block-end: 0; }body .is-layout-flex { gap: 12px; }body { --wp--style--block-gap: 12px; }body .is-layout-flow > .alignleft { float: left; margin-inline-start: 0; margin-inline-end: 2em; }body .is-layout-flow > .alignright { float: right; margin-inline-start: 2em; margin-inline-end: 0; }body .is-layout-flow > .aligncenter { margin-left: auto !important; margin-right: auto !important; }body .is-layout-flex { display:flex; }body .is-layout-flex { flex-wrap: wrap; align-items: center; }body .is-layout-flex > * { margin: 0; }'
|
|
585
|
+
);
|
|
586
|
+
} );
|
|
587
|
+
|
|
588
|
+
it( 'should return real gap layout style if blockGap is enabled', () => {
|
|
589
|
+
const style = { spacing: { blockGap: '12px' } };
|
|
590
|
+
|
|
591
|
+
const layoutStyles = getLayoutStyles( {
|
|
592
|
+
tree: layoutDefinitionsTree,
|
|
593
|
+
style,
|
|
594
|
+
selector: '.wp-block-group',
|
|
595
|
+
hasBlockGapSupport: true,
|
|
596
|
+
hasFallbackGapSupport: true,
|
|
597
|
+
} );
|
|
598
|
+
|
|
599
|
+
expect( layoutStyles ).toEqual(
|
|
600
|
+
'.wp-block-group.is-layout-flow > * { margin-block-start: 0; margin-block-end: 0; }.wp-block-group.is-layout-flow > * + * { margin-block-start: 12px; margin-block-end: 0; }.wp-block-group.is-layout-flex { gap: 12px; }'
|
|
601
|
+
);
|
|
602
|
+
} );
|
|
603
|
+
|
|
604
|
+
it( 'should return fallback gap flex layout style for a block if blockGap is disabled, and a fallback value is provided', () => {
|
|
605
|
+
const style = { spacing: { blockGap: '12px' } };
|
|
606
|
+
|
|
607
|
+
const layoutStyles = getLayoutStyles( {
|
|
608
|
+
tree: layoutDefinitionsTree,
|
|
609
|
+
style,
|
|
610
|
+
selector: '.wp-block-group',
|
|
611
|
+
hasBlockGapSupport: false, // This means that the fallback value will be used instead of the "real" one.
|
|
612
|
+
hasFallbackGapSupport: true,
|
|
613
|
+
fallbackGapValue: '2em',
|
|
614
|
+
} );
|
|
615
|
+
|
|
616
|
+
expect( layoutStyles ).toEqual(
|
|
617
|
+
'.wp-block-group.is-layout-flex { gap: 2em; }'
|
|
618
|
+
);
|
|
619
|
+
} );
|
|
620
|
+
} );
|
|
453
621
|
} );
|