'use client'; import * as React from 'react'; import { toPng } from 'html-to-image'; import { Card } from '@/components/ui/Card'; import { Button } from '@/components/ui/Button'; import { Skeleton } from '@/components/ui/Skeleton'; import { EmptyState } from '@/components/ui/EmptyState'; import { Copy, Download, Share2, Image as ImageIcon, AlignLeft, AlignCenter, AlignRight, Type } from 'lucide-react'; import { cn } from '@/lib/utils/cn'; import { useToast } from '@/components/ui/Toast'; export interface FontPreviewProps { text: string; font?: string; isLoading?: boolean; onCopy?: () => void; onDownload?: () => void; onShare?: () => void; className?: string; } type TextAlign = 'left' | 'center' | 'right'; export function FontPreview({ text, font, isLoading, onCopy, onDownload, onShare, className }: FontPreviewProps) { const lineCount = text ? text.split('\n').length : 0; const charCount = text ? text.length : 0; const previewRef = React.useRef(null); const [textAlign, setTextAlign] = React.useState('left'); const [fontSize, setFontSize] = React.useState<'xs' | 'sm' | 'base'>('sm'); const { addToast } = useToast(); const handleExportPNG = async () => { if (!previewRef.current || !text) return; try { const dataUrl = await toPng(previewRef.current, { backgroundColor: getComputedStyle(previewRef.current).backgroundColor, pixelRatio: 2, }); const link = document.createElement('a'); link.download = `figlet-${font || 'export'}-${Date.now()}.png`; link.href = dataUrl; link.click(); addToast('Exported as PNG!', 'success'); } catch (error) { console.error('Failed to export PNG:', error); addToast('Failed to export PNG', 'error'); } }; return (

Preview

{font && ( {font} )}
{onCopy && ( )} {onShare && ( )} {onDownload && ( )}
{/* Controls */}
{!isLoading && text && (
{lineCount} lines {charCount} chars
)}
{isLoading ? (
) : text ? (
              {text}
            
) : ( )}
); }