Move components/favicon/CodeSnippet.tsx → components/ui/code-snippet.tsx. Update Favicon tool import path. Replace Animate tool's local CodeBlock (with external copy/download buttons) with the shared CodeSnippet. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
44 lines
1.5 KiB
TypeScript
44 lines
1.5 KiB
TypeScript
'use client';
|
|
|
|
import { useMemo, useState } from 'react';
|
|
import { cn } from '@/lib/utils/cn';
|
|
import { buildCSS, buildTailwindCSS } from '@/lib/animate/cssBuilder';
|
|
import { CodeSnippet } from '@/components/ui/code-snippet';
|
|
import type { AnimationConfig } from '@/types/animate';
|
|
|
|
interface Props {
|
|
config: AnimationConfig;
|
|
}
|
|
|
|
type ExportTab = 'css' | 'tailwind';
|
|
|
|
export function ExportPanel({ config }: Props) {
|
|
const [tab, setTab] = useState<ExportTab>('css');
|
|
const css = useMemo(() => buildCSS(config), [config]);
|
|
const tailwind = useMemo(() => buildTailwindCSS(config), [config]);
|
|
|
|
return (
|
|
<div className="space-y-3">
|
|
<div className="flex items-center justify-between">
|
|
<span className="text-[10px] font-semibold text-muted-foreground uppercase tracking-widest">Export</span>
|
|
<div className="flex glass rounded-lg p-0.5 gap-0.5">
|
|
{(['css', 'tailwind'] as ExportTab[]).map((t) => (
|
|
<button
|
|
key={t}
|
|
onClick={() => setTab(t)}
|
|
className={cn(
|
|
'px-2.5 py-1 rounded-md text-[10px] font-mono transition-all',
|
|
tab === t ? 'bg-primary text-primary-foreground' : 'text-muted-foreground hover:text-foreground'
|
|
)}
|
|
>
|
|
{t === 'css' ? 'Plain CSS' : 'Tailwind v4'}
|
|
</button>
|
|
))}
|
|
</div>
|
|
</div>
|
|
{tab === 'css' && <CodeSnippet code={css} maxHeight="16rem" />}
|
|
{tab === 'tailwind' && <CodeSnippet code={tailwind} maxHeight="16rem" />}
|
|
</div>
|
|
);
|
|
}
|