add darkmode, minimize js/css

This commit is contained in:
2024-08-09 10:53:16 +02:00
parent db660b3a89
commit 354aa9c3be
11 changed files with 665 additions and 490 deletions
@@ -0,0 +1,27 @@
import { Controller } from '@hotwired/stimulus';
export default class extends Controller {
modes;
currentState;
connect() {
this.modes = $(this.element).find('p');
this.currentState = localStorage.getItem('themeMode');
this.changeState()
}
switch(event) {
var mode = event.params.mode;
this.changeState(mode);
}
changeState(newState) {
if (typeof newState !== 'undefined') {
localStorage.setItem("themeMode", newState);
this.currentState = newState;
}
// $('html').attr('data-bs-theme', this.currentState);
this.modes.filter((e,tmp)=>{
const obj = $(tmp);
obj.toggle(!obj.hasClass(this.currentState));
})
}
}