Skip to content

Commit

Permalink
Respect linter
Browse files Browse the repository at this point in the history
  • Loading branch information
Djordje Atlialp committed May 12, 2020
1 parent c6ecbfb commit 9474c64
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 10 deletions.
10 changes: 8 additions & 2 deletions assets/js/menu.js
Original file line number Diff line number Diff line change
Expand Up @@ -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());
Expand All @@ -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);
18 changes: 10 additions & 8 deletions assets/js/theme.js
Original file line number Diff line number Diff line change
@@ -1,23 +1,25 @@
// 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", () => {
document.body.classList.toggle("dark-theme");
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");
});

0 comments on commit 9474c64

Please sign in to comment.