Files
d5319037-d06e-4635-adcb-fee…/src/components/shared/SvgTextLogo/SvgTextLogo.tsx

49 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 width = textLength * charWidth + letterSpacing * (textLength - 1) + 20;
const height = fontSize + 20;
const x = 10;
const y = fontSize + 10;
return (
<svg
width={width}
height={height}
viewBox={`0 0 ${width} ${height}`}
xmlns="http://www.w3.org/2000/svg"
className={className}
aria-label={text}
>
<text
x={x}
y={y}
fontSize={fontSize}
fontWeight={fontWeight}
letterSpacing={letterSpacing}
fill="currentColor"
dominantBaseline="middle"
>
{text}
</text>
</svg>
);
};
export default SvgTextLogo;