Files
drags-and-nerds/js/theme.js
T

17 lines
735 B
JavaScript

const container = document.querySelector('#colorBtnContainer');
const themeToggler = container.querySelector('.switch input');
const background = document.querySelector('aside > #gradient');
export function themeSwitcher(){
container.style.visibility = 'visible'
console.log('selected switch', themeToggler);
themeToggler.addEventListener('change', (event) => {
if (event.target.checked){
document.documentElement.setAttribute('data-theme', 'light');
background.style.filter = 'invert(1) saturate(333%) brightness(93%) hue-rotate(90deg)';
}else{
document.documentElement.setAttribute('data-theme', 'dark');
background.style.filter = 'unset';
}
})
}