Skip to content

Commit

Permalink
Use dark mode when class=dark is anywhere in document
Browse files Browse the repository at this point in the history
Instead of just checking html tag
  • Loading branch information
sverhoeven committed Jul 26, 2024
1 parent 99ef427 commit a0e1bb5
Showing 1 changed file with 1 addition and 3 deletions.
4 changes: 1 addition & 3 deletions src/molviewer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,8 @@ import {

function currentBackground() {
let backgroundColor = "white";
if (document?.documentElement?.classList.contains("dark")) {
if (document?.getElementsByClassName("dark").length) {
backgroundColor = "black";
} else if (document?.documentElement?.classList.contains("light")) {
backgroundColor = "white";
} else if (window?.matchMedia("(prefers-color-scheme: dark)").matches) {
backgroundColor = "black";
}
Expand Down

0 comments on commit a0e1bb5

Please sign in to comment.