Skip to content
Source
Sign inSign up
pingdotgg/t3code
Open History to see the last commit

PreviewPanel.tsx

54 lines1.5 KB

1"use client";
2​
3import type { PreviewAnnotationPayload, ScopedThreadRef } from "@t3tools/contracts";
4​
5import type { ComposerImageAttachment } from "~/composerDraftStore";
6import { isPreviewSupportedInRuntime } from "~/previewStateStore";
7​
8import { PreviewPanelShell, type PreviewPanelMode } from "./PreviewPanelShell";
9import { PreviewView } from "./PreviewView";
10​
11interface Props {
12 mode: PreviewPanelMode;
13 threadRef: ScopedThreadRef;
14 tabId?: string | null;
15 configuredUrls?: ReadonlyArray<string> | undefined;
16 visible: boolean;
17 onSendAnnotation?: (
18 annotation: PreviewAnnotationPayload,
19 image: ComposerImageAttachment | null,
20 ) => void;
22​
23export function PreviewPanel({
24 mode,
25 threadRef,
26 tabId,
27 configuredUrls,
28 visible,
29 onSendAnnotation,
30}: Props) {
31 if (!isPreviewSupportedInRuntime()) {
32 return (
33 <PreviewPanelShell mode={mode}>
34 <div className="flex min-h-0 flex-1 flex-col items-center justify-center gap-3 p-8 text-center">
35 <p className="max-w-sm text-sm text-muted-foreground">
36 Preview is only available in the T3 Code desktop app.
37 </p>
38 </div>
39 </PreviewPanelShell>
40 );
41 }
42​
43 return (
44 <PreviewPanelShell mode={mode}>
45 <PreviewView
46 threadRef={threadRef}
47 {...(tabId !== undefined ? { tabId } : {})}
48 configuredUrls={configuredUrls}
49 visible={visible}
50 {...(onSendAnnotation ? { onSendAnnotation } : {})}
51 />
52 </PreviewPanelShell>
53 );