Files
ba04bc5a-3ab9-4f38-99cf-3fe…/src/components/shared/SvgTextLogo/SvgTextLogo.tsx

55 lines
1.3 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 = 48,
fontWeight = 700,
letterSpacing = 0,
}) => {
const textLength = text.length;
const charWidth = fontSize * 0.6;
const width = textLength * charWidth + letterSpacing * (textLength - 1);
const height = fontSize * 1.4;
return (
<svg
width={width}
height={height}
viewBox={`0 0 ${width} ${height}`}
className={className}
xmlns="http://www.w3.org/2000/svg"
>
<defs>
<linearGradient id="textGradient" x1="0%" y1="0%" x2="100%" y2="100%">
<stop offset="0%" stopColor="#00D4FF" />
<stop offset="50%" stopColor="#0099FF" />
<stop offset="100%" stopColor="#6633FF" />
</linearGradient>
</defs>
<text
x="50%"
y="50%"
dominantBaseline="middle"
textAnchor="middle"
fontSize={fontSize}
fontWeight={fontWeight}
letterSpacing={letterSpacing}
fill="url(#textGradient)"
fontFamily="system-ui, -apple-system, sans-serif"
>
{text}
</text>
</svg>
);
};
export default SvgTextLogo;