/* ═══════════════════════════════════════════════════════════════ 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. ═══════════════════════════════════════════════════════════════ */ import { useState } from 'react' 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' /* 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 [failed, setFailed] = useState(false) const src = card.image ? mediaUrl(card.image.file) : null const photo = card.image ? PHOTO_KINDS.has(card.image.kind) : false if (!src || failed) { return
} return photo ? ( setFailed(true)} className="aspect-video w-full object-cover" /> ) : (
setFailed(true)} className="max-h-full max-w-full object-contain" />
) } function VideoPicture({ card }: { card: FeaturedCard }) { const own = card.image ? mediaUrl(card.image.file) : null return } function Card({ card }: { card: FeaturedCard }) { 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.
    ) : ( )} {text}
  • ) } export default function FeaturedCards({ cards }: { cards: FeaturedCard[] }) { return ( ) }