import { memo } from "react"; import { useThemeColor } from "renderer/hooks/use-theme-color.hook"; import { motion, Variants } from "framer-motion"; import { useObservable } from "renderer/hooks/use-observable.hook"; import { AudioPlayerService } from "renderer/services/audio-player.service"; import { useService } from "renderer/hooks/use-service.hook"; // Thanks to cheddZy for the icon : https://github.com/cheddZy export const BsManagerIcon = memo(({ className }: { className?: string }) => { const audioPlayer = useService(AudioPlayerService); const { firstColor, secondColor } = useThemeColor(); const playing = useObservable(() => audioPlayer.playing$); const { bpm } = audioPlayer; const transitions: Variants = { playing: { scale: [1, 1.05, 1], transition: { repeat: Infinity, duration: 60 / bpm / 2, repeatDelay: 60 / bpm / 2 }, }, idle: {}, }; const clickAction = () => { if (playing) { audioPlayer.pause(); } else { audioPlayer.resume(); } }; return ( 0 ? "playing" : "idle"} onClick={clickAction}> ); });