Files
HokmPlay/src/lib/sound-store.ts
T

27 lines
529 B
TypeScript
Raw Normal View History

"use client";
import { create } from "zustand";
import { sound } from "./sound";
interface SoundStore {
sfx: boolean;
music: boolean;
toggleSfx: () => void;
toggleMusic: () => void;
}
export const useSoundStore = create<SoundStore>((set, get) => ({
sfx: sound.sfxEnabled,
music: sound.musicEnabled,
toggleSfx: () => {
const v = !get().sfx;
sound.setSfxEnabled(v);
set({ sfx: v });
},
toggleMusic: () => {
const v = !get().music;
sound.setMusicEnabled(v);
set({ music: v });
},
}));