diff --git a/blocks/contrast-checker/index.js b/blocks/contrast-checker/index.js index 8659ba3cfa75e1..db973045eb2ef1 100644 --- a/blocks/contrast-checker/index.js +++ b/blocks/contrast-checker/index.js @@ -20,7 +20,9 @@ function ContrastChecker( { backgroundColor, textColor, isLargeText, fallbackBac } const tinyBackgroundColor = tinycolor( backgroundColor || fallbackBackgroundColor ); const tinyTextColor = tinycolor( textColor || fallbackTextColor ); - if ( tinycolor.isReadable( + const hasTransparency = tinyBackgroundColor.getAlpha() !== 1 || tinyTextColor.getAlpha() !== 1; + + if ( hasTransparency || tinycolor.isReadable( tinyBackgroundColor, tinyTextColor, { level: 'AA', size: ( isLargeText ? 'large' : 'small' ) } diff --git a/blocks/contrast-checker/test/index.js b/blocks/contrast-checker/test/index.js index 545e7dc671213b..f8351e154d199d 100644 --- a/blocks/contrast-checker/test/index.js +++ b/blocks/contrast-checker/test/index.js @@ -15,6 +15,7 @@ describe( 'ContrastChecker', () => { const fallbackBackgroundColor = '#fff'; const fallbackTextColor = '#000'; const sameShade = '#666'; + const colorWithTransparency = 'rgba(102,102,102,0.5)'; const wrapper = mount( { expect( componentWrapper ).toMatchSnapshot(); } ); + test( 'should render render null if background color contains a transparency', () => { + const componentWrapper = mount( + + ); + + expect( componentWrapper.html() ).toBeNull(); + } ); + + test( 'should render render null if text color contains a transparency', () => { + const componentWrapper = mount( + + ); + + expect( componentWrapper.html() ).toBeNull(); + } ); + test( 'should render different message matching snapshot when background color has less brightness than text color.', () => { const darkerShade = '#555'; diff --git a/blocks/library/paragraph/editor.scss b/blocks/library/paragraph/editor.scss index 36c22e7acfc45b..cc49ca86b80702 100644 --- a/blocks/library/paragraph/editor.scss +++ b/blocks/library/paragraph/editor.scss @@ -1,12 +1,3 @@ -.editor-block-list__block:not( .is-multi-selected ) .wp-block-paragraph { - background: white; -} - -// Don't show white background when a nesting parent is selected -.editor-block-list__layout .editor-block-list__layout .editor-block-list__block .wp-block-paragraph { - background: inherit; -} - .blocks-font-size__main { display: flex; justify-content: space-between;