Files
355322fc-2b94-4e3a-bf8f-976…/src/components/shared/SvgTextLogo/SvgTextLogo.tsx

49 lines
1.0 KiB
TypeScript

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