-
Notifications
You must be signed in to change notification settings - Fork 0
/
script.js
33 lines (28 loc) · 920 Bytes
/
script.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
const body = document.querySelector("body");
const nav = document.querySelector(".nav__ul");
const menu = document.querySelector(".menu");
const close = document.querySelector(".close");
const toggleButton = document.querySelector(".mode");
const logo = document.querySelector(".logo img");
const moon = document.querySelector("#moon");
const sun = document.querySelector("#sun");
const sunMode = () => {
sun.className = "mode--activate";
moon.className = "";
body.className = "";
};
const moonMode = () => {
body.className = "dark";
moon.className = "mode--activate";
sun.className = "";
};
const showNav = () => {
nav.style.transform = "translateX(0px)";
};
const closeNav = () => {
nav.style.transform = "translateX(424px)";
};
menu.addEventListener("click", showNav);
close.addEventListener("click", closeNav);
sun.addEventListener("click", sunMode);
moon.addEventListener("click", moonMode);