Files
17ea8a15-1723-4d91-83d9-ff4…/src/components/shared/SvgTextLogo/SvgTextLogo.tsx

49 lines
1.1 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' | 'ideographic' | 'mathematical' | 'central';
}
export 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 width = textLength * charWidth + 40;
const height = fontSize + 40;
return (
<svg
viewBox={`0 0 ${width} ${height}`}
width={width}
height={height}
className={className}
xmlns="http://www.w3.org/2000/svg"
>
<text
x={width / 2}
y={height / 2}
textAnchor="middle"
dominantBaseline={dominantBaseline}
fontSize={fontSize}
fontWeight={fontWeight}
letterSpacing={letterSpacing}
fill="currentColor"
>
{text}
</text>
</svg>
);
};
export default SvgTextLogo;