MCPcopy Index your code
hub / github.com/CodebuffAI/codebuff / BrowserPreview

Function BrowserPreview

web/src/components/TerminalDemo.tsx:177–230  ·  view source on GitHub ↗
({
  content,
  showError = false,
  isRainbow = false,
  theme = 'default',
  isLoading = false,
})

Source from the content-addressed store, hash-verified

175}
176
177const BrowserPreview: React.FC<BrowserPreviewProps> = ({
178 content,
179 showError = false,
180 isRainbow = false,
181 theme = 'default',
182 isLoading = false,
183}) => {
184 return (
185 <div
186 className={cn(
187 'rounded-lg overflow-hidden w-full flex flex-col min-h-[200px]',
188 )}
189 >
190 <div className="rounded-lg bg-white dark:bg-gray-900 flex flex-col flex-1">
191 {/* Browser-like title bar */}
192 <div className="bg-gray-100 dark:bg-gray-800 p-2 flex items-center gap-2 border-b border-gray-200 dark:border-gray-700">
193 {/* Traffic light circles */}
194 <div className="flex gap-1.5">
195 <div className="w-3 h-3 rounded-full bg-red-500"></div>
196 <div className="w-3 h-3 rounded-full bg-yellow-500"></div>
197 <div className="w-3 h-3 rounded-full bg-green-500"></div>
198 </div>
199 {/* URL bar */}
200 <div className="flex-1 ml-2">
201 <div className="bg-white dark:bg-gray-700 rounded px-3 py-1 text-sm text-gray-600 dark:text-gray-300 font-mono">
202 http://localhost:3000
203 </div>
204 </div>
205 </div>
206 {/* Content area */}
207 <div
208 className={cn(
209 'flex-1 border rounded-b-lg border-gray-200 dark:border-gray-700 relative',
210 theme === 'light' && 'bg-white',
211 theme === 'terminal-y' && 'bg-black',
212 theme === 'retro' && 'bg-[#002448]',
213 )}
214 >
215 {isLoading ? (
216 <div className="absolute inset-0 flex items-center justify-center">
217 <div className="animate-spin rounded-full h-32 w-32 border-b-2 border-gray-900 dark:border-gray-100"></div>
218 </div>
219 ) : (
220 <iframe
221 srcDoc={getIframeContent(content, showError, isRainbow, theme)}
222 className="w-full h-full border-none"
223 sandbox="allow-scripts"
224 />
225 )}
226 </div>
227 </div>
228 </div>
229 )
230}
231
232interface DemoResponse {
233 html: string

Callers

nothing calls this directly

Calls 2

cnFunction · 0.90
getIframeContentFunction · 0.85

Tested by

no test coverage detected