topbar anpassungen

This commit is contained in:
2026-03-05 12:51:53 +01:00
parent c5f657c8c8
commit b2dab5bd6c
14 changed files with 494 additions and 113 deletions

View File

@@ -14,18 +14,24 @@ const setIcon = (button, contrast) => {
icon.classList.add(contrast === 'high' ? 'bi-highlights' : 'bi-circle-half');
};
const setPressedState = (button, contrast) => {
button.setAttribute('aria-pressed', contrast === 'high' ? 'true' : 'false');
};
const initContrastToggle = () => {
const button = requireEl('[data-contrast-toggle]', { module: 'contrast-toggle' });
if (!button) {return;}
const root = document.documentElement;
const getCurrent = () => (root.dataset.contrast === 'high' ? 'high' : 'normal');
setIcon(button, getCurrent());
const current = getCurrent();
setIcon(button, current);
setPressedState(button, current);
button.addEventListener('click', () => {
const current = getCurrent();
const next = current === 'high' ? 'normal' : 'high';
const next = getCurrent() === 'high' ? 'normal' : 'high';
setContrast(next);
setIcon(button, next);
setPressedState(button, next);
try {
window.localStorage.setItem(STORAGE_KEY, next);
} catch (e) {