25 lines
926 B
JavaScript
25 lines
926 B
JavaScript
import '../css/app.css';
|
|
import './bootstrap';
|
|
import Chart from 'chart.js/auto';
|
|
window.Chart = Chart;
|
|
|
|
// Alpine stores registered via alpine:init — Livewire v3 owns Alpine lifecycle
|
|
document.addEventListener('alpine:init', () => {
|
|
Alpine.store('theme', {
|
|
current: localStorage.getItem('nimuli_theme') || document.documentElement.dataset.theme || 'dark',
|
|
init() { this.apply(this.current); },
|
|
apply(theme) {
|
|
this.current = theme;
|
|
document.documentElement.dataset.theme = theme;
|
|
localStorage.setItem('nimuli_theme', theme);
|
|
document.cookie = 'nimuli_theme=' + theme + '; path=/; max-age=31536000; SameSite=Lax';
|
|
},
|
|
cycle() {
|
|
const order = ['dark', 'light', 'system'];
|
|
this.apply(order[(order.indexOf(this.current) + 1) % order.length]);
|
|
},
|
|
});
|
|
|
|
Alpine.store('sidebar', { open: false });
|
|
});
|