mcServerWebsite/assets/js/header.js
2026-03-25 19:49:56 +01:00

27 lines
701 B
JavaScript

/**
* assets/js/header.js
* ES Module — gestion simple du thème
* Les contrôleurs Stimulus gèrent les interactions interactives
*/
// Fonction pour appliquer le fond d'écran
function applyBackground() {
const body = document.getElementById('page-body');
if (!body) return;
const theme = document.documentElement.getAttribute('data-theme') || 'light';
const bg = theme === 'dark' ? body.dataset.bgDark : body.dataset.bgLight;
if (bg) {
body.style.backgroundImage = `url('${bg}')`;
}
}
// Appliquer le fond au chargement
applyBackground();
// Réappliquer après navigation Turbo
document.addEventListener('turbo:load', () => {
applyBackground();
});