50 lines
1.1 KiB
TypeScript
50 lines
1.1 KiB
TypeScript
import React from 'react';
|
|
|
|
interface SvgTextLogoProps {
|
|
text: string;
|
|
className?: string;
|
|
textClassName?: string;
|
|
fontSize?: number;
|
|
fontWeight?: number | string;
|
|
fontFamily?: string;
|
|
fill?: string;
|
|
}
|
|
|
|
const SvgTextLogo: React.FC<SvgTextLogoProps> = ({
|
|
text,
|
|
className = '',
|
|
textClassName = '',
|
|
fontSize = 24,
|
|
fontWeight = 'bold',
|
|
fontFamily = 'system-ui, -apple-system, sans-serif',
|
|
fill = 'currentColor',
|
|
}) => {
|
|
const estimatedWidth = text.length * (fontSize as number) * 0.6;
|
|
const estimatedHeight = (fontSize as number) * 1.2;
|
|
|
|
return (
|
|
<svg
|
|
width={estimatedWidth}
|
|
height={estimatedHeight}
|
|
viewBox={`0 0 ${estimatedWidth} ${estimatedHeight}`}
|
|
className={className}
|
|
role="img"
|
|
aria-label={text}
|
|
>
|
|
<text
|
|
x="0"
|
|
y={fontSize}
|
|
className={textClassName}
|
|
fontSize={fontSize}
|
|
fontWeight={fontWeight}
|
|
fontFamily={fontFamily}
|
|
fill={fill}
|
|
dominantBaseline="hanging"
|
|
>
|
|
{text}
|
|
</text>
|
|
</svg>
|
|
);
|
|
};
|
|
|
|
export default SvgTextLogo; |