Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@
"color": true,
"radius": true,
"width": true,
"__experimentalSelector": "img, .block-editor-media-placeholder",
"__experimentalSelector": "img, .block-editor-media-placeholder, .wp-block-post-featured-image__overlay",
"__experimentalSkipSerialization": true,
"__experimentalDefaultControls": {
"color": true,
Expand Down
17 changes: 9 additions & 8 deletions packages/block-library/src/post-featured-image/index.php
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,14 @@ function get_block_core_post_featured_image_overlay_element_markup( $attributes
return '';
}

$styles = '';
$border_attributes = get_block_core_post_featured_image_border_attributes( $attributes );

// Generate required classes for the element.
if ( ! empty( $border_attributes['class'] ) ) {
$class_names[] = $border_attributes['class'];
}

if ( $has_dim_background ) {
$class_names[] = 'has-background-dim';
$class_names[] = "has-background-dim-{$attributes['dimRatio']}";
Expand All @@ -104,12 +111,8 @@ function get_block_core_post_featured_image_overlay_element_markup( $attributes
}

// Generate required CSS properties and their values.
if ( ! empty( $attributes['style']['border']['radius'] ) ) {
$styles_properties['border-radius'] = $attributes['style']['border']['radius'];
}

if ( ! empty( $attributes['style']['border']['width'] ) ) {
$styles_properties['border-width'] = $attributes['style']['border']['width'];
if ( ! empty( $border_attributes['style'] ) ) {
$styles = "{$border_attributes['style']} ";
}

if ( $has_custom_gradient ) {
Expand All @@ -120,8 +123,6 @@ function get_block_core_post_featured_image_overlay_element_markup( $attributes
$styles_properties['background-color'] = $attributes['customOverlayColor'];
}

$styles = '';

foreach ( $styles_properties as $style_attribute => $style_attribute_value ) {
$styles .= "{$style_attribute}: $style_attribute_value; ";
}
Expand Down
30 changes: 16 additions & 14 deletions packages/block-library/src/post-featured-image/overlay.js
Original file line number Diff line number Diff line change
Expand Up @@ -47,20 +47,22 @@ const Overlay = ( {

return (
<>
<span
aria-hidden="true"
className={ classnames(
'wp-block-post-featured-image__overlay',
dimRatioToClass( dimRatio ),
{
[ overlayColor.class ]: overlayColor.class,
'has-background-dim': dimRatio !== undefined,
'has-background-gradient': gradientValue,
[ gradientClass ]: gradientClass,
}
) }
style={ overlayStyles }
/>
{ !! dimRatio && (
<span
aria-hidden="true"
className={ classnames(
'wp-block-post-featured-image__overlay',
dimRatioToClass( dimRatio ),
{
[ overlayColor.class ]: overlayColor.class,
'has-background-dim': dimRatio !== undefined,
'has-background-gradient': gradientValue,
[ gradientClass ]: gradientClass,
}
) }
style={ overlayStyles }
/>
) }
<InspectorControls __experimentalGroup="color">
<ColorGradientSettingsDropdown
__experimentalHasMultipleOrigins
Expand Down