'use client'; import { forwardRef, HTMLAttributes } from 'react'; import styles from './ornaments.module.css'; export const ORNAMENT_SYMBOLS = { cross: '✝', maltese: '✠', orthodox: '☦', fleurDeLis: '⚜', star: '✦', diamond: '◆', heart: '❧', leaf: '❦', dagger: '†', doubleDagger: '‡', asterisk: '✽', florette: '✿', skull: '☠', crown: '♔', swords: '⚔', }; export interface OrnamentsProps extends HTMLAttributes { /** Ornament type */ type?: 'divider' | 'corner' | 'frame' | 'fleuron' | 'symbols'; /** Symbol to use */ symbol?: keyof typeof ORNAMENT_SYMBOLS | string; /** Multiple symbols */ symbols?: (keyof typeof ORNAMENT_SYMBOLS | string)[]; /** Color variant */ variant?: 'gold' | 'bone' | 'blood' | 'iron'; /** Size */ size?: 'sm' | 'md' | 'lg'; /** Animate */ animated?: boolean; /** Corner position (for type='corner') */ position?: 'top-left' | 'top-right' | 'bottom-left' | 'bottom-right' | 'all'; } 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 baseClasses = `${styles.ornament} ${styles[variant]} ${styles[size]} ${animated ? styles.animated : ''}`; const sym = getSymbol(symbol); 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 corners = position === 'all' ? ['TopLeft', 'TopRight', 'BottomLeft', 'BottomRight'] : [position.split('-').map((p, i) => i === 0 ? p.charAt(0).toUpperCase() + p.slice(1) : p.charAt(0).toUpperCase() + p.slice(1)).join('')]; return ( <> {corners.map((pos) => (
{sym}
))} ); } if (type === 'frame') { return (
{sym}
{sym}
); } return null; } ); Ornaments.displayName = 'Ornaments'; export default Ornaments;