From c4426bceb2d216cbbb5d3c6cd12de5a45f288936 Mon Sep 17 00:00:00 2001 From: bender Date: Thu, 12 Mar 2026 04:18:49 +0000 Subject: [PATCH] Update src/components/shared/SvgTextLogo/SvgTextLogo.tsx --- .../shared/SvgTextLogo/SvgTextLogo.tsx | 80 +++++++++++-------- 1 file changed, 45 insertions(+), 35 deletions(-) diff --git a/src/components/shared/SvgTextLogo/SvgTextLogo.tsx b/src/components/shared/SvgTextLogo/SvgTextLogo.tsx index f214190..84b3382 100644 --- a/src/components/shared/SvgTextLogo/SvgTextLogo.tsx +++ b/src/components/shared/SvgTextLogo/SvgTextLogo.tsx @@ -1,51 +1,61 @@ -"use client"; - -import { memo } from "react"; -import useSvgTextLogo from "./useSvgTextLogo"; -import { cls } from "@/lib/utils"; +import React, { useEffect, useRef } from 'react'; interface SvgTextLogoProps { - logoText: string; - adjustHeightFactor?: number; - verticalAlign?: "top" | "center"; + text?: string; className?: string; + textClassName?: string; + fontSize?: number; + fontWeight?: number | string; + letterSpacing?: number; + dominantBaseline?: 'auto' | 'text-top' | 'hanging' | 'middle' | 'central' | 'text-bottom' | 'ideographic' | 'mathematical' | 'inherit'; } -const SvgTextLogo = memo(function SvgTextLogo({ - logoText, - adjustHeightFactor, - verticalAlign = "top", - className = "", -}) { - const { svgRef, textRef, viewBox, aspectRatio } = useSvgTextLogo(logoText, false, adjustHeightFactor); +export const SvgTextLogo: React.FC = ({ + text = 'Logo', + className = '', + textClassName = '', + fontSize = 32, + fontWeight = 700, + letterSpacing = 0, + dominantBaseline = 'central', +}) => { + const svgRef = useRef(null); + + useEffect(() => { + if (svgRef.current) { + const textElement = svgRef.current.querySelector('text'); + if (textElement) { + const bbox = textElement.getBBox(); + svgRef.current.setAttribute('viewBox', `${bbox.x - 10} ${bbox.y - 10} ${bbox.width + 20} ${bbox.height + 20}`); + svgRef.current.setAttribute('width', String(bbox.width + 20)); + svgRef.current.setAttribute('height', String(bbox.height + 20)); + } + } + }, [text]); return ( - {logoText} + {text} ); -}); +}; -SvgTextLogo.displayName = "SvgTextLogo"; - -export default SvgTextLogo; +export default SvgTextLogo; \ No newline at end of file