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

This commit is contained in:
2026-03-11 08:14:29 +00:00
parent 76aad1c53c
commit 53dcf46144

View File

@@ -1,51 +1,51 @@
"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;
textClassName?: string;
svgClassName?: string;
animationDuration?: number;
}
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 = '',
textClassName = '',
svgClassName = '',
animationDuration = 2,
}) => {
const textId = `text-path-${Math.random().toString(36).substr(2, 9)}`;
return (
<svg
ref={svgRef}
viewBox={viewBox}
className={cls("w-full", className)}
style={{ aspectRatio: aspectRatio }}
preserveAspectRatio="none"
role="img"
aria-label={`${logoText} logo`}
>
<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"
}}
<div className={`flex items-center justify-center ${className}`}>
<svg
viewBox="0 0 800 600"
className={`w-full h-full ${svgClassName}`}
preserveAspectRatio="xMidYMid meet"
>
{logoText}
</text>
</svg>
);
});
<defs>
<path
id={textId}
d="M 100,300 Q 400,100 700,300"
fill="none"
/>
</defs>
SvgTextLogo.displayName = "SvgTextLogo";
<text
className={`fill-current font-bold ${textClassName}`}
fontSize="48"
letterSpacing="2"
fill="currentColor"
dominantBaseline="middle"
>
<textPath href={`#${textId}`} startOffset="50%" textAnchor="middle">
{text}
</textPath>
</text>
</svg>
</div>
);
};
export default SvgTextLogo;