js code for a11y toggle
This commit is contained in:
@@ -58,6 +58,28 @@
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
// accessibility toggle
|
||||||
|
|
||||||
|
const STORAGE_KEY = 'extra-css-enabled';
|
||||||
|
|
||||||
|
function applyOverrideState(enabled) {
|
||||||
|
const link = document.getElementById('a11y-css');
|
||||||
|
const button = document.getElementById('a11y-toggle');
|
||||||
|
if (!link) return;
|
||||||
|
|
||||||
|
link.disabled = !enabled;
|
||||||
|
button?.setAttribute('aria-pressed', String(enabled));
|
||||||
|
}
|
||||||
|
|
||||||
|
const enabled = localStorage.getItem(STORAGE_KEY) === 'true';
|
||||||
|
applyOverrideState(enabled);
|
||||||
|
|
||||||
|
document.getElementById('a11y-toggle')?.addEventListener('click', () => {
|
||||||
|
const nextState = localStorage.getItem(STORAGE_KEY) !== 'true';
|
||||||
|
localStorage.setItem(STORAGE_KEY, String(nextState));
|
||||||
|
applyOverrideState(nextState);
|
||||||
|
});
|
||||||
|
|
||||||
// light-dark toggle
|
// light-dark toggle
|
||||||
|
|
||||||
const STORAGE_KEY = 'theme-preference';
|
const STORAGE_KEY = 'theme-preference';
|
||||||
|
|||||||
Reference in New Issue
Block a user