SponsorCard.tsx 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. import classNames from "classnames"
  2. import Image from "next/legacy/image"
  3. import { FormattedMessage } from "react-intl"
  4. const tierName = (tierId) => {
  5. switch(tierId) {
  6. case 'gold':
  7. return <FormattedMessage id="gold_sponsor" defaultMessage="Gold sponsor" />;
  8. case 'silver':
  9. return <FormattedMessage id="silver_sponsor" defaultMessage="Silver sponsor" />;
  10. default:
  11. return <FormattedMessage id="sponsor" defaultMessage="Sponsor" />;
  12. }
  13. };
  14. /** Sponsor Card, supporting data from `silver`, `generalHighlighted`, and `general` */
  15. const SponsorCard = ({ sponsor, tier }) => {
  16. return (
  17. <div
  18. className={classNames(
  19. "grid grid-cols-[auto_1fr] gap-4 rounded p-4",
  20. tier === "generalHighlighted" && "bg-nightshade-900 text-white",
  21. (tier === "silver" || tier === "gold") && "border border-gray-3 hover:bg-gray-4"
  22. )}
  23. >
  24. {(tier === "silver" || tier === "gold") && (
  25. <div className="relative h-[56px] w-[56px] overflow-hidden rounded-md bg-blurple-gradient">
  26. {sponsor.logo && (
  27. <Image src={sponsor.logo} alt="" layout="fill" objectFit="cover" />
  28. )}
  29. </div>
  30. )}
  31. <div
  32. className={classNames("truncate", tier !== "silver" ? "w-full" : null)}
  33. >
  34. <span
  35. className={classNames(
  36. "b3 !leading-[1.5]",
  37. tier === "generalHighlighted"
  38. ? "text-nightshade-100"
  39. : "text-gray-1"
  40. )}
  41. >
  42. {tierName(tier)}
  43. </span>
  44. <p className="b2 truncate !font-semibold">{sponsor.name || sponsor}</p>
  45. </div>
  46. </div>
  47. )
  48. }
  49. export default SponsorCard