From 293869e1743c925519d938ebeeff033c773a1ec6 Mon Sep 17 00:00:00 2001
From: MohamedBassem <me@mbassem.com>
Date: Wed, 7 Feb 2024 16:57:47 +0000
Subject: [ui] Styling the bookmarks page

---
 web/app/bookmarks/components/LinkCard.tsx | 74 +++++++++++++++++++++++++------
 1 file changed, 61 insertions(+), 13 deletions(-)

(limited to 'web/app/bookmarks/components/LinkCard.tsx')

diff --git a/web/app/bookmarks/components/LinkCard.tsx b/web/app/bookmarks/components/LinkCard.tsx
index 103f97ef..75973f7e 100644
--- a/web/app/bookmarks/components/LinkCard.tsx
+++ b/web/app/bookmarks/components/LinkCard.tsx
@@ -1,19 +1,67 @@
+"use client";
+
+import { Button } from "@/components/ui/button";
+import {
+  DropdownMenu,
+  DropdownMenuContent,
+  DropdownMenuItem,
+  DropdownMenuTrigger,
+} from "@/components/ui/dropdown-menu";
+import {
+  ImageCard,
+  ImageCardBody,
+  ImageCardFooter,
+  ImageCardTitle,
+} from "@/components/ui/imageCard";
 import { ZBookmarkedLink } from "@/lib/types/api/links";
+import { MoreHorizontal, Trash2 } from "lucide-react";
 import Link from "next/link";
 
-export default async function LinkCard({ link }: { link: ZBookmarkedLink }) {
+export function LinkOptions() {
+  // TODO: Implement deletion
+  return (
+    <DropdownMenu>
+      <DropdownMenuTrigger asChild>
+        <Button variant="ghost">
+          <MoreHorizontal />
+        </Button>
+      </DropdownMenuTrigger>
+      <DropdownMenuContent className="w-fit">
+          <DropdownMenuItem className="text-destructive">
+            <Trash2 className="mr-2 h-4 w-4" />
+            <span>Delete</span>
+          </DropdownMenuItem>
+      </DropdownMenuContent>
+    </DropdownMenu>
+  );
+}
+
+export default function LinkCard({ link }: { link: ZBookmarkedLink }) {
+  const parsedUrl = new URL(link.url);
+
   return (
-    <Link href={link.url} className="border rounded-md hover:border-blue-300">
-      <div className="p-4">
-        <h2 className="text-lg font-semibold">
-          {link.details?.favicon && (
-            // eslint-disable-next-line @next/next/no-img-element
-            <img alt="" width="10" height="10" src={link.details?.favicon} />
-          )}
-          {link.details?.title ?? link.id}
-        </h2>
-        <p className="text-gray-600">{link.details?.description ?? link.url}</p>
-      </div>
-    </Link>
+    <ImageCard
+      className={
+        "bg-gray-50 duration-300 ease-in border border-grey-100 hover:transition-all hover:border-blue-300"
+      }
+      image={link.details?.imageUrl ?? undefined}
+    >
+      <ImageCardTitle>
+        <Link className="line-clamp-3" href={link.url}>
+          {link.details?.title ?? parsedUrl.host}
+        </Link>
+      </ImageCardTitle>
+      <ImageCardBody />
+      <ImageCardFooter>
+        <div className="flex justify-between text-gray-500">
+          <div className="my-auto">
+            <Link className="line-clamp-1 hover:text-black" href={link.url}>
+              {parsedUrl.host}
+            </Link>
+          </div>
+          <LinkOptions />
+        </div>
+      </ImageCardFooter>
+    </ImageCard>
   );
 }
-- 
cgit v1.2.3-70-g09d2

