Files
c5372218-ef76-4e62-965a-9c9…/src/components/shared/SvgTextLogo/SvgTextLogo.tsx

51 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 as number) * 0.6;
const padding = 20;
const width = estimatedWidth + padding * 2;
const height = (fontSize as number) + 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 as number) * 0.75}
fontSize={fontSize}
fontWeight={fontWeight}
letterSpacing={letterSpacing}
fill={fill}
dominantBaseline="central"
textAnchor="start"
>
{text}
</text>
</svg>
);
};
export default SvgTextLogo;