Press n or j to go to the next uncovered block, b, p or k for the previous block.
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 | 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x | 'use client'
import { useEffect } from 'react'
import confetti from 'canvas-confetti'
import { css } from '../../../../styled-system/css'
interface CelebrationBurstProps {
stars: number
onDone: () => void
}
const CELEBRATION_DURATION = 1500
const MESSAGES = ['Nice!', 'Great!', 'Perfect!']
/**
* Brief celebration overlay between words.
* Shows stars and an encouraging message for 1.5s.
* Fires a confetti burst on 3-star celebrations.
*/
export function CelebrationBurst({ stars, onDone }: CelebrationBurstProps) {
useEffect(() => {
const timer = setTimeout(onDone, CELEBRATION_DURATION)
return () => clearTimeout(timer)
}, [onDone])
// Fire a small confetti burst for perfect (3-star) words
useEffect(() => {
if (stars >= 3) {
confetti({
particleCount: 25,
spread: 60,
origin: { x: 0.5, y: 0.4 },
colors: ['#FFD700', '#FFA500', '#FF6347'],
zIndex: 10001,
ticks: 50,
})
}
}, [stars])
const message = stars >= 3 ? MESSAGES[2] : stars >= 2 ? MESSAGES[1] : MESSAGES[0]
return (
<div
data-component="CelebrationBurst"
className={css({
position: 'absolute',
inset: 0,
display: 'flex',
flexDirection: 'column',
alignItems: 'center',
justifyContent: 'center',
bg: 'rgba(255, 255, 255, 0.92)',
zIndex: 10,
animation: 'fadeIn 0.2s ease-out',
})}
>
<div
className={css({
fontSize: '48px',
mb: '3',
animation: 'bounceIn 0.4s ease-out',
})}
>
{'⭐'.repeat(stars)}
</div>
<div
className={css({
fontSize: '2xl',
fontWeight: 'bold',
color: 'orange.600',
animation: 'fadeInScale 0.3s ease-out 0.1s both',
})}
>
{message}
</div>
</div>
)
}
|