fix(theme): fix theme not being applied on a single click

This commit is contained in:
zyachel 2024-04-18 23:52:37 +05:30
parent 69f464d7f7
commit c5dff2a617

View file

@ -17,7 +17,8 @@ const setMetaTheme = () => {
// EVENT LISTENER
////////////////////////////////////////////////////////
btnTheme.addEventListener('click', () => {
const themeToSet = document.documentElement.getAttribute('theme') === 'light' ? 'dark' : 'light';
const curTheme = document.documentElement.getAttribute('theme') ?? 'light';
const themeToSet = curTheme === 'light' ? 'dark' : 'light';
setTheme(themeToSet);
if (isLocalStorageAccessible()) localStorage.setItem('theme', themeToSet);
setMetaTheme();