Files
DevToysWeb/components/sidebar/tool-link.tsx
2023-06-24 14:15:31 +09:00

37 lines
1.0 KiB
TypeScript

"use client";
import { memo } from "react";
import Link, { LinkProps } from "next/link";
import { Tool } from "@/config/tools";
import { cn } from "@/lib/style";
import { Indicator } from "@/components/indicator";
type Props = Pick<Tool, "Icon" | "shortTitle"> &
Pick<LinkProps<unknown>, "className" | "href" | "onClick"> & {
highlight: "both" | "indicatorOnly" | "none";
};
function RawToolLink({ Icon, shortTitle: title, href, onClick, className, highlight }: Props) {
return (
<Link
className={cn(
"flex h-10 items-center gap-3 rounded hover:bg-accent",
highlight === "both" && "bg-accent",
className
)}
{...{ href, onClick }}
>
<span className={cn("invisible flex items-center", highlight !== "none" && "visible")}>
<Indicator />
</span>
<span className="flex select-none items-center">
<Icon size={16} />
<span className="ml-4">{title}</span>
</span>
</Link>
);
}
export const ToolLink = memo(RawToolLink);