diff --git a/src/components/shared/SvgTextLogo/SvgTextLogo.tsx b/src/components/shared/SvgTextLogo/SvgTextLogo.tsx index f214190..0b738c8 100644 --- a/src/components/shared/SvgTextLogo/SvgTextLogo.tsx +++ b/src/components/shared/SvgTextLogo/SvgTextLogo.tsx @@ -1,51 +1,77 @@ -"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; + fill?: string; + strokeWidth?: number; + stroke?: 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, + className = '', + fontSize = 48, + fontWeight = 700, + letterSpacing = 0, + fill = 'currentColor', + strokeWidth = 0, + stroke = 'none', +}) => { + const canvas = React.useRef(null); + const [dimensions, setDimensions] = React.useState({ width: 400, height: 100 }); + + React.useEffect(() => { + if (!canvas.current) return; + + const ctx = canvas.current.getContext('2d'); + if (!ctx) return; + + ctx.font = `${fontWeight} ${fontSize}px system-ui, -apple-system, sans-serif`; + ctx.letterSpacing = `${letterSpacing}px`; + + const metrics = ctx.measureText(text); + const width = Math.ceil(metrics.width) + 40; + const height = Math.ceil(fontSize) + 40; + + setDimensions({ width, height }); + }, [text, fontSize, fontWeight, letterSpacing]); + + const textAnchor = 'start'; + const dominantBaseline = 'middle'; + const x = 20; + const y = dimensions.height / 2; return ( - {logoText} + {text} ); -}); - -SvgTextLogo.displayName = "SvgTextLogo"; +}; export default SvgTextLogo;