project.tsx 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128
  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. link = true,
  52. }: {
  53. project: Project;
  54. lang: Locale;
  55. look: keyof typeof LOOKS;
  56. /** A local import (sized automatically) or a remote URL with its size. */
  57. image?: string | StaticImageData;
  58. width?: number;
  59. height?: number;
  60. /** Show the corner pill that opens the project. Off makes the card purely visual. */
  61. link?: boolean;
  62. }) {
  63. const l = LOOKS[look];
  64. return (
  65. <div className={cn("group relative h-full w-full overflow-hidden", l.bg)}>
  66. <div className={cn("absolute rounded-full bg-stage-blob", l.blob)} />
  67. {/* The lean is 3D only under the cursor (--tx/--ty are 0 elsewhere): a
  68. perspective at rest held the screenshot in a GPU layer of its own. */}
  69. <div
  70. className={cn(
  71. "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))]",
  72. l.shot,
  73. )}
  74. data-lens
  75. >
  76. {image ? (
  77. <Image
  78. alt={`${project.name}: ${project.blurb}`}
  79. className={cn(
  80. "rounded-2xl shadow-[0_24px_48px_-24px_rgb(0_0_0/0.45)]",
  81. l.img,
  82. )}
  83. height={height}
  84. placeholder={typeof image === "string" ? "empty" : "blur"}
  85. quality={65}
  86. sizes={l.sizes}
  87. src={image}
  88. width={width}
  89. />
  90. ) : (
  91. <div
  92. className={cn(
  93. "grid place-items-center rounded-2xl text-[13px] font-medium text-muted",
  94. l.img,
  95. )}
  96. >
  97. {project.name}
  98. </div>
  99. )}
  100. </div>
  101. {/* The original expanding link, now in liquid glass. */}
  102. {link && (
  103. <a
  104. aria-label={`${project.name}: ${project.blurb}`}
  105. 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"
  106. data-cursor={getMessages(lang).common.openLink(project.linkLabel)}
  107. href={project.href}
  108. rel="noopener noreferrer"
  109. target="_blank"
  110. >
  111. <span aria-hidden className="lg-caustic" />
  112. <span className="grid size-10 shrink-0 place-items-center md:size-11">
  113. <ArrowUpRight className="size-4" />
  114. </span>
  115. <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]">
  116. {project.name}
  117. </span>
  118. </a>
  119. )}
  120. </div>
  121. );
  122. }