Skip to content

Commit

Permalink
Fix preset colors
Browse files Browse the repository at this point in the history
  • Loading branch information
tellthemachines committed Jan 21, 2025
1 parent a18d0de commit fb6550a
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions projects/plugins/jetpack/extensions/blocks/button/button.php
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,7 @@ function get_button_classes( $attributes ) {
$has_custom_gradient = array_key_exists( 'customGradient', $attributes );
$has_border_radius = array_key_exists( 'borderRadius', $attributes );
$has_font_size = array_key_exists( 'fontSize', $attributes );
$has_named_border_color = array_key_exists( 'borderColor', $attributes );

if ( $has_font_size ) {
$classes[] = 'has-' . $attributes['fontSize'] . '-font-size';
Expand All @@ -127,6 +128,10 @@ function get_button_classes( $attributes ) {
$classes[] = sprintf( 'has-%s-color', $attributes['textColor'] );
}

if ( $has_named_border_color ) {
$classes[] = sprintf( 'has-%s-border-color', $attributes['borderColor'] );
}

if (
$has_named_background_color ||
$has_custom_background_color ||
Expand Down Expand Up @@ -172,7 +177,6 @@ function get_button_styles( $attributes ) {
$has_custom_font_size = $has_typography_styles && array_key_exists( 'fontSize', $attributes['style']['typography'] );
$has_custom_text_transform = $has_typography_styles && array_key_exists( 'textTransform', $attributes['style']['typography'] );
$border_styles = array();
$has_named_border_color = array_key_exists( 'borderColor', $attributes );
$has_custom_border_color = array_key_exists( 'style', $attributes ) && array_key_exists( 'border', $attributes['style'] ) && array_key_exists( 'color', $attributes['style']['border'] );
$has_border_style = array_key_exists( 'style', $attributes ) && array_key_exists( 'border', $attributes['style'] ) && array_key_exists( 'style', $attributes['style']['border'] );
$has_border_width = array_key_exists( 'style', $attributes ) && array_key_exists( 'border', $attributes['style'] ) && array_key_exists( 'width', $attributes['style']['border'] );
Expand Down Expand Up @@ -217,9 +221,7 @@ function get_button_styles( $attributes ) {
$styles[] = 'max-width: 100%';
}

if ( $has_named_border_color ) {
$border_styles['color'] = "var:preset|color|{$attributes['borderColor']}";
} elseif ( $has_custom_border_color ) {
if ( $has_custom_border_color ) {
$border_styles['color'] = $attributes['style']['border']['color'];
}

Expand Down

0 comments on commit fb6550a

Please sign in to comment.