-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'develop' of https://github.com/boostcampwm-2024/web30-s…
…top-troublepainter into feature/#141
- Loading branch information
Showing
20 changed files
with
447 additions
and
36 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file not shown.
Binary file not shown.
52 changes: 52 additions & 0 deletions
52
client/src/components/bgm-button/BackgroundMusicButton.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
import { useState } from 'react'; | ||
import soundLogo from '@/assets/sound-logo.svg'; | ||
import { useBackgroundMusic } from '@/hooks/useBackgroundMusic'; | ||
import { cn } from '@/utils/cn'; | ||
|
||
export const BackgroundMusicButton = () => { | ||
const { volume, togglePlay, adjustVolume } = useBackgroundMusic(); | ||
const [isHovered, setIsHovered] = useState(false); | ||
|
||
const isMuted = volume === 0; | ||
|
||
return ( | ||
<div | ||
className="fixed left-4 top-4 z-30 flex flex-col items-center gap-2 xs:left-8 xs:top-8" | ||
onMouseEnter={() => setIsHovered(true)} | ||
onMouseLeave={() => setIsHovered(false)} | ||
> | ||
{/* 음소거/재생 토글 버튼 */} | ||
<button | ||
onClick={togglePlay} | ||
className={cn( | ||
'flex h-10 w-10 items-center justify-center rounded-full bg-chartreuseyellow-600 text-white transition-colors hover:bg-chartreuseyellow-500', | ||
isMuted && 'opacity-50 grayscale', | ||
)} | ||
aria-label={isMuted ? '배경음악 재생' : '배경음악 음소거'} | ||
> | ||
<img src={soundLogo} className="h-8 w-8 transition-all duration-300" /> | ||
</button> | ||
|
||
{/* 볼륨 슬라이더 */} | ||
<div | ||
className={cn( | ||
'flex flex-col items-center rounded-lg bg-chartreuseyellow-500 p-2 transition-all duration-300', | ||
isHovered ? 'translate-y-0 opacity-100' : 'pointer-events-none -translate-y-4 opacity-0', | ||
)} | ||
> | ||
<input | ||
type="range" | ||
min="0" | ||
max="1" | ||
step="0.1" | ||
value={volume} | ||
onChange={(e) => adjustVolume(Number(e.target.value))} | ||
className="h-24 w-1 appearance-none rounded-full bg-chartreuseyellow-200 [-webkit-appearance:slider-vertical] [writing-mode:bt-lr]" | ||
aria-label="배경음악 볼륨 조절" | ||
/> | ||
</div> | ||
</div> | ||
); | ||
}; | ||
|
||
export default BackgroundMusicButton; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.