animation-swith.tsx 1.2 KB

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