Skip to content

Commit

Permalink
Change the textcolor passed to ContrastChecker
Browse files Browse the repository at this point in the history
  • Loading branch information
Jackie6 committed Mar 29, 2019
1 parent 1d22b84 commit 5c08569
Showing 1 changed file with 15 additions and 1 deletion.
16 changes: 15 additions & 1 deletion packages/block-library/src/paragraph/edit.js
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,20 @@ class ParagraphBlock extends Component {
}
}

getDisplayedTextColor( backgroundColorClass, textColor ) {
// If backgroundColor class is primary, secondary, dark gray, light grary,
// then the displayed color of text is '#fff' (white), even if the textColor remains undefined.
// If backgroundColor class is white, then the displayed color of text is '#111' (black).
// This is a feature to improve accessibility.
if ( backgroundColorClass ) {
if ( backgroundColorClass === 'has-white-background-color' ) {
return '#111';
}
return '#fff';
}
return textColor;
}

render() {
const {
attributes,
Expand Down Expand Up @@ -209,7 +223,7 @@ class ParagraphBlock extends Component {
>
<ContrastChecker
{ ...{
textColor: textColor.color,
textColor: this.getDisplayedTextColor( backgroundColor.class, textColor.color ),
backgroundColor: backgroundColor.color,
fallbackTextColor,
fallbackBackgroundColor,
Expand Down

0 comments on commit 5c08569

Please sign in to comment.