Files
73745f92-e50c-4d4c-a921-63f…/src/components/shared/SvgTextLogo/SvgTextLogo.tsx

50 lines
1.2 KiB
TypeScript

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' | 'ideographic' | 'alphabetic' | 'central' | 'mathematical' | 'inherit';
}
const SvgTextLogo: React.FC<SvgTextLogoProps> = ({
text,
className = '',
fontSize = 32,
fontWeight = 'bold',
letterSpacing = 0,
textAnchor = 'middle',
dominantBaseline = 'middle',
}) => {
const svgWidth = text.length * (fontSize * 0.6) + 40;
const svgHeight = fontSize + 20;
return (
<svg
width={svgWidth}
height={svgHeight}
viewBox={`0 0 ${svgWidth} ${svgHeight}`}
className={className}
xmlns="http://www.w3.org/2000/svg"
>
<text
x={svgWidth / 2}
y={svgHeight / 2}
fontSize={fontSize}
fontWeight={fontWeight}
letterSpacing={letterSpacing}
textAnchor={textAnchor}
dominantBaseline={dominantBaseline}
fill="currentColor"
>
{text}
</text>
</svg>
);
};
export default SvgTextLogo;