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

This commit is contained in:
2026-03-13 02:11:33 +00:00
parent 49d3f657b4
commit 36fe70957a

View File

@@ -1,51 +1,41 @@
"use client";
import React, { SVGProps } from "react";
import { memo } from "react";
import useSvgTextLogo from "./useSvgTextLogo";
import { cls } from "@/lib/utils";
interface SvgTextLogoProps {
logoText: string;
adjustHeightFactor?: number;
verticalAlign?: "top" | "center";
className?: string;
export interface SvgTextLogoProps extends SVGProps<SVGSVGElement> {
text: string;
fontSize?: number;
fontWeight?: number | string;
fontFamily?: string;
letterSpacing?: number;
}
const SvgTextLogo = memo<SvgTextLogoProps>(function SvgTextLogo({
logoText,
adjustHeightFactor,
verticalAlign = "top",
className = "",
}) {
const { svgRef, textRef, viewBox, aspectRatio } = useSvgTextLogo(logoText, false, adjustHeightFactor);
export function SvgTextLogo({
text,
fontSize = 24,
fontWeight = 700,
fontFamily = "system-ui, -apple-system, sans-serif", letterSpacing = 0,
...props
}: SvgTextLogoProps) {
return (
<svg
ref={svgRef}
viewBox={viewBox}
className={cls("w-full", className)}
style={{ aspectRatio: aspectRatio }}
preserveAspectRatio="none"
role="img"
aria-label={`${logoText} logo`}
viewBox="0 0 200 50"
xmlns="http://www.w3.org/2000/svg"
{...props}
>
<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"
}}
x="50%"
y="50%"
textAnchor="middle"
dominantBaseline="central"
fontSize={fontSize}
fontWeight={fontWeight}
fontFamily={fontFamily}
letterSpacing={letterSpacing}
fill="currentColor"
>
{logoText}
{text}
</text>
</svg>
);
});
}
SvgTextLogo.displayName = "SvgTextLogo";
export default SvgTextLogo;
export default SvgTextLogo;