import Link from 'next/link' import { buildContentPieceCatalogHref, contentPieceAspectClass, contentPieceMediaKind, } from '@/lib/contentPieceCatalog' import type { ContentPieceHomeItem, ContentPieceHomeMatch } from '@/lib/contentPieceHomeSelection' import { slugify } from '@/lib/slug' import { cn } from '@/lib/utils' import { ContentPieceShareButton } from './ContentPieceActions' import { ContentPieceCardMeta, ContentPieceCardTitle, ContentPieceTagChevron, } from './ContentPieceCardParts' import { ContentPieceMedia } from './ContentPieceMedia' import { CONTENT_PIECE_CARD, CONTENT_PIECE_HOME_LOCAL_TAG, CONTENT_PIECE_HOME_TAG, CONTENT_PIECE_LOCAL_TAG_LINK, CONTENT_PIECE_PIECE_LINK, CONTENT_PIECE_TAG_LINK, } from './contentPieceClasses' const MATCH_LABELS: Record = { municipality: 'Do seu município', region: 'Da sua região', recent: 'Mais recente', } /** * S42 — the canonical facet of a tag, or null when the tag has no honest one * (origin and "Mais recente" stay static). The match only exists with its * label, so the null guard is a contract, never a rendered case. */ const matchHref = (item: ContentPieceHomeItem, match: ContentPieceHomeMatch): string | null => { if (match === 'municipality' && item.cityLabel) { return buildContentPieceCatalogHref({ cidade: slugify(item.cityLabel) }) } if (match === 'region' && item.regionLabel) { return buildContentPieceCatalogHref({ regiao: slugify(item.regionLabel) }) } return null } /** * S39/S42 — the home sample card (artefato: cenas 01/02/05): a lighter sibling * of the catalogue card. Horizontal on the phone (`[124px | 1fr]`, cena 02) and * vertical from `sm` on; the asset is the shared `ContentPieceMedia`, so * video/audio only mount the media after the tap. S42 gives it the direct * shortcut: `Compartilhar` opens the section's own share sheet (the S27 one) * and the honest tags open `/conteudos` already filtered. */ export const ContentPieceHomeCard = ({ item, match, playing, onToggle, onEnded, onShare, }: { item: ContentPieceHomeItem match: ContentPieceHomeMatch playing: boolean onToggle: () => void onEnded: () => void onShare: (item: ContentPieceHomeItem) => void }) => { const typeHref = item.isLink ? null : buildContentPieceCatalogHref({ tipo: item.type }) const matchFacetHref = matchHref(item, match) // S45 — the thumb keeps the form of the type (photo 4:5, Reel 9:16); the // wide kinds (audio/link/text) keep a short fixed column on the phone and the // wide block from `sm` up, where the card becomes a full block. const aspectClass = contentPieceAspectClass(contentPieceMediaKind(item)) return (
{typeHref ? ( {item.typeLabel} ) : ( {item.isLink ? item.originLabel : item.typeLabel} )} {matchFacetHref ? ( {MATCH_LABELS[match]} ) : ( {MATCH_LABELS[match]} )}
Ver esta peça →
) }