Files
f7dc5a9f-e042-4e99-a2f7-f01…/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?: string | number;
letterSpacing?: string | number;
}
export const SvgTextLogo: React.FC<SvgTextLogoProps> = ({
text,
className = '',
fontSize = 48,
fontWeight = 700,
letterSpacing = 2,
}) => {
const textLength = text.length;
const charWidth = fontSize * 0.6;
const totalWidth = textLength * charWidth + (textLength - 1) * 2;
const svgWidth = totalWidth + 40;
const svgHeight = fontSize + 20;
return (
<svg
width={svgWidth}
height={svgHeight}
viewBox={`0 0 ${svgWidth} ${svgHeight}`}
className={className}
xmlns="http://www.w3.org/2000/svg"
>
<text
x={svgWidth / 2}
y={svgHeight / 2}
fontSize={fontSize}
fontWeight={fontWeight}
letterSpacing={letterSpacing}
textAnchor="middle"
dominantBaseline="central"
fill="currentColor"
>
{text}
</text>
</svg>
);
};
export default SvgTextLogo;