Loading files
05241c15dThis file is pinned to the selected release. Download the original to open it in your design tool.
"use client";
import type { RemoteTrack } from "livekit-client";
import { CameraTile } from "@/components/livekit/CameraTile";
import { ACCENTS } from "@/components/cabinet/accents";
import { CHANNELS, type Channel } from "@/lib/config";
/** Live/NO-SIG chip in the corner of a tile, in the channel's accent. */
function LiveChip({ live, accent }: { live: boolean; accent: (typeof ACCENTS)[keyof typeof ACCENTS] }) {
return (
<span className="absolute left-2 top-2 z-40 flex items-center gap-1.5 rounded bg-black/55 px-2 py-1 font-pixel text-[9px] sm:text-[10px]">
{live ? (
<>
<span className={`h-2 w-2 rounded-full ${accent.dot} blink`} />
<span className={accent.text}>LIVE</span>
</>
) : (
<span className="text-cab-500">NO SIG</span>
)}
</span>
);
}
/** One feed tile — a plain div, or a button when `onSelect` is given (click to pin it). */
function Tile({
ch,
track,
big,
frame,
fit,
borderW = "border-2",
onSelect,
}: {
ch: Channel;
track: RemoteTrack | undefined;
big: boolean;
/** sizing classes for the tile box (flex-fill in landscape, aspect-square in the vertical stream) */
frame: string;
fit?: "cover" | "contain";
/** neon border width (Tailwind class) — thicker on the vertical stream */
borderW?: string;
onSelect?: (id: string) => void;
}) {
const a = ACCENTS[ch.accent];
const shape = big ? "scan-sweep rounded-lg" : "rounded-md";
const base = `crt relative overflow-hidden ${borderW} ${a.border} ${a.text} neon-box ${shape} ${frame}`;
const label = (
<span
className={`absolute z-40 font-pixel ${a.text} ${
big ? "bottom-2 left-3 text-xs neon-text-soft sm:text-sm" : "bottom-1.5 left-2 text-[9px] sm:text-[11px]"
}`}
>
{ch.short}
</span>
);
const inner = (
<>
<CameraTile track={track} label={ch.short} fit={fit} />
<LiveChip live={Boolean(track)} accent={a} />
{label}
</>
);
if (onSelect) {
return (
<button
type="button"
aria-label={`Show ${ch.label} on the main screen`}
onClick={() => onSelect(ch.id)}
className={`${base} pointer-events-auto cursor-pointer transition hover:brightness-110 focus-visible:outline focus-visible:outline-2 focus-visible:outline-offset-2`}
>
{inner}
</button>
);
}
return <div className={base}>{inner}</div>;
}
/**
* The multicam stage shared by /broadcast and the arcade cabinet's CRT screen: the pinned camera fills
* the frame; the other three ride alongside — a right-hand column on desktop, a horizontal row below
* the pinned feed on mobile. Same tiles, CRT styling, neon borders and LIVE/NO-SIG statuses in both.
*
* `onSelect(channelId)` makes the non-pinned tiles clickable (used on the cabinet to re-pin a camera);
* omit it for a passive stream (/broadcast). Prop-driven (no useRoom/useTeleop) so it renders identically
* as a plain page child or portaled onto the 3D plane by drei's <Html>.
*/
export function CameraWall({
videoTracks,
pinnedTrackName,
onSelect,
stacked = false,
fit,
}: {
videoTracks: Record<string, RemoteTrack>;
pinnedTrackName: string;
onSelect?: (id: string) => void;
/** force the portrait layout (pinned on top, others in a row below) at any width — for the 9:16 stream */
stacked?: boolean;
/** "contain" shows the whole feed (no crop); default "cover" fills each tile */
fit?: "cover" | "contain";
}) {
const primary = CHANNELS.find((c) => c.trackName === pinnedTrackName) ?? CHANNELS[0];
const others = CHANNELS.filter((c) => c.trackName !== primary.trackName);
// Vertical (9:16) stream: all tiles SQUARE (pinned full-width, the other three in a row of thirds),
// the whole group vertically centered in the stage.
if (stacked) {
// Sizes are height-capped (min(width, vh)) so the squares always fit the 9:16 frame — never wider
// than the column, never taller than their vh budget — and shrink-0 so flex can't squish them out
// of square when the header/footer text is large.
return (
<div className="flex h-full min-h-0 w-full flex-col items-center justify-center gap-3">
{/* pinned grows to full width (keeps its height) — no side gap; the small tiles stay square */}
<Tile ch={primary} track={videoTracks[primary.trackName]} big fit={fit} borderW="border-4" frame="h-[44vh] w-full shrink-0" />
<div className="flex w-full justify-center gap-3">
{others.map((ch) => (
<Tile key={ch.id} ch={ch} track={videoTracks[ch.trackName]} big={false} fit={fit} borderW="border-4" frame="aspect-square w-[min(32%,16vh)] shrink-0" onSelect={onSelect} />
))}
</div>
</div>
);
}
// Landscape / responsive: pinned fills, the other three ride below (mobile) or in a right rail (>=sm).
return (
<div className="flex h-full min-h-0 w-full flex-col gap-2 sm:flex-row sm:gap-4">
<Tile ch={primary} track={videoTracks[primary.trackName]} big fit={fit} frame="min-h-0 min-w-0 flex-1" />
<div className="flex min-h-0 shrink-0 basis-[26%] flex-row gap-2 sm:w-[clamp(190px,22vw,360px)] sm:basis-auto sm:flex-col sm:gap-4">
{others.map((ch) => (
<Tile key={ch.id} ch={ch} track={videoTracks[ch.trackName]} big={false} fit={fit} frame="min-h-0 min-w-0 flex-1" onSelect={onSelect} />
))}
</div>
</div>
);
}