'use client'; import React, { useState, useRef } from 'react'; import Link from 'next/link'; import { QRCodeSVG } from 'qrcode.react'; import { Music, Download, Check, Sparkles, Video, Share2 } 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 - TikTok Theme const QR_COLORS = [ { name: 'TikTok Black', value: '#000000' }, { name: 'TikTok Pink', value: '#FE2C55' }, { name: 'TikTok Cyan', value: '#25F4EE' }, { name: 'Deep Blue', value: '#1A1265' }, { 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' }, { id: 'watch', label: 'Watch' }, ]; export default function TiktokGenerator() { const [username, setUsername] = useState(''); const [qrColor, setQrColor] = useState('#000000'); const [frameType, setFrameType] = useState('none'); const qrRef = useRef(null); // TikTok URL: https://www.tiktok.com/@username const getUrl = () => { const cleanUser = username.replace(/^@/, '').replace(/https?:\/\/(www\.)?tiktok\.com\/@?/, '').replace(/\/$/, ''); return cleanUser ? `https://www.tiktok.com/@${cleanUser}` : 'https://www.tiktok.com'; }; 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 = `tiktok-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 = `tiktok-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 */}
{/* TikTok Details */}

TikTok Username

setUsername(e.target.value)} className="h-12 text-base rounded-xl border-slate-200 focus:border-black focus:ring-black" />

Enter your TikTok handle (e.g. @charlidamelio).

{/* 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 */}

{username || '@username'}

Opens in TikTok
{/* Download Buttons */}

Scanning redirects directly to your TikTok profile.

{/* Upsell Banner */}

Cross-promote on Socials?

Use one Dynamic Link to share your TikTok, Insta, and YouTube all at once.

); }