mirror of
https://github.com/LCE-Hub/LCE-Emerald-Launcher.git
synced 2026-07-18 00:07:09 +00:00
feat: add sfx to toasts
This commit is contained in:
parent
bd632e7e0b
commit
c6b26454e7
BIN
public/sounds/in.ogg
Normal file
BIN
public/sounds/in.ogg
Normal file
Binary file not shown.
BIN
public/sounds/notification.ogg
Normal file
BIN
public/sounds/notification.ogg
Normal file
Binary file not shown.
BIN
public/sounds/out.ogg
Normal file
BIN
public/sounds/out.ogg
Normal file
Binary file not shown.
|
|
@ -1,5 +1,6 @@
|
|||
import { useEffect } from "react";
|
||||
import { motion, AnimatePresence } from "framer-motion";
|
||||
import { useAudio } from "../../context/LauncherContext";
|
||||
|
||||
interface AchievementToastProps {
|
||||
message: string | null;
|
||||
|
|
@ -16,14 +17,24 @@ export function AchievementToast({
|
|||
title = "Error!",
|
||||
variant = "error",
|
||||
}: AchievementToastProps) {
|
||||
const { playSfx } = useAudio();
|
||||
|
||||
useEffect(() => {
|
||||
if (message) {
|
||||
if (variant === "update") {
|
||||
playSfx("notification.ogg");
|
||||
} else {
|
||||
playSfx("in.ogg");
|
||||
}
|
||||
const timer = setTimeout(() => {
|
||||
onClose();
|
||||
}, 8000);
|
||||
return () => clearTimeout(timer);
|
||||
return () => {
|
||||
clearTimeout(timer);
|
||||
playSfx("out.ogg");
|
||||
};
|
||||
}
|
||||
}, [message, onClose]);
|
||||
}, [message, onClose, variant, playSfx]);
|
||||
|
||||
const getIcon = () => {
|
||||
if (variant === "update") {
|
||||
|
|
|
|||
Loading…
Reference in a new issue