Files
f09315ec-87b1-4b70-a1fc-ac3…/src/components/shared/SvgTextLogo/SvgTextLogo.tsx

50 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 = 48,
fontWeight = 700,
letterSpacing = 0,
fill = 'currentColor',
}) => {
const estimatedWidth = text.length * (fontSize * 0.6);
const padding = 20;
const width = estimatedWidth + padding * 2;
const height = fontSize + padding * 2;
return (
<svg
width="100%"
height="100%"
viewBox={`0 0 ${width} ${height}`}
preserveAspectRatio="xMidYMid meet"
className={className}
xmlns="http://www.w3.org/2000/svg"
>
<text
x={padding}
y={padding + fontSize * 0.75}
fontSize={fontSize}
fontWeight={fontWeight}
letterSpacing={letterSpacing}
fill={fill}
dominantBaseline="middle"
textAnchor="start"
>
{text}
</text>
</svg>
);
};
export default SvgTextLogo;