Update switches to include breakpoints
This commit is contained in:
@@ -26,12 +26,26 @@ core.init({
|
||||
|
||||
|
||||
|
||||
|
||||
// deprecated switch handler
|
||||
const flipDeprecated = (e, s = e.currentTarget) => {
|
||||
core.cookie.set("show-deprecated", s.getAttribute("aria-checked"), 30, "/");
|
||||
document.querySelector("main").querySelectorAll("article[data-status=deprecated]").forEach((a) => {
|
||||
a.classList[( s.getAttribute("aria-checked") == "true" ? "add" : "remove" )]("show-deprecated")
|
||||
});
|
||||
const flipInfoSwitch = (e, s = e.currentTarget) => {
|
||||
|
||||
switch(s.getAttribute("id")) {
|
||||
|
||||
case "deprecated" :
|
||||
core.cookie.set("show-deprecated", s.getAttribute("aria-checked"), 30, "/");
|
||||
document.querySelector("main").querySelectorAll("article[data-status=deprecated]").forEach((a) => {
|
||||
a.classList[( s.getAttribute("aria-checked") == "true" ? "add" : "remove" )]("show-deprecated");
|
||||
});
|
||||
break;
|
||||
|
||||
case "breakpoints" :
|
||||
console.log("here")
|
||||
core.cookie.set("show-breakpoints", s.getAttribute("aria-checked"), 30, "/");
|
||||
document.querySelector("html").classList[( s.getAttribute("aria-checked") == "true" ? "add" : "remove" )]("show-breakpoints");
|
||||
break;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// create a pure JS mouse click event
|
||||
@@ -42,15 +56,24 @@ const click = new MouseEvent('click', {
|
||||
});
|
||||
|
||||
// get the switch, initialize it and add the handler
|
||||
let switches = document.querySelector(".info-switches");
|
||||
swtch.init(switches);
|
||||
|
||||
let deprecated = document.querySelector("#deprecated");
|
||||
swtch.init(deprecated.parentNode)
|
||||
deprecated.onclick = flipDeprecated;
|
||||
deprecated.keypress = flipDeprecated;
|
||||
let breakpoints = document.querySelector("#breakpoints");
|
||||
|
||||
deprecated.onclick = flipInfoSwitch;
|
||||
deprecated.keypress = flipInfoSwitch;
|
||||
breakpoints.onclick = flipInfoSwitch;
|
||||
breakpoints.keypress = flipInfoSwitch;
|
||||
|
||||
// check a cookie to get the switch's state
|
||||
if (core.cookie.get("show-deprecated") == "true") {
|
||||
deprecated.dispatchEvent(click);
|
||||
}
|
||||
if (core.cookie.get("show-breakpoints") == "true") {
|
||||
breakpoints.dispatchEvent(click);
|
||||
}
|
||||
|
||||
// just for fun... We'll show deprecated if they match the path
|
||||
// document.querySelector(`#${core.url.p.replace(/\//g, "-")}`).classList.add("show-deprecated");
|
||||
|
Reference in New Issue
Block a user