Files
f787a21e-0fbd-4226-8a9f-dec…/src/components/shared/SvgTextLogo/SvgTextLogo.tsx

59 lines
1.6 KiB
TypeScript

import React from 'react';
interface SvgTextLogoProps {
text: string;
className?: string;
fontSize?: number;
fontWeight?: number | string;
letterSpacing?: number;
dominantBaseline?: 'auto' | 'middle' | 'hanging' | 'text-top' | 'text-bottom' | 'ideographic' | 'central' | 'mathematical' | 'inherit';
}
const SvgTextLogo: React.FC<SvgTextLogoProps> = ({
text,
className = '',
fontSize = 48,
fontWeight = 700,
letterSpacing = 2,
dominantBaseline = 'middle',
}) => {
const textLength = text.length;
const charWidth = fontSize * 0.6;
const totalWidth = textLength * charWidth + letterSpacing * (textLength - 1) + 40;
const svgHeight = fontSize + 40;
return (
<svg
width={totalWidth}
height={svgHeight}
viewBox={`0 0 ${totalWidth} ${svgHeight}`}
xmlns="http://www.w3.org/2000/svg"
className={className}
role="img"
aria-label={text}
>
<defs>
<linearGradient id="textGradient" x1="0%" y1="0%" x2="100%" y2="100%">
<stop offset="0%" style={{ stopColor: '#3b82f6', stopOpacity: 1 }} />
<stop offset="100%" style={{ stopColor: '#1e40af', stopOpacity: 1 }} />
</linearGradient>
</defs>
<text
x={totalWidth / 2}
y={svgHeight / 2}
fontSize={fontSize}
fontWeight={fontWeight}
textAnchor="middle"
dominantBaseline="middle"
fill="url(#textGradient)"
letterSpacing={letterSpacing}
fontFamily="-apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', 'Oxygen', 'Ubuntu', 'Cantarell', sans-serif"
>
{text}
</text>
</svg>
);
};
export default SvgTextLogo;