Eidetic

AI Result Preview

AI
Results
Block

Live preview component for AI-generated content. Supports markdown, code, HTML, and table rendering with raw/preview toggle, copy, download, and streaming indicators.

Markdown Preview

Document preview with parsed markdown

Project Summary

Project Summary

Overview

The application uses a modern React architecture with server-side rendering.

Key Features

  • Real-time collaboration with WebSocket support
  • AI-powered content generation
  • Role-based access control
  • This project follows industry best practices for scalability and maintainability.

    Performance Metrics

  • Load time: 1.2s average
  • Lighthouse score: 94/100
  • Bundle size: 156KB gzipped
  • Code Preview

    Code block with syntax display

    Custom Hook

    TypeScript
    import { useState, useEffect } from 'react'
    
    interface User {
     id: string
     name: string
     email: string
    }
    
    export function useUser(userId: string) {
     const [user, setUser] = useState<User | null>(null)
     const [loading, setLoading] = useState(true)
    
     useEffect(() => {
     fetch(`/api/users/${userId}`)
     .then(res => res.json())
     .then(data => {
     setUser(data)
     setLoading(false)
     })
     }, [userId])
    
     return { user, loading }
    }

    Table Preview

    Auto-parsed table from pipe-delimited data

    Phone Comparison

    NameCategoryPriceRating
    iPhone 15 ProSmartphone$9994.7
    Samsung S24Smartphone$8994.5
    Google Pixel 8Smartphone$6994.6

    Streaming State

    Active generation indicator

    Generating Report

    Generating...

    Q4 Report\n\nAnalyzing quarterly data across all departments...

    Inline Variant

    Compact preview for embedded use

    const greeting = "Hello, World!"
    console.log(greeting)

    Props

    AIResultPreview component API reference

    PropTypeDefaultDescription
    content*stringThe raw content to preview
    type'markdown' | 'code' | 'html' | 'table' | 'image''markdown'Type of content
    titlestringPreview title
    languagestringLanguage label for code previews
    showTogglebooleantrueShow raw/preview toggle
    streamingbooleanfalseShow streaming indicator
    variant'card' | 'inline' | 'fullscreen''card'Display variant
    onCopy() => voidCallback when content is copied
    onDownload() => voidCallback for download action
    onRegenerate() => voidCallback for regeneration

    Usage

    Import and implementation example

    import { AIResultPreview } from '@/blocks/ai-conversation/ai-result-preview'
    <AIResultPreview
    type="markdown"
    title="Generated Report"
    content={generatedMarkdown}
    streaming={isGenerating}
    onRegenerate={() => regenerate()}
    onDownload={() => downloadAsPDF()}
    />

    Built With

    2 components

    This block uses the following UI components from the design system:

    Features

    Built-in functionality

    • Five content types: Markdown, code, HTML, table, and image preview modes
    • Raw/preview toggle: Switch between rendered preview and raw source
    • Streaming indicator: Animated indicator during active generation
    • Copy to clipboard: One-click content copying with confirmation
    • Fullscreen mode: Expand preview to fill viewport
    • Auto table parsing: Pipe-delimited text auto-parsed into tables

    Accessibility

    Accessibility considerations

    ARIA Attributes

    Content type conveyed through icon and label

    Keyboard Navigation

    KeyAction
    TabNavigate between toolbar actions
    Enter / SpaceToggle view mode and activate buttons

    Notes

    • Preview/Raw toggle uses clear text labels
    • Copy confirmation shown visually and through icon change