File tree Expand file tree Collapse file tree
src/functions/isDarkTheme Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -20,10 +20,19 @@ export function checkIfDarkTheme(el: HTMLElement = document.body): boolean {
2020 // 2. second priority is the data-themes attribute on the body, aka the user setting
2121 // 3. third priority is the system preference
2222 // 4. lastly is the default light theme
23- const darkModeSystemPreference = window ?. matchMedia ?.( '(prefers-color-scheme: dark)' ) ?. matches
24- const darkModeAccountSetting = document . body . getAttribute ( 'data-themes' ) ?. includes ( 'dark' )
25- const darkModeElementOverride = el . closest ( '[data-theme-dark]' ) !== null
26- return darkModeElementOverride || darkModeAccountSetting || darkModeSystemPreference || false
23+ if ( el . closest ( '[data-theme-dark]' ) !== null ) {
24+ return true
25+ }
26+
27+ if ( document . body . getAttribute ( 'data-themes' ) ?. includes ( 'dark' ) ) {
28+ return true
29+ }
30+
31+ if ( window . matchMedia ( '(prefers-color-scheme: dark)' ) ?. matches ) {
32+ return true
33+ }
34+
35+ return false
2736}
2837
2938/**
You can’t perform that action at this time.
0 commit comments