Created
June 24, 2024 15:19
-
-
Save tfeldmann/c87effd886834a7c2bf37fe9407291f4 to your computer and use it in GitHub Desktop.
Find the currently active django admin mode (light / dark)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function currentTheme() { | |
const currentTheme = localStorage.getItem("theme") || "auto"; | |
const prefersDark = window.matchMedia("(prefers-color-scheme: dark)").matches; | |
if (currentTheme === "auto") { | |
return prefersDark ? "dark" : "light"; | |
} | |
return currentTheme; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment