"use client"; import type { CSSProperties } from "react"; import type { ReplayPreviewDialog, ReplayPreviewImage, ReplayPreviewToast, } from "@/uhm/lib/replay/useReplayPreview"; type Props = { isPreviewMode: boolean; isPlaying: boolean; title: string; descriptions: string; subtitle: string | null; dialog: ReplayPreviewDialog | null; image: ReplayPreviewImage | null; toasts: ReplayPreviewToast[]; sidebarOpen: boolean; playbackSpeed: number; activeStepLabel: string | null; activeStepNumber: number | null; totalSteps: number; onPlayPreview: () => void; onStopPreview: () => void; onResetPreview: () => void; onExitPreview: () => void; }; export default function ReplayPreviewOverlay({ isPreviewMode, isPlaying, title, descriptions, subtitle, dialog, image, toasts, sidebarOpen, playbackSpeed, activeStepLabel, activeStepNumber, totalSteps, onPlayPreview, onStopPreview, onResetPreview, onExitPreview, }: Props) { const hasNarrativeCard = title.trim().length > 0 || descriptions.trim().length > 0; const hasWikiPreview = sidebarOpen; const shouldRender = isPreviewMode || isPlaying || hasNarrativeCard || Boolean(subtitle) || Boolean(dialog) || Boolean(image) || Boolean(toasts.length); if (!shouldRender) { return null; } return (
{hasNarrativeCard ? (
{title.trim().length ? (
{title}
) : null} {descriptions.trim().length ? (
{descriptions}
) : null}
) : null} {toasts.length ? (
{toasts.map((toast) => (
{toast.message}
))}
) : null} {image ? (
{image.caption {image.caption?.trim() ? (
{image.caption}
) : null}
) : null} {dialog ? (
{dialog.avatar.trim().length ? ( {dialog.speaker ) : null}
{dialog.speaker?.trim() ? (
{dialog.speaker}
) : null}
{dialog.text}
) : null} {subtitle?.trim() ? (
{subtitle}
) : null} {isPreviewMode ? (
Preview {activeStepLabel ? ( {activeStepLabel} ) : null} x{playbackSpeed.toFixed(2)}
{totalSteps > 0 ? (
Step {activeStepNumber || 0}/{totalSteps}
) : null}
{isPlaying ? ( <> ) : ( )}
) : null}
); } function previewButtonStyle(background: string): CSSProperties { return { border: "none", background, color: "white", borderRadius: 10, padding: "8px 12px", cursor: "pointer", fontSize: 12, fontWeight: 800, boxShadow: "inset 0 0 0 1px rgba(255,255,255,0.08)", }; }