Spaces:
Paused
Paused
Download frontend/src/components/BuildTerminalBox.tsx from 2Btainment/repospace: direct link, hf CLI and curl.
- Browser
- Download file 1.6 kB
-
https://huggingface.co/spaces/2Btainment/repospace/resolve/main/frontend/src/components/BuildTerminalBox.tsx
- Command line
-
hf download hf://spaces/2Btainment/repospace/frontend/src/components/BuildTerminalBox.tsx
-
curl -L -o BuildTerminalBox.tsx https://huggingface.co/spaces/2Btainment/repospace/resolve/main/frontend/src/components/BuildTerminalBox.tsx
1.6 kB
| 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<HTMLDivElement>(null); | |
| useEffect(() => { | |
| if (ref.current && open) ref.current.scrollTop = ref.current.scrollHeight; | |
| }, [lines, open]); | |
| return ( | |
| <section className={`logs-dock ${open ? "open" : "collapsed"}`} data-testid="logs-dock"> | |
| <div | |
| className="logs-head" | |
| onClick={onToggle} | |
| role="button" | |
| tabIndex={0} | |
| onKeyDown={(e) => { | |
| if (e.key === "Enter" || e.key === " ") { | |
| e.preventDefault(); | |
| onToggle(); | |
| } | |
| }} | |
| aria-expanded={open} | |
| > | |
| <div className="row" style={{ gap: ".5rem" }}> | |
| <strong>{m.logs}</strong> | |
| <span className="meta-line">{lines.length} lines</span> | |
| </div> | |
| <span className="chev" aria-hidden> | |
| ▾ | |
| </span> | |
| </div> | |
| {open ? ( | |
| <div className="terminal" ref={ref} role="log" aria-live="polite"> | |
| {lines.length === 0 ? ( | |
| <span className="ts">waiting for logs…</span> | |
| ) : ( | |
| lines.map((l) => ( | |
| <div key={l.id}> | |
| <span className="ts">{new Date(l.ts * 1000).toLocaleTimeString()}</span> | |
| {l.line} | |
| </div> | |
| )) | |
| )} | |
| </div> | |
| ) : null} | |
| </section> | |
| ); | |
| } | |