All files / src/features/results MostLovedHero.tsx

100% Statements 1/1
50% Branches 1/2
100% Functions 1/1
100% Lines 1/1

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46                            25x                                                              
import type { Item } from "@/types";
import { itemDisplayName, itemInitial } from "@/lib/items";
import { Card, CardImage } from "@/components/ui";
import Link from "next/link";
 
interface MostLovedHeroProps {
  item: Item;
  collectionId: string;
  heroPhotoUrl?: string;
}
 
/** The affirmation peak of the results page: the single most-loved item, given
 *  real presence. The photograph leads; the lone citron spark marks the moment. */
export function MostLovedHero({ item, collectionId, heroPhotoUrl }: MostLovedHeroProps) {
  return (
    <Link href={`/collections/${collectionId}/items/${item.number}`} className="group block">
      <Card interactive padding="none" className="overflow-hidden">
        <div className="flex flex-col md:flex-row">
          {/* The photograph is the loudest thing on screen. */}
          <div className="relative aspect-4/3 md:aspect-auto md:w-2/5 md:self-stretch bg-content-soft flex items-center justify-center overflow-hidden">
            <CardImage
              src={heroPhotoUrl}
              alt={itemDisplayName(item)}
              fallback={
                <span className="font-display text-7xl text-ink-soft" aria-hidden>
                  {itemInitial(item)}
                </span>
              }
            />
          </div>
 
          {/* The affirmation, held in calm. */}
          <div className="flex flex-1 flex-col justify-center gap-3 p-6 sm:p-10">
            <div className="flex items-center gap-2">
              <span className="h-3.5 w-3.5 shrink-0 rounded-full bg-spark" aria-hidden="true" />
              <h2 className="font-display text-lg text-ink">What you love most</h2>
            </div>
            <p className="font-display text-3xl text-ink sm:text-4xl">{itemDisplayName(item)}</p>
            {item.brand && <p className="text-ink-soft">{item.brand}</p>}
          </div>
        </div>
      </Card>
    </Link>
  );
}