From a0e1bb5cb39796bb8470ec477ac8a652d726c57c Mon Sep 17 00:00:00 2001 From: sverhoeven Date: Fri, 26 Jul 2024 14:15:16 +0200 Subject: [PATCH] Use dark mode when class=dark is anywhere in document Instead of just checking html tag --- src/molviewer.tsx | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/src/molviewer.tsx b/src/molviewer.tsx index cf27223..c13120a 100644 --- a/src/molviewer.tsx +++ b/src/molviewer.tsx @@ -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"; }