Files
b20c3c8e-84d1-4b95-8d98-b82…/src/components/shared/SvgTextLogo/SvgTextLogo.tsx

48 lines
1.0 KiB
TypeScript

import React from 'react';
interface SvgTextLogoProps {
text: string;
className?: string;
fontSize?: number;
fontWeight?: number | string;
letterSpacing?: number;
}
const SvgTextLogo: React.FC<SvgTextLogoProps> = ({
text,
className = '',
fontSize = 24,
fontWeight = 700,
letterSpacing = 0,
}) => {
const textLength = text.length;
const charWidth = fontSize * 0.6;
const totalWidth = textLength * charWidth + letterSpacing * (textLength - 1);
const padding = 16;
const width = totalWidth + padding * 2;
const height = fontSize + padding * 2;
return (
<svg
width={width}
height={height}
viewBox={`0 0 ${width} ${height}`}
xmlns="http://www.w3.org/2000/svg"
className={className}
>
<text
x={padding}
y={padding + fontSize * 0.75}
fontSize={fontSize}
fontWeight={fontWeight}
letterSpacing={letterSpacing}
fill="currentColor"
dominantBaseline="central"
>
{text}
</text>
</svg>
);
};
export default SvgTextLogo;