Skip to content

Commit

Permalink
[FIX] lightmode when alpha channel = 0
Browse files Browse the repository at this point in the history
[This issue][1] reported that the darkmode of the panel could be applied although the background is white.

When the alpha channel is 0, it takes the color of the document which is `rgb(0,0,0,0)` by default. The extension would thus think the background is black.

Now if the alpha channel is 0, it default to light mode.

[1]: #39
  • Loading branch information
Dj0ulo committed Mar 23, 2024
1 parent fa49756 commit 9d45fca
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions src/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -320,6 +320,9 @@ function getBackgroundColor() {
function isDarkMode() {
try {
const rgba = textColorToRGBA(getBackgroundColor());
if (rgba[3] === 0) {
return false;
}

const av = rgba.slice(0, 3).reduce((a, v) => a + v) / 3;
return av < 128;
Expand Down

0 comments on commit 9d45fca

Please sign in to comment.