Download frontend/src/components/Celebration.jsx from MoBkr/dosemate: direct link, hf CLI and curl.
- Browser
- Download file 3.28 kB
-
https://huggingface.co/spaces/MoBkr/dosemate/resolve/main/frontend/src/components/Celebration.jsx
- Command line
-
hf download hf://spaces/MoBkr/dosemate/frontend/src/components/Celebration.jsx
-
curl -L -o Celebration.jsx https://huggingface.co/spaces/MoBkr/dosemate/resolve/main/frontend/src/components/Celebration.jsx
3.28 kB
| import { T } from "../theme" | |
| import { useI18n } from "../i18n/I18nContext" | |
| const CONFETTI_COLORS = ["#16a34a", "#f59e0b", "#3b82f6", "#ef4444", "#0d9488", "#a855f7"] | |
| // Big celebratory overlay shown when the user unlocks one or more badges. | |
| export default function Celebration({ badges, onClose }) { | |
| const { t } = useI18n() | |
| if (!badges || badges.length === 0) return null | |
| const main = badges[0] | |
| const pieces = Array.from({ length: 60 }) | |
| return ( | |
| <div style={overlay} onClick={onClose}> | |
| {/* confetti */} | |
| {pieces.map((_, i) => { | |
| const left = Math.random() * 100 | |
| const delay = Math.random() * 0.6 | |
| const dur = 1.8 + Math.random() * 1.4 | |
| const color = CONFETTI_COLORS[i % CONFETTI_COLORS.length] | |
| const size = 7 + Math.random() * 7 | |
| return ( | |
| <span key={i} style={{ | |
| position: "fixed", top: 0, left: `${left}%`, | |
| width: size, height: size * 1.4, background: color, | |
| borderRadius: 2, opacity: 0, | |
| animation: `confettiFall ${dur}s ${delay}s linear forwards`, | |
| }} /> | |
| ) | |
| })} | |
| <div style={cardStyle} onClick={(e) => e.stopPropagation()}> | |
| <div style={banner}>{t("achievement_unlocked")}</div> | |
| <div style={badgeCircle}> | |
| <span style={{ fontSize: 64, animation: "badgeSpin .7s ease both" }}>{main.emoji}</span> | |
| </div> | |
| <div style={{ fontSize: 13, color: T.muted, marginTop: 18 }}>{t("congrats_badge")}</div> | |
| <div style={{ fontSize: 22, fontWeight: 800, color: T.text, marginTop: 4 }}>{main.label}</div> | |
| {badges.length > 1 && ( | |
| <div style={{ display: "flex", gap: 8, justifyContent: "center", marginTop: 14, flexWrap: "wrap" }}> | |
| {badges.slice(1).map((b) => ( | |
| <span key={b.code} style={miniBadge}>{b.emoji} {b.label}</span> | |
| ))} | |
| </div> | |
| )} | |
| <button onClick={onClose} style={btn}>{t("awesome")}</button> | |
| </div> | |
| </div> | |
| ) | |
| } | |
| const overlay = { position: "fixed", inset: 0, background: "rgba(15,23,42,.6)", display: "flex", alignItems: "center", justifyContent: "center", zIndex: 3000, backdropFilter: "blur(3px)", overflow: "hidden" } | |
| const cardStyle = { position: "relative", width: "90%", maxWidth: 360, background: "#fff", borderRadius: 24, padding: "30px 26px", textAlign: "center", boxShadow: T.shadowLg, animation: "popBig .5s ease both" } | |
| const banner = { display: "inline-block", background: T.gradientWarm, color: "#fff", fontSize: 12, fontWeight: 800, letterSpacing: ".08em", textTransform: "uppercase", padding: "6px 16px", borderRadius: 999 } | |
| const badgeCircle = { width: 120, height: 120, borderRadius: "50%", margin: "22px auto 0", display: "flex", alignItems: "center", justifyContent: "center", background: "radial-gradient(circle at 50% 40%, #fef3c7, #fde68a)", boxShadow: "0 10px 30px rgba(245,158,11,.4)" } | |
| const miniBadge = { fontSize: 12, fontWeight: 600, color: T.muted, background: T.surfaceAlt, border: `1px solid ${T.border}`, borderRadius: 999, padding: "5px 12px" } | |
| const btn = { marginTop: 24, width: "100%", padding: "13px", borderRadius: 12, border: "none", background: T.gradient, color: "#fff", fontSize: 15, fontWeight: 700, cursor: "pointer", boxShadow: T.shadowGreen } | |