55 lines
1.1 KiB
TypeScript
55 lines
1.1 KiB
TypeScript
import React from 'react';
|
|
|
|
interface SvgTextLogoProps {
|
|
text: string;
|
|
className?: string;
|
|
fontSize?: number;
|
|
fontWeight?: number | string;
|
|
letterSpacing?: number;
|
|
fill?: string;
|
|
strokeWidth?: number;
|
|
stroke?: string;
|
|
}
|
|
|
|
const SvgTextLogo: React.FC<SvgTextLogoProps> = ({
|
|
text,
|
|
className = '',
|
|
fontSize = 48,
|
|
fontWeight = 700,
|
|
letterSpacing = 0,
|
|
fill = 'currentColor',
|
|
strokeWidth = 0,
|
|
stroke = 'none',
|
|
}) => {
|
|
const textLength = text.length;
|
|
const charWidth = fontSize * 0.6;
|
|
const svgWidth = textLength * charWidth + 40;
|
|
const svgHeight = fontSize + 40;
|
|
|
|
return (
|
|
<svg
|
|
width={svgWidth}
|
|
height={svgHeight}
|
|
viewBox={`0 0 ${svgWidth} ${svgHeight}`}
|
|
className={className}
|
|
xmlns="http://www.w3.org/2000/svg"
|
|
>
|
|
<text
|
|
x="20"
|
|
y={fontSize + 10}
|
|
fontSize={fontSize}
|
|
fontWeight={fontWeight}
|
|
letterSpacing={letterSpacing}
|
|
fill={fill}
|
|
strokeWidth={strokeWidth}
|
|
stroke={stroke}
|
|
fontFamily="inherit"
|
|
dominantBaseline="hanging"
|
|
>
|
|
{text}
|
|
</text>
|
|
</svg>
|
|
);
|
|
};
|
|
|
|
export default SvgTextLogo; |