You've already forked wp-bootstrap
v0.3.0 - Polish: accessibility, security, performance, RTL, French translation
Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
@@ -61,6 +61,7 @@
|
||||
var newTheme = currentTheme === 'dark' ? 'light' : 'dark';
|
||||
localStorage.setItem(STORAGE_KEY, newTheme);
|
||||
setTheme(newTheme);
|
||||
announceTheme(newTheme);
|
||||
});
|
||||
});
|
||||
});
|
||||
@@ -71,4 +72,23 @@
|
||||
setTheme(e.matches ? 'dark' : 'light');
|
||||
}
|
||||
});
|
||||
|
||||
/**
|
||||
* Announce theme change to screen readers via a live region.
|
||||
*
|
||||
* @param {string} theme - 'dark' or 'light'
|
||||
*/
|
||||
function announceTheme(theme) {
|
||||
var msg = theme === 'dark' ? 'Dark mode enabled' : 'Light mode enabled';
|
||||
var el = document.getElementById('wp-bootstrap-theme-status');
|
||||
if (!el) {
|
||||
el = document.createElement('div');
|
||||
el.id = 'wp-bootstrap-theme-status';
|
||||
el.setAttribute('role', 'status');
|
||||
el.setAttribute('aria-live', 'polite');
|
||||
el.className = 'visually-hidden';
|
||||
document.body.appendChild(el);
|
||||
}
|
||||
el.textContent = msg;
|
||||
}
|
||||
})();
|
||||
|
||||
Reference in New Issue
Block a user