Files
5c805d6e-3b2e-4f57-a3d6-9d5…/src/components/shared/SvgTextLogo/SvgTextLogo.tsx

50 lines
1.0 KiB
TypeScript

import React from 'react';
interface SvgTextLogoProps {
text: string;
className?: string;
fontSize?: number;
fontWeight?: number | string;
letterSpacing?: number;
fill?: string;
}
const SvgTextLogo: React.FC<SvgTextLogoProps> = ({
text,
className,
fontSize = 32,
fontWeight = 700,
letterSpacing = 0,
fill = 'currentColor',
}) => {
const textLength = text.length;
const charWidth = fontSize * 0.6;
const width = textLength * charWidth + letterSpacing * (textLength - 1);
const height = fontSize * 1.2;
return (
<svg
viewBox={`0 0 ${width} ${height}`}
className={className}
preserveAspectRatio="xMidYMid meet"
role="img"
aria-label={text}
>
<text
x="50%"
y="50%"
textAnchor="middle"
dominantBaseline="central"
fontSize={fontSize}
fontWeight={fontWeight}
fill={fill}
letterSpacing={letterSpacing}
>
{text}
</text>
</svg>
);
};
export default SvgTextLogo;