52 lines
1.2 KiB
TypeScript
52 lines
1.2 KiB
TypeScript
import React from 'react';
|
|
|
|
interface SvgTextLogoProps {
|
|
text: string;
|
|
className?: string;
|
|
fontSize?: number;
|
|
fontWeight?: number | string;
|
|
textAnchor?: 'start' | 'middle' | 'end';
|
|
dominantBaseline?: 'auto' | 'text-top' | 'hanging' | 'middle' | 'central' | 'text-bottom' | 'ideographic' | 'mathematical' | 'baseline' | 'inherit';
|
|
fill?: string;
|
|
}
|
|
|
|
const SvgTextLogo: React.FC<SvgTextLogoProps> = ({
|
|
text,
|
|
className = '',
|
|
fontSize = 24,
|
|
fontWeight = 700,
|
|
textAnchor = 'middle',
|
|
dominantBaseline = 'middle',
|
|
fill = 'currentColor',
|
|
}) => {
|
|
const viewBoxWidth = text.length * fontSize * 0.6;
|
|
const viewBoxHeight = fontSize * 1.5;
|
|
const xPosition = viewBoxWidth / 2;
|
|
const yPosition = viewBoxHeight / 2;
|
|
|
|
return (
|
|
<svg
|
|
viewBox={`0 0 ${viewBoxWidth} ${viewBoxHeight}`}
|
|
className={`text-logo ${className}`}
|
|
xmlns="http://www.w3.org/2000/svg"
|
|
aria-label={`Logo: ${text}`}
|
|
role="img"
|
|
>
|
|
<text
|
|
x={xPosition}
|
|
y={yPosition}
|
|
fontSize={fontSize}
|
|
fontWeight={fontWeight}
|
|
textAnchor={textAnchor}
|
|
dominantBaseline={dominantBaseline}
|
|
fill={fill}
|
|
fontFamily="inherit"
|
|
>
|
|
{text}
|
|
</text>
|
|
</svg>
|
|
);
|
|
};
|
|
|
|
export default SvgTextLogo;
|