'use client'; import React, { useState, useRef } from 'react'; import Link from 'next/link'; import { QRCodeSVG } from 'qrcode.react'; import { Facebook, Download, Check, Sparkles, ThumbsUp, Globe } from 'lucide-react'; import { Button } from '@/components/ui/Button'; import { Input } from '@/components/ui/Input'; import { cn } from '@/lib/utils'; // Brand Colors const BRAND = { paleGrey: '#EBEBDF', richBlue: '#1A1265', richBlueLight: '#2A2275', }; // QR Color Options - Facebook Theme const QR_COLORS = [ { name: 'Facebook Blue', value: '#1877F2' }, { name: 'Classic Black', value: '#000000' }, { name: 'Dark Blue', value: '#1A1265' }, { name: 'Teal', value: '#0D9488' }, { name: 'Coral', value: '#F43F5E' }, { name: 'Purple', value: '#7C3AED' }, { name: 'Emerald', value: '#10B981' }, { name: 'Rose', value: '#F43F5E' }, ]; // Frame Options const FRAME_OPTIONS = [ { id: 'none', label: 'No Frame' }, { id: 'scanme', label: 'Scan Me' }, { id: 'follow', label: 'Follow Us' }, { id: 'like', label: 'Like Us' }, ]; export default function FacebookGenerator() { const [url, setUrl] = useState(''); const [qrColor, setQrColor] = useState('#1877F2'); // Default to FB Blue const [frameType, setFrameType] = useState('none'); const qrRef = useRef(null); const handleDownload = async (format: 'png' | 'svg') => { if (!qrRef.current) return; try { if (format === 'png') { const { toPng } = await import('html-to-image'); const dataUrl = await toPng(qrRef.current, { cacheBust: true, pixelRatio: 3 }); const link = document.createElement('a'); link.download = `facebook-qr-code.png`; link.href = dataUrl; link.click(); } else { const svgData = qrRef.current.querySelector('svg')?.outerHTML; if (svgData) { const blob = new Blob([svgData], { type: 'image/svg+xml;charset=utf-8' }); const url = URL.createObjectURL(blob); const link = document.createElement('a'); link.href = url; link.download = `facebook-qr-code.svg`; link.click(); } } } catch (err) { console.error('Download failed', err); } }; const getFrameLabel = () => { const frame = FRAME_OPTIONS.find(f => f.id === frameType); return frame?.id !== 'none' ? frame?.label : null; }; return (
{/* Main Generator Card */}
{/* LEFT: Input Section */}
{/* Facebook Details */}

Facebook Page or Profile

setUrl(e.target.value)} className="h-12 text-base rounded-xl border-slate-200 focus:border-[#1877F2] focus:ring-[#1877F2]" />

Paste the full link to your profile, page, group, or post.

{/* Design Options */}

Design Options

{/* Color Picker */}
{QR_COLORS.map((c) => ( ))}
{/* Frame Selector */}
{FRAME_OPTIONS.map((frame) => ( ))}
{/* RIGHT: Preview Section */}
{/* QR Card with Frame */}
{/* Frame Label */} {getFrameLabel() && (
{getFrameLabel()}
)} {/* QR Code */}
{/* Info Preview */}

{url ? url.replace('https://', '') : 'facebook.com/...'}

Opens in Facebook App
{/* Download Buttons */}

Scanning redirects directly to the Facebook profile or page.

{/* Upsell Banner */}

Running a Social Media Campaign?

Dynamic QR Codes allow you to track clicks, likes, and engagement rates in real-time.

); }