From d9971537de4c61ef09a880c92fcf09cae47586b3 Mon Sep 17 00:00:00 2001 From: arsam Date: Fri, 18 Sep 2026 23:17:56 +0330 Subject: [PATCH] Import source: vault/components/snippet-card Import the existing local project snapshot. This commit organizes existing files; it does not represent newly developed functionality. --- vault/components/snippet-card.tsx | 119 ++++++++++++++++++++++++++++++ 1 file changed, 119 insertions(+) create mode 100644 vault/components/snippet-card.tsx diff --git a/vault/components/snippet-card.tsx b/vault/components/snippet-card.tsx new file mode 100644 index 0000000..153d01c --- /dev/null +++ b/vault/components/snippet-card.tsx @@ -0,0 +1,119 @@ +"use client"; + +import Link from "next/link"; +import { motion } from "framer-motion"; +import { Lock, Link as LinkIcon, Clock } from "lucide-react"; +import { Badge } from "@/components/ui/badge"; +import { Snippet } from "@/lib/types"; +import { formatExpiry } from "@/lib/expiry-format"; +import { cn } from "@/lib/utils"; + +interface SnippetCardProps { + snippet: Snippet; + view: "grid" | "list"; + index?: number; +} + +function timeAgo(dateStr: string): string { + const diff = Date.now() - new Date(dateStr).getTime(); + const mins = Math.floor(diff / 60000); + if (mins < 60) return `${mins}m ago`; + const hrs = Math.floor(mins / 60); + if (hrs < 24) return `${hrs}h ago`; + const days = Math.floor(hrs / 24); + if (days < 7) return `${days}d ago`; + return new Date(dateStr).toLocaleDateString(); +} + +export function SnippetCard({ snippet, view, index = 0 }: SnippetCardProps) { + const isGrid = view === "grid"; + + return ( + + +
+
+
+

{snippet.title}

+ + {snippet.privacy === "password" ? ( + + ) : ( + + )} + {snippet.privacy === "password" ? "Password" : "Secret"} + +
+ + {isGrid && ( +
+                {snippet.code}
+              
+ )} + +
+ + {snippet.language} + + {snippet.expiration !== "never" && (() => { + const label = formatExpiry(snippet.expiresAt); + return label ? ( + + + {label} + + ) : null; + })()} + {timeAgo(snippet.createdAt)} +
+ + {snippet.tags.length > 0 && ( +
+ {snippet.tags.slice(0, 3).map((tag) => ( + + {tag} + + ))} + {snippet.tags.length > 3 && ( + + +{snippet.tags.length - 3} + + )} +
+ )} +
+
+ +
+ ); +}