import { Download } from "lucide-react"; import { useEffect, useRef, useState } from "react"; import { ProgressCard } from "@/components/common/progress-card"; import { useToolProcessor } from "@/hooks/use-tool-processor"; import { useFileStore } from "@/stores/file-store"; type Position = "center" | "top-left" | "top-right" | "bottom-left" | "bottom-right" | "tiled"; export interface WatermarkTextControlsProps { onChange?: (settings: Record) => void; } export function WatermarkTextControls({ onChange }: WatermarkTextControlsProps) { const [text, setText] = useState("Sample Watermark"); const [fontSize, setFontSize] = useState(48); const [color, setColor] = useState("#000000"); const [opacity, setOpacity] = useState(50); const [position, setPosition] = useState("center"); const [rotation, setRotation] = useState(0); const onChangeRef = useRef(onChange); useEffect(() => { onChangeRef.current = onChange; }); useEffect(() => { onChangeRef.current?.({ text, fontSize, color, opacity, position, rotation }); }, [text, fontSize, color, opacity, position, rotation]); return (
setText(e.target.value)} className="w-full mt-0.5 px-2 py-1.5 rounded border border-border bg-background text-sm text-foreground" />
{fontSize}px
setFontSize(Number(e.target.value))} className="w-full mt-1" />
setColor(e.target.value)} className="w-full mt-0.5 h-8 rounded border border-border" />
{opacity}%
setOpacity(Number(e.target.value))} className="w-full mt-1" />
{rotation}°
setRotation(Number(e.target.value))} className="w-full mt-1" />
); } export function WatermarkTextSettings() { const { files } = useFileStore(); const { processFiles, processAllFiles, processing, error, downloadUrl, originalSize, processedSize, progress, } = useToolProcessor("watermark-text"); const [settings, setSettings] = useState>({}); const handleProcess = () => { if (files.length > 1) { processAllFiles(files, settings); } else { processFiles(files, settings); } }; const hasFile = files.length > 0; return (
{error &&

{error}

} {originalSize != null && processedSize != null && (

Original: {(originalSize / 1024).toFixed(1)} KB

Processed: {(processedSize / 1024).toFixed(1)} KB

)} {processing ? ( ) : ( )} {downloadUrl && ( Download )}
); }