Update src/components/shared/SvgTextLogo/SvgTextLogo.tsx

This commit is contained in:
2026-03-11 02:34:07 +00:00
parent 76d7100745
commit cefbc5c19b

View File

@@ -1,51 +1,45 @@
"use client"; import React from 'react';
import { memo } from "react";
import useSvgTextLogo from "./useSvgTextLogo";
import { cls } from "@/lib/utils";
interface SvgTextLogoProps { interface SvgTextLogoProps {
logoText: string; text: string;
adjustHeightFactor?: number;
verticalAlign?: "top" | "center";
className?: string; className?: string;
fontSize?: number;
fontWeight?: number | string;
fill?: string;
strokeWidth?: number;
stroke?: string;
} }
const SvgTextLogo = memo<SvgTextLogoProps>(function SvgTextLogo({ const SvgTextLogo: React.FC<SvgTextLogoProps> = ({
logoText, text,
adjustHeightFactor, className = '',
verticalAlign = "top", fontSize = 48,
className = "", fontWeight = 'bold',
}) { fill = 'currentColor',
const { svgRef, textRef, viewBox, aspectRatio } = useSvgTextLogo(logoText, false, adjustHeightFactor); strokeWidth = 0,
stroke = 'none',
}) => {
return ( return (
<svg <svg
ref={svgRef} viewBox={`0 0 ${text.length * fontSize * 0.6} ${fontSize * 1.2}`}
viewBox={viewBox} className={className}
className={cls("w-full", className)} xmlns="http://www.w3.org/2000/svg"
style={{ aspectRatio: aspectRatio }}
preserveAspectRatio="none"
role="img"
aria-label={`${logoText} logo`}
> >
<text <text
ref={textRef} x="50%"
x="0" y="50%"
y={verticalAlign === "center" ? "50%" : "0"} textAnchor="middle"
className="font-bold fill-current" dominantBaseline="central"
style={{ fontSize={fontSize}
fontSize: "20px", fontWeight={fontWeight}
letterSpacing: "-0.02em", fill={fill}
dominantBaseline: verticalAlign === "center" ? "middle" : "text-before-edge" strokeWidth={strokeWidth}
}} stroke={stroke}
> >
{logoText} {text}
</text> </text>
</svg> </svg>
); );
}); };
SvgTextLogo.displayName = "SvgTextLogo";
export default SvgTextLogo; export default SvgTextLogo;