diff --git a/src/components/buttons/buttons.module.css b/src/components/buttons/buttons.module.css new file mode 100644 index 0000000..e53a005 --- /dev/null +++ b/src/components/buttons/buttons.module.css @@ -0,0 +1,51 @@ +.buttons { + position: sticky; + z-index: 10; + top: 30px; + display: flex; + align-items: center; + justify-content: center; + column-gap: 10px; + + & .playButton { + display: flex; + width: 150px; + height: 45px; + align-items: center; + justify-content: center; + border: none; + border-radius: 100px; + border-top: 2px solid #818cf8; + border-bottom: 3px solid #4f46e5; + background-color: #6366f1; + color: var(--color-foreground); + cursor: pointer; + font-family: var(--font-heading); + font-size: var(--font-base); + line-height: 0; + outline: none; + + & span { + font-size: var(--font-lg); + } + } + + & .shuffleButton { + display: flex; + width: 45px; + height: 45px; + align-items: center; + justify-content: center; + border: none; + border-radius: 100px; + border-top: 2px solid var(--color-neutral-950); + border-bottom: 3px solid var(--color-neutral-600); + background-color: var(--color-neutral-800); + color: var(--color-neutral-200); + cursor: pointer; + font-family: var(--font-heading); + font-size: var(--font-md); + line-height: 0; + outline: none; + } +} diff --git a/src/components/buttons/buttons.tsx b/src/components/buttons/buttons.tsx new file mode 100644 index 0000000..ffbe1c8 --- /dev/null +++ b/src/components/buttons/buttons.tsx @@ -0,0 +1,55 @@ +import { useEffect } from 'react'; +import { BiPause, BiPlay, BiShuffle } from 'react-icons/bi/index'; + +import { useSoundStore } from '@/store'; +import { usePlay } from '@/contexts/play'; + +import styles from './buttons.module.css'; + +export function Buttons() { + const { isPlaying, pause, play, toggle } = usePlay(); + const noSelected = useSoundStore(state => state.noSelected()); + const shuffle = useSoundStore(state => state.shuffle); + + const handleClick = () => { + if (noSelected) return pause(); + + toggle(); + }; + + useEffect(() => { + if (isPlaying && noSelected) pause(); + }, [isPlaying, pause, noSelected]); + + return ( +