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

This commit is contained in:
2026-03-10 19:44:09 +00:00
parent 4b1e72f0c8
commit 7cf3ef505e

View File

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