riffusion-app/components/Pause.tsx

42 lines
1.1 KiB
TypeScript
Raw Normal View History

import { useEffect } from "react";
import { FiPause, FiPlay } from "react-icons/fi";
2022-11-23 22:46:32 -07:00
interface PauseProps {
paused: boolean;
setPaused: (value: boolean) => void;
}
export default function Pause({
paused,
setPaused,
}: PauseProps) {
2022-11-24 21:58:44 -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) {
classNameCondition="fixed z-90 top-28 right-8 bg-sky-300 w-14 h-14 rounded-full drop-shadow-lg flex justify-center items-center text-sky-900 text-2xl hover:bg-sky-500 hover:drop-shadow-2xl"
} else {
classNameCondition="fixed z-90 top-28 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:bg-sky-500 hover:drop-shadow-2xl"
}
2022-11-23 22:46:32 -07:00
return (
<>
<button
title="Pause"
2022-11-24 21:58:44 -07:00
className= {classNameCondition}
onClick={() => setPaused(!paused)}
2022-11-23 22:46:32 -07:00
>
{paused ? <FiPlay /> : <FiPause />}
2022-11-23 22:46:32 -07:00
</button>
</>
);
};