'use client'; import { forwardRef, HTMLAttributes } from 'react'; export interface HandwrittenTextProps extends HTMLAttributes { /** Text content */ children: string; /** Handwriting style */ font?: 'cursive' | 'script' | 'signature' | 'messy' | 'neat' | 'custom'; /** Custom font family */ customFont?: string; /** Size variation (for natural feel) */ sizeVariation?: boolean; /** Rotation variation (for natural feel) */ rotationVariation?: boolean; /** Baseline shift (for natural feel) */ baselineShift?: boolean; /** Ink bleed effect */ inkBleed?: boolean; /** Paper texture behind */ paperBackground?: boolean; } const fontClasses = { cursive: 'font-["Brush_Script_MT",_"Lucida_Calligraphy",_"Comic_Sans_MS",cursive]', script: 'font-["Great_Vibes",_"Pinyon_Script",_"Brush_Script_MT",cursive]', signature: 'font-["Sacramento",_"Great_Vibes",cursive]', messy: 'font-["Marker_Felt",_"Comic_Sans_MS",cursive]', neat: 'font-["Snell_Roundhand",_"Lucida_Handwriting",cursive]', custom: '', }; export const HandwrittenText = forwardRef( ( { children, font = 'cursive', customFont, sizeVariation = true, rotationVariation = true, baselineShift = true, inkBleed = false, paperBackground = false, className = '', ...props }, ref ) => { // Process text to apply variations to each character const chars = children.split('').map((char, index) => { const sizeMod = sizeVariation ? (Math.random() * 0.2 + 0.9) : 1; const rotMod = rotationVariation ? (Math.random() * 6 - 3) : 0; const baselineMod = baselineShift ? (Math.random() * 4 - 2) : 0; return ( {char === ' ' ? '\u00A0' : char} ); }); return ( {chars} {paperBackground && ( ); } ); HandwrittenText.displayName = 'HandwrittenText'; export default HandwrittenText;