project.tsx 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110
  1. import Image, { type StaticImageData } from "next/image";
  2. import { ArrowUpRight } from "./ui";
  3. import type { Project } from "@/config/site";
  4. import type { Locale } from "@/lib/i18n";
  5. import { cn } from "@/lib/utils";
  6. import { getMessages } from "@/messages";
  7. /*
  8. * Each composition keeps the original, hand-tuned placement: a pastel card
  9. * (a deep tint of it in dark mode), a soft pink blob, and the screenshot
  10. * tilted -30°. On top of that the
  11. * screenshot leans toward the cursor (the grid feeds --tx/--ty), lifts on
  12. * hover, and gets a liquid-glass loupe.
  13. */
  14. const LOOKS = {
  15. secondself: {
  16. bg: "bg-stage-sky",
  17. blob: "-bottom-32 left-1/2 h-56 w-64 -translate-x-1/2 md:-bottom-52 md:h-96 md:w-96",
  18. shot: "top-16 left-20 w-[80%] -translate-y-1/2 md:top-36 md:left-44",
  19. img: "h-full w-full object-contain",
  20. sizes: "(max-width: 768px) 300px, 500px",
  21. },
  22. webagent: {
  23. bg: "bg-stage-mint",
  24. blob: "-bottom-96 left-16 h-full w-[145%]",
  25. shot: "top-1/2 left-24 w-[80%] -translate-y-1/2 md:left-32",
  26. img: "h-full w-full object-contain",
  27. sizes: "(max-width: 768px) 300px, 500px",
  28. },
  29. chatbot: {
  30. bg: "bg-stage-butter",
  31. blob: "-top-40 left-40 h-full w-[135%]",
  32. shot: "top-1/2 left-20 w-[400px] -translate-y-1/2 md:left-44 md:w-[800px]",
  33. img: "h-48 object-cover md:h-96",
  34. sizes: "(max-width: 768px) 400px, 800px",
  35. },
  36. paper: {
  37. bg: "bg-stage-lilac",
  38. blob: "-top-40 left-40 h-full w-[135%]",
  39. shot: "top-16 left-12 w-full -translate-y-1/2 md:top-1/2 md:left-16",
  40. img: "h-full w-full object-contain",
  41. sizes: "(max-width: 768px) 300px, 500px",
  42. },
  43. } as const;
  44. export function ProjectCard({
  45. project,
  46. look,
  47. image,
  48. width,
  49. height,
  50. lang,
  51. }: {
  52. project: Project;
  53. lang: Locale;
  54. look: keyof typeof LOOKS;
  55. /** A local import (sized automatically) or a remote URL with its size. */
  56. image: string | StaticImageData;
  57. width?: number;
  58. height?: number;
  59. }) {
  60. const l = LOOKS[look];
  61. return (
  62. <div className={cn("group relative h-full w-full overflow-hidden", l.bg)}>
  63. <div className={cn("absolute rounded-full bg-stage-blob", l.blob)} />
  64. <div
  65. className={cn(
  66. "absolute rounded-2xl -rotate-[30deg] transition-[rotate,scale,translate] duration-700 ease-[cubic-bezier(.2,.9,.25,1)] [transform:perspective(1100px)_rotateX(calc(var(--ty,0)*-6deg))_rotateY(calc(var(--tx,0)*8deg))] group-hover:scale-[1.03] group-hover:-rotate-[27deg]",
  67. l.shot,
  68. )}
  69. data-lens
  70. >
  71. <Image
  72. alt={`${project.name}: ${project.blurb}`}
  73. className={cn(
  74. "rounded-2xl shadow-[0_24px_48px_-24px_rgb(0_0_0/0.45)]",
  75. l.img,
  76. )}
  77. height={height}
  78. placeholder={typeof image === "string" ? "empty" : "blur"}
  79. quality={65}
  80. sizes={l.sizes}
  81. src={image}
  82. width={width}
  83. />
  84. </div>
  85. {/* The original expanding link, now in liquid glass. */}
  86. <a
  87. aria-label={`${project.name}: ${project.blurb}`}
  88. className="lg absolute bottom-2 left-2 z-10 flex h-10 max-w-10 items-center overflow-hidden rounded-full p-0 transition-[max-width] duration-500 ease-[cubic-bezier(.2,.9,.25,1)] group-hover:max-w-[calc(100%-1rem)] focus-visible:max-w-[calc(100%-1rem)] md:h-11 md:max-w-11"
  89. data-cursor={getMessages(lang).common.openLink(project.linkLabel)}
  90. href={project.href}
  91. rel="noopener noreferrer"
  92. target="_blank"
  93. >
  94. <span aria-hidden className="lg-caustic" />
  95. <span className="grid size-10 shrink-0 place-items-center md:size-11">
  96. <ArrowUpRight className="size-4" />
  97. </span>
  98. <span className="pr-4 text-[13px] font-medium whitespace-nowrap opacity-0 transition-opacity duration-300 group-hover:opacity-100 group-focus-visible:opacity-100 md:text-[14px]">
  99. {project.name}
  100. </span>
  101. </a>
  102. </div>
  103. );
  104. }