ViannyCruz commited on
Commit
bc774b9
·
verified ·
1 Parent(s): 83296cb

Update web/index.html

Browse files
Files changed (1) hide show
  1. web/index.html +49 -26
web/index.html CHANGED
@@ -1986,39 +1986,62 @@
1986
  _fObserver.observe(document.body, { childList: true, subtree: true });
1987
  });
1988
  </script>
1989
- <script>
1990
  (function () {
1991
 
1992
- // Inyecta el CSS de transición en el <head>
1993
- const style = document.createElement('style');
1994
- style.textContent = [
1995
- '.theme-transitioning *,',
1996
- '.theme-transitioning *::before,',
1997
- '.theme-transitioning *::after {',
1998
- ' transition:',
1999
- ' background-color 0.25s ease,',
2000
- ' color 0.20s ease,',
2001
- ' border-color 0.20s ease,',
2002
- ' box-shadow 0.20s ease !important;',
2003
- '}'
2004
- ].join('\n');
2005
- document.head.appendChild(style);
2006
-
2007
- // Activa la transición durante el cambio de tema
2008
- function smoothThemeSwitch() {
2009
- document.body.classList.add('theme-transitioning');
 
 
 
 
 
 
 
2010
  setTimeout(function () {
2011
- document.body.classList.remove('theme-transitioning');
2012
- }, 400);
 
 
 
 
 
 
 
 
 
2013
  }
2014
 
2015
- // Intercepta el botón #modeSwitcher que ya existe en tu HTML
2016
  document.addEventListener('DOMContentLoaded', function () {
2017
  const btn = document.getElementById('modeSwitcher');
2018
- if (btn) {
2019
- btn.addEventListener('click', smoothThemeSwitch, true);
2020
- // true = capture phase: se ejecuta antes que el listener de apps.js
2021
- }
 
 
 
 
 
 
 
2022
  });
2023
 
2024
  })();
 
1986
  _fObserver.observe(document.body, { childList: true, subtree: true });
1987
  });
1988
  </script>
1989
+ <script>
1990
  (function () {
1991
 
1992
+ // Crea un overlay negro/blanco que hace fade sobre toda la página
1993
+ const overlay = document.createElement('div');
1994
+ overlay.id = 'theme-overlay';
1995
+ overlay.style.cssText = [
1996
+ 'position:fixed',
1997
+ 'inset:0',
1998
+ 'z-index:99999',
1999
+ 'pointer-events:none',
2000
+ 'opacity:0',
2001
+ 'transition:opacity 0.18s ease',
2002
+ 'background:#fff'
2003
+ ].join(';');
2004
+ document.body.appendChild(overlay);
2005
+
2006
+ function switchTheme() {
2007
+ const lightTheme = document.getElementById('lightTheme');
2008
+ const darkTheme = document.getElementById('darkTheme');
2009
+ const goingDark = !darkTheme.disabled;
2010
+
2011
+ // El overlay es blanco al ir a dark, negro al ir a light
2012
+ overlay.style.background = goingDark ? '#fff' : '#1a1a2e';
2013
+
2014
+ // 1. Fade IN del overlay (tapa la página)
2015
+ overlay.style.opacity = '1';
2016
+
2017
  setTimeout(function () {
2018
+
2019
+ // 2. Cambia el tema mientras está tapado
2020
+ lightTheme.disabled = !lightTheme.disabled;
2021
+ darkTheme.disabled = !darkTheme.disabled;
2022
+
2023
+ // 3. Fade OUT del overlay (revela el nuevo tema)
2024
+ setTimeout(function () {
2025
+ overlay.style.opacity = '0';
2026
+ }, 50);
2027
+
2028
+ }, 180);
2029
  }
2030
 
2031
+ // Reemplaza el comportamiento del botón existente
2032
  document.addEventListener('DOMContentLoaded', function () {
2033
  const btn = document.getElementById('modeSwitcher');
2034
+ if (!btn) return;
2035
+
2036
+ // Clona el botón para eliminar listeners anteriores de apps.js
2037
+ const newBtn = btn.cloneNode(true);
2038
+ btn.parentNode.replaceChild(newBtn, btn);
2039
+
2040
+ newBtn.addEventListener('click', function (e) {
2041
+ e.preventDefault();
2042
+ e.stopPropagation();
2043
+ switchTheme();
2044
+ });
2045
  });
2046
 
2047
  })();