feat: add sfx to toasts

This commit is contained in:
KayJann 2026-06-02 01:49:30 +02:00
parent bd632e7e0b
commit c6b26454e7
4 changed files with 13 additions and 2 deletions

BIN
public/sounds/in.ogg Normal file

Binary file not shown.

Binary file not shown.

BIN
public/sounds/out.ogg Normal file

Binary file not shown.

View file

@ -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") {