Compare commits
1 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 4542a07f34 |
@@ -1,51 +1,52 @@
|
|||||||
"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;
|
||||||
|
fontSize?: number;
|
||||||
|
fontWeight?: number | string;
|
||||||
|
fill?: string;
|
||||||
|
strokeWidth?: number;
|
||||||
|
stroke?: string;
|
||||||
|
textAnchor?: 'start' | 'middle' | 'end';
|
||||||
|
dominantBaseline?: 'auto' | 'middle' | 'hanging';
|
||||||
}
|
}
|
||||||
|
|
||||||
const SvgTextLogo = memo<SvgTextLogoProps>(function SvgTextLogo({
|
const SvgTextLogo: React.FC<SvgTextLogoProps> = ({
|
||||||
logoText,
|
text,
|
||||||
adjustHeightFactor,
|
className = '',
|
||||||
verticalAlign = "top",
|
fontSize = 48,
|
||||||
className = "",
|
fontWeight = 700,
|
||||||
}) {
|
fill = 'currentColor',
|
||||||
const { svgRef, textRef, viewBox, aspectRatio } = useSvgTextLogo(logoText, false, adjustHeightFactor);
|
strokeWidth = 0,
|
||||||
|
stroke = 'none',
|
||||||
|
textAnchor = 'middle',
|
||||||
|
dominantBaseline = 'middle',
|
||||||
|
}) => {
|
||||||
return (
|
return (
|
||||||
<svg
|
<svg
|
||||||
ref={svgRef}
|
viewBox="0 0 800 200"
|
||||||
viewBox={viewBox}
|
className={className}
|
||||||
className={cls("w-full", className)}
|
xmlns="http://www.w3.org/2000/svg"
|
||||||
style={{ aspectRatio: aspectRatio }}
|
preserveAspectRatio="xMidYMid meet"
|
||||||
preserveAspectRatio="none"
|
|
||||||
role="img"
|
|
||||||
aria-label={`${logoText} logo`}
|
|
||||||
>
|
>
|
||||||
<text
|
<text
|
||||||
ref={textRef}
|
x="50%"
|
||||||
x="0"
|
y="50%"
|
||||||
y={verticalAlign === "center" ? "50%" : "0"}
|
fontSize={fontSize}
|
||||||
className="font-bold fill-current"
|
fontWeight={fontWeight}
|
||||||
style={{
|
fill={fill}
|
||||||
fontSize: "20px",
|
strokeWidth={strokeWidth}
|
||||||
letterSpacing: "-0.02em",
|
stroke={stroke}
|
||||||
dominantBaseline: verticalAlign === "center" ? "middle" : "text-before-edge"
|
textAnchor={textAnchor}
|
||||||
}}
|
dominantBaseline={dominantBaseline}
|
||||||
|
fontFamily="inherit"
|
||||||
|
letterSpacing="-0.02em"
|
||||||
>
|
>
|
||||||
{logoText}
|
{text}
|
||||||
</text>
|
</text>
|
||||||
</svg>
|
</svg>
|
||||||
);
|
);
|
||||||
});
|
};
|
||||||
|
|
||||||
SvgTextLogo.displayName = "SvgTextLogo";
|
|
||||||
|
|
||||||
export default SvgTextLogo;
|
export default SvgTextLogo;
|
||||||
|
|||||||
Reference in New Issue
Block a user