Compare commits
4 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 34c20cf6b0 | |||
| c53fc19dba | |||
| 6c048fc56b | |||
| 4542a07f34 |
@@ -1,51 +1,49 @@
|
|||||||
"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;
|
||||||
|
letterSpacing?: number;
|
||||||
|
fill?: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
const SvgTextLogo = memo<SvgTextLogoProps>(function SvgTextLogo({
|
const SvgTextLogo: React.FC<SvgTextLogoProps> = ({
|
||||||
logoText,
|
text,
|
||||||
adjustHeightFactor,
|
className = '',
|
||||||
verticalAlign = "top",
|
fontSize = 48,
|
||||||
className = "",
|
fontWeight = 700,
|
||||||
}) {
|
letterSpacing = 0,
|
||||||
const { svgRef, textRef, viewBox, aspectRatio } = useSvgTextLogo(logoText, false, adjustHeightFactor);
|
fill = 'currentColor',
|
||||||
|
}) => {
|
||||||
|
const charWidth = fontSize * 0.5;
|
||||||
|
const width = text.length * charWidth + 20;
|
||||||
|
const height = fontSize + 20;
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<svg
|
<svg
|
||||||
ref={svgRef}
|
width={width}
|
||||||
viewBox={viewBox}
|
height={height}
|
||||||
className={cls("w-full", className)}
|
viewBox={`0 0 ${width} ${height}`}
|
||||||
style={{ aspectRatio: aspectRatio }}
|
className={className}
|
||||||
preserveAspectRatio="none"
|
|
||||||
role="img"
|
role="img"
|
||||||
aria-label={`${logoText} logo`}
|
aria-label={text}
|
||||||
>
|
>
|
||||||
<text
|
<text
|
||||||
ref={textRef}
|
x="10"
|
||||||
x="0"
|
y={fontSize}
|
||||||
y={verticalAlign === "center" ? "50%" : "0"}
|
fontSize={fontSize}
|
||||||
className="font-bold fill-current"
|
fontWeight={fontWeight}
|
||||||
style={{
|
letterSpacing={letterSpacing}
|
||||||
fontSize: "20px",
|
fill={fill}
|
||||||
letterSpacing: "-0.02em",
|
fontFamily="inherit"
|
||||||
dominantBaseline: verticalAlign === "center" ? "middle" : "text-before-edge"
|
dominantBaseline="hanging"
|
||||||
}}
|
|
||||||
>
|
>
|
||||||
{logoText}
|
{text}
|
||||||
</text>
|
</text>
|
||||||
</svg>
|
</svg>
|
||||||
);
|
);
|
||||||
});
|
};
|
||||||
|
|
||||||
SvgTextLogo.displayName = "SvgTextLogo";
|
|
||||||
|
|
||||||
export default SvgTextLogo;
|
export default SvgTextLogo;
|
||||||
|
|||||||
Reference in New Issue
Block a user