You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: app/js/script.js
+3Lines changed: 3 additions & 0 deletions
Original file line number
Diff line number
Diff line change
@@ -130,12 +130,14 @@ let toggleTheme = document.getElementById('toggleTheme');
130
130
letball=document.getElementById('ball');
131
131
lettheme=localStorage.getItem('theme');
132
132
133
+
// Creamos una función que nos permita habiltar el tema oscuro de la página, agregando la clase correspondiente al body y seteando el local storage para guardar el modo.
133
134
constenableDarkTheme=()=>{
134
135
document.body.classList.add('dark-theme');
135
136
localStorage.setItem('theme','darkTheme');
136
137
ball.style.transform='translateX(20px)';
137
138
}
138
139
140
+
// Creamos una función que nos permita deshabiltar el tema oscuro de la página, removiendo la clase al body y seteando el local storage para guardar el modo.
139
141
constdisableDarkTheme=()=>{
140
142
document.body.classList.remove('dark-theme');
141
143
localStorage.setItem('theme','normal');
@@ -146,6 +148,7 @@ if (theme === 'darkTheme'){
146
148
enableDarkTheme()
147
149
}
148
150
151
+
// Cuando se aplique el evento click al botón toggle, si el local storage 'theme' no es 'darkTheme', lo habilitamos y sino lo deshabilitamos.
0 commit comments