Files
aa09b440-5ae5-494d-87ec-86d…/src/components/shared/SvgTextLogo/SvgTextLogo.tsx

56 lines
1.2 KiB
TypeScript

import React from 'react';
interface SvgTextLogoProps {
text: string;
className?: string;
fontSize?: number;
fontWeight?: string | number;
letterSpacing?: number;
fill?: string;
strokeWidth?: number;
stroke?: string;
}
const SvgTextLogo: React.FC<SvgTextLogoProps> = ({
text,
className = '',
fontSize = 48,
fontWeight = 700,
letterSpacing = 0,
fill = 'currentColor',
strokeWidth = 0,
stroke = 'none',
}) => {
const padding = 20;
const estimatedWidth = text.length * fontSize * 0.6;
const svgWidth = estimatedWidth + padding * 2;
const svgHeight = fontSize + padding * 2;
return (
<svg
viewBox={`0 0 ${svgWidth} ${svgHeight}`}
className={className}
preserveAspectRatio="xMidYMid meet"
xmlns="http://www.w3.org/2000/svg"
>
<text
x={svgWidth / 2}
y={svgHeight / 2}
textAnchor="middle"
dominantBaseline="central"
fontSize={fontSize}
fontWeight={fontWeight}
letterSpacing={letterSpacing}
fill={fill}
strokeWidth={strokeWidth}
stroke={stroke}
fontFamily="inherit"
>
{text}
</text>
</svg>
);
};
export default SvgTextLogo;