mirror of
https://github.com/gosticks/wordpress-develop.git
synced 2026-08-11 20:30:23 +00:00
Editor: add box shadow support to blocks.
Adds the ability for blocks to declare support for CSS box-shadow and processing of necessary styles. Props madhudollu, sabernhardt, ramonopoly, spacedmonkey, mukesh27. Fixes #58590. git-svn-id: https://develop.svn.wordpress.org/trunk@56046 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
@@ -0,0 +1,89 @@
|
||||
<?php
|
||||
/**
|
||||
* @group block-supports
|
||||
*
|
||||
* @covers ::wp_apply_shadow_support
|
||||
*/
|
||||
class Test_Block_Supports_Shadow extends WP_UnitTestCase {
|
||||
/**
|
||||
* @var string|null
|
||||
*/
|
||||
private $test_block_name;
|
||||
|
||||
public function set_up() {
|
||||
parent::set_up();
|
||||
$this->test_block_name = null;
|
||||
}
|
||||
|
||||
public function tear_down() {
|
||||
unregister_block_type( $this->test_block_name );
|
||||
$this->test_block_name = null;
|
||||
parent::set_up();
|
||||
}
|
||||
|
||||
/**
|
||||
* @ticket 58590
|
||||
*/
|
||||
public function test_shadow_style_is_applied() {
|
||||
$this->test_block_name = 'test/shadow-style-is-applied';
|
||||
register_block_type(
|
||||
$this->test_block_name,
|
||||
array(
|
||||
'api_version' => 3,
|
||||
'attributes' => array(
|
||||
'style' => array(
|
||||
'type' => 'object',
|
||||
),
|
||||
),
|
||||
'supports' => array(
|
||||
'shadow' => true,
|
||||
),
|
||||
)
|
||||
);
|
||||
$registry = WP_Block_Type_Registry::get_instance();
|
||||
$block_type = $registry->get_registered( $this->test_block_name );
|
||||
$block_atts = array(
|
||||
'style' => array(
|
||||
'shadow' => '60px -16px teal',
|
||||
),
|
||||
);
|
||||
|
||||
$actual = wp_apply_shadow_support( $block_type, $block_atts );
|
||||
$expected = array(
|
||||
'style' => 'box-shadow:60px -16px teal;',
|
||||
);
|
||||
|
||||
$this->assertSame( $expected, $actual );
|
||||
}
|
||||
|
||||
/**
|
||||
* @ticket 58590
|
||||
*/
|
||||
public function test_shadow_without_block_supports() {
|
||||
$this->test_block_name = 'test/shadow-with-skipped-serialization-block-supports';
|
||||
register_block_type(
|
||||
$this->test_block_name,
|
||||
array(
|
||||
'api_version' => 2,
|
||||
'attributes' => array(
|
||||
'style' => array(
|
||||
'type' => 'object',
|
||||
),
|
||||
),
|
||||
'supports' => array(),
|
||||
)
|
||||
);
|
||||
$registry = WP_Block_Type_Registry::get_instance();
|
||||
$block_type = $registry->get_registered( $this->test_block_name );
|
||||
$block_atts = array(
|
||||
'style' => array(
|
||||
'shadow' => '60px -16px teal',
|
||||
),
|
||||
);
|
||||
|
||||
$actual = wp_apply_spacing_support( $block_type, $block_atts );
|
||||
$expected = array();
|
||||
|
||||
$this->assertSame( $expected, $actual );
|
||||
}
|
||||
}
|
||||
@@ -26,6 +26,7 @@ class Tests_wpStyleEngine extends WP_UnitTestCase {
|
||||
*
|
||||
* @ticket 56467
|
||||
* @ticket 58549
|
||||
* @ticket 58590
|
||||
*
|
||||
* @covers ::wp_style_engine_get_styles
|
||||
*
|
||||
@@ -182,6 +183,19 @@ class Tests_wpStyleEngine extends WP_UnitTestCase {
|
||||
),
|
||||
),
|
||||
|
||||
'inline_valid_shadow_style' => array(
|
||||
'block_styles' => array(
|
||||
'shadow' => 'inset 5em 1em gold',
|
||||
),
|
||||
'options' => null,
|
||||
'expected_output' => array(
|
||||
'css' => 'box-shadow:inset 5em 1em gold;',
|
||||
'declarations' => array(
|
||||
'box-shadow' => 'inset 5em 1em gold',
|
||||
),
|
||||
),
|
||||
),
|
||||
|
||||
'inline_valid_typography_style' => array(
|
||||
'block_styles' => array(
|
||||
'typography' => array(
|
||||
|
||||
Reference in New Issue
Block a user