Editor: add text columns to typography support.

Adds a text columns feature to the typography block support that uses CSS `column-count` for multi-column text.

Props ramonopoly, aaronrobertshaw.
Fixes #58549.


git-svn-id: https://develop.svn.wordpress.org/trunk@55985 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
Isabel Brison
2023-06-22 08:16:05 +00:00
parent 3c365e55dc
commit 9a9a672a83
5 changed files with 39 additions and 6 deletions
@@ -25,6 +25,7 @@ class Tests_wpStyleEngine extends WP_UnitTestCase {
* Tests generating block styles and classnames based on various manifestations of the $block_styles argument.
*
* @ticket 56467
* @ticket 58549
*
* @covers ::wp_style_engine_get_styles
*
@@ -189,6 +190,7 @@ class Tests_wpStyleEngine extends WP_UnitTestCase {
'fontStyle' => 'italic',
'fontWeight' => '800',
'lineHeight' => '1.3',
'textColumns' => '2',
'textDecoration' => 'underline',
'textTransform' => 'uppercase',
'letterSpacing' => '2',
@@ -196,13 +198,14 @@ class Tests_wpStyleEngine extends WP_UnitTestCase {
),
'options' => null,
'expected_output' => array(
'css' => 'font-size:clamp(2em, 2vw, 4em);font-family:Roboto,Oxygen-Sans,Ubuntu,sans-serif;font-style:italic;font-weight:800;line-height:1.3;text-decoration:underline;text-transform:uppercase;letter-spacing:2;',
'css' => 'font-size:clamp(2em, 2vw, 4em);font-family:Roboto,Oxygen-Sans,Ubuntu,sans-serif;font-style:italic;font-weight:800;line-height:1.3;column-count:2;text-decoration:underline;text-transform:uppercase;letter-spacing:2;',
'declarations' => array(
'font-size' => 'clamp(2em, 2vw, 4em)',
'font-family' => 'Roboto,Oxygen-Sans,Ubuntu,sans-serif',
'font-style' => 'italic',
'font-weight' => '800',
'line-height' => '1.3',
'column-count' => '2',
'text-decoration' => 'underline',
'text-transform' => 'uppercase',
'letter-spacing' => '2',
+11 -5
View File
@@ -476,6 +476,7 @@ class Tests_Theme_wpThemeJson extends WP_UnitTestCase {
* @ticket 53175
* @ticket 54336
* @ticket 56611
* @ticket 58549
*/
public function test_get_stylesheet() {
$theme_json = new WP_Theme_JSON(
@@ -548,7 +549,7 @@ class Tests_Theme_wpThemeJson extends WP_UnitTestCase {
),
),
'blocks' => array(
'core/group' => array(
'core/group' => array(
'color' => array(
'gradient' => 'var:preset|gradient|custom-gradient',
),
@@ -566,7 +567,7 @@ class Tests_Theme_wpThemeJson extends WP_UnitTestCase {
'padding' => '24px',
),
),
'core/heading' => array(
'core/heading' => array(
'color' => array(
'text' => '#123456',
),
@@ -582,7 +583,7 @@ class Tests_Theme_wpThemeJson extends WP_UnitTestCase {
),
),
),
'core/post-date' => array(
'core/post-date' => array(
'color' => array(
'text' => '#123456',
),
@@ -595,7 +596,12 @@ class Tests_Theme_wpThemeJson extends WP_UnitTestCase {
),
),
),
'core/image' => array(
'core/post-excerpt' => array(
'typography' => array(
'textColumns' => 2,
),
),
'core/image' => array(
'border' => array(
'radius' => array(
'topLeft' => '10px',
@@ -621,7 +627,7 @@ class Tests_Theme_wpThemeJson extends WP_UnitTestCase {
);
$variables = "body{--wp--preset--color--grey: grey;--wp--preset--gradient--custom-gradient: linear-gradient(135deg,rgba(0,0,0) 0%,rgb(0,0,0) 100%);--wp--preset--duotone--custom-duotone: url('#wp-duotone-custom-duotone');--wp--preset--font-family--small: 14px;--wp--preset--font-family--big: 41px;}.wp-block-group{--wp--custom--base-font: 16;--wp--custom--line-height--small: 1.2;--wp--custom--line-height--medium: 1.4;--wp--custom--line-height--large: 1.8;}";
$styles = 'body { margin: 0; }.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; }body{color: var(--wp--preset--color--grey);}a:where(:not(.wp-element-button)){background-color: #333;color: #111;}.wp-element-button, .wp-block-button__link{box-shadow: 10px 10px 5px 0px rgba(0,0,0,0.66);}.wp-block-group{background: var(--wp--preset--gradient--custom-gradient);border-radius: 10px;padding: 24px;}.wp-block-group a:where(:not(.wp-element-button)){color: #111;}.wp-block-heading{color: #123456;}.wp-block-heading a:where(:not(.wp-element-button)){background-color: #333;color: #111;font-size: 60px;}.wp-block-post-date{color: #123456;}.wp-block-post-date a:where(:not(.wp-element-button)){background-color: #777;color: #555;}.wp-block-image{margin-bottom: 30px;}.wp-block-image img, .wp-block-image .components-placeholder{filter: var(--wp--preset--duotone--custom-duotone);}.wp-block-image img, .wp-block-image .wp-block-image__crop-area{border-top-left-radius: 10px;border-bottom-right-radius: 1em;}';
$styles = 'body { margin: 0; }.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; }body{color: var(--wp--preset--color--grey);}a:where(:not(.wp-element-button)){background-color: #333;color: #111;}.wp-element-button, .wp-block-button__link{box-shadow: 10px 10px 5px 0px rgba(0,0,0,0.66);}.wp-block-group{background: var(--wp--preset--gradient--custom-gradient);border-radius: 10px;padding: 24px;}.wp-block-group a:where(:not(.wp-element-button)){color: #111;}.wp-block-heading{color: #123456;}.wp-block-heading a:where(:not(.wp-element-button)){background-color: #333;color: #111;font-size: 60px;}.wp-block-post-date{color: #123456;}.wp-block-post-date a:where(:not(.wp-element-button)){background-color: #777;color: #555;}.wp-block-post-excerpt{column-count: 2;}.wp-block-image{margin-bottom: 30px;}.wp-block-image img, .wp-block-image .components-placeholder{filter: var(--wp--preset--duotone--custom-duotone);}.wp-block-image img, .wp-block-image .wp-block-image__crop-area{border-top-left-radius: 10px;border-bottom-right-radius: 1em;}';
$presets = '.has-grey-color{color: var(--wp--preset--color--grey) !important;}.has-grey-background-color{background-color: var(--wp--preset--color--grey) !important;}.has-grey-border-color{border-color: var(--wp--preset--color--grey) !important;}.has-custom-gradient-gradient-background{background: var(--wp--preset--gradient--custom-gradient) !important;}.has-small-font-family{font-family: var(--wp--preset--font-family--small) !important;}.has-big-font-family{font-family: var(--wp--preset--font-family--big) !important;}';
$all = $variables . $styles . $presets;
$this->assertSame( $all, $theme_json->get_stylesheet() );