Skip to content

Commit 561882c

Browse files
committed
add deprecation warning
1 parent 893266f commit 561882c

1 file changed

Lines changed: 19 additions & 5 deletions

File tree

src/button/edit.js

Lines changed: 19 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -67,11 +67,25 @@ const BootstrapButtonEdit = ( {
6767
};
6868

6969
// Fill empty color values with default values and check for usage of deprecated color attribute in styleOptions
70-
const styleOptionsWithDefault = styleOptions.map( ( styleOption ) => ( {
71-
...styleOption,
72-
textColor: styleOption.textColor || DEFAULT_TEXT_COLOR,
73-
bgColor: styleOption.bgColor || styleOption.color || DEFAULT_BG_COLOR, // Fallback to deprecated color attribute
74-
} ) );
70+
let hasDeprecatedColorAttributes = false;
71+
const styleOptionsWithDefault = styleOptions.map( ( styleOption ) => {
72+
if ( styleOption.color ) {
73+
hasDeprecatedColorAttributes = true;
74+
}
75+
return {
76+
...styleOption,
77+
textColor: styleOption.textColor || DEFAULT_TEXT_COLOR,
78+
bgColor:
79+
styleOption.bgColor || styleOption.color || DEFAULT_BG_COLOR, // Fallback to deprecated color attribute
80+
};
81+
} );
82+
83+
if ( hasDeprecatedColorAttributes ) {
84+
// eslint-disable-next-line no-console
85+
console.warn(
86+
'[wpBootstrapBlocks.button.styleOptions filter] The color attribute in styleOptions is deprecated. Please us bgColor and textColor instead.'
87+
);
88+
}
7589

7690
// Prepare CSS rules for selected button style
7791
let inlineStyle = {

0 commit comments

Comments
 (0)