Comparing version 0.3.6 to 0.3.7
@@ -71,8 +71,7 @@ (() => { | ||
const options = switcher.querySelectorAll('button'); | ||
//// Start with user preference | ||
const prefersDarkScheme = window.matchMedia('(prefers-color-scheme: dark)'); | ||
document.documentElement.dataset.theme = (prefersDarkScheme.matches) ? 'dark' : 'light'; | ||
//// Then check for localStorage | ||
const currentTheme = localStorage.getItem('theme'); | ||
document.documentElement.dataset.theme = (currentTheme === 'dark') ? 'dark' : 'light'; | ||
if (currentTheme) { | ||
document.documentElement.dataset.theme = (currentTheme === 'dark') ? 'dark' : 'light'; | ||
} | ||
//// Apply expected theme | ||
@@ -87,4 +86,11 @@ if (document.documentElement.dataset.theme === 'dark') { | ||
option.addEventListener('click', () => { | ||
document.documentElement.dataset.theme = option.dataset.scheme; | ||
localStorage.setItem('theme', option.dataset.scheme); | ||
switcher.querySelector('[aria-pressed="true"]').setAttribute('aria-pressed', 'false'); | ||
option.setAttribute('aria-pressed', 'true'); | ||
if (option.dataset.scheme === 'none') { | ||
delete document.documentElement.dataset.theme; | ||
localStorage.removeItem('theme'); | ||
} else { | ||
document.documentElement.dataset.theme = option.dataset.scheme; | ||
localStorage.setItem('theme', option.dataset.scheme); | ||
} | ||
}); | ||
@@ -91,0 +97,0 @@ }); |
@@ -1,1 +0,1 @@ | ||
(()=>{"use strict";document.querySelectorAll('[role="switch"]').forEach((e=>{e.addEventListener("click",(()=>{const t="true"===e.getAttribute("aria-checked")||!1;e.setAttribute("aria-checked",!t)}))}));const e=document.querySelectorAll(".table-container");window.matchMedia("(min-width: 30em)").matches&&e.forEach((e=>{const t=e.offsetWidth;e.querySelector("table").offsetWidth>t&&e.setAttribute("tabindex","0")}));document.querySelectorAll(".dialog-opener").forEach((e=>{const t=e.nextElementSibling;"DIALOG"===t.nodeName&&e.addEventListener("click",(()=>{t.showModal()}))}));document.querySelectorAll('[type="range"]').forEach((e=>{const t=e.parentNode.querySelector("output");e.addEventListener("input",(()=>{e.style.setProperty("--value",`${e.value}%`),t.style.setProperty("--value",e.value),t.value=e.value})),document.addEventListener("DOMContentLoaded",(()=>{e.style.setProperty("--value",`${e.value}%`),t.style.setProperty("--value",e.value),t.value=e.value}))}));document.querySelectorAll(".toggle").forEach((e=>{const t=e.querySelectorAll("button");t.forEach((e=>{e.addEventListener("click",(()=>{for(let e of t)e.setAttribute("aria-pressed","false");e.setAttribute("aria-pressed","true")}))}))}));const t=document.getElementById("theme").querySelectorAll("button"),r=window.matchMedia("(prefers-color-scheme: dark)");document.documentElement.dataset.theme=r.matches?"dark":"light";const a=localStorage.getItem("theme");document.documentElement.dataset.theme="dark"===a?"dark":"light","dark"===document.documentElement.dataset.theme?document.querySelector('[data-scheme="dark"]').setAttribute("aria-pressed","true"):document.querySelector('[data-scheme="light"]').setAttribute("aria-pressed","true"),t.forEach((e=>{e.addEventListener("click",(()=>{document.documentElement.dataset.theme=e.dataset.scheme,localStorage.setItem("theme",e.dataset.scheme)}))}))})(document); | ||
(()=>{"use strict";document.querySelectorAll('[role="switch"]').forEach((e=>{e.addEventListener("click",(()=>{const t="true"===e.getAttribute("aria-checked")||!1;e.setAttribute("aria-checked",!t)}))}));const e=document.querySelectorAll(".table-container");window.matchMedia("(min-width: 30em)").matches&&e.forEach((e=>{const t=e.offsetWidth;e.querySelector("table").offsetWidth>t&&e.setAttribute("tabindex","0")}));document.querySelectorAll(".dialog-opener").forEach((e=>{const t=e.nextElementSibling;"DIALOG"===t.nodeName&&e.addEventListener("click",(()=>{t.showModal()}))}));document.querySelectorAll('[type="range"]').forEach((e=>{const t=e.parentNode.querySelector("output");e.addEventListener("input",(()=>{e.style.setProperty("--value",`${e.value}%`),t.style.setProperty("--value",e.value),t.value=e.value})),document.addEventListener("DOMContentLoaded",(()=>{e.style.setProperty("--value",`${e.value}%`),t.style.setProperty("--value",e.value),t.value=e.value}))}));document.querySelectorAll(".toggle").forEach((e=>{const t=e.querySelectorAll("button");t.forEach((e=>{e.addEventListener("click",(()=>{for(let e of t)e.setAttribute("aria-pressed","false");e.setAttribute("aria-pressed","true")}))}))}));const t=document.getElementById("theme"),r=t.querySelectorAll("button"),a=localStorage.getItem("theme");a&&(document.documentElement.dataset.theme="dark"===a?"dark":"light"),"dark"===document.documentElement.dataset.theme?document.querySelector('[data-scheme="dark"]').setAttribute("aria-pressed","true"):document.querySelector('[data-scheme="light"]').setAttribute("aria-pressed","true"),r.forEach((e=>{e.addEventListener("click",(()=>{t.querySelector('[aria-pressed="true"]').setAttribute("aria-pressed","false"),e.setAttribute("aria-pressed","true"),"none"===e.dataset.scheme?(delete document.documentElement.dataset.theme,localStorage.removeItem("theme")):(document.documentElement.dataset.theme=e.dataset.scheme,localStorage.setItem("theme",e.dataset.scheme))}))}))})(document); |
{ | ||
"name": "sseeeedd", | ||
"version": "0.3.6", | ||
"version": "0.3.7", | ||
"description": "Sow sseeeedd and see your front-end grow", | ||
@@ -73,3 +73,3 @@ "repository": { | ||
"stylelint-config-recommended-scss": "^13.0.0", | ||
"stylelint-scss": "^5.1.0", | ||
"stylelint-scss": "^5.2.1", | ||
"svg-sprite": "^2.0.2", | ||
@@ -76,0 +76,0 @@ "svgo": "^3.0.2", |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
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
565862
100
5813