import clsx from "clsx"; import React from "react"; import Link from "@docusaurus/Link"; import { FontAwesomeIcon } from "@fortawesome/react-fontawesome"; import type { Obj, Tag as TagType } from "../../libs/store"; function pickTextColor(bgColor, lightColor, darkColor) { var color = bgColor.charAt(0) === "#" ? bgColor.substring(1, 7) : bgColor; var r = parseInt(color.substring(0, 2), 16); // hexToR var g = parseInt(color.substring(2, 4), 16); // hexToG var b = parseInt(color.substring(4, 6), 16); // hexToB return r * 0.299 + g * 0.587 + b * 0.114 > 186 ? darkColor : lightColor; } export function Tag({ label, color, className, onClick, }: TagType & { className?: string; onClick?: React.MouseEventHandler; }): JSX.Element { return ( {label} ); } export default function Card({ module_name, name, desc, author, homepage, tags, is_official, }: Obj): JSX.Element { const isGithub = /^https:\/\/github.com\/[^/]+\/[^/]+/.test(homepage); return (
{name} {is_official && ( )} {homepage && ( {isGithub ? ( ) : ( )} )}
{tags && (
{tags.map((tag, index) => ( {tag.label} ))}
)} {desc && (
{desc}
)} {module_name && (
{module_name}
)} {author && (
{author}
)}
); }