@assortment/darkmodejs
Advanced tools
Comparing version 1.0.0 to 1.0.1
24
index.js
@@ -16,19 +16,21 @@ module.exports = ({ onChange = () => {} }) => { | ||
if (!isSupported) { | ||
return onChange(themes.NO_SUPP, themes); | ||
if (isSupported) { | ||
if (darkQuery.matches) onChange(themes.DARK, themes); | ||
if (lightQuery.matches) onChange(themes.LIGHT, themes); | ||
if (noPrefQuery.matches) onChange(themes.NO_PREF, themes); | ||
darkQuery.addListener(darkQueryListener); | ||
lightQuery.addListener(lightQueryListener); | ||
} else { | ||
onChange(themes.NO_SUPP, themes); | ||
} | ||
if (darkQuery.matches) onChange(themes.DARK, themes); | ||
if (lightQuery.matches) onChange(themes.LIGHT, themes); | ||
if (noPrefQuery.matches) onChange(themes.NO_PREF, themes); | ||
darkQuery.addListener(darkQueryListener); | ||
lightQuery.addListener(lightQueryListener); | ||
return { | ||
removeListeners: () => { | ||
darkQuery.removeListener(darkQueryListener); | ||
lightQuery.removeListener(lightQueryListener); | ||
if (isSupported) { | ||
darkQuery.removeListener(darkQueryListener); | ||
lightQuery.removeListener(lightQueryListener); | ||
} | ||
} | ||
} | ||
}; |
{ | ||
"name": "@assortment/darkmodejs", | ||
"version": "1.0.0", | ||
"version": "1.0.1", | ||
"description": "Utility package for managing Dark Mode on the web", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
12239
148