From 3c5fbf9c4f8112ebfe57b4e6e2e049fbf41017dc Mon Sep 17 00:00:00 2001 From: bender Date: Wed, 11 Mar 2026 18:33:00 +0000 Subject: [PATCH] Update src/components/shared/SvgTextLogo/SvgTextLogo.tsx --- .../shared/SvgTextLogo/SvgTextLogo.tsx | 122 ++++++++++++------ 1 file changed, 84 insertions(+), 38 deletions(-) diff --git a/src/components/shared/SvgTextLogo/SvgTextLogo.tsx b/src/components/shared/SvgTextLogo/SvgTextLogo.tsx index f214190..bf2b4c6 100644 --- a/src/components/shared/SvgTextLogo/SvgTextLogo.tsx +++ b/src/components/shared/SvgTextLogo/SvgTextLogo.tsx @@ -1,51 +1,97 @@ -"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; + fontSize?: number; + fontWeight?: number | string; + letterSpacing?: number; className?: string; + textClassName?: string; } -const SvgTextLogo = memo(function SvgTextLogo({ - logoText, - adjustHeightFactor, - verticalAlign = "top", - className = "", -}) { - const { svgRef, textRef, viewBox, aspectRatio } = useSvgTextLogo(logoText, false, adjustHeightFactor); +const SvgTextLogo: React.FC = ({ + text, + fontSize = 48, + fontWeight = 700, + letterSpacing = 0, + className = '', + textClassName = '', +}) => { + const words = text.split(' '); + let currentX = 0; + const padding = 20; + const lineHeight = fontSize * 1.2; + const maxWidth = 800; + let lines: Array<{ words: string[]; width: number }> = []; + let currentLine: string[] = []; + let currentLineWidth = 0; + + // Simple word wrapping + words.forEach((word) => { + const wordWidth = word.length * (fontSize * 0.6); + if (currentLineWidth + wordWidth > maxWidth && currentLine.length > 0) { + lines.push({ words: currentLine, width: currentLineWidth }); + currentLine = [word]; + currentLineWidth = wordWidth; + } else { + currentLine.push(word); + currentLineWidth += wordWidth + letterSpacing; + } + }); + + if (currentLine.length > 0) { + lines.push({ words: currentLine, width: currentLineWidth }); + } + + const svgHeight = lines.length * lineHeight + padding * 2; + const svgWidth = maxWidth + padding * 2; return ( - - {logoText} - + + + + {lines.map((line, lineIndex) => { + const y = padding + (lineIndex + 1) * lineHeight; + let x = padding; + + return ( + + {line.words.map((word, wordIndex) => { + const wordElement = ( + + {word} + + ); + + x += word.length * (fontSize * 0.6) + letterSpacing; + + return wordElement; + })} + + ); + })} ); -}); - -SvgTextLogo.displayName = "SvgTextLogo"; +}; export default SvgTextLogo;