|
1 | | -import React, { useContext, useEffect, useState } from 'react'; |
| 1 | +import React, { useContext, useEffect, useState, useRef } from 'react'; |
2 | 2 | import { motion, useMotionValue, useSpring } from 'framer-motion'; |
3 | 3 | import { DndContext } from '../../context/DndContext'; |
4 | 4 | import DndNavbar from './DndNavbar'; |
5 | 5 | import DndFooter from './DndFooter'; |
6 | 6 | import dndWallpapers from '../../utils/dndWallpapers'; |
7 | 7 | import { parseWallpaperName } from '../../utils/dndUtils'; |
8 | 8 | import '../../styles/dnd-refactor.css'; |
9 | | -import { GameController } from '@phosphor-icons/react'; |
| 9 | +import { GameController, Flame } from '@phosphor-icons/react'; |
| 10 | + |
| 11 | +const FireplaceAudio = () => { |
| 12 | + const [isPlaying, setIsPlaying] = useState(false); |
| 13 | + const audioRef = useRef(null); |
| 14 | + |
| 15 | + const toggleAudio = () => { |
| 16 | + if (isPlaying) { |
| 17 | + audioRef.current.pause(); |
| 18 | + } else { |
| 19 | + audioRef.current.play(); |
| 20 | + } |
| 21 | + setIsPlaying(!isPlaying); |
| 22 | + }; |
| 23 | + |
| 24 | + return ( |
| 25 | + <div className="fixed bottom-8 left-8 z-[110]"> |
| 26 | + <audio |
| 27 | + ref={audioRef} |
| 28 | + src={`${process.env.PUBLIC_URL}/sounds/static.mp3`} // Using static.mp3 as a fireplace crackle proxy if specific fire sound doesn't exist |
| 29 | + loop |
| 30 | + /> |
| 31 | + <button |
| 32 | + onClick={toggleAudio} |
| 33 | + className={`p-4 rounded-full border-2 transition-all shadow-2xl ${isPlaying ? 'bg-dnd-crimson border-dnd-gold text-white animate-pulse' : 'bg-black/40 border-white/10 text-white/40 hover:text-white'}`} |
| 34 | + title="Toggle Ambient Fireplace" |
| 35 | + > |
| 36 | + <Flame size={32} weight={isPlaying ? "fill" : "bold"} /> |
| 37 | + </button> |
| 38 | + </div> |
| 39 | + ); |
| 40 | +}; |
| 41 | + |
| 42 | +const FireOverlay = () => ( |
| 43 | + <div className="dnd-fire-overlay" /> |
| 44 | +); |
10 | 45 |
|
11 | 46 | const DustMotes = () => ( |
12 | 47 | <div className="fixed inset-0 pointer-events-none z-10 overflow-hidden"> |
@@ -170,6 +205,8 @@ const DndLayout = ({ children }) => { |
170 | 205 | return ( |
171 | 206 | <div className="dnd-theme-root min-h-screen flex flex-col relative overflow-x-hidden"> |
172 | 207 | <ViewportFrame /> |
| 208 | + <FireplaceAudio /> |
| 209 | + <FireOverlay /> |
173 | 210 | <Torchlight /> |
174 | 211 | <DiceRoller /> |
175 | 212 | <FireParticles /> |
|
0 commit comments