-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.js
75 lines (66 loc) · 2.44 KB
/
main.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
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
import "normalize.css";
import "./style.css";
const header = document.querySelector(".header");
const main = document.querySelector(".main");
const mainNavLinks = document.querySelector(".main__nav-links");
const projectsSection = document.querySelector(".projects-section");
const slidesBtn = document.querySelector(".slides-btn");
const boxBtn = document.querySelector(".box-btn");
const dayNightBtn = document.querySelectorAll(".day-night-btn");
const msgOpenBtns = document.querySelectorAll(".msg-open-btn");
const msgCloseBtn = document.querySelector(".msg-close-btn");
const msgSection = document.querySelector(".msg-section");
const projects = document.querySelector(".projects");
const project = document.querySelectorAll(".project");
const msgStarBtns = document.querySelectorAll(".msg-star-btn");
msgOpenBtns.forEach((msgOpenBtn) => {
msgOpenBtn.addEventListener("click", () => {
msgSection.classList.add("msg-section-display");
header.classList.add("opacity");
mainNavLinks.classList.add("opacity");
projectsSection.classList.add("opacity");
});
});
msgCloseBtn.addEventListener("click", () => {
msgSection.classList.remove("msg-section-display");
header.classList.remove("opacity");
mainNavLinks.classList.remove("opacity");
projectsSection.classList.remove("opacity");
});
msgStarBtns.forEach((starBtn) => {
starBtn.addEventListener("click", () => {
const star = starBtn.firstElementChild;
if (star.getAttribute("class").charAt(2) === "r") {
star.classList.remove("far");
star.classList.remove("fa-star");
star.classList.add("fa");
star.classList.add("fa-star");
} else {
star.classList.remove("fa");
star.classList.remove("fa-star");
star.classList.add("far");
star.classList.add("fa-star");
}
});
});
dayNightBtn.forEach((singleBtn) => {
singleBtn.addEventListener("click", () => {
document.body.classList.toggle("night");
});
});
slidesBtn.addEventListener("click", () => {
slidesBtn.classList.add("nav-link-active");
boxBtn.classList.remove("nav-link-active");
projects.classList.add("projects-slides");
project.forEach((project) => {
project.classList.add("project-grid");
});
});
boxBtn.addEventListener("click", () => {
slidesBtn.classList.remove("nav-link-active");
boxBtn.classList.add("nav-link-active");
projects.classList.remove("projects-slides");
project.forEach((project) => {
project.classList.remove("project-grid");
});
});