animation-swith.tsx 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. "use client";
  2. import { Button } from "@heroui/button";
  3. import { Dispatch, FC, SetStateAction } from "react";
  4. import { FaMagic } from "react-icons/fa";
  5. import { FaImage } from "react-icons/fa6";
  6. import { Tooltip } from "@heroui/react";
  7. import { cn } from "@/lib/utils";
  8. export interface AnimationSwitchProps {
  9. className?: string;
  10. animated: boolean;
  11. setAnimated: Dispatch<SetStateAction<boolean>>;
  12. }
  13. export const AnimationSwitch: FC<AnimationSwitchProps> = ({
  14. className,
  15. animated,
  16. setAnimated,
  17. }) => {
  18. const onChange = () => {
  19. setAnimated((prev) => !prev);
  20. };
  21. return (
  22. <div className={cn(className)}>
  23. {!animated ? (
  24. <Tooltip content="Animate it!" placement="bottom">
  25. <Button
  26. isIconOnly
  27. className="dark:border-knight dark:bg-transparent dark:border-2 bg-midnight border-0"
  28. radius="full"
  29. variant="bordered"
  30. onPress={onChange}
  31. >
  32. <FaMagic size={16} />
  33. </Button>
  34. </Tooltip>
  35. ) : (
  36. <Button
  37. isIconOnly
  38. className="dark:border-knight dark:bg-transparent dark:border-2 bg-midnight border-0"
  39. radius="full"
  40. variant="bordered"
  41. onPress={onChange}
  42. >
  43. <FaImage size={16} />
  44. </Button>
  45. )}
  46. </div>
  47. );
  48. };