Skip to content

Commit

Permalink
Add the default eslint react hooks config to the wordpress eslint pac…
Browse files Browse the repository at this point in the history
…kage (#14995)
  • Loading branch information
youknowriad authored Apr 16, 2019
1 parent b080acc commit 7339a09
Show file tree
Hide file tree
Showing 6 changed files with 304 additions and 83 deletions.
7 changes: 7 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

34 changes: 23 additions & 11 deletions packages/block-editor/src/components/contrast-checker/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,22 @@ import { __ } from '@wordpress/i18n';
import { Notice } from '@wordpress/components';
import { useEffect } from '@wordpress/element';

function ContrastCheckerMessage( { tinyBackgroundColor, tinyTextColor, backgroundColor, textColor } ) {
const msg = tinyBackgroundColor.getBrightness() < tinyTextColor.getBrightness() ?
__( 'This color combination may be hard for people to read. Try using a darker background color and/or a brighter text color.' ) :
__( 'This color combination may be hard for people to read. Try using a brighter background color and/or a darker text color.' );
useEffect( () => {
speak( __( 'This color combination may be hard for people to read.' ) );
}, [ backgroundColor, textColor ] );
return (
<div className="editor-contrast-checker block-editor-contrast-checker">
<Notice status="warning" isDismissible={ false }>
{ msg }
</Notice>
</div>
);
}

function ContrastChecker( {
backgroundColor,
fallbackBackgroundColor,
Expand All @@ -33,18 +49,14 @@ function ContrastChecker( {
) ) {
return null;
}
const msg = tinyBackgroundColor.getBrightness() < tinyTextColor.getBrightness() ?
__( 'This color combination may be hard for people to read. Try using a darker background color and/or a brighter text color.' ) :
__( 'This color combination may be hard for people to read. Try using a brighter background color and/or a darker text color.' );
useEffect( () => {
speak( __( 'This color combination may be hard for people to read.' ) );
}, [ backgroundColor, textColor ] );

return (
<div className="editor-contrast-checker block-editor-contrast-checker">
<Notice status="warning" isDismissible={ false }>
{ msg }
</Notice>
</div>
<ContrastCheckerMessage
backgroundColor={ backgroundColor }
textColor={ textColor }
tinyBackgroundColor={ tinyBackgroundColor }
tinyTextColor={ tinyTextColor }
/>
);
}

Expand Down
Loading

0 comments on commit 7339a09

Please sign in to comment.