51 lines
1.2 KiB
TypeScript
51 lines
1.2 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 = 48,
|
|
fontWeight = 700,
|
|
letterSpacing = 0,
|
|
}) => {
|
|
const textLength = text.length;
|
|
const charWidth = fontSize * 0.6;
|
|
const totalWidth = textLength * charWidth + letterSpacing * (textLength - 1);
|
|
const padding = 20;
|
|
const svgWidth = totalWidth + padding * 2;
|
|
const svgHeight = fontSize + padding * 2;
|
|
|
|
return (
|
|
<svg
|
|
width={svgWidth}
|
|
height={svgHeight}
|
|
viewBox={`0 0 ${svgWidth} ${svgHeight}`}
|
|
xmlns="http://www.w3.org/2000/svg"
|
|
className={className}
|
|
preserveAspectRatio="xMidYMid meet"
|
|
>
|
|
<text
|
|
x={padding}
|
|
y={padding + fontSize * 0.75}
|
|
fontSize={fontSize}
|
|
fontWeight={fontWeight}
|
|
letterSpacing={letterSpacing}
|
|
fill="currentColor"
|
|
fontFamily="system-ui, -apple-system, sans-serif"
|
|
dominantBaseline="middle"
|
|
>
|
|
{text}
|
|
</text>
|
|
</svg>
|
|
);
|
|
};
|
|
|
|
export default SvgTextLogo;
|