-
Notifications
You must be signed in to change notification settings - Fork 110
/
dark.js
89 lines (74 loc) · 2.4 KB
/
dark.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
76
77
78
79
80
81
82
83
84
85
86
87
88
89
let darkMode=false;
var dark=document.getElementById("dark");
var moon=document.getElementById("moon");
var sun=document.getElementById("sun");
var nav=document.getElementById("nav");
var body=document.getElementById("body");
var logo=document.getElementById("logo")
dark.addEventListener('click',handleCLick)
function handleCLick(){
if(darkMode===false){
darkMode=true;
moon.style.visibility="hidden";
sun.style.visibility="visible";
dark.style.backgroundColor="white";
logo.style.color="white";
body.style.backgroundColor="rgb(40, 46, 65)"
nav.style.backgroundColor="#28292e"
// console.log(nav);
}
else{
darkMode=false;
logo.style.color="black";
dark.style.backgroundColor="#2e2f30";
body.style.backgroundColor="#eee"
sun.style.visibility="hidden";
moon.style.visibility="visible";
nav.style.backgroundColor="#dcdee6";
}
// console.log(darkMode);
}
let darkMode = false;
var dark = document.getElementById("dark");
var moon = document.getElementById("moon");
var sun = document.getElementById("sun");
var nav = document.getElementById("nav");
var body = document.getElementById("body");
let logo = document.getElementById("logo")
dark.addEventListener('click', handleCLick)
function handleCLick() {
if (darkMode === false) {
darkMode = true;
moon.style.visibility = "hidden";
sun.style.visibility = "visible";
dark.style.backgroundColor = "white";
body.style.backgroundColor = "rgb(40, 46, 65)"
nav.style.backgroundColor = "#28292e"
logo.src = "./assets/blueQuote_dark.svg"
}
else {
darkMode = false;
dark.style.backgroundColor = "#2e2f30";
body.style.backgroundColor = "#eee"
sun.style.visibility = "hidden";
moon.style.visibility = "visible";
nav.style.backgroundColor = "#dcdee6";
logo.src = "./assets/blueQuote_light.svg"
}
}
function handleClick(){
darkMode=true
console.log(darkMode)
}
// Code for sticky navbar
window.onscroll = function () { myNav() };
var navbar = document.getElementById("nav");
var sticky = navbar.offsetTop;
// Add the sticky class to the navbar when you reach its scroll position. Remove "sticky" when you leave the scroll position
function myNav() {
if (window.pageYOffset >= sticky) {
navbar.classList.add("sticky")
} else {
navbar.classList.remove("sticky");
}
}