Skip to content

Commit

Permalink
Assume light theme when editor canvas background color isn't set (#32477
Browse files Browse the repository at this point in the history
)
  • Loading branch information
tellthemachines authored Jun 8, 2021
1 parent 8fbc4d6 commit 2d37d98
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion packages/block-editor/src/components/editor-styles/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,11 @@ function useDarkThemeBodyClassName( styles ) {
.getComputedStyle( canvas, null )
.getPropertyValue( 'background-color' );

if ( tinycolor( backgroundColor ).getLuminance() > 0.5 ) {
// If background is transparent, it should be treated as light color.
if (
tinycolor( backgroundColor ).getLuminance() > 0.5 ||
tinycolor( backgroundColor ).getAlpha() === 0
) {
body.classList.remove( 'is-dark-theme' );
} else {
body.classList.add( 'is-dark-theme' );
Expand Down

0 comments on commit 2d37d98

Please sign in to comment.