project.tsx 3.7 KB

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