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

This commit is contained in:
2026-03-11 15:39:58 +00:00
parent 43d3833b72
commit ce7bc03435

View File

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