@wordpress/edit-site 4.9.0 → 4.12.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 +6 -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 +82 -61
- package/build/components/add-new-template/add-custom-template-modal.js.map +1 -1
- package/build/components/add-new-template/new-template.js +94 -81
- package/build/components/add-new-template/new-template.js.map +1 -1
- package/build/components/add-new-template/utils.js +574 -57
- package/build/components/add-new-template/utils.js.map +1 -1
- package/build/components/block-editor/index.js +1 -3
- package/build/components/block-editor/index.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 +191 -21
- 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 +11 -2
- 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 +59 -7
- package/build/components/global-styles/screen-colors.js.map +1 -1
- package/build/components/global-styles/screen-heading-color.js +157 -0
- package/build/components/global-styles/screen-heading-color.js.map +1 -0
- 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/screen-typography-element.js +4 -0
- package/build/components/global-styles/screen-typography-element.js.map +1 -1
- package/build/components/global-styles/screen-typography.js +5 -0
- package/build/components/global-styles/screen-typography.js.map +1 -1
- package/build/components/global-styles/typography-panel.js +73 -12
- package/build/components/global-styles/typography-panel.js.map +1 -1
- package/build/components/global-styles/typography-utils.js +217 -0
- package/build/components/global-styles/typography-utils.js.map +1 -0
- package/build/components/global-styles/ui.js +11 -0
- package/build/components/global-styles/ui.js.map +1 -1
- package/build/components/global-styles/use-global-styles-output.js +298 -61
- package/build/components/global-styles/use-global-styles-output.js.map +1 -1
- package/build/components/global-styles/utils.js +49 -3
- package/build/components/global-styles/utils.js.map +1 -1
- package/build/components/header/index.js +22 -10
- package/build/components/header/index.js.map +1 -1
- package/build/components/header/undo-redo/redo.js +2 -1
- package/build/components/header/undo-redo/redo.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/list/actions/index.js +1 -1
- package/build/components/list/actions/index.js.map +1 -1
- package/build/components/save-button/index.js +2 -3
- package/build/components/save-button/index.js.map +1 -1
- package/build/components/sidebar/navigation-menu-sidebar/navigation-menu.js +2 -2
- package/build/components/sidebar/navigation-menu-sidebar/navigation-menu.js.map +1 -1
- package/build/components/sidebar/template-card/template-actions.js +1 -1
- package/build/components/sidebar/template-card/template-actions.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 +2 -21
- package/build/components/template-details/index.js.map +1 -1
- package/build/components/template-details/template-areas.js +1 -1
- package/build/components/template-details/template-areas.js.map +1 -1
- package/build/components/template-part-converter/convert-to-template-part.js +4 -1
- package/build/components/template-part-converter/convert-to-template-part.js.map +1 -1
- package/build/hooks/index.js +2 -0
- package/build/hooks/index.js.map +1 -1
- package/build/hooks/template-part-edit.js +86 -0
- package/build/hooks/template-part-edit.js.map +1 -0
- 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 +82 -61
- 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 +96 -84
- package/build-module/components/add-new-template/new-template.js.map +1 -1
- package/build-module/components/add-new-template/utils.js +555 -50
- package/build-module/components/add-new-template/utils.js.map +1 -1
- package/build-module/components/block-editor/index.js +1 -2
- package/build-module/components/block-editor/index.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 +191 -22
- 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 +11 -2
- 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 +59 -7
- package/build-module/components/global-styles/screen-colors.js.map +1 -1
- package/build-module/components/global-styles/screen-heading-color.js +143 -0
- package/build-module/components/global-styles/screen-heading-color.js.map +1 -0
- 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/screen-typography-element.js +4 -0
- package/build-module/components/global-styles/screen-typography-element.js.map +1 -1
- package/build-module/components/global-styles/screen-typography.js +5 -0
- package/build-module/components/global-styles/screen-typography.js.map +1 -1
- package/build-module/components/global-styles/typography-panel.js +74 -13
- package/build-module/components/global-styles/typography-panel.js.map +1 -1
- package/build-module/components/global-styles/typography-utils.js +204 -0
- package/build-module/components/global-styles/typography-utils.js.map +1 -0
- package/build-module/components/global-styles/ui.js +10 -0
- package/build-module/components/global-styles/ui.js.map +1 -1
- package/build-module/components/global-styles/use-global-styles-output.js +294 -69
- package/build-module/components/global-styles/use-global-styles-output.js.map +1 -1
- package/build-module/components/global-styles/utils.js +47 -4
- package/build-module/components/global-styles/utils.js.map +1 -1
- package/build-module/components/header/index.js +25 -12
- package/build-module/components/header/index.js.map +1 -1
- package/build-module/components/header/undo-redo/redo.js +3 -2
- package/build-module/components/header/undo-redo/redo.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/list/actions/index.js +1 -1
- package/build-module/components/list/actions/index.js.map +1 -1
- package/build-module/components/save-button/index.js +3 -4
- package/build-module/components/save-button/index.js.map +1 -1
- package/build-module/components/sidebar/navigation-menu-sidebar/navigation-menu.js +3 -3
- package/build-module/components/sidebar/navigation-menu-sidebar/navigation-menu.js.map +1 -1
- package/build-module/components/sidebar/template-card/template-actions.js +1 -1
- package/build-module/components/sidebar/template-card/template-actions.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 +3 -22
- package/build-module/components/template-details/index.js.map +1 -1
- package/build-module/components/template-details/template-areas.js +1 -1
- package/build-module/components/template-details/template-areas.js.map +1 -1
- package/build-module/components/template-part-converter/convert-to-template-part.js +3 -1
- package/build-module/components/template-part-converter/convert-to-template-part.js.map +1 -1
- package/build-module/hooks/index.js +1 -0
- package/build-module/hooks/index.js.map +1 -1
- package/build-module/hooks/template-part-edit.js +67 -0
- package/build-module/hooks/template-part-edit.js.map +1 -0
- package/build-module/store/selectors.js +5 -2
- package/build-module/store/selectors.js.map +1 -1
- package/build-style/style-rtl.css +55 -48
- package/build-style/style.css +55 -48
- 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 +93 -68
- package/src/components/add-new-template/new-template.js +126 -95
- package/src/components/add-new-template/style.scss +41 -8
- package/src/components/add-new-template/utils.js +622 -80
- package/src/components/block-editor/index.js +0 -2
- 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 +214 -24
- package/src/components/global-styles/global-styles-provider.js +8 -9
- package/src/components/global-styles/hooks.js +18 -0
- package/src/components/global-styles/screen-color-palette.js +25 -27
- package/src/components/global-styles/screen-colors.js +55 -7
- package/src/components/global-styles/screen-heading-color.js +201 -0
- package/src/components/global-styles/screen-link-color.js +65 -23
- package/src/components/global-styles/screen-typography-element.js +4 -0
- package/src/components/global-styles/screen-typography.js +6 -0
- package/src/components/global-styles/style.scss +14 -11
- package/src/components/global-styles/test/typography-utils.js +130 -0
- package/src/components/global-styles/test/use-global-styles-output.js +296 -2
- package/src/components/global-styles/typography-panel.js +85 -16
- package/src/components/global-styles/typography-utils.js +228 -0
- package/src/components/global-styles/ui.js +13 -0
- package/src/components/global-styles/use-global-styles-output.js +387 -89
- package/src/components/global-styles/utils.js +43 -2
- package/src/components/header/index.js +37 -13
- package/src/components/header/style.scss +5 -3
- package/src/components/header/undo-redo/redo.js +6 -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/actions/index.js +3 -1
- package/src/components/list/style.scss +0 -8
- package/src/components/save-button/index.js +10 -13
- package/src/components/sidebar/navigation-menu-sidebar/navigation-menu.js +1 -5
- package/src/components/sidebar/style.scss +4 -0
- package/src/components/sidebar/template-card/template-actions.js +3 -1
- package/src/components/template-details/edit-template-title.js +10 -2
- package/src/components/template-details/index.js +7 -22
- package/src/components/template-details/template-areas.js +3 -1
- package/src/components/template-part-converter/convert-to-template-part.js +3 -1
- package/src/components/test/error-boundary.js +38 -0
- package/src/hooks/index.js +1 -0
- package/src/hooks/template-part-edit.js +82 -0
- package/src/store/selectors.js +11 -5
- package/src/style.scss +0 -1
- package/build/components/edit-template-part-menu-button/index.js +0 -90
- package/build/components/edit-template-part-menu-button/index.js.map +0 -1
- package/build-module/components/edit-template-part-menu-button/index.js +0 -72
- package/build-module/components/edit-template-part-menu-button/index.js.map +0 -1
- package/src/components/edit-template-part-menu-button/index.js +0 -82
|
@@ -7,10 +7,13 @@ 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,
|
|
13
|
+
getBlockSelectors,
|
|
12
14
|
toCustomProperties,
|
|
13
15
|
toStyles,
|
|
16
|
+
getStylesDeclarations,
|
|
14
17
|
} from '../use-global-styles-output';
|
|
15
18
|
import { ROOT_BLOCK_SELECTOR } from '../utils';
|
|
16
19
|
|
|
@@ -56,6 +59,11 @@ describe( 'global styles renderer', () => {
|
|
|
56
59
|
},
|
|
57
60
|
},
|
|
58
61
|
},
|
|
62
|
+
'core/image': {
|
|
63
|
+
border: {
|
|
64
|
+
radius: '9999px',
|
|
65
|
+
},
|
|
66
|
+
},
|
|
59
67
|
},
|
|
60
68
|
elements: {
|
|
61
69
|
link: {
|
|
@@ -83,6 +91,10 @@ describe( 'global styles renderer', () => {
|
|
|
83
91
|
'core/heading': {
|
|
84
92
|
selector: '.my-heading1, .my-heading2',
|
|
85
93
|
},
|
|
94
|
+
'core/image': {
|
|
95
|
+
selector: '.my-image',
|
|
96
|
+
featureSelectors: '.my-image img, .my-image .crop-area',
|
|
97
|
+
},
|
|
86
98
|
};
|
|
87
99
|
|
|
88
100
|
expect( getNodesWithStyles( tree, blockSelectors ) ).toEqual( [
|
|
@@ -158,6 +170,15 @@ describe( 'global styles renderer', () => {
|
|
|
158
170
|
},
|
|
159
171
|
selector: '.my-heading1 a, .my-heading2 a',
|
|
160
172
|
},
|
|
173
|
+
{
|
|
174
|
+
styles: {
|
|
175
|
+
border: {
|
|
176
|
+
radius: '9999px',
|
|
177
|
+
},
|
|
178
|
+
},
|
|
179
|
+
selector: '.my-image',
|
|
180
|
+
featureSelectors: '.my-image img, .my-image .crop-area',
|
|
181
|
+
},
|
|
161
182
|
] );
|
|
162
183
|
} );
|
|
163
184
|
} );
|
|
@@ -429,6 +450,14 @@ describe( 'global styles renderer', () => {
|
|
|
429
450
|
},
|
|
430
451
|
},
|
|
431
452
|
},
|
|
453
|
+
'core/image': {
|
|
454
|
+
color: {
|
|
455
|
+
text: 'red',
|
|
456
|
+
},
|
|
457
|
+
border: {
|
|
458
|
+
radius: '9999px',
|
|
459
|
+
},
|
|
460
|
+
},
|
|
432
461
|
},
|
|
433
462
|
},
|
|
434
463
|
};
|
|
@@ -440,14 +469,279 @@ describe( 'global styles renderer', () => {
|
|
|
440
469
|
'core/heading': {
|
|
441
470
|
selector: 'h1,h2,h3,h4,h5,h6',
|
|
442
471
|
},
|
|
472
|
+
'core/image': {
|
|
473
|
+
selector: '.wp-block-image',
|
|
474
|
+
featureSelectors: {
|
|
475
|
+
border: '.wp-block-image img, .wp-block-image .wp-crop-area',
|
|
476
|
+
},
|
|
477
|
+
},
|
|
443
478
|
};
|
|
444
479
|
|
|
445
480
|
expect( toStyles( tree, blockSelectors ) ).toEqual(
|
|
446
481
|
'body {margin: 0;}' +
|
|
447
|
-
'body{background-color: red;margin: 10px;padding: 10px;}
|
|
448
|
-
'.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; }' +
|
|
482
|
+
'body{background-color: red;margin: 10px;padding: 10px;}a{color: blue;}a:hover{color: orange;}a:focus{color: orange;}h1{font-size: 42px;}.wp-block-group{margin-top: 10px;margin-right: 20px;margin-bottom: 30px;margin-left: 40px;padding-top: 11px;padding-right: 22px;padding-bottom: 33px;padding-left: 44px;}h1,h2,h3,h4,h5,h6{color: orange;}h1 a,h2 a,h3 a,h4 a,h5 a,h6 a{color: hotpink;}h1 a:hover,h2 a:hover,h3 a:hover,h4 a:hover,h5 a:hover,h6 a:hover{color: red;}h1 a:focus,h2 a:focus,h3 a:focus,h4 a:focus,h5 a:focus,h6 a:focus{color: red;}' +
|
|
483
|
+
'.wp-block-image img, .wp-block-image .wp-crop-area{border-radius: 9999px }.wp-block-image{color: red;}.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; }' +
|
|
449
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;}'
|
|
450
485
|
);
|
|
451
486
|
} );
|
|
452
487
|
} );
|
|
488
|
+
|
|
489
|
+
describe( 'getLayoutStyles', () => {
|
|
490
|
+
const layoutDefinitionsTree = {
|
|
491
|
+
settings: {
|
|
492
|
+
layout: {
|
|
493
|
+
definitions: {
|
|
494
|
+
default: {
|
|
495
|
+
name: 'default',
|
|
496
|
+
slug: 'flow',
|
|
497
|
+
className: 'is-layout-flow',
|
|
498
|
+
baseStyles: [
|
|
499
|
+
{
|
|
500
|
+
selector: ' > .alignleft',
|
|
501
|
+
rules: {
|
|
502
|
+
float: 'left',
|
|
503
|
+
'margin-inline-start': '0',
|
|
504
|
+
'margin-inline-end': '2em',
|
|
505
|
+
},
|
|
506
|
+
},
|
|
507
|
+
{
|
|
508
|
+
selector: ' > .alignright',
|
|
509
|
+
rules: {
|
|
510
|
+
float: 'right',
|
|
511
|
+
'margin-inline-start': '2em',
|
|
512
|
+
'margin-inline-end': '0',
|
|
513
|
+
},
|
|
514
|
+
},
|
|
515
|
+
{
|
|
516
|
+
selector: ' > .aligncenter',
|
|
517
|
+
rules: {
|
|
518
|
+
'margin-left': 'auto !important',
|
|
519
|
+
'margin-right': 'auto !important',
|
|
520
|
+
},
|
|
521
|
+
},
|
|
522
|
+
],
|
|
523
|
+
spacingStyles: [
|
|
524
|
+
{
|
|
525
|
+
selector: ' > *',
|
|
526
|
+
rules: {
|
|
527
|
+
'margin-block-start': '0',
|
|
528
|
+
'margin-block-end': '0',
|
|
529
|
+
},
|
|
530
|
+
},
|
|
531
|
+
{
|
|
532
|
+
selector: ' > * + *',
|
|
533
|
+
rules: {
|
|
534
|
+
'margin-block-start': null,
|
|
535
|
+
'margin-block-end': '0',
|
|
536
|
+
},
|
|
537
|
+
},
|
|
538
|
+
],
|
|
539
|
+
},
|
|
540
|
+
flex: {
|
|
541
|
+
name: 'flex',
|
|
542
|
+
slug: 'flex',
|
|
543
|
+
className: 'is-layout-flex',
|
|
544
|
+
displayMode: 'flex',
|
|
545
|
+
baseStyles: [
|
|
546
|
+
{
|
|
547
|
+
selector: '',
|
|
548
|
+
rules: {
|
|
549
|
+
'flex-wrap': 'wrap',
|
|
550
|
+
'align-items': 'center',
|
|
551
|
+
},
|
|
552
|
+
},
|
|
553
|
+
{
|
|
554
|
+
selector: ' > *',
|
|
555
|
+
rules: {
|
|
556
|
+
margin: '0',
|
|
557
|
+
},
|
|
558
|
+
},
|
|
559
|
+
],
|
|
560
|
+
spacingStyles: [
|
|
561
|
+
{
|
|
562
|
+
selector: '',
|
|
563
|
+
rules: {
|
|
564
|
+
gap: null,
|
|
565
|
+
},
|
|
566
|
+
},
|
|
567
|
+
],
|
|
568
|
+
},
|
|
569
|
+
},
|
|
570
|
+
},
|
|
571
|
+
},
|
|
572
|
+
};
|
|
573
|
+
|
|
574
|
+
it( 'should return fallback gap flex layout style, and all base styles, if block styles are enabled and blockGap is disabled', () => {
|
|
575
|
+
const style = { spacing: { blockGap: '12px' } };
|
|
576
|
+
|
|
577
|
+
const layoutStyles = getLayoutStyles( {
|
|
578
|
+
tree: layoutDefinitionsTree,
|
|
579
|
+
style,
|
|
580
|
+
selector: 'body',
|
|
581
|
+
hasBlockGapSupport: false,
|
|
582
|
+
hasFallbackGapSupport: true,
|
|
583
|
+
} );
|
|
584
|
+
|
|
585
|
+
expect( layoutStyles ).toEqual(
|
|
586
|
+
':where(.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; }'
|
|
587
|
+
);
|
|
588
|
+
} );
|
|
589
|
+
|
|
590
|
+
it( 'should return fallback gap layout styles, and base styles, if blockGap is enabled, but there is no blockGap value', () => {
|
|
591
|
+
const style = {};
|
|
592
|
+
|
|
593
|
+
const layoutStyles = getLayoutStyles( {
|
|
594
|
+
tree: layoutDefinitionsTree,
|
|
595
|
+
style,
|
|
596
|
+
selector: 'body',
|
|
597
|
+
hasBlockGapSupport: true,
|
|
598
|
+
hasFallbackGapSupport: true,
|
|
599
|
+
} );
|
|
600
|
+
|
|
601
|
+
expect( layoutStyles ).toEqual(
|
|
602
|
+
'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; }'
|
|
603
|
+
);
|
|
604
|
+
} );
|
|
605
|
+
|
|
606
|
+
it( 'should return real gap layout style if blockGap is enabled, and base styles', () => {
|
|
607
|
+
const style = { spacing: { blockGap: '12px' } };
|
|
608
|
+
|
|
609
|
+
const layoutStyles = getLayoutStyles( {
|
|
610
|
+
tree: layoutDefinitionsTree,
|
|
611
|
+
style,
|
|
612
|
+
selector: 'body',
|
|
613
|
+
hasBlockGapSupport: true,
|
|
614
|
+
hasFallbackGapSupport: true,
|
|
615
|
+
} );
|
|
616
|
+
|
|
617
|
+
expect( layoutStyles ).toEqual(
|
|
618
|
+
'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; }'
|
|
619
|
+
);
|
|
620
|
+
} );
|
|
621
|
+
|
|
622
|
+
it( 'should return real gap layout style if blockGap is enabled', () => {
|
|
623
|
+
const style = { spacing: { blockGap: '12px' } };
|
|
624
|
+
|
|
625
|
+
const layoutStyles = getLayoutStyles( {
|
|
626
|
+
tree: layoutDefinitionsTree,
|
|
627
|
+
style,
|
|
628
|
+
selector: '.wp-block-group',
|
|
629
|
+
hasBlockGapSupport: true,
|
|
630
|
+
hasFallbackGapSupport: true,
|
|
631
|
+
} );
|
|
632
|
+
|
|
633
|
+
expect( layoutStyles ).toEqual(
|
|
634
|
+
'.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; }'
|
|
635
|
+
);
|
|
636
|
+
} );
|
|
637
|
+
|
|
638
|
+
it( 'should return fallback gap flex layout style for a block if blockGap is disabled, and a fallback value is provided', () => {
|
|
639
|
+
const style = { spacing: { blockGap: '12px' } };
|
|
640
|
+
|
|
641
|
+
const layoutStyles = getLayoutStyles( {
|
|
642
|
+
tree: layoutDefinitionsTree,
|
|
643
|
+
style,
|
|
644
|
+
selector: '.wp-block-group',
|
|
645
|
+
hasBlockGapSupport: false, // This means that the fallback value will be used instead of the "real" one.
|
|
646
|
+
hasFallbackGapSupport: true,
|
|
647
|
+
fallbackGapValue: '2em',
|
|
648
|
+
} );
|
|
649
|
+
|
|
650
|
+
expect( layoutStyles ).toEqual(
|
|
651
|
+
':where(.wp-block-group.is-layout-flex) { gap: 2em; }'
|
|
652
|
+
);
|
|
653
|
+
} );
|
|
654
|
+
} );
|
|
655
|
+
|
|
656
|
+
describe( 'getBlockSelectors', () => {
|
|
657
|
+
it( 'should return block selectors data', () => {
|
|
658
|
+
const imageSupports = {
|
|
659
|
+
__experimentalBorder: {
|
|
660
|
+
radius: true,
|
|
661
|
+
__experimentalSelector: 'img, .crop-area',
|
|
662
|
+
},
|
|
663
|
+
color: {
|
|
664
|
+
__experimentalDuotone: 'img',
|
|
665
|
+
},
|
|
666
|
+
__experimentalSelector: '.my-image',
|
|
667
|
+
};
|
|
668
|
+
const imageBlock = { name: 'core/image', supports: imageSupports };
|
|
669
|
+
const blockTypes = [ imageBlock ];
|
|
670
|
+
|
|
671
|
+
expect( getBlockSelectors( blockTypes ) ).toEqual( {
|
|
672
|
+
'core/image': {
|
|
673
|
+
name: imageBlock.name,
|
|
674
|
+
selector: imageSupports.__experimentalSelector,
|
|
675
|
+
duotoneSelector: imageSupports.color.__experimentalDuotone,
|
|
676
|
+
fallbackGapValue: undefined,
|
|
677
|
+
featureSelectors: {
|
|
678
|
+
border: '.my-image img, .my-image .crop-area',
|
|
679
|
+
},
|
|
680
|
+
hasLayoutSupport: false,
|
|
681
|
+
},
|
|
682
|
+
} );
|
|
683
|
+
} );
|
|
684
|
+
} );
|
|
685
|
+
|
|
686
|
+
describe( 'getStylesDeclarations', () => {
|
|
687
|
+
const blockStyles = {
|
|
688
|
+
spacing: {
|
|
689
|
+
padding: {
|
|
690
|
+
top: '33px',
|
|
691
|
+
right: '33px',
|
|
692
|
+
bottom: '33px',
|
|
693
|
+
left: '33px',
|
|
694
|
+
},
|
|
695
|
+
},
|
|
696
|
+
color: {
|
|
697
|
+
background: 'var:preset|color|light-green-cyan',
|
|
698
|
+
},
|
|
699
|
+
typography: {
|
|
700
|
+
fontFamily: 'sans-serif',
|
|
701
|
+
},
|
|
702
|
+
};
|
|
703
|
+
|
|
704
|
+
it( 'Should output padding variables and other properties if useRootPaddingAwareAlignments is enabled', () => {
|
|
705
|
+
expect(
|
|
706
|
+
getStylesDeclarations( blockStyles, 'body', true )
|
|
707
|
+
).toEqual( [
|
|
708
|
+
'font-family: sans-serif',
|
|
709
|
+
'--wp--style--root--padding-top: 33px',
|
|
710
|
+
'--wp--style--root--padding-right: 33px',
|
|
711
|
+
'--wp--style--root--padding-bottom: 33px',
|
|
712
|
+
'--wp--style--root--padding-left: 33px',
|
|
713
|
+
'background-color: var(--wp--preset--color--light-green-cyan)',
|
|
714
|
+
] );
|
|
715
|
+
} );
|
|
716
|
+
|
|
717
|
+
it( 'Should output padding and other properties if useRootPaddingAwareAlignments is disabled', () => {
|
|
718
|
+
expect(
|
|
719
|
+
getStylesDeclarations( blockStyles, 'body', false )
|
|
720
|
+
).toEqual( [
|
|
721
|
+
'font-family: sans-serif',
|
|
722
|
+
'background-color: var(--wp--preset--color--light-green-cyan)',
|
|
723
|
+
'padding-top: 33px',
|
|
724
|
+
'padding-right: 33px',
|
|
725
|
+
'padding-bottom: 33px',
|
|
726
|
+
'padding-left: 33px',
|
|
727
|
+
] );
|
|
728
|
+
} );
|
|
729
|
+
|
|
730
|
+
it( 'Should not output padding variables if selector is not root', () => {
|
|
731
|
+
expect(
|
|
732
|
+
getStylesDeclarations(
|
|
733
|
+
blockStyles,
|
|
734
|
+
'.wp-block-button__link',
|
|
735
|
+
true
|
|
736
|
+
)
|
|
737
|
+
).toEqual( [
|
|
738
|
+
'font-family: sans-serif',
|
|
739
|
+
'background-color: var(--wp--preset--color--light-green-cyan)',
|
|
740
|
+
'padding-top: 33px',
|
|
741
|
+
'padding-right: 33px',
|
|
742
|
+
'padding-bottom: 33px',
|
|
743
|
+
'padding-left: 33px',
|
|
744
|
+
] );
|
|
745
|
+
} );
|
|
746
|
+
} );
|
|
453
747
|
} );
|
|
@@ -11,8 +11,11 @@ import {
|
|
|
11
11
|
PanelBody,
|
|
12
12
|
FontSizePicker,
|
|
13
13
|
__experimentalSpacer as Spacer,
|
|
14
|
+
__experimentalToggleGroupControl as ToggleGroupControl,
|
|
15
|
+
__experimentalToggleGroupControlOption as ToggleGroupControlOption,
|
|
14
16
|
} from '@wordpress/components';
|
|
15
|
-
|
|
17
|
+
import { __ } from '@wordpress/i18n';
|
|
18
|
+
import { useState } from '@wordpress/element';
|
|
16
19
|
/**
|
|
17
20
|
* Internal dependencies
|
|
18
21
|
*/
|
|
@@ -59,9 +62,14 @@ function useHasLetterSpacingControl( name ) {
|
|
|
59
62
|
}
|
|
60
63
|
|
|
61
64
|
export default function TypographyPanel( { name, element } ) {
|
|
65
|
+
const [ selectedLevel, setCurrentTab ] = useState( 'heading' );
|
|
62
66
|
const supports = getSupportedGlobalStylesPanels( name );
|
|
63
|
-
|
|
64
|
-
|
|
67
|
+
let prefix = '';
|
|
68
|
+
if ( element === 'heading' ) {
|
|
69
|
+
prefix = `elements.${ selectedLevel }.`;
|
|
70
|
+
} else if ( element && element !== 'text' ) {
|
|
71
|
+
prefix = `elements.${ element }.`;
|
|
72
|
+
}
|
|
65
73
|
const [ fontSizes ] = useSetting( 'typography.fontSizes', name );
|
|
66
74
|
const disableCustomFontSizes = ! useSetting(
|
|
67
75
|
'typography.customFontSize',
|
|
@@ -78,6 +86,12 @@ export default function TypographyPanel( { name, element } ) {
|
|
|
78
86
|
const hasAppearanceControl = useHasAppearanceControl( name );
|
|
79
87
|
const hasLetterSpacingControl = useHasLetterSpacingControl( name );
|
|
80
88
|
|
|
89
|
+
/* Disable font size controls when the option to style all headings is selected. */
|
|
90
|
+
let hasFontSizeEnabled = supports.includes( 'fontSize' );
|
|
91
|
+
if ( element === 'heading' && selectedLevel === 'heading' ) {
|
|
92
|
+
hasFontSizeEnabled = false;
|
|
93
|
+
}
|
|
94
|
+
|
|
81
95
|
const [ fontFamily, setFontFamily ] = useStyle(
|
|
82
96
|
prefix + 'typography.fontFamily',
|
|
83
97
|
name
|
|
@@ -130,30 +144,79 @@ export default function TypographyPanel( { name, element } ) {
|
|
|
130
144
|
>
|
|
131
145
|
Aa
|
|
132
146
|
</div>
|
|
133
|
-
|
|
147
|
+
{ element === 'heading' && (
|
|
148
|
+
<div>
|
|
149
|
+
<h4>{ __( 'Select heading level' ) }</h4>
|
|
150
|
+
<ToggleGroupControl
|
|
151
|
+
label={ __( 'Select heading level' ) }
|
|
152
|
+
hideLabelFromVision={ true }
|
|
153
|
+
value={ selectedLevel }
|
|
154
|
+
onChange={ setCurrentTab }
|
|
155
|
+
isBlock
|
|
156
|
+
size="__unstable-large"
|
|
157
|
+
>
|
|
158
|
+
<ToggleGroupControlOption
|
|
159
|
+
value="heading"
|
|
160
|
+
/* translators: 'All' refers to selecting all heading levels
|
|
161
|
+
and applying the same style to h1-h6. */
|
|
162
|
+
label={ __( 'All' ) }
|
|
163
|
+
/>
|
|
164
|
+
<ToggleGroupControlOption
|
|
165
|
+
value="h1"
|
|
166
|
+
label={ __( 'H1' ) }
|
|
167
|
+
/>
|
|
168
|
+
<ToggleGroupControlOption
|
|
169
|
+
value="h2"
|
|
170
|
+
label={ __( 'H2' ) }
|
|
171
|
+
/>
|
|
172
|
+
<ToggleGroupControlOption
|
|
173
|
+
value="h3"
|
|
174
|
+
label={ __( 'H3' ) }
|
|
175
|
+
/>
|
|
176
|
+
<ToggleGroupControlOption
|
|
177
|
+
value="h4"
|
|
178
|
+
label={ __( 'H4' ) }
|
|
179
|
+
/>
|
|
180
|
+
<ToggleGroupControlOption
|
|
181
|
+
value="h5"
|
|
182
|
+
label={ __( 'H5' ) }
|
|
183
|
+
/>
|
|
184
|
+
<ToggleGroupControlOption
|
|
185
|
+
value="h6"
|
|
186
|
+
label={ __( 'H6' ) }
|
|
187
|
+
/>
|
|
188
|
+
</ToggleGroupControl>
|
|
189
|
+
</div>
|
|
190
|
+
) }
|
|
134
191
|
{ supports.includes( 'fontFamily' ) && (
|
|
135
192
|
<FontFamilyControl
|
|
136
193
|
fontFamilies={ fontFamilies }
|
|
137
194
|
value={ fontFamily }
|
|
138
195
|
onChange={ setFontFamily }
|
|
196
|
+
size="__unstable-large"
|
|
139
197
|
/>
|
|
140
198
|
) }
|
|
141
|
-
{
|
|
199
|
+
{ hasFontSizeEnabled && (
|
|
142
200
|
<FontSizePicker
|
|
143
201
|
value={ fontSize }
|
|
144
202
|
onChange={ setFontSize }
|
|
145
203
|
fontSizes={ fontSizes }
|
|
146
204
|
disableCustomFontSizes={ disableCustomFontSizes }
|
|
205
|
+
size="__unstable-large"
|
|
147
206
|
/>
|
|
148
207
|
) }
|
|
149
208
|
{ hasLineHeightEnabled && (
|
|
150
|
-
<
|
|
151
|
-
<
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
209
|
+
<div className="edit-site-typography-panel__half-width-control">
|
|
210
|
+
<Spacer marginBottom={ 6 }>
|
|
211
|
+
<LineHeightControl
|
|
212
|
+
__nextHasNoMarginBottom={ true }
|
|
213
|
+
__unstableInputWidth="auto"
|
|
214
|
+
value={ lineHeight }
|
|
215
|
+
onChange={ setLineHeight }
|
|
216
|
+
size="__unstable-large"
|
|
217
|
+
/>
|
|
218
|
+
</Spacer>
|
|
219
|
+
</div>
|
|
157
220
|
) }
|
|
158
221
|
{ hasAppearanceControl && (
|
|
159
222
|
<FontAppearanceControl
|
|
@@ -170,13 +233,19 @@ export default function TypographyPanel( { name, element } ) {
|
|
|
170
233
|
} }
|
|
171
234
|
hasFontStyles={ hasFontStyles }
|
|
172
235
|
hasFontWeights={ hasFontWeights }
|
|
236
|
+
size="__unstable-large"
|
|
237
|
+
__nextUnconstrainedWidth
|
|
173
238
|
/>
|
|
174
239
|
) }
|
|
175
240
|
{ hasLetterSpacingControl && (
|
|
176
|
-
<
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
241
|
+
<div className="edit-site-typography-panel__half-width-control">
|
|
242
|
+
<LetterSpacingControl
|
|
243
|
+
value={ letterSpacing }
|
|
244
|
+
onChange={ setLetterSpacing }
|
|
245
|
+
size="__unstable-large"
|
|
246
|
+
__unstableInputWidth="auto"
|
|
247
|
+
/>
|
|
248
|
+
</div>
|
|
180
249
|
) }
|
|
181
250
|
</PanelBody>
|
|
182
251
|
);
|