Merge version_1 into main

Merge version_1 into main
This commit was merged in pull request #1.
This commit is contained in:
2026-03-12 14:55:31 +00:00

View File

@@ -1,51 +1,71 @@
"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;
fontSize?: number;
letterSpacing?: number;
fontWeight?: number | string;
fill?: 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 = '',
textClassName = '',
svgClassName = '',
fontSize = 48,
letterSpacing = 0,
fontWeight = 'bold',
fill = 'currentColor',
}) => {
const textRef = React.useRef<SVGTextElement>(null);
const [dimensions, setDimensions] = React.useState({ width: 400, height: 100 });
React.useEffect(() => {
if (textRef.current) {
try {
const bbox = textRef.current.getBBox();
setDimensions({
width: Math.ceil(bbox.width) + 20,
height: Math.ceil(bbox.height) + 20,
});
} catch (e) {
// SVG not yet rendered, use defaults
}
}
}, [text, fontSize, letterSpacing, fontWeight]);
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={`inline-flex items-center justify-center ${className}`}>
<svg
width={dimensions.width}
height={dimensions.height}
viewBox={`0 0 ${dimensions.width} ${dimensions.height}`}
className={`${svgClassName}`}
xmlns="http://www.w3.org/2000/svg"
role="img"
aria-label={text}
>
{logoText}
</text>
</svg>
<text
ref={textRef}
x={dimensions.width / 2}
y={dimensions.height / 2}
fontSize={fontSize}
fontWeight={fontWeight}
letterSpacing={letterSpacing}
fill={fill}
textAnchor="middle"
dominantBaseline="middle"
className={`${textClassName}`}
>
{text}
</text>
</svg>
</div>
);
});
SvgTextLogo.displayName = "SvgTextLogo";
};
export default SvgTextLogo;