set theme color outside of preference (console error)
This commit is contained in:
parent
befda89a25
commit
2ee8042644
1 changed files with 4 additions and 1 deletions
|
|
@ -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);
|
||||
|
|
|
|||
Loading…
Reference in a new issue