Files
063d3d89-b7d2-4e3d-8916-54c…/src/components/shared/SvgTextLogo/SvgTextLogo.tsx

54 lines
1.1 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 = 64,
fontWeight = 'bold',
letterSpacing = 2,
fill = 'currentColor',
}) => {
const textLength = text.length;
const charWidth = fontSize * 0.6;
const totalWidth = textLength * charWidth + (textLength - 1) * letterSpacing + 40;
const svgHeight = fontSize + 40;
return (
<svg
viewBox={`0 0 ${totalWidth} ${svgHeight}`}
className={className}
preserveAspectRatio="xMidYMid meet"
style={{
width: '100%',
height: 'auto',
display: 'block',
}}
>
<text
x="50%"
y="50%"
dominantBaseline="central"
textAnchor="middle"
fontSize={fontSize}
fontWeight={fontWeight}
letterSpacing={letterSpacing}
fill={fill}
fontFamily="inherit"
>
{text}
</text>
</svg>
);
};
export default SvgTextLogo;