-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathscript.js
81 lines (61 loc) · 2.42 KB
/
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
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
// Menu header
const btnMenu = document.querySelector(".btn-menu")
function toggleMenu (event) {
if(event.type === 'touchstart'){
event.preventDefault()
}
const nav = document.querySelector(".header-navegation")
nav.classList.toggle('active')
}
btnMenu.addEventListener('click', toggleMenu)
btnMenu.addEventListener('touchstart', toggleMenu)
// Galeria
const imgs = document.querySelectorAll(".images-container img")
const img1 = document.querySelector(".images-container img:nth-child(1)")
const img2 = document.querySelector(".images-container img:nth-child(2)")
const img3 = document.querySelector(".images-container img:nth-child(3)")
const mainImage = document.querySelector(".main-image")
imgs[1].style = "border-bottom: 5px solid var(--red);margin-bottom: -5px;"
function switchImage(event){
for (let i = 0; i < imgs.length; i++){
imgs[i].style = "border-bottom: none"
}
if (event.target.alt === 'tenis1') {
imgs[0].style = "border-bottom: 5px solid var(--red);margin-bottom: -5px;"
mainImage.attributes[0].value = "assets/tenis-1-ampliado.png"
}else if (event.target.alt === 'tenis2'){
imgs[1].style = "border-bottom: 5px solid var(--red);margin-bottom: -5px;"
mainImage.attributes[0].value = "assets/tenis-2-ampliado.png"
}else{
imgs[2].style = "border-bottom: 5px solid var(--red);margin-bottom: -5px;"
mainImage.attributes[0].value = "assets/tenis-3-ampliado.png"
}
}
img1.addEventListener('click', switchImage)
img2.addEventListener('click', switchImage)
img3.addEventListener('click', switchImage)
// Dark Mode
const switcher = document.querySelector("#checkbox")
const html = document.querySelector('html')
const bag = document.querySelector('.bag')
const logo = document.querySelector('.logo')
const searchIcon = document.querySelector('.search-icon')
const search = document.querySelector('.search')
if(localStorage.darkmode === 'true'){
themeSwitch()
switcher.checked = true
}
function themeSwitch(){
console.log(searchIcon)
html.classList.toggle('dark-mode')
if(document.querySelector('html.dark-mode')){
localStorage.darkmode = 'true'
bag.src = "assets/icon-bag-dark.svg"
logo.src = "assets/logo-dark.svg"
} else {
localStorage.darkmode = 'false'
bag.src = "assets/icon-bag.svg"
logo.src = "assets/logo.svg"
}
}
switcher.addEventListener('change', themeSwitch)