project.tsx 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112
  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. {/* The lean is 3D only under the cursor (--tx/--ty are 0 elsewhere): a
  65. perspective at rest held the screenshot in a GPU layer of its own. */}
  66. <div
  67. className={cn(
  68. "absolute rounded-2xl -rotate-[30deg] transition-[rotate,scale,translate] duration-700 ease-[cubic-bezier(.2,.9,.25,1)] group-hover:scale-[1.03] group-hover:-rotate-[27deg] group-hover:[transform:perspective(1100px)_rotateX(calc(var(--ty,0)*-6deg))_rotateY(calc(var(--tx,0)*8deg))]",
  69. l.shot,
  70. )}
  71. data-lens
  72. >
  73. <Image
  74. alt={`${project.name}: ${project.blurb}`}
  75. className={cn(
  76. "rounded-2xl shadow-[0_24px_48px_-24px_rgb(0_0_0/0.45)]",
  77. l.img,
  78. )}
  79. height={height}
  80. placeholder={typeof image === "string" ? "empty" : "blur"}
  81. quality={65}
  82. sizes={l.sizes}
  83. src={image}
  84. width={width}
  85. />
  86. </div>
  87. {/* The original expanding link, now in liquid glass. */}
  88. <a
  89. aria-label={`${project.name}: ${project.blurb}`}
  90. 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"
  91. data-cursor={getMessages(lang).common.openLink(project.linkLabel)}
  92. href={project.href}
  93. rel="noopener noreferrer"
  94. target="_blank"
  95. >
  96. <span aria-hidden className="lg-caustic" />
  97. <span className="grid size-10 shrink-0 place-items-center md:size-11">
  98. <ArrowUpRight className="size-4" />
  99. </span>
  100. <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]">
  101. {project.name}
  102. </span>
  103. </a>
  104. </div>
  105. );
  106. }