Files
crosscode-platform/apps/website/frontend/src/site/MessagePlayer.tsx
T
joshuaandClaude Opus 5.5 5ed7201efa feat(website): the four templates and the public site
Heritage, Bold, Community and Clean drawing all 26 section variants
with their headers, homepage order and style settings; colours made
safe (WCAG AA) by the backend; fonts and corners from the shared brand
style. Publishing into numbered versions, the content API with live
messages and events and the church profile from Accounts, uploads,
every page kind, simple event pages, Coming soon, 404, sitemap, SEO
basics and the church's JSON-LD. The demo church (npm run demo) and
Playwright e2e: every template's pages pass axe and the SEO checks.
website.sh builds packages/seo. Decision 17 (first Owner) recorded.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-25 10:59:03 +02:00

34 lines
1.7 KiB
TypeScript

"use client";
import { useState } from "react";
/**
* A message's video or audio, loaded only when clicked (WEBSITE-1.0-PLAN §7): a thumbnail first,
* then youtube-nocookie or Spotify's player. Nothing loads from YouTube or Spotify until then.
*/
export function MessagePlayer({ title, embedUrl, thumbnail, url, source, className }: { title: string; embedUrl: string | null; thumbnail: string | null; url: string; source: "youtube" | "spotify"; className?: string }) {
const [playing, setPlaying] = useState(false);
const ratio = source === "spotify" ? "aspect-[16/7]" : "aspect-video";
if (playing && embedUrl) {
return (
<div className={`cc-frame ${ratio} ${className ?? ""}`}>
<iframe src={embedUrl} title={title} className="h-full w-full" allow="autoplay; encrypted-media; picture-in-picture" allowFullScreen referrerPolicy="strict-origin-when-cross-origin" />
</div>
);
}
return (
<div className={`cc-frame relative ${ratio} ${className ?? ""} bg-gray-900`}>
{thumbnail && <img src={thumbnail} alt="" className="cc-img absolute inset-0 opacity-80" loading="lazy" />}
{embedUrl ? (
<button type="button" onClick={() => setPlaying(true)} className="absolute inset-0 flex items-center justify-center" aria-label={`Play ${title}`}>
<span className="flex h-16 w-16 items-center justify-center rounded-full bg-white/95 text-gray-900 shadow-lg">
<svg viewBox="0 0 24 24" className="ml-1 h-7 w-7" aria-hidden="true"><path fill="currentColor" d="M8 5v14l11-7z" /></svg>
</span>
</button>
) : (
<a href={url} rel="noopener" className="absolute inset-0 flex items-center justify-center font-semibold text-white underline">Open the message</a>
)}
</div>
);
}