MCPcopy Create free account
hub / github.com/MoonshotAI/kimi-code / SizePreview

Function SizePreview

apps/vis/web/src/components/shared/SizePreview.tsx:15–49  ·  view source on GitHub ↗
({
  label = 'payload',
  sizeBytes,
  preview,
  children,
  defaultOpen = false,
}: SizePreviewProps)

Source from the content-addressed store, hash-verified

13}
14
15export function SizePreview({
16 label = 'payload',
17 sizeBytes,
18 preview,
19 children,
20 defaultOpen = false,
21}: SizePreviewProps) {
22 const [open, setOpen] = useState(defaultOpen);
23 const size = formatBytes(sizeBytes);
24 return (
25 <div className="my-1 border border-border bg-surface-0">
26 <button
27 onClick={() =>{ setOpen((v) => !v); }}
28 className="flex w-full items-center justify-between gap-2 px-2 py-1 font-mono text-[11px] text-fg-2 hover:bg-surface-2 hover:text-fg-1"
29 >
30 <span className="flex items-center gap-2">
31 <span className="text-fg-3">{open ? '▾' : '▸'}</span>
32 <span className="uppercase tracking-[0.08em]">{label}</span>
33 <span className="text-fg-3 tabular">{size}</span>
34 </span>
35 {!open && preview ? (
36 <span className="truncate text-fg-3 font-mono text-[11px]">
37 {preview.slice(0, 120)}
38 {preview.length > 120 ? '…' : ''}
39 </span>
40 ) : null}
41 </button>
42 {open ? (
43 <div className="border-t border-border px-2 py-1 font-mono text-[12px]">
44 {children}
45 </div>
46 ) : null}
47 </div>
48 );
49}
50
51export function formatBytes(n: number): string {
52 if (n < 1024) return `${n}B`;

Callers

nothing calls this directly

Calls 1

formatBytesFunction · 0.70

Tested by

no test coverage detected