Merge version_1 into main #2

Merged
bender merged 1 commits from version_1 into main 2026-03-12 17:52:45 +00:00

View File

@@ -1,51 +1,79 @@
"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;
fontSize?: number;
fontFamily?: string;
fontWeight?: string | number;
letterSpacing?: number;
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 = '',
fontSize = 48,
fontFamily = 'Arial, sans-serif',
fontWeight = 'bold',
letterSpacing = 0,
animationDuration = 1.5,
}) => {
const textLength = text.length;
const letterWidth = fontSize * 0.6;
const svgWidth = textLength * letterWidth + letterSpacing * (textLength - 1);
const svgHeight = fontSize * 1.5;
return (
<svg
ref={svgRef}
viewBox={viewBox}
className={cls("w-full", className)}
style={{ aspectRatio: aspectRatio }}
preserveAspectRatio="none"
role="img"
aria-label={`${logoText} logo`}
width={svgWidth}
height={svgHeight}
viewBox={`0 0 ${svgWidth} ${svgHeight}`}
className={className}
style={{
overflow: 'visible',
}}
>
<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>
<defs>
<style>
{`
@keyframes fadeInUp {
from {
opacity: 0;
transform: translateY(20px);
}
to {
opacity: 1;
transform: translateY(0);
}
}
.svg-letter {
animation: fadeInUp ${animationDuration}s ease-out forwards;
transform-origin: center bottom;
}
`}
</style>
</defs>
{text.split('').map((letter, index) => (
<text
key={index}
x={index * (letterWidth + letterSpacing)}
y={svgHeight * 0.7}
fontSize={fontSize}
fontFamily={fontFamily}
fontWeight={fontWeight}
fill="currentColor"
dominantBaseline="middle"
className="svg-letter"
style={{
animationDelay: `${index * 0.05}s`,
}}
>
{letter}
</text>
))}
</svg>
);
});
SvgTextLogo.displayName = "SvgTextLogo";
};
export default SvgTextLogo;