Skip to content

Commit 89874d9

Browse files
author
tcaish
committed
added yay sound to score reached
1 parent 432d7ce commit 89874d9

2 files changed

Lines changed: 8 additions & 1 deletion

File tree

src/assets/sounds/yay.mp3

110 KB
Binary file not shown.

src/components/score-reached/score-reached.jsx

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,22 @@
11
import { useEffect } from 'react';
22
import confetti from 'canvas-confetti';
33
import { animateCSS } from '../../exports/functions';
4+
import useSound from 'use-sound';
5+
import YaySound from '../../assets/sounds/yay.mp3';
46
import './score-reached.scss';
57
import './score-reached.mobile.scss';
68

79
function ScoreReached({ scoreReached, setShowScoreReached }) {
10+
const [playYaySound] = useSound(YaySound);
11+
812
// Animate component into view, throw confetti, then animate out
913
useEffect(() => {
1014
// Throw confetti
1115
confetti({ particleCount: 100, spread: 70, origin: { y: 0.3 } });
1216

17+
// Play yay sound
18+
playYaySound();
19+
1320
// Fade in
1421
animateCSS('.score-reached', 'fadeInDown', true).then(() => {
1522
// Fade out after 2.5 seconds
@@ -24,7 +31,7 @@ function ScoreReached({ scoreReached, setShowScoreReached }) {
2431
2500
2532
);
2633
});
27-
}, [setShowScoreReached]);
34+
}, [setShowScoreReached, playYaySound]);
2835

2936
return (
3037
<div className="score-reached">

0 commit comments

Comments
 (0)