Skip to content

Commit 3273b64

Browse files
committed
fix inherited values
1 parent e1a1a8a commit 3273b64

File tree

4 files changed

+26
-22
lines changed

4 files changed

+26
-22
lines changed

src/plugins/global-settings/color-schemes/color-scheme-picker.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ const COLOR_SETTINGS = [ {
6868
property: 'accentColor',
6969
disabledTooltip: {
7070
hover: sprintf( __( 'Changing the %s is not allowed for %s state.', i18n ),
71-
__( 'Text Color', i18n ), __( 'hover', i18n ) ),
71+
__( 'Accent Color', i18n ), __( 'hover', i18n ) ),
7272
},
7373
}, {
7474
label: __( 'Button Color', i18n ),

src/plugins/global-settings/color-schemes/index.php

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -359,10 +359,10 @@ public function get_css_custom_properties( $mode = '' ) {
359359
return $properties_per_state;
360360
}
361361

362-
public function get_inherited_value( $property, $current_state, $mode ) {
362+
public function get_inherited_value( $property, $current_state, $inheritParentHover = true ) {
363363
$value = $property[ $current_state ] ?? false;
364364

365-
if ( ! $value && $current_state == 'desktopHover' && $mode === 'container' ) {
365+
if ( ! $value && $current_state == 'desktopHover' && $inheritParentHover ) {
366366
$value = $property[ 'desktopParentHover' ] ?? false;
367367
}
368368

@@ -425,9 +425,17 @@ public function generate_css_rules( $scheme, $mode = '' ) {
425425
$decls[ $state ][ $css_property ] = $scheme[ $property ][ $state ];
426426
}
427427

428-
$inherited_value = $this->get_inherited_value( $scheme[ $property ], $state, $mode );
429-
if ( $state === 'desktopHover' && ! $this->has_value( $scheme, $property, $state ) && $mode === 'container' ) {
430-
$decls[ $state ][ $css_property ] = $inherited_value;
428+
$inherited_value = $this->get_inherited_value( $scheme[ $property ], $state );
429+
$inherited_normal_value = $this->get_inherited_value( $scheme[ $property ], $state, false );
430+
431+
// Inherit the normal value on hover state
432+
if ( $state === 'desktopHover' && ! $this->has_value( $scheme, $property, $state ) && $inherited_normal_value) {
433+
$decls[ 'desktop' ][ $css_property ] = $inherited_normal_value;
434+
}
435+
436+
// Inherit the parent-hover value on hover state
437+
if ( $state === 'desktopHover' && ! $this->has_value( $scheme, $property, $state ) && $inherited_value) {
438+
$decls[ 'desktopParentHover' ][ $css_property ] = $inherited_value;
431439
}
432440

433441
// If button background color is gradient, plain style buuttons should use the button outline color.

src/plugins/global-settings/color-schemes/utils.js

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -41,11 +41,11 @@ const camelToKebab = property => {
4141
return '--stk-' + result
4242
}
4343

44-
const getInheritedValue = ( property, currentState, mode ) => {
44+
const getInheritedValue = ( property, currentState, inheritParentHover = true ) => {
4545
let value = property?.[ currentState ]
4646

4747
// The block should inherit the desktopParentHover value on hover state if it is a container scheme
48-
if ( ! value && currentState === 'desktopHover' && mode === 'container' ) {
48+
if ( ! value && currentState === 'desktopHover' && inheritParentHover ) {
4949
value = property?.desktopParentHover
5050
}
5151

@@ -93,13 +93,20 @@ export const getCSS = ( scheme, currentHoverState = 'normal', mode = '' ) => {
9393
decls[ state ].push( `${ customProperty }${ suffix }: ${ scheme[ property ]?.[ state ] };` )
9494
}
9595

96-
const inheritedValue = getInheritedValue( scheme[ property ], state, mode )
96+
const inheritedValue = getInheritedValue( scheme[ property ], state )
97+
const inheritedNormalValue = getInheritedValue( scheme[ property ], state, false )
9798
if ( state === 'desktopParentHover' && currentHoverState !== 'normal' && property !== 'backgroundColor' && inheritedValue ) {
9899
decls.desktopHover.push( `${ customProperty }-parent-hover: ${ inheritedValue };` )
99100
}
100101

101-
if ( state === 'desktopHover' && ! scheme[ property ]?.[ state ] && inheritedValue && mode === 'container' ) {
102-
decls[ state ].push( `${ customProperty }${ suffix }: ${ inheritedValue };` )
102+
// Inherit the normal value on hover state
103+
if ( state === 'desktopHover' && ! scheme[ property ]?.[ state ] && inheritedNormalValue ) {
104+
decls.desktop.push( `${ customProperty }${ suffix }: ${ inheritedNormalValue };` )
105+
}
106+
107+
// Inherit the parent-hover value on hover state
108+
if ( state === 'desktopHover' && ! scheme[ property ]?.[ state ] && inheritedValue ) {
109+
decls.desktopParentHover.push( `${ customProperty }${ suffix }: ${ inheritedValue };` )
103110
}
104111

105112
if ( currentHoverState !== 'normal' ) {

src/styles/block-design-system-blocks.scss

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -237,17 +237,6 @@ body:not(.wp-admin) .stk-block-columns:has(> .stk-block-content > .stk-block-col
237237
padding: cssvar(block-background-padding-parent-hover);
238238
}
239239
}
240-
// Inherit parent-hover/normal state colors when hovering over a block.
241-
.stk-block-background {
242-
#{ '--stk-button-background-color-hover' }: var(--stk-button-background-color);
243-
#{ '--stk-button-text-color-hover' }: var(--stk-button-text-color);
244-
#{ '--stk-button-outline-color-hover' }: var(--stk-button-outline-color);
245-
}
246-
// :where(.stk-hover-parent:hover) .stk-block-background {
247-
// #{ '--stk-button-background-color-hover' }: var(--stk-button-background-color);
248-
// #{ '--stk-button-text-color-hover' }: var(--stk-button-text-color);
249-
// #{ '--stk-button-outline-color-hover' }: var(--stk-button-outline-color);
250-
// }
251240

252241
// Images
253242
.stk-img-wrapper {

0 commit comments

Comments
 (0)