Update src/components/shared/SvgTextLogo/SvgTextLogo.tsx
This commit is contained in:
@@ -1,51 +1,29 @@
|
|||||||
"use client";
|
import React from 'react';
|
||||||
|
|
||||||
import { memo } from "react";
|
|
||||||
import useSvgTextLogo from "./useSvgTextLogo";
|
|
||||||
import { cls } from "@/lib/utils";
|
|
||||||
|
|
||||||
interface SvgTextLogoProps {
|
interface SvgTextLogoProps {
|
||||||
logoText: string;
|
text: string;
|
||||||
adjustHeightFactor?: number;
|
|
||||||
verticalAlign?: "top" | "center";
|
|
||||||
className?: string;
|
className?: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
const SvgTextLogo = memo<SvgTextLogoProps>(function SvgTextLogo({
|
const SvgTextLogo: React.FC<SvgTextLogoProps> = ({ text, className = '' }) => {
|
||||||
logoText,
|
|
||||||
adjustHeightFactor,
|
|
||||||
verticalAlign = "top",
|
|
||||||
className = "",
|
|
||||||
}) {
|
|
||||||
const { svgRef, textRef, viewBox, aspectRatio } = useSvgTextLogo(logoText, false, adjustHeightFactor);
|
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<svg
|
<svg
|
||||||
ref={svgRef}
|
className={className}
|
||||||
viewBox={viewBox}
|
viewBox="0 0 200 50"
|
||||||
className={cls("w-full", className)}
|
xmlns="http://www.w3.org/2000/svg"
|
||||||
style={{ aspectRatio: aspectRatio }}
|
|
||||||
preserveAspectRatio="none"
|
|
||||||
role="img"
|
|
||||||
aria-label={`${logoText} logo`}
|
|
||||||
>
|
>
|
||||||
<text
|
<text
|
||||||
ref={textRef}
|
x="10"
|
||||||
x="0"
|
y="35"
|
||||||
y={verticalAlign === "center" ? "50%" : "0"}
|
fontSize="24"
|
||||||
className="font-bold fill-current"
|
fontWeight="bold"
|
||||||
style={{
|
fill="currentColor"
|
||||||
fontSize: "20px",
|
dominantBaseline="middle"
|
||||||
letterSpacing: "-0.02em",
|
|
||||||
dominantBaseline: verticalAlign === "center" ? "middle" : "text-before-edge"
|
|
||||||
}}
|
|
||||||
>
|
>
|
||||||
{logoText}
|
{text}
|
||||||
</text>
|
</text>
|
||||||
</svg>
|
</svg>
|
||||||
);
|
);
|
||||||
});
|
};
|
||||||
|
|
||||||
SvgTextLogo.displayName = "SvgTextLogo";
|
|
||||||
|
|
||||||
export default SvgTextLogo;
|
export default SvgTextLogo;
|
||||||
|
|||||||
Reference in New Issue
Block a user