'use client'; import { forwardRef, HTMLAttributes } from 'react'; export const ORNAMENT_SYMBOLS = { cross: '✝', maltese: '✠', orthodox: '☦', fleurDeLis: '⚜', star: '✦', diamond: '◆', heart: '❧', leaf: '❦', dagger: '†', doubleDagger: '‡', asterisk: '✽', florette: '✿', skull: '☠', crown: '♔', swords: '⚔', }; export interface OrnamentsProps extends HTMLAttributes { type?: 'divider' | 'corner' | 'frame' | 'fleuron' | 'symbols'; symbol?: keyof typeof ORNAMENT_SYMBOLS | string; symbols?: (keyof typeof ORNAMENT_SYMBOLS | string)[]; variant?: 'gold' | 'bone' | 'blood' | 'iron'; size?: 'sm' | 'md' | 'lg'; animated?: boolean; position?: 'top-left' | 'top-right' | 'bottom-left' | 'bottom-right' | 'all'; } const variantColors = { gold: 'text-amber-600', bone: 'text-stone-400', blood: 'text-red-800', iron: 'text-zinc-500', }; const sizeClasses = { sm: { symbol: 'text-sm', fleuron: 'text-xl' }, md: { symbol: 'text-xl', fleuron: 'text-3xl' }, lg: { symbol: 'text-2xl', fleuron: 'text-5xl' }, }; const getSymbol = (s: keyof typeof ORNAMENT_SYMBOLS | string): string => ORNAMENT_SYMBOLS[s as keyof typeof ORNAMENT_SYMBOLS] || s; export const Ornaments = forwardRef( ({ type = 'divider', symbol = 'cross', symbols, variant = 'gold', size = 'md', animated = false, position = 'all', className = '', ...props }, ref) => { const color = variantColors[variant]; const sizes = sizeClasses[size]; const sym = getSymbol(symbol); const animClass = animated ? 'animate-pulse' : ''; if (type === 'divider') { return (
{sym}
); } if (type === 'fleuron') { return (
{sym}
); } if (type === 'symbols') { const syms = symbols || ['star', 'diamond', 'star']; return (
{syms.map((s, i) => ( {getSymbol(s)} ))}
); } if (type === 'corner') { const cornerPositions = { 'top-left': 'top-0 left-0', 'top-right': 'top-0 right-0 -scale-x-100', 'bottom-left': 'bottom-0 left-0 -scale-y-100', 'bottom-right': 'bottom-0 right-0 -scale-100', }; const corners = position === 'all' ? Object.keys(cornerPositions) : [position]; return ( <> {corners.map((pos) => (
{sym}
))} ); } if (type === 'frame') { return (
{sym}
{sym}
); } return null; } ); Ornaments.displayName = 'Ornaments'; export default Ornaments;