70 lines
2.2 KiB
TypeScript
Executable File
70 lines
2.2 KiB
TypeScript
Executable File
import classNames from "classnames";
|
|
import { StyleColorVariants, StyleColorVariantsMap } from "core/_variants";
|
|
import React from "react";
|
|
|
|
type Props = {
|
|
className?: string | undefined;
|
|
children: string;
|
|
fontSize?: number;
|
|
variant?: StyleColorVariants | undefined;
|
|
};
|
|
|
|
const hexagonStyles: StyleColorVariantsMap<string> = {
|
|
gray: "fill-gray-500",
|
|
pink: "fill-pink-500",
|
|
blue: "fill-blue-500",
|
|
purple: "fill-purple-500",
|
|
red: "fill-red-500",
|
|
yellow: "fill-yellow-600",
|
|
emerald: "fill-emerald-500",
|
|
sky: "fill-sky-500",
|
|
"dark-coral": "fill-dark-coral-500"
|
|
};
|
|
|
|
/**
|
|
* Hexagon sign
|
|
* @param {string} children Characters to exclude from svg figure
|
|
* @param {string|undefined} className Classes used to customize svg element
|
|
* @param {number} fontSize Font size for excluding characters
|
|
* @return {JSX.Element}
|
|
*/
|
|
export default function Hexagon({
|
|
className,
|
|
children,
|
|
fontSize = 24,
|
|
variant = "blue",
|
|
}: Props): JSX.Element {
|
|
const classes = hexagonStyles[variant];
|
|
return (
|
|
<svg
|
|
viewBox="0 0 60 60"
|
|
xmlns="http://www.w3.org/2000/svg"
|
|
className={classNames(className, classes)}
|
|
>
|
|
{fontSize && (
|
|
<defs>
|
|
<mask id={children} maskUnits="userSpaceOnUse">
|
|
<rect width="100%" height="100%" fill="white" />
|
|
<text
|
|
textAnchor="middle"
|
|
x="30"
|
|
y="38"
|
|
fontSize={fontSize}
|
|
fontWeight="bold"
|
|
fontFamily="Poppins"
|
|
>
|
|
{children}
|
|
</text>
|
|
</mask>
|
|
</defs>
|
|
)}
|
|
<path
|
|
// eslint-disable-next-line max-len
|
|
d="M27 1.73205C28.8564 0.660254 31.1436 0.660254 33 1.73205L52.9808 13.2679C54.8372 14.3397 55.9808 16.3205 55.9808 18.4641V41.5359C55.9808 43.6795 54.8372 45.6603 52.9808 46.7321L33 58.2679C31.1436 59.3397 28.8564 59.3397 27 58.2679L7.01924 46.7321C5.16283 45.6603 4.01924 43.6795 4.01924 41.5359V18.4641C4.01924 16.3205 5.16283 14.3397 7.01924 13.2679L27 1.73205Z"
|
|
fillRule="evenodd"
|
|
mask={fontSize ? `url(#${children})` : ""}
|
|
/>
|
|
</svg>
|
|
);
|
|
}
|