Merge version_1 into main #2

Merged
bender merged 1 commits from version_1 into main 2026-03-11 22:20:18 +00:00

View File

@@ -1,51 +1,80 @@
"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;
fontWeight?: number | string;
letterSpacing?: number;
fillColor?: string;
strokeColor?: string;
strokeWidth?: number;
shadowColor?: string;
shadowBlur?: number;
shadowOffsetX?: number;
shadowOffsetY?: number;
}
const SvgTextLogo = memo<SvgTextLogoProps>(function SvgTextLogo({
logoText,
adjustHeightFactor,
verticalAlign = "top",
className = "",
}) {
const { svgRef, textRef, viewBox, aspectRatio } = useSvgTextLogo(logoText, false, adjustHeightFactor);
const SvgTextLogo = React.forwardRef<SVGSVGElement, SvgTextLogoProps>(
(
{
text,
className = '',
fontSize = 48,
fontWeight = 700,
letterSpacing = 2,
fillColor = '#000000',
strokeColor = '#ffffff',
strokeWidth = 0,
shadowColor = '#000000',
shadowBlur = 4,
shadowOffsetX = 0,
shadowOffsetY = 2,
},
ref
) => {
const filterId = `shadow-${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"
}}
return (
<svg
ref={ref}
viewBox={`0 0 ${text.length * (fontSize * 0.6)} ${fontSize * 1.2}`}
className={className}
xmlns="http://www.w3.org/2000/svg"
>
{logoText}
</text>
</svg>
);
});
<defs>
<filter id={filterId} x="-50%" y="-50%" width="200%" height="200%">
<feGaussianBlur in="SourceAlpha" stdDeviation={shadowBlur} />
<feOffset dx={shadowOffsetX} dy={shadowOffsetY} result="offsetblur" />
<feComponentTransfer>
<feFuncA type="linear" slope="0.3" />
</feComponentTransfer>
<feMerge>
<feMergeNode />
<feMergeNode in="SourceGraphic" />
</feMerge>
</filter>
</defs>
<text
x={fontSize * 0.1}
y={fontSize * 0.8}
fontSize={fontSize}
fontWeight={fontWeight}
letterSpacing={letterSpacing}
fill={fillColor}
stroke={strokeColor}
strokeWidth={strokeWidth}
filter={`url(#${filterId})`}
dominantBaseline="middle"
fontFamily="system-ui, -apple-system, sans-serif"
>
{text}
</text>
</svg>
);
}
);
SvgTextLogo.displayName = "SvgTextLogo";
SvgTextLogo.displayName = 'SvgTextLogo';
export default SvgTextLogo;