Agregar soporte para tema claro/oscuro

This commit is contained in:
2026-02-19 14:20:29 -06:00
parent 38a8447a64
commit b79a03e379
3 changed files with 56 additions and 5 deletions

21
templates/footer.php Executable file → Normal file
View File

@@ -5,6 +5,27 @@
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0/dist/js/bootstrap.bundle.min.js"></script>
<script src="https://code.jquery.com/jquery-3.6.0.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/summernote@0.8.18/dist/summernote-lite.min.js"></script>
<script>
(function() {
const html = document.documentElement;
const toggleBtn = document.getElementById('theme-toggle');
const icon = toggleBtn.querySelector('i');
function updateIcon(theme) {
icon.className = theme === 'dark' ? 'bi bi-sun-fill' : 'bi bi-moon-fill';
}
updateIcon(html.getAttribute('data-bs-theme'));
toggleBtn.addEventListener('click', function() {
const currentTheme = html.getAttribute('data-bs-theme');
const newTheme = currentTheme === 'dark' ? 'light' : 'dark';
html.setAttribute('data-bs-theme', newTheme);
document.cookie = 'theme=' + newTheme + ';path=/;max-age=31536000';
updateIcon(newTheme);
});
})();
</script>
<?php if (isset($extraScripts)): ?>
<?= $extraScripts ?>
<?php endif; ?>