-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathscripts.js
More file actions
30 lines (25 loc) · 1.14 KB
/
Copy pathscripts.js
File metadata and controls
30 lines (25 loc) · 1.14 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
document.addEventListener('DOMContentLoaded', () => {
const themeSwitch = document.querySelector('.theme-switch');
const root = document.documentElement;
const savedTheme = localStorage.getItem('theme') || 'light';
root.setAttribute('data-theme', savedTheme);
themeSwitch.addEventListener('click', () => {
const currentTheme = root.getAttribute('data-theme');
const newTheme = currentTheme === 'light' ? 'dark' : 'light';
root.setAttribute('data-theme', newTheme);
localStorage.setItem('theme', newTheme);
});
});
document.addEventListener('DOMContentLoaded', () => {
const profileIcon = document.getElementById('profile-icon');
const dropdownMenu = document.getElementById('profile-dropdown');
profileIcon.addEventListener('click', () => {
const isVisible = dropdownMenu.style.display === 'block';
dropdownMenu.style.display = isVisible ? 'none' : 'block';
});
document.addEventListener('click', (event) => {
if (!profileIcon.contains(event.target) && !dropdownMenu.contains(event.target)) {
dropdownMenu.style.display = 'none';
}
});
});