From 580e798e16346eb894eb899edac82d2efdf40adc Mon Sep 17 00:00:00 2001 From: Christian Cleberg Date: Sat, 18 Apr 2026 22:32:53 -0500 Subject: initial commit --- src/components/PreviewPanel.tsx | 116 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 116 insertions(+) create mode 100644 src/components/PreviewPanel.tsx (limited to 'src/components/PreviewPanel.tsx') diff --git a/src/components/PreviewPanel.tsx b/src/components/PreviewPanel.tsx new file mode 100644 index 0000000..695698a --- /dev/null +++ b/src/components/PreviewPanel.tsx @@ -0,0 +1,116 @@ +import type { BrandInputs, BrandOutputs, LockedSections } from '../types'; +import { BrandDoc } from './BrandDoc'; +import { CopyButton } from './CopyButton'; +import { toMarkdown, toJSON, toHTML, downloadFile } from '../lib/export'; + +interface Props { + inputs: BrandInputs; + outputs: BrandOutputs | null; + locked: LockedSections; + onToggleLock: (section: keyof LockedSections) => void; + onEdit: (key: K, value: BrandOutputs[K]) => void; + isGenerating: boolean; + generateMode?: 'template' | string; + generateError?: string | null; + onGenerate?: () => void; +} + +export function PreviewPanel({ inputs, outputs, locked, onToggleLock, onEdit, isGenerating, generateMode, generateError, onGenerate }: Props) { + const handleExportMd = () => { + if (!outputs) return; + downloadFile(toMarkdown(inputs, outputs), `${inputs.name || 'brand'}-package.md`, 'text/markdown'); + }; + + const handleExportJson = () => { + if (!outputs) return; + downloadFile(toJSON(inputs, outputs), `${inputs.name || 'brand'}-package.json`, 'application/json'); + }; + + const handleExportHtml = () => { + if (!outputs) return; + downloadFile(toHTML(inputs, outputs), `${inputs.name || 'brand'}-guidelines.html`, 'text/html'); + }; + + const fullMarkdown = outputs ? toMarkdown(inputs, outputs) : ''; + + return ( +
+
+
+ + {outputs ? 'Brand Package' : 'Preview'} + + {outputs && ( + + · {new Date().toLocaleDateString('en-US', { month: 'short', day: 'numeric', year: 'numeric' })} + + )} +
+ {outputs && ( +
+ +
+ )} +
+ + {generateError && ( +
+ + {generateError} + {onGenerate && ( + + )} +
+ )} + +
+ {isGenerating ? ( +
+
+ {generateMode && generateMode !== 'template' + ? `Thinking with ${generateMode}…` + : 'Generating…'} +
+ {generateMode && generateMode !== 'template' && ( +
This may take 15–60 seconds depending on your hardware
+ )} +
+ ) : outputs ? ( + + ) : ( +
+
No package generated yet
+
Fill in the project details and click Generate
+
+ )} +
+ + {outputs && ( +
+ + Export + +
+ + + +
+
+ )} +
+ ); +} -- cgit v1.2.3