import React from 'react';

interface SvgTextLogoProps {
  text: string;
  className?: string;
  fontSize?: number;
  fontWeight?: number | string;
  letterSpacing?: number;
  textAnchor?: 'start' | 'middle' | 'end';
  dominantBaseline?: 'auto' | 'middle' | 'hanging';
}

export const SvgTextLogo: React.FC<SvgTextLogoProps> = ({
  text,
  className = '',
  fontSize = 24,
  fontWeight = 700,
  letterSpacing = 0,
  textAnchor = 'middle',
  dominantBaseline = 'middle',
}) => {
  // Calculate SVG dimensions based on text length and font size
  const charWidth = fontSize * 0.6;
  const width = Math.max(text.length * charWidth + 40, 200);
  const height = fontSize + 40;
  const x = width / 2;
  const y = height / 2;

  return (
    <svg
      width={width}
      height={height}
      viewBox={`0 0 ${width} ${height}`}
      className={`inline-block ${className}`}
      role="img"
      aria-label={text}
    >
      <text
        x={x}
        y={y}
        fontSize={fontSize}
        fontWeight={fontWeight}
        letterSpacing={letterSpacing}
        textAnchor={textAnchor}
        dominantBaseline={dominantBaseline}
        className="fill-current"
      >
        {text}
      </text>
    </svg>
  );
};

export default SvgTextLogo;