project.tsx 3.7 KB

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