-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.js
48 lines (39 loc) · 1.39 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
const wrapper = document.querySelector(".wrapper");
const header = document.querySelector(".header");
wrapper.addEventListener("scroll", (e) => {
e.target.scrollTop > 30
? header.classList.add("header-shadow")
: header.classList.remove("header-shadow");
});
const toggleButton = document.querySelector(".dark-light");
toggleButton.addEventListener("click", () => {
document.body.classList.toggle("dark-mode");
});
const jobCards = document.querySelectorAll(".job-card");
const logo = document.querySelector(".logo");
const jobLogos = document.querySelector(".job-logos");
const jobDetailTitle = document.querySelector(
".job-explain-content .job-card-title"
);
const jobBg = document.querySelector(".job-bg");
jobCards.forEach((jobCard) => {
jobCard.addEventListener("click", () => {
const number = Math.floor(Math.random() * 10);
const url = `https://unsplash.it/640/425?image=${number}`;
jobBg.src = url;
const logo = jobCard.querySelector("svg");
const bg = logo.style.backgroundColor;
console.log(bg);
jobBg.style.background = bg;
const title = jobCard.querySelector(".job-card-title");
jobDetailTitle.textContent = title.textContent;
jobLogos.innerHTML = logo.outerHTML;
wrapper.classList.add("detail-page");
wrapper.scrollTop = 0;
});
});
logo.addEventListener("click", () => {
wrapper.classList.remove("detail-page");
wrapper.scrollTop = 0;
jobBg.style.background = bg;
});