Skip to content

Commit

Permalink
[RNMobile] Correct colors usage in Button (#21603)
Browse files Browse the repository at this point in the history
* Correct colors usage in Buttons
  • Loading branch information
lukewalczak authored Apr 15, 2020
1 parent 08161b8 commit b1edf9b
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 15 deletions.
37 changes: 22 additions & 15 deletions packages/block-library/src/button/edit.native.js
Original file line number Diff line number Diff line change
Expand Up @@ -152,12 +152,25 @@ class ButtonEdit extends Component {
}

getBackgroundColor() {
const { backgroundColor } = this.props;
if ( backgroundColor.color ) {
// `backgroundColor` which should be set when we are able to resolve it
return backgroundColor.color;
}
return styles.fallbackButton.backgroundColor;
const { backgroundColor, attributes } = this.props;
const { style } = attributes;

return (
( style && style.color && style.color.background ) ||
backgroundColor.color ||
styles.fallbackButton.backgroundColor
);
}

getTextColor() {
const { textColor, attributes } = this.props;
const { style } = attributes;

return (
( style && style.color && style.color.text ) ||
textColor.color ||
styles.fallbackButton.color
);
}

onChangeText( value ) {
Expand Down Expand Up @@ -293,13 +306,7 @@ class ButtonEdit extends Component {
}

render() {
const {
attributes,
textColor,
isSelected,
clientId,
onReplace,
} = this.props;
const { attributes, isSelected, clientId, onReplace } = this.props;
const {
placeholder,
text,
Expand Down Expand Up @@ -365,7 +372,7 @@ class ButtonEdit extends Component {
onChange={ this.onChangeText }
style={ {
...richTextStyle.richText,
color: textColor.color || '#fff',
color: this.getTextColor(),
} }
textAlign="center"
placeholderTextColor={
Expand All @@ -382,7 +389,7 @@ class ButtonEdit extends Component {
this.onToggleButtonFocus( true )
}
__unstableMobileNoFocusOnMount={ ! isSelected }
selectionColor={ textColor.color || '#fff' }
selectionColor={ this.getTextColor() }
onReplace={ onReplace }
onRemove={ () => onReplace( [] ) }
/>
Expand Down
1 change: 1 addition & 0 deletions packages/block-library/src/button/editor.native.scss
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@

.fallbackButton {
background-color: $button-fallback-bg;
color: $white;
}

.clearLinkButton {
Expand Down

0 comments on commit b1edf9b

Please sign in to comment.