Files
b8037b52-d8f0-47ce-b45b-2f7…/src/components/shared/SvgTextLogo/SvgTextLogo.tsx

58 lines
1.4 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 = 'bold',
letterSpacing = 2,
}) => {
const charWidth = fontSize * 0.6;
const totalWidth = text.length * charWidth + (text.length - 1) * letterSpacing;
const padding = 20;
const width = totalWidth + padding * 2;
const height = fontSize + padding * 2;
return (
<svg
width={width}
height={height}
viewBox={`0 0 ${width} ${height}`}
className={className}
role="img"
aria-label={text}
>
<defs>
<linearGradient id="textGradient" x1="0%" y1="0%" x2="100%" y2="0%">
<stop offset="0%" stopColor="#3b82f6" />
<stop offset="50%" stopColor="#8b5cf6" />
<stop offset="100%" stopColor="#ec4899" />
</linearGradient>
</defs>
<text
x={padding}
y={padding + fontSize}
fontSize={fontSize}
fontWeight={fontWeight}
letterSpacing={letterSpacing}
fill="url(#textGradient)"
dominantBaseline="hanging"
fontFamily="system-ui, -apple-system, sans-serif"
>
{text}
</text>
</svg>
);
};
export default SvgTextLogo;