el.xwx.moe/components/LinkViews/LinkComponents/LinkCollection.tsx

50 lines
1.4 KiB
TypeScript
Raw Normal View History

import Icon from "@/components/Icon";
2023-12-15 21:25:39 -06:00
import {
CollectionIncludingMembersAndLinkCount,
LinkIncludingShortenedCollectionAndTags,
} from "@/types/global";
import { IconWeight } from "@phosphor-icons/react";
2024-03-10 05:08:28 -05:00
import Link from "next/link";
2024-11-07 06:32:06 -06:00
import { useRouter } from "next/router";
2023-12-17 02:30:09 -06:00
import React from "react";
2023-12-15 21:25:39 -06:00
2023-12-17 22:32:33 -06:00
export default function LinkCollection({
link,
collection,
}: {
2023-12-15 21:25:39 -06:00
link: LinkIncludingShortenedCollectionAndTags;
collection: CollectionIncludingMembersAndLinkCount;
}) {
2024-11-07 06:32:06 -06:00
const router = useRouter();
const isPublicRoute = router.pathname.startsWith("/public") ? true : false;
return !isPublicRoute && collection?.name ? (
<>
<Link
href={`/collections/${link.collection.id}`}
onClick={(e) => {
e.stopPropagation();
}}
className="flex items-center gap-1 max-w-full w-fit hover:opacity-70 duration-100 select-none"
title={collection?.name}
>
{link.collection.icon ? (
<Icon
icon={link.collection.icon}
size={20}
weight={(link.collection.iconWeight || "regular") as IconWeight}
2024-08-30 01:38:58 -05:00
color={link.collection.color}
/>
) : (
<i
className="bi-folder-fill text-lg"
2024-08-30 01:38:58 -05:00
style={{ color: link.collection.color }}
></i>
)}
<p className="truncate capitalize">{collection?.name}</p>
</Link>
</>
2024-11-07 06:32:06 -06:00
) : null;
2023-12-15 21:25:39 -06:00
}