-
Notifications
You must be signed in to change notification settings - Fork 41
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Co-authored-by: Bruno Barbieri <[email protected]>
- Loading branch information
1 parent
1384320
commit eabf2e8
Showing
13 changed files
with
113 additions
and
15 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
import create from 'zustand'; | ||
|
||
import { createStore } from '../internal/createStore'; | ||
|
||
export interface SoundState { | ||
soundsEnabled: boolean; | ||
toggleSoundsEnabled: (enabled: boolean) => void; | ||
} | ||
|
||
export const soundStore = createStore<SoundState>( | ||
(set) => ({ | ||
soundsEnabled: true, | ||
toggleSoundsEnabled: (soundsEnabled) => set({ soundsEnabled }), | ||
}), | ||
{ | ||
persist: { | ||
name: 'sound', | ||
version: 0, | ||
}, | ||
}, | ||
); | ||
|
||
export const useSoundStore = create(soundStore); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
import CorrectSeedQuiz from 'static/assets/audio/correct_seed_quiz.mp3'; | ||
import IncorrectSeedQuiz from 'static/assets/audio/incorrect_seed_quiz.mp3'; | ||
import LockSound from 'static/assets/audio/ui_lock.mp3'; | ||
import UnlockSound from 'static/assets/audio/ui_unlock.mp3'; | ||
import SendSound from 'static/assets/audio/woosh.mp3'; | ||
import { soundStore } from '~/core/state/sound'; | ||
|
||
const SOUNDS = { | ||
CorrectSeedQuiz, | ||
IncorrectSeedQuiz, | ||
LockSound, | ||
SendSound, | ||
UnlockSound, | ||
}; | ||
|
||
export default function playSound(sound: keyof typeof SOUNDS) { | ||
const { soundsEnabled } = soundStore.getState(); | ||
if (soundsEnabled) { | ||
new Audio(SOUNDS[sound]).play(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters