Files
5a00e24c-9010-4b35-aadc-a01…/src/components/shared/SvgTextLogo/SvgTextLogo.tsx

49 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 textLength = text.length;
const charWidth = fontSize * 0.6;
const totalWidth = textLength * charWidth + (textLength - 1) * letterSpacing + 40;
const totalHeight = fontSize * 1.5;
return (
<svg
viewBox={`0 0 ${totalWidth} ${totalHeight}`}
className={`w-full h-auto ${className}`}
preserveAspectRatio="xMidYMid meet"
>
<text
x={totalWidth / 2}
y={totalHeight / 2}
textAnchor="middle"
dominantBaseline="central"
fontSize={fontSize}
fontWeight={fontWeight}
letterSpacing={letterSpacing}
fill={fill}
fontFamily="inherit"
>
{text}
</text>
</svg>
);
};
export default SvgTextLogo;