From 6a894d416f8d138ca0d4054b9efcb810c1eb29a0 Mon Sep 17 00:00:00 2001 From: bender Date: Tue, 10 Mar 2026 23:26:09 +0000 Subject: [PATCH] Update src/components/shared/SvgTextLogo/SvgTextLogo.tsx --- .../shared/SvgTextLogo/SvgTextLogo.tsx | 78 +++++++++++-------- 1 file changed, 44 insertions(+), 34 deletions(-) diff --git a/src/components/shared/SvgTextLogo/SvgTextLogo.tsx b/src/components/shared/SvgTextLogo/SvgTextLogo.tsx index f214190..2178fb7 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 from 'react'; interface SvgTextLogoProps { - logoText: string; - adjustHeightFactor?: number; - verticalAlign?: "top" | "center"; + text: string; className?: string; + fontSize?: number; + fontWeight?: number | string; + letterSpacing?: number; + dominantBaseline?: 'auto' | 'middle' | 'hanging' | 'mathematical'; } -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 = 48, + fontWeight = 700, + letterSpacing = 0, + dominantBaseline = 'middle', +}) => { + const textRef = React.useRef(null); + const [bbox, setBbox] = React.useState({ width: 0, height: 0 }); + + React.useEffect(() => { + if (textRef.current) { + try { + const bounds = textRef.current.getBBox(); + setBbox({ width: bounds.width, height: bounds.height }); + } catch (e) { + console.error('Error getting text bbox:', e); + } + } + }, [text]); + + const padding = 20; + const viewBoxWidth = bbox.width + padding * 2; + const viewBoxHeight = bbox.height + padding * 2; return ( - {logoText} + {text} ); -}); - -SvgTextLogo.displayName = "SvgTextLogo"; +}; export default SvgTextLogo; -- 2.49.1