Respect linter
This commit is contained in:
parent
c6ecbfb9e4
commit
9474c646ca
2 changed files with 18 additions and 10 deletions
|
@ -2,7 +2,9 @@
|
|||
|
||||
const menuTrigger = document.querySelector(".menu-trigger");
|
||||
const menu = document.querySelector(".menu");
|
||||
const mobileQuery = getComputedStyle(document.body).getPropertyValue("--phoneWidth");
|
||||
const mobileQuery = getComputedStyle(document.body).getPropertyValue(
|
||||
"--phoneWidth"
|
||||
);
|
||||
const isMobile = () => window.matchMedia(mobileQuery).matches;
|
||||
const isMobileMenu = () => {
|
||||
menuTrigger && menuTrigger.classList.toggle("hidden", !isMobile());
|
||||
|
@ -11,6 +13,10 @@ const isMobileMenu = () => {
|
|||
|
||||
isMobileMenu();
|
||||
|
||||
menuTrigger && menuTrigger.addEventListener("click", () => menu && menu.classList.toggle("hidden"));
|
||||
menuTrigger &&
|
||||
menuTrigger.addEventListener(
|
||||
"click",
|
||||
() => menu && menu.classList.toggle("hidden")
|
||||
);
|
||||
|
||||
window.addEventListener("resize", isMobileMenu);
|
||||
|
|
|
@ -1,13 +1,15 @@
|
|||
// Toggle theme
|
||||
|
||||
const getTheme = window.localStorage && window.localStorage.getItem("theme");
|
||||
const theme = window.localStorage && window.localStorage.getItem("theme");
|
||||
const themeToggle = document.querySelector(".theme-toggle");
|
||||
const isDark = getTheme === "dark";
|
||||
const isDark = theme === "dark";
|
||||
var metaThemeColor = document.querySelector("meta[name=theme-color]");
|
||||
|
||||
if (getTheme !== null) {
|
||||
if (theme !== null) {
|
||||
document.body.classList.toggle("dark-theme", isDark);
|
||||
isDark ? metaThemeColor.setAttribute("content", "#252627") : metaThemeColor.setAttribute("content", "#fafafa");
|
||||
isDark
|
||||
? metaThemeColor.setAttribute("content", "#252627")
|
||||
: metaThemeColor.setAttribute("content", "#fafafa");
|
||||
}
|
||||
|
||||
themeToggle.addEventListener("click", () => {
|
||||
|
@ -15,9 +17,9 @@ themeToggle.addEventListener("click", () => {
|
|||
window.localStorage &&
|
||||
window.localStorage.setItem(
|
||||
"theme",
|
||||
document.body.classList.contains("dark-theme") ? "dark" : "light",
|
||||
document.body.classList.contains("dark-theme") ? "dark" : "light"
|
||||
);
|
||||
document.body.classList.contains("dark-theme") ?
|
||||
metaThemeColor.setAttribute("content", "#252627") : metaThemeColor.setAttribute("content", "#fafafa");
|
||||
;
|
||||
document.body.classList.contains("dark-theme")
|
||||
? metaThemeColor.setAttribute("content", "#252627")
|
||||
: metaThemeColor.setAttribute("content", "#fafafa");
|
||||
});
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue