You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

45 lines
1.2 KiB

  1. "use client";
  2. import React, { FC, useState } from "react";
  3. export interface BtnLikeIconProps {
  4. className?: string;
  5. colorClass?: string;
  6. isLiked?: boolean;
  7. }
  8. const BtnLikeIcon: FC<BtnLikeIconProps> = ({
  9. className = "",
  10. colorClass = "text-white bg-black bg-opacity-30 hover:bg-opacity-50",
  11. isLiked = false,
  12. }) => {
  13. const [likedState, setLikedState] = useState(isLiked);
  14. return (
  15. <div
  16. className={`nc-BtnLikeIcon w-8 h-8 flex items-center justify-center rounded-full cursor-pointer ${
  17. likedState ? "nc-BtnLikeIcon--liked" : ""
  18. } ${colorClass} ${className}`}
  19. data-nc-id="BtnLikeIcon"
  20. title="Save"
  21. onClick={() => setLikedState(!likedState)}
  22. >
  23. <svg
  24. xmlns="http://www.w3.org/2000/svg"
  25. className="h-5 w-5"
  26. fill={likedState ? "currentColor" : "none"}
  27. viewBox="0 0 24 24"
  28. stroke="currentColor"
  29. >
  30. <path
  31. strokeLinecap="round"
  32. strokeLinejoin="round"
  33. strokeWidth={1.5}
  34. d="M4.318 6.318a4.5 4.5 0 000 6.364L12 20.364l7.682-7.682a4.5 4.5 0 00-6.364-6.364L12 7.636l-1.318-1.318a4.5 4.5 0 00-6.364 0z"
  35. />
  36. </svg>
  37. </div>
  38. );
  39. };
  40. export default BtnLikeIcon;