set theme color outside of preference (console error)

This commit is contained in:
madrilene 2024-06-25 14:58:23 +02:00
parent befda89a25
commit 2ee8042644

View file

@ -20,6 +20,7 @@ window.onload = () => {
}
reflectPreference();
updateThemeColor();
lightThemeToggle.addEventListener('click', () => onClick('light'));
darkThemeToggle.addEventListener('click', () => onClick('dark'));
@ -58,7 +59,9 @@ function reflectPreference() {
document.firstElementChild.setAttribute('data-theme', theme.value);
document.querySelector('#light-theme-toggle')?.setAttribute('aria-label', lightLabel);
document.querySelector('#dark-theme-toggle')?.setAttribute('aria-label', darkLabel);
// adjust the theme color
}
function updateThemeColor() {
document
.querySelector('meta[name="theme-color"]')
.setAttribute('content', theme.value === 'dark' ? themeColors.dark : themeColors.light);