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

This commit is contained in:
2026-03-10 22:31:08 +00:00
parent 4441455ddf
commit 9191bb2011

View File

@@ -1,51 +1,63 @@
"use client";
import React, { CSSProperties } from 'react';
import { memo } from "react";
import useSvgTextLogo from "./useSvgTextLogo";
import { cls } from "@/lib/utils";
interface SvgTextLogoProps {
logoText: string;
adjustHeightFactor?: number;
verticalAlign?: "top" | "center";
export interface SvgTextLogoProps {
text: string;
size?: 'small' | 'medium' | 'large';
weight?: 'light' | 'normal' | 'bold';
color?: string;
className?: string;
style?: CSSProperties;
}
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,
size = 'medium',
weight = 'normal',
color = 'currentColor',
className = '',
style = {},
}) => {
const sizes = {
small: { fontSize: '16px', height: '24px' },
medium: { fontSize: '24px', height: '32px' },
large: { fontSize: '32px', height: '48px' },
};
const weights = {
light: 300,
normal: 400,
bold: 700,
};
const baselineOffset = '0.35em';
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 ${text.length * 20} 40`}
className={className}
style={{
...sizes[size],
...style,
}}
preserveAspectRatio="xMidYMid meet"
>
<text
ref={textRef}
x="0"
y={verticalAlign === "center" ? "50%" : "0"}
className="font-bold fill-current"
x="50%"
y="50%"
dominantBaseline="middle"
textAnchor="middle"
fontSize={sizes[size].fontSize}
fontWeight={weights[weight]}
fill={color}
style={{
fontSize: "20px",
letterSpacing: "-0.02em",
dominantBaseline: verticalAlign === "center" ? "middle" : "text-before-edge"
fontFamily: 'system-ui, -apple-system, sans-serif',
userSelect: 'none',
}}
>
{logoText}
{text}
</text>
</svg>
);
});
SvgTextLogo.displayName = "SvgTextLogo";
};
export default SvgTextLogo;