From 4dec85c0ee90b0971fff1b8e70340e16caa33379 Mon Sep 17 00:00:00 2001 From: bender Date: Fri, 13 Mar 2026 06:47:47 +0000 Subject: [PATCH] Update src/components/shared/SvgTextLogo/SvgTextLogo.tsx --- .../shared/SvgTextLogo/SvgTextLogo.tsx | 84 +++++++++++-------- 1 file changed, 49 insertions(+), 35 deletions(-) diff --git a/src/components/shared/SvgTextLogo/SvgTextLogo.tsx b/src/components/shared/SvgTextLogo/SvgTextLogo.tsx index f214190..d60adab 100644 --- a/src/components/shared/SvgTextLogo/SvgTextLogo.tsx +++ b/src/components/shared/SvgTextLogo/SvgTextLogo.tsx @@ -1,51 +1,65 @@ -"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; + dominantBaseline?: 'auto' | 'baseline' | 'before-edge' | 'text-before-edge' | 'middle' | 'central' | 'after-edge' | 'text-after-edge' | 'ideographic' | 'alphabetic' | 'hanging' | 'mathematical' | 'inherit'; } -const SvgTextLogo = memo(function SvgTextLogo({ - logoText, - adjustHeightFactor, - verticalAlign = "top", - className = "", -}) { - const { svgRef, textRef, viewBox, aspectRatio } = useSvgTextLogo(logoText, false, adjustHeightFactor); +const SvgTextLogo: React.FC = ({ + text, + className = '', + fontSize = 32, + fontWeight = 700, + letterSpacing = 0, + dominantBaseline = 'central', +}) => { + const textElement = React.useRef(null); + const [bbox, setBbox] = React.useState({ x: 0, y: 0, width: 0, height: 0 }); + + React.useEffect(() => { + if (textElement.current) { + try { + const bboxValue = textElement.current.getBBox(); + setBbox(bboxValue); + } catch (error) { + console.error('Error getting text bbox:', error); + } + } + }, [text, fontSize, fontWeight, letterSpacing]); + + const padding = 16; + const viewBoxX = bbox.x - padding; + const viewBoxY = bbox.y - padding; + const viewBoxWidth = bbox.width + padding * 2; + const viewBoxHeight = bbox.height + padding * 2; return ( - {logoText} + {text} ); -}); +}; -SvgTextLogo.displayName = "SvgTextLogo"; - -export default SvgTextLogo; +export default SvgTextLogo; \ No newline at end of file