From 015362c9b4389a50108b3224f8153a9a840c481a Mon Sep 17 00:00:00 2001
From: MohamedBassem <me@mbassem.com>
Date: Thu, 29 Feb 2024 13:13:40 +0000
Subject: refactor: Use a Slot for passing classnames to children instead

---
 .../bookmarks/components/BookmarksGrid.tsx         | 26 +++++++++++-----------
 1 file changed, 13 insertions(+), 13 deletions(-)

(limited to 'packages/web/app/dashboard/bookmarks/components/BookmarksGrid.tsx')

diff --git a/packages/web/app/dashboard/bookmarks/components/BookmarksGrid.tsx b/packages/web/app/dashboard/bookmarks/components/BookmarksGrid.tsx
index 7f7dda5c..f05d240e 100644
--- a/packages/web/app/dashboard/bookmarks/components/BookmarksGrid.tsx
+++ b/packages/web/app/dashboard/bookmarks/components/BookmarksGrid.tsx
@@ -4,18 +4,23 @@ import LinkCard from "./LinkCard";
 import { ZBookmark, ZGetBookmarksRequest } from "@/lib/types/api/bookmarks";
 import { api } from "@/lib/trpc";
 import TextCard from "./TextCard";
+import { Slot } from "@radix-ui/react-slot";
 
-function renderBookmark(bookmark: ZBookmark, className: string) {
+function renderBookmark(bookmark: ZBookmark) {
+  let comp;
   switch (bookmark.content.type) {
     case "link":
-      return (
-        <LinkCard key={bookmark.id} bookmark={bookmark} className={className} />
-      );
+      comp = <LinkCard key={bookmark.id} bookmark={bookmark} />;
+      break;
     case "text":
-      return (
-        <TextCard key={bookmark.id} bookmark={bookmark} className={className} />
-      );
+      comp = <TextCard key={bookmark.id} bookmark={bookmark} />;
+      break;
   }
+  return (
+    <Slot className="border-grey-100 mb-4 border bg-gray-50 duration-300 ease-in hover:border-blue-300 hover:transition-all">
+      {comp}
+    </Slot>
+  );
 }
 
 export default function BookmarksGrid({
@@ -33,12 +38,7 @@ export default function BookmarksGrid({
   }
   return (
     <div className="columns-1 gap-4 transition-all duration-300 md:columns-2 lg:columns-3">
-      {data.bookmarks.map((b) =>
-        renderBookmark(
-          b,
-          "border-grey-100 border bg-gray-50 duration-300 ease-in hover:border-blue-300 hover:transition-all mb-4",
-        ),
-      )}
+      {data.bookmarks.map((b) => renderBookmark(b))}
     </div>
   );
 }
-- 
cgit v1.2.3-70-g09d2

