'use client'; import { Slider } from '@/components/ui/slider'; import { cn } from '@/lib/utils/cn'; import type { ErrorCorrectionLevel } from '@/types/qrcode'; interface QROptionsProps { errorCorrection: ErrorCorrectionLevel; foregroundColor: string; backgroundColor: string; margin: number; onErrorCorrectionChange: (ec: ErrorCorrectionLevel) => void; onForegroundColorChange: (color: string) => void; onBackgroundColorChange: (color: string) => void; onMarginChange: (margin: number) => void; } const EC_OPTIONS: { value: ErrorCorrectionLevel; label: string; desc: string }[] = [ { value: 'L', label: 'L', desc: '7%' }, { value: 'M', label: 'M', desc: '15%' }, { value: 'Q', label: 'Q', desc: '25%' }, { value: 'H', label: 'H', desc: '30%' }, ]; const inputCls = 'w-full bg-transparent border border-border/40 rounded-lg px-3 py-1.5 text-xs font-mono outline-none focus:border-primary/50 transition-colors text-foreground/80 placeholder:text-muted-foreground/30'; export function QROptions({ errorCorrection, foregroundColor, backgroundColor, margin, onErrorCorrectionChange, onForegroundColorChange, onBackgroundColorChange, onMarginChange, }: QROptionsProps) { const isTransparent = backgroundColor === '#00000000'; return (
{/* Error Correction */}
Error Correction
{EC_OPTIONS.map((opt) => ( ))}
{/* Colors */}
Colors {/* Foreground */}
onForegroundColorChange(e.target.value)} className="w-8 h-8 rounded-lg cursor-pointer border border-border/40 bg-transparent shrink-0 p-0.5" /> onForegroundColorChange(e.target.value)} className={inputCls} />
{/* Background */}
onBackgroundColorChange(e.target.value)} className={cn( 'w-8 h-8 rounded-lg cursor-pointer border border-border/40 bg-transparent shrink-0 p-0.5 transition-opacity', isTransparent && 'opacity-30 cursor-not-allowed' )} /> onBackgroundColorChange(e.target.value)} className={cn(inputCls, isTransparent && 'opacity-30')} />
{/* Margin */}
Margin {margin}
onMarginChange(v)} min={0} max={8} step={1} />
); }