mirror of
https://github.com/NNTmux/newznab-tmux.git
synced 2026-09-01 10:48:53 +00:00
32 lines
839 B
JavaScript
32 lines
839 B
JavaScript
/**
|
|
* Alpine.data('themeToggle') - Theme toggle button (cycles light/dark/system)
|
|
* Used on the header theme button and profile edit radio buttons.
|
|
*/
|
|
import Alpine from '@alpinejs/csp';
|
|
|
|
Alpine.data('themeToggle', () => ({
|
|
cycle() {
|
|
Alpine.store('theme').cycle();
|
|
}
|
|
}));
|
|
|
|
Alpine.data('themeRadio', () => ({
|
|
_updating: false,
|
|
|
|
init() {
|
|
// Watch for external theme changes and sync radio buttons
|
|
this.$watch('$store.theme.current', () => {
|
|
if (this._updating) return;
|
|
this._updating = true;
|
|
this.$nextTick(() => { this._updating = false; });
|
|
});
|
|
},
|
|
|
|
select(value) {
|
|
if (this._updating) return;
|
|
this._updating = true;
|
|
Alpine.store('theme').set(value);
|
|
this.$nextTick(() => { this._updating = false; });
|
|
}
|
|
}));
|