aboutsummaryrefslogtreecommitdiffstats
path: root/web/app
diff options
context:
space:
mode:
authorMohamedBassem <me@mbassem.com>2024-02-07 16:57:47 +0000
committerMohamedBassem <me@mbassem.com>2024-02-07 16:57:47 +0000
commit293869e1743c925519d938ebeeff033c773a1ec6 (patch)
treecc61ae06d6ab36b9eea9d5313e7d82981efcaaf7 /web/app
parentdaebbf0154a290fb690ed94fca23377e0f739f53 (diff)
downloadkarakeep-293869e1743c925519d938ebeeff033c773a1ec6.tar.zst
[ui] Styling the bookmarks page
Diffstat (limited to 'web/app')
-rw-r--r--web/app/bookmarks/components/AddLink.tsx15
-rw-r--r--web/app/bookmarks/components/LinkCard.tsx74
-rw-r--r--web/app/bookmarks/components/LinksGrid.tsx2
3 files changed, 71 insertions, 20 deletions
diff --git a/web/app/bookmarks/components/AddLink.tsx b/web/app/bookmarks/components/AddLink.tsx
index 54cf9137..fab4db8b 100644
--- a/web/app/bookmarks/components/AddLink.tsx
+++ b/web/app/bookmarks/components/AddLink.tsx
@@ -1,6 +1,9 @@
"use client";
+import { Button } from "@/components/ui/button";
+import { Input } from "@/components/ui/input";
import APIClient from "@/lib/api";
+import { Plus } from "lucide-react";
import { useRouter } from "next/navigation";
import { useState } from "react";
@@ -11,6 +14,7 @@ export default function AddLink() {
const bookmarkLink = async () => {
const [_resp, error] = await APIClient.bookmarkLink(link);
if (error) {
+ // TODO: Proper error handling
alert(error.message);
return;
}
@@ -18,8 +22,8 @@ export default function AddLink() {
};
return (
- <div className="p-4">
- <input
+ <div className="py-4 container flex w-full items-center space-x-2">
+ <Input
type="text"
placeholder="Link"
value={link}
@@ -30,11 +34,10 @@ export default function AddLink() {
setLink("");
}
}}
- className="w-10/12 px-4 py-2 border rounded-md focus:outline-none focus:border-blue-300"
/>
- <button className="w-2/12 px-1 py-2" onClick={bookmarkLink}>
- Submit
- </button>
+ <Button onClick={bookmarkLink}>
+ <Plus />
+ </Button>
</div>
);
}
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>
);
}
diff --git a/web/app/bookmarks/components/LinksGrid.tsx b/web/app/bookmarks/components/LinksGrid.tsx
index 83aaca80..4b82df98 100644
--- a/web/app/bookmarks/components/LinksGrid.tsx
+++ b/web/app/bookmarks/components/LinksGrid.tsx
@@ -12,7 +12,7 @@ export default async function LinksGrid() {
const links = await getLinks(session.user.id);
return (
- <div className="container mx-auto mt-8 grid gap-4 grid-cols-1 sm:grid-cols-2 md:grid-cols-3 lg:grid-cols-4">
+ <div className="container p-8 mx-auto grid gap-4 grid-cols-1 sm:grid-cols-2 md:grid-cols-3 lg:grid-cols-4">
{links.map((l) => (
<LinkCard key={l.id} link={l} />
))}