diff --git a/src/app/page.tsx b/src/app/page.tsx index e89a739..ffac3e0 100644 --- a/src/app/page.tsx +++ b/src/app/page.tsx @@ -15,7 +15,7 @@ export default function LandingPage() { return ( diff --git a/src/components/shared/SvgTextLogo/SvgTextLogo.tsx b/src/components/shared/SvgTextLogo/SvgTextLogo.tsx index f214190..baf6dd0 100644 --- a/src/components/shared/SvgTextLogo/SvgTextLogo.tsx +++ b/src/components/shared/SvgTextLogo/SvgTextLogo.tsx @@ -1,51 +1,73 @@ -"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; + fontFamily?: string; + fontWeight?: string | number; + letterSpacing?: number; + fill?: string; + dominantBaseline?: 'auto' | 'text-bottom' | 'alphabetic' | 'ideographic' | 'middle' | 'central' | 'mathematical' | 'hanging'; } -const SvgTextLogo = memo(function SvgTextLogo({ - logoText, - adjustHeightFactor, - verticalAlign = "top", - className = "", -}) { - const { svgRef, textRef, viewBox, aspectRatio } = useSvgTextLogo(logoText, false, adjustHeightFactor); +const SvgTextLogo = React.forwardRef( + ( + { + text, + className = '', + fontSize = 48, + fontFamily = 'system-ui, -apple-system, sans-serif', + fontWeight = 'bold', + letterSpacing = 0, + fill = 'currentColor', + dominantBaseline = 'middle', + }, + ref, + ) => { + const svgRef = React.useRef(null); + const [dimensions, setDimensions] = React.useState({ width: 400, height: 100 }); - return ( - - { + if (svgRef.current) { + const textElement = svgRef.current.querySelector('text'); + if (textElement) { + const bbox = textElement.getBBox(); + setDimensions({ + width: Math.ceil(bbox.width + 20), + height: Math.ceil(bbox.height + 20), + }); + } + } + }, [text, fontSize, fontFamily, fontWeight]); + + React.useImperativeHandle(ref, () => svgRef.current!); + + return ( + - {logoText} - - - ); -}); + + {text} + + + ); + }, +); -SvgTextLogo.displayName = "SvgTextLogo"; +SvgTextLogo.displayName = 'SvgTextLogo'; export default SvgTextLogo;