Files
38d2948d-1bcb-456a-b794-db3…/src/components/shared/SvgTextLogo/SvgTextLogo.tsx

48 lines
1.0 KiB
TypeScript

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