-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathscript.js
More file actions
93 lines (82 loc) · 2.9 KB
/
script.js
File metadata and controls
93 lines (82 loc) · 2.9 KB
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
90
91
92
93
const hamburger = document.querySelector('.hamburger');
const mobileMenu = document.querySelector('.nav-list');
const header = document.querySelector('.header');
const navLink = document.querySelectorAll('.nav-link ');
// console.log(navLinks);
const themeSwitchers = document.querySelectorAll('span');
const dynamicInputs = document.querySelectorAll('input.input-color-picker');
const landingH1s = document.querySelectorAll('#hero h1 span');
const heroH1s = document.querySelectorAll('#hero h1');
const heroName = document.querySelector('#hero h1:nth-child(3)');
console.log(landingH1s);
//* Function to handle the theme color selector
const handleThemeUpdate = (cssVars) => {
const root = document.querySelector(':root');
const keys = Object.keys(cssVars);
keys.forEach((key) => {
inputColor = cssVars[key];
root.style.setProperty(key, cssVars[key]);
console.log(cssVars[key]);
});
};
//* Looping through the inputs provided from the color selector to set the
//* primary color variable.
dynamicInputs.forEach((item) => {
item.addEventListener('input', (e) => {
const cssPropName = `--primary-${e.target.getAttribute('data-id')}`;
console.log(cssPropName);
console.log(e.target.getAttribute('data-id'));
handleThemeUpdate({
[cssPropName]: e.target.value,
});
triggerAnimations();
});
});
const triggerAnimations = function () {
console.log('triggered');
landingH1s.forEach((h1) => {
h1.classList.toggle('activate-show-text');
});
heroH1s.forEach((h1) => {
h1.classList.toggle('activate-reveal-text');
});
heroName.classList.toggle('activate-reveal-name');
};
// * Hamburger Menu Event Listener
hamburger.addEventListener('click', () => {
hamburger.classList.toggle('active');
mobileMenu.classList.toggle('active');
});
//* Change Header Background Color on Scroll
document.addEventListener('scroll', () => {
let scrollPosition = window.scrollY;
if (scrollPosition > 250) {
header.style.backgroundColor = '#1f1e1e96';
} else {
header.style.backgroundColor = 'transparent';
}
});
navLink.forEach((link) => {
link.addEventListener('click', () => {
hamburger.classList.toggle('active');
mobileMenu.classList.toggle('active');
});
});
// * Open an closing the resume modal
const modalContainer = document.querySelector('#modal-container');
const closeButton = document.querySelector('.close-modal');
const closeIcon = document.querySelector('.close-icon');
const resumeButton = document.querySelector('.resume-button');
resumeButton.addEventListener('click', (event) => {
modalContainer.classList.add('show');
header.classList.add('hide');
});
//* Adding event listenters to close modal.
closeButton.addEventListener('click', (event) => {
modalContainer.classList.remove('show');
header.classList.remove('hide');
});
closeIcon.addEventListener('click', (event) => {
modalContainer.classList.remove('show');
header.classList.remove('hide');
});