Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix: Contrast checker: Consider fontSize large when size >= 24px instead of >= 18px #9268

Merged
merged 1 commit into from
Nov 8, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion packages/block-library/src/button/edit.js
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,9 @@ class ButtonEdit extends Component {
>
<ContrastChecker
{ ...{
isLargeText: true,
// Text is considered large if font size is greater or equal to 18pt or 24px,
// currently that's not the case for button.
isLargeText: false,
textColor: textColor.color,
backgroundColor: backgroundColor.color,
fallbackBackgroundColor,
Expand Down
4 changes: 2 additions & 2 deletions packages/editor/src/components/contrast-checker/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ function ContrastChecker( {
backgroundColor,
fallbackBackgroundColor,
fallbackTextColor,
fontSize,
fontSize, // font size value in pixels
isLargeText,
textColor,
} ) {
Expand All @@ -27,7 +27,7 @@ function ContrastChecker( {
if ( hasTransparency || tinycolor.isReadable(
tinyBackgroundColor,
tinyTextColor,
{ level: 'AA', size: ( isLargeText || ( isLargeText !== false && fontSize >= 18 ) ? 'large' : 'small' ) }
{ level: 'AA', size: ( isLargeText || ( isLargeText !== false && fontSize >= 24 ) ? 'large' : 'small' ) }
) ) {
return null;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ exports[`ContrastChecker should render messages when the textColor is valid, but
exports[`ContrastChecker should take into consideration the font size passed 1`] = `
<ContrastChecker
backgroundColor="#C44B4B"
fontSize={17}
fontSize={23}
textColor="#000000"
>
<div
Expand Down Expand Up @@ -141,7 +141,7 @@ exports[`ContrastChecker should take into consideration wherever text is large o
exports[`ContrastChecker should use isLargeText to make decisions if both isLargeText and fontSize props are passed 1`] = `
<ContrastChecker
backgroundColor="#C44B4B"
fontSize={18}
fontSize={24}
isLargeText={false}
textColor="#000000"
>
Expand Down
8 changes: 4 additions & 4 deletions packages/editor/src/components/contrast-checker/test/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ describe( 'ContrastChecker', () => {
<ContrastChecker
backgroundColor="#C44B4B"
textColor="#000000"
fontSize={ 17 }
fontSize={ 23 }
/>
);

Expand All @@ -125,7 +125,7 @@ describe( 'ContrastChecker', () => {
<ContrastChecker
backgroundColor="#C44B4B"
textColor="#000000"
fontSize={ 18 }
fontSize={ 24 }
/>
);

Expand All @@ -137,7 +137,7 @@ describe( 'ContrastChecker', () => {
<ContrastChecker
backgroundColor="#C44B4B"
textColor="#000000"
fontSize={ 17 }
fontSize={ 23 }
isLargeText={ true }
/>
);
Expand All @@ -148,7 +148,7 @@ describe( 'ContrastChecker', () => {
<ContrastChecker
backgroundColor="#C44B4B"
textColor="#000000"
fontSize={ 18 }
fontSize={ 24 }
isLargeText={ false }
/>
);
Expand Down