2022-11-27 17:46:10 -07:00
|
|
|
import { useEffect } from "react";
|
2022-11-23 15:48:40 -07:00
|
|
|
import { FiPause, FiPlay } from "react-icons/fi";
|
|
|
|
|
2022-11-23 22:46:32 -07:00
|
|
|
interface PauseProps {
|
|
|
|
paused: boolean;
|
|
|
|
setPaused: (value: boolean) => void;
|
|
|
|
}
|
|
|
|
|
2022-11-24 21:16:45 -07:00
|
|
|
export default function Pause({
|
|
|
|
paused,
|
|
|
|
setPaused,
|
|
|
|
}: PauseProps) {
|
2022-11-24 21:58:44 -07:00
|
|
|
|
2022-11-27 17:46:10 -07:00
|
|
|
// Print the state into the console
|
|
|
|
useEffect(() => {
|
|
|
|
if (paused) {
|
|
|
|
console.log("Pause");
|
|
|
|
} else {
|
|
|
|
console.log("Play");
|
|
|
|
}
|
|
|
|
}, [paused]);
|
|
|
|
|
2022-11-24 21:58:44 -07:00
|
|
|
var classNameCondition = ""
|
|
|
|
if (paused) {
|
2022-12-12 10:41:50 -07:00
|
|
|
classNameCondition="animate-pulse fixed z-20 top-4 right-4 md:top-8 md:right-8 w-14 h-14 rounded-full drop-shadow-lg flex justify-center items-center text-white text-2xl bg-red-500 hover:bg-red-600 ring-4 ring-red-700 focus:outline-none hover:drop-shadow-2xl"
|
2022-11-24 21:58:44 -07:00
|
|
|
} else {
|
2022-12-08 15:20:55 -07:00
|
|
|
classNameCondition="fixed z-20 top-4 right-4 md:top-8 md:right-8 bg-slate-100 w-14 h-14 rounded-full drop-shadow-lg flex justify-center items-center text-sky-900 text-2xl hover:text-white hover:bg-sky-600 hover:drop-shadow-2xl"
|
2022-11-24 21:58:44 -07:00
|
|
|
}
|
|
|
|
|
2022-11-23 22:46:32 -07:00
|
|
|
return (
|
|
|
|
<>
|
|
|
|
<button
|
|
|
|
title="Pause"
|
2022-11-24 21:58:44 -07:00
|
|
|
className= {classNameCondition}
|
2022-11-24 21:16:45 -07:00
|
|
|
onClick={() => setPaused(!paused)}
|
2022-11-23 22:46:32 -07:00
|
|
|
>
|
2022-11-24 21:16:45 -07:00
|
|
|
{paused ? <FiPlay /> : <FiPause />}
|
2022-11-23 22:46:32 -07:00
|
|
|
</button>
|
|
|
|
</>
|
|
|
|
);
|
|
|
|
};
|