Skip to content
Snippets Groups Projects
Commit 83dbe166 authored by maria-moroz's avatar maria-moroz
Browse files

Update theme-switcher.js

parent 2b9bc09c
No related branches found
No related tags found
No related merge requests found
......@@ -13,6 +13,12 @@ function onDarkTheme() {
footer.classList.toggle('dark');
footerText.classList.toggle('dark');
filmInfo.classList.toggle('dark-modal');
if (localStorage.getItem('theme') === 'light') {
localStorage.setItem('theme', 'dark');
} else {
localStorage.setItem('theme', 'light');
}
}
export function showSwitcher() {
......@@ -22,3 +28,19 @@ export function showSwitcher() {
export function hideSwitcher() {
switcher.classList.add('visually-hidden');
}
export function checkTheme() {
const currentTheme = localStorage.getItem('theme');
if (currentTheme === null) {
localStorage.setItem('theme', 'light');
return;
}
if (currentTheme === 'light') {
return;
} else {
localStorage.setItem('theme', 'light');
onDarkTheme();
}
}
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment