import { useEffect, useRef } from "react"; import type { LogLine } from "../types"; import { t } from "../i18n"; interface Props { lines: LogLine[]; open: boolean; onToggle: () => void; } export function BuildTerminalBox({ lines, open, onToggle }: Props) { const m = t(); const ref = useRef(null); useEffect(() => { if (ref.current && open) ref.current.scrollTop = ref.current.scrollHeight; }, [lines, open]); return (
{ if (e.key === "Enter" || e.key === " ") { e.preventDefault(); onToggle(); } }} aria-expanded={open} >
{m.logs} {lines.length} lines
▾
{open ? (
{lines.length === 0 ? ( waiting for logs… ) : ( lines.map((l) => (
{new Date(l.ts * 1000).toLocaleTimeString()} {l.line}
)) )}
) : null}
); }