forked from bluelearn-open-source/blue-quotes
-
Notifications
You must be signed in to change notification settings - Fork 0
/
dark.js
52 lines (44 loc) · 1.41 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
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");
}
}