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
Have you thought of handling the toggle through JS?
Here's an example
humhub.module('dark-mode').on('humhub:ready',function(event,el){consttoggleSwitch=document.createElement('input');toggleSwitch.setAttribute('type','checkbox');toggleSwitch.setAttribute('id','modeToggle');constlabel=document.createElement('label');label.setAttribute('for','modeToggle');label.textContent='Switch mode:';constcontentContainer=document.querySelector('.dark-mode-container-selector');contentContainer.appendChild(label);contentContainer.appendChild(toggleSwitch);// Function to set the theme based on the toggle statefunctionswitchTheme(e){if(e.target.checked){// Apply night mode theme or trigger HumHub's theme change method// Example: humhub.theme.apply('night-mode');}else{// Apply day mode theme or trigger HumHub's theme change method// Example: humhub.theme.apply('day-mode');}}// Event listener for the toggle switchtoggleSwitch.addEventListener('change',switchTheme);// Logic to check user's preference from HumHub settings or storage// Save user's preference to HumHub settings or storagetoggleSwitch.addEventListener('change',function(e){if(e.target.checked){// Save night mode preference// Example: humhub.settings.set('theme', 'night');}else{// Save day mode preference// Example: humhub.settings.set('theme', 'day');}});});
The text was updated successfully, but these errors were encountered:
Have you thought of handling the toggle through JS?
Here's an example
The text was updated successfully, but these errors were encountered: