/* ═══════════════════════════════════════════════════════════════ FEATURED CARDS A grid of cards that point somewhere: the front page's featured band now, the Community blog's posts next. The data comes from loadFeaturedCards in server/src/shape.js, already resolved, so this only draws. Three kinds of card: record links to the record's own page (hrefs.ts builds it) link links to its URL, a new tab when it leaves the site video VideoPlayer: a still with a play button that swaps in the player when pressed. The still is the card's image, else YouTube's thumbnail, else a plain panel. A photo fills the picture area; a logo sits inside it on a soft panel instead, since cropping a logo to 16:9 cuts it off. The grid is one continuous block: no gaps and no frame, only a colored rule between cards (each card's right and bottom border, with the grid pulled past its clipping wrapper so the outer ones fall outside), 4px thick. With three or more cards the first is the large one, two rows tall, and the next two stack beside it, so it no longer stretches its neighbor. ═══════════════════════════════════════════════════════════════ */ import HomeLink from '../pages/sections/home/HomeLink.tsx' import VideoPlayer from './VideoPlayer.tsx' import { refHref } from '../lib/hrefs.ts' import { mediaUrl } from '../lib/media.ts' import type { FeaturedCard } from '../lib/useFrontPage.ts' import { useSmallImage } from '../lib/useSmallImage.ts' /* Image kinds that are photographs, drawn edge to edge. Anything else is a logo, drawn whole. */ const PHOTO_KINDS = new Set(['event-background', 'featured', 'person']) function hrefFor(card: FeaturedCard): string | null { if (card.kind === 'record' && card.ref) { return refHref(card.ref.kind, card.ref.id, card.ref.org_kind) } return card.kind === 'link' ? card.url : null } function Picture({ card }: { card: FeaturedCard }) { const img = useSmallImage(card.image ? mediaUrl(card.image.file) : null) const photo = card.image ? PHOTO_KINDS.has(card.image.kind) : false if (img.failed) { return
} return photo ? ( ) : (
) } function VideoPicture({ card }: { card: FeaturedCard }) { const own = card.image ? mediaUrl(card.image.file) : null return } const RULE = 'border-brand' function Card({ card, large }: { card: FeaturedCard; large: boolean }) { const href = hrefFor(card) const text = (
{card.eyebrow && (

{card.eyebrow}

)} {card.title && (

{href ? ( // Stretched over the whole card, so the picture and the // blurb are part of the click without nesting links. {card.title} ) : ( card.title )}

)} {card.blurb && (

{card.blurb}

)}
) return (
  • {card.kind === 'video' ? ( // Above the stretched link, which a video card doesn't have // anyway, so the play button always gets the click. Inset // from the card's edges, so the frame sits inside the cell.
    ) : ( )} {text}
  • ) } export default function FeaturedCards({ cards }: { cards: FeaturedCard[] }) { const leadLarge = cards.length >= 3 return (
      {cards.map((card, index) => ( ))}
    ) }