'use client'; import { forwardRef, HTMLAttributes } from 'react'; import styles from './handwritten-text.module.css'; 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; } 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} ); } ); HandwrittenText.displayName = 'HandwrittenText'; export default HandwrittenText;