-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathapp.js
More file actions
35 lines (31 loc) · 1.08 KB
/
app.js
File metadata and controls
35 lines (31 loc) · 1.08 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
/* Dark / Light mode toggle */
(function () {
const toggle = document.querySelector('[data-theme-toggle]');
const root = document.documentElement;
// Determine initial theme from system preference
let theme = matchMedia('(prefers-color-scheme: dark)').matches ? 'dark' : 'light';
root.setAttribute('data-theme', theme);
if (toggle) {
toggle.addEventListener('click', () => {
theme = theme === 'dark' ? 'light' : 'dark';
root.setAttribute('data-theme', theme);
toggle.setAttribute('aria-label', 'Switch to ' + (theme === 'dark' ? 'light' : 'dark') + ' mode');
});
}
})();
/* "More profiles" collapsible toggle */
(function () {
const btn = document.querySelector('.more-profiles-toggle');
if (!btn) return;
const list = document.getElementById('more-profiles-list');
if (!list) return;
btn.addEventListener('click', () => {
const expanded = btn.getAttribute('aria-expanded') === 'true';
btn.setAttribute('aria-expanded', String(!expanded));
if (expanded) {
list.hidden = true;
} else {
list.hidden = false;
}
});
})();