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.

58 lines
1.7 KiB

  1. import React, { FC } from "react";
  2. import { AuthorType } from "@/data/types";
  3. import { StarIcon } from "@heroicons/react/24/solid";
  4. import Avatar from "@/shared/Avatar";
  5. import Badge from "@/shared/Badge";
  6. import Link from "next/link";
  7. export interface CardAuthorBoxProps {
  8. className?: string;
  9. author: AuthorType;
  10. index?: number;
  11. }
  12. const CardAuthorBox: FC<CardAuthorBoxProps> = ({
  13. className = "",
  14. author,
  15. index,
  16. }) => {
  17. const { displayName, href = "/", avatar, starRating } = author;
  18. return (
  19. <Link
  20. href={href}
  21. className={`nc-CardAuthorBox relative flex flex-col items-center justify-center text-center px-3 py-5 sm:px-6 sm:py-7 [ nc-box-has-hover ] [ nc-dark-box-bg-has-hover ] ${className}`}
  22. >
  23. {index && (
  24. <Badge
  25. className="absolute left-3 top-3"
  26. color={index === 1 ? "red" : index === 2 ? "blue" : "green"}
  27. name={`#${index}`}
  28. />
  29. )}
  30. <Avatar
  31. sizeClass="w-20 h-20 text-2xl"
  32. radius="rounded-full"
  33. imgUrl={avatar}
  34. userName={displayName}
  35. />
  36. <div className="mt-3">
  37. <h2 className={`text-base font-medium`}>
  38. <span className="line-clamp-1">{displayName}</span>
  39. </h2>
  40. <span
  41. className={`block mt-1.5 text-sm text-neutral-500 dark:text-neutral-400`}
  42. >
  43. New York
  44. </span>
  45. </div>
  46. <div className="py-2 px-5 mt-4 bg-neutral-100 dark:bg-neutral-800 rounded-full flex items-center justify-center ">
  47. <span className="text-xs font-medium pt-[1px]">
  48. {starRating || 4.9}
  49. </span>
  50. <StarIcon className="w-5 h-5 text-amber-500 ml-2 " />
  51. </div>
  52. </Link>
  53. );
  54. };
  55. export default CardAuthorBox;