2025-11-09 12:20:42 +01:00
|
|
|
'use client';
|
|
|
|
|
|
|
|
|
|
import * as React from 'react';
|
|
|
|
|
import { Card } from '@/components/ui/Card';
|
|
|
|
|
import { Button } from '@/components/ui/Button';
|
2025-11-09 12:28:27 +01:00
|
|
|
import { Copy, Download, Share2 } from 'lucide-react';
|
2025-11-09 12:20:42 +01:00
|
|
|
import { cn } from '@/lib/utils/cn';
|
|
|
|
|
|
|
|
|
|
export interface FontPreviewProps {
|
|
|
|
|
text: string;
|
|
|
|
|
isLoading?: boolean;
|
|
|
|
|
onCopy?: () => void;
|
|
|
|
|
onDownload?: () => void;
|
2025-11-09 12:28:27 +01:00
|
|
|
onShare?: () => void;
|
2025-11-09 12:20:42 +01:00
|
|
|
className?: string;
|
|
|
|
|
}
|
|
|
|
|
|
2025-11-09 12:28:27 +01:00
|
|
|
export function FontPreview({ text, isLoading, onCopy, onDownload, onShare, className }: FontPreviewProps) {
|
2025-11-09 12:20:42 +01:00
|
|
|
return (
|
|
|
|
|
<Card className={cn('relative', className)}>
|
|
|
|
|
<div className="p-6">
|
|
|
|
|
<div className="flex items-center justify-between mb-4">
|
|
|
|
|
<h3 className="text-sm font-medium">Preview</h3>
|
|
|
|
|
<div className="flex gap-2">
|
|
|
|
|
{onCopy && (
|
|
|
|
|
<Button variant="outline" size="sm" onClick={onCopy}>
|
|
|
|
|
<Copy className="h-4 w-4" />
|
|
|
|
|
Copy
|
|
|
|
|
</Button>
|
|
|
|
|
)}
|
2025-11-09 12:28:27 +01:00
|
|
|
{onShare && (
|
|
|
|
|
<Button variant="outline" size="sm" onClick={onShare} title="Copy shareable URL">
|
|
|
|
|
<Share2 className="h-4 w-4" />
|
|
|
|
|
Share
|
|
|
|
|
</Button>
|
|
|
|
|
)}
|
2025-11-09 12:20:42 +01:00
|
|
|
{onDownload && (
|
|
|
|
|
<Button variant="outline" size="sm" onClick={onDownload}>
|
|
|
|
|
<Download className="h-4 w-4" />
|
|
|
|
|
Download
|
|
|
|
|
</Button>
|
|
|
|
|
)}
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
|
|
|
|
|
<div className="relative min-h-[200px] bg-muted/50 rounded-lg p-4 overflow-x-auto">
|
|
|
|
|
{isLoading ? (
|
|
|
|
|
<div className="absolute inset-0 flex items-center justify-center">
|
|
|
|
|
<div className="text-sm text-muted-foreground">Generating...</div>
|
|
|
|
|
</div>
|
|
|
|
|
) : text ? (
|
|
|
|
|
<pre className="font-mono text-xs sm:text-sm whitespace-pre overflow-x-auto">
|
|
|
|
|
{text}
|
|
|
|
|
</pre>
|
|
|
|
|
) : (
|
|
|
|
|
<div className="absolute inset-0 flex items-center justify-center">
|
|
|
|
|
<div className="text-sm text-muted-foreground">Your ASCII art will appear here</div>
|
|
|
|
|
</div>
|
|
|
|
|
)}
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
</Card>
|
|
|
|
|
);
|
|
|
|
|
}
|