54 lines
1.4 KiB
TypeScript
54 lines
1.4 KiB
TypeScript
import React from 'react';
|
|
|
|
interface SvgTextLogoProps {
|
|
text: string;
|
|
className?: string;
|
|
fontSize?: number;
|
|
fontWeight?: number | string;
|
|
letterSpacing?: number;
|
|
}
|
|
|
|
export const SvgTextLogo: React.FC<SvgTextLogoProps> = ({
|
|
text,
|
|
className = '',
|
|
fontSize = 32,
|
|
fontWeight = 700,
|
|
letterSpacing = 0,
|
|
}) => {
|
|
const textLength = text.length;
|
|
const charWidth = fontSize * 0.6;
|
|
const totalWidth = textLength * charWidth + letterSpacing * (textLength - 1);
|
|
const viewBoxWidth = totalWidth + fontSize;
|
|
const viewBoxHeight = fontSize * 1.5;
|
|
|
|
return (
|
|
<svg
|
|
viewBox={`0 0 ${viewBoxWidth} ${viewBoxHeight}`}
|
|
className={`w-auto h-auto ${className}`}
|
|
preserveAspectRatio="xMidYMid meet"
|
|
xmlns="http://www.w3.org/2000/svg"
|
|
>
|
|
<defs>
|
|
<linearGradient id="textGradient" x1="0%" y1="0%" x2="100%" y2="0%">
|
|
<stop offset="0%" style={{ stopColor: 'currentColor', stopOpacity: 1 }} />
|
|
<stop offset="100%" style={{ stopColor: 'currentColor', stopOpacity: 0.8 }} />
|
|
</linearGradient>
|
|
</defs>
|
|
<text
|
|
x={fontSize / 2}
|
|
y={viewBoxHeight * 0.65}
|
|
fontSize={fontSize}
|
|
fontWeight={fontWeight}
|
|
letterSpacing={letterSpacing}
|
|
fill="url(#textGradient)"
|
|
fontFamily="system-ui, -apple-system, sans-serif"
|
|
dominantBaseline="middle"
|
|
>
|
|
{text}
|
|
</text>
|
|
</svg>
|
|
);
|
|
};
|
|
|
|
export default SvgTextLogo;
|