Update code
This commit is contained in:
@@ -0,0 +1,40 @@
|
||||
"use client";
|
||||
|
||||
import { motion } from "framer-motion";
|
||||
import { useRouter } from "next/navigation";
|
||||
import { useRef } from "react";
|
||||
import LordIcon from "./LordIcon";
|
||||
|
||||
export default function Header({ user }: { user?: string | null }) {
|
||||
const plusIconRef = useRef<any>(null);
|
||||
const router = useRouter();
|
||||
|
||||
return (
|
||||
<div className="flex justify-between items-center mb-8">
|
||||
<h1 className="text-2xl font-bold text-white">
|
||||
Welcome back, <span className="text-blue-400">{user || "User"}</span>
|
||||
</h1>
|
||||
|
||||
<motion.button
|
||||
whileHover={{ scale: 1.05 }}
|
||||
whileTap={{ scale: 0.97 }}
|
||||
onClick={() => router.push("/")}
|
||||
className="cursor-pointer flex items-center gap-2 px-6 py-3 rounded-xl text-base font-medium
|
||||
text-white bg-gradient-to-r from-blue-600 to-blue-500 shadow-lg shadow-blue-500/30
|
||||
hover:shadow-blue-500/50 transition-all duration-300"
|
||||
onMouseEnter={() => plusIconRef.current?.playFromBeginning()}
|
||||
onMouseLeave={() => plusIconRef.current?.goToFirstFrame()}
|
||||
>
|
||||
<div className="w-6 h-6 flex items-center justify-center">
|
||||
<LordIcon
|
||||
ref={plusIconRef}
|
||||
url="https://cdn.lordicon.com/vjgknpfx.json"
|
||||
size={28}
|
||||
colorize="#ffffff"
|
||||
/>
|
||||
</div>
|
||||
Create New Paste
|
||||
</motion.button>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
@@ -0,0 +1,77 @@
|
||||
"use client";
|
||||
|
||||
export default function LoadingDashboard() {
|
||||
const StatSkeleton = () => (
|
||||
<div className="rounded-2xl bg-[#11131c] p-5 border border-white/10">
|
||||
<div className="flex items-center gap-3">
|
||||
<div className="w-10 h-10 rounded-xl bg-white/10 animate-pulse" />
|
||||
<div className="flex-1 space-y-2">
|
||||
<div className="h-3 w-24 bg-white/10 rounded animate-pulse" />
|
||||
<div className="h-4 w-16 bg-white/10 rounded animate-pulse" />
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
|
||||
const PasteSkeleton = () => (
|
||||
<div className="rounded-xl border border-white/10 bg-[#11131c] p-5 shadow-sm">
|
||||
<div className="flex items-center gap-3 mb-3">
|
||||
<div className="w-7 h-7 rounded-lg bg-white/10 animate-pulse" />
|
||||
<div className="h-4 w-40 bg-white/10 rounded animate-pulse" />
|
||||
</div>
|
||||
<div className="space-y-2 mb-3">
|
||||
<div className="h-3 w-full bg-white/10 rounded animate-pulse" />
|
||||
<div className="h-3 w-5/6 bg-white/10 rounded animate-pulse" />
|
||||
<div className="h-3 w-2/3 bg-white/10 rounded animate-pulse" />
|
||||
</div>
|
||||
<div className="flex justify-between items-center mt-auto">
|
||||
<div className="h-3 w-28 bg-white/10 rounded animate-pulse" />
|
||||
<div className="h-5 w-16 bg-white/10 rounded-full animate-pulse" />
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
|
||||
return (
|
||||
<div className="flex h-screen bg-[#0d1117]">
|
||||
{/* Sidebar skeleton */}
|
||||
<aside className="hidden md:flex flex-col w-64 bg-[#11131c] border-r border-white/10 p-6">
|
||||
<div className="h-6 w-40 bg-white/10 rounded mb-8 animate-pulse" />
|
||||
<div className="space-y-4">
|
||||
<div className="h-4 w-28 bg-white/10 rounded animate-pulse" />
|
||||
<div className="h-4 w-24 bg-white/10 rounded animate-pulse" />
|
||||
</div>
|
||||
<div className="mt-auto h-9 w-28 bg-white/10 rounded animate-pulse" />
|
||||
</aside>
|
||||
|
||||
<main className="flex-1 p-8 overflow-y-auto">
|
||||
{/* Header skeleton + spinner */}
|
||||
<div className="flex justify-between items-center mb-8">
|
||||
<div className="h-7 w-80 bg-white/10 rounded animate-pulse" />
|
||||
<div className="flex items-center gap-3">
|
||||
<div className="h-5 w-5 rounded-full border-2 border-white/30 border-t-transparent animate-spin" />
|
||||
<span className="text-white/70 text-sm">Loading dashboard...</span>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{/* Stat cards skeleton */}
|
||||
<div className="grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-4 gap-6 mb-10">
|
||||
{Array.from({ length: 8 }).map((_, i) => (
|
||||
<StatSkeleton key={i} />
|
||||
))}
|
||||
</div>
|
||||
|
||||
{/* Search skeleton */}
|
||||
<div className="relative w-full md:w-1/3 mb-8">
|
||||
<div className="h-10 w-full rounded-xl bg-white/10 animate-pulse" />
|
||||
</div>
|
||||
|
||||
{/* Pastes skeleton grid */}
|
||||
<div className="grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-6">
|
||||
{Array.from({ length: 6 }).map((_, i) => (
|
||||
<PasteSkeleton key={i} />
|
||||
))}
|
||||
</div>
|
||||
</main>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
@@ -0,0 +1,20 @@
|
||||
"use client";
|
||||
|
||||
import { Player } from "@lordicon/react";
|
||||
import { forwardRef, useEffect, useState } from "react";
|
||||
|
||||
const LordIcon = forwardRef(function LordIcon(
|
||||
{ url, size = 28, colorize = "#3b82f6" }: { url: string; size?: number; colorize?: string },
|
||||
ref: any
|
||||
) {
|
||||
const [iconData, setIconData] = useState<any>(null);
|
||||
|
||||
useEffect(() => {
|
||||
fetch(url).then((res) => res.json()).then(setIconData);
|
||||
}, [url]);
|
||||
|
||||
if (!iconData) return null;
|
||||
return <Player ref={ref} icon={iconData} size={size} colorize={colorize} />;
|
||||
});
|
||||
|
||||
export default LordIcon;
|
||||
@@ -0,0 +1,31 @@
|
||||
"use client";
|
||||
|
||||
export default function Pagination({
|
||||
totalPages,
|
||||
currentPage,
|
||||
onPageChange,
|
||||
}: {
|
||||
totalPages: number;
|
||||
currentPage: number;
|
||||
onPageChange: (page: number) => void;
|
||||
}) {
|
||||
if (totalPages <= 1) return null;
|
||||
|
||||
return (
|
||||
<div className="flex justify-center mt-10 gap-2">
|
||||
{Array.from({ length: totalPages }, (_, i) => (
|
||||
<button
|
||||
key={i}
|
||||
onClick={() => onPageChange(i + 1)}
|
||||
className={`px-4 py-2 rounded-full text-sm transition-colors cursor-pointer ${
|
||||
currentPage === i + 1
|
||||
? "bg-blue-600 text-white shadow-md"
|
||||
: "bg-neutral-800 text-white hover:bg-neutral-700"
|
||||
}`}
|
||||
>
|
||||
{i + 1}
|
||||
</button>
|
||||
))}
|
||||
</div>
|
||||
);
|
||||
}
|
||||
@@ -0,0 +1,60 @@
|
||||
"use client";
|
||||
|
||||
import { motion } from "framer-motion";
|
||||
import { useRef } from "react";
|
||||
import LordIcon from "./LordIcon";
|
||||
|
||||
export default function PasteCard({
|
||||
paste,
|
||||
onDelete,
|
||||
pasteIconUrl,
|
||||
}: {
|
||||
paste: any;
|
||||
onDelete: (id: string) => void;
|
||||
pasteIconUrl: string;
|
||||
}) {
|
||||
const pasteIconRef = useRef<any>(null);
|
||||
|
||||
return (
|
||||
<motion.div
|
||||
className="rounded-xl border border-white/10 bg-[#11131c] p-5 flex flex-col shadow-sm hover:shadow-lg hover:border-blue-500/30 transition-all"
|
||||
variants={{ hidden: { opacity: 0, scale: 0.95 }, visible: { opacity: 1, scale: 1 } }}
|
||||
onMouseEnter={() => pasteIconRef.current?.playFromBeginning()}
|
||||
onMouseLeave={() => pasteIconRef.current?.goToFirstFrame()}
|
||||
>
|
||||
<div className="flex items-center gap-3 mb-3">
|
||||
<div className="p-2 rounded-lg bg-blue-500/20 text-blue-400">
|
||||
<LordIcon ref={pasteIconRef} url={pasteIconUrl} size={28} colorize="#3b82f6" />
|
||||
</div>
|
||||
<div className="font-mono text-white text-sm truncate">
|
||||
{paste.title || 'Untitled'}
|
||||
</div>
|
||||
</div>
|
||||
<div className="text-xs text-neutral-400 font-mono mb-3 line-clamp-3">
|
||||
{paste.content || 'No content'}
|
||||
</div>
|
||||
<div className="flex justify-between items-center mt-auto text-xs text-neutral-500">
|
||||
<span>{new Date(paste.createdAt).toLocaleString()}</span>
|
||||
<span className="px-2 py-0.5 rounded-full bg-blue-500/20 text-blue-400">
|
||||
{paste.views} views
|
||||
</span>
|
||||
</div>
|
||||
<div className="flex justify-end gap-2 mt-4">
|
||||
<a
|
||||
href={`/${paste.id}`}
|
||||
className="cursor-pointer px-3 py-1.5 rounded-lg bg-blue-600 text-white text-sm hover:bg-blue-500 transition-colors"
|
||||
target="_blank"
|
||||
rel="noopener noreferrer"
|
||||
>
|
||||
View
|
||||
</a>
|
||||
<button
|
||||
onClick={() => onDelete(paste.id)}
|
||||
className="cursor-pointer px-3 py-1.5 rounded-lg bg-red-600 text-white text-sm hover:bg-red-500 transition-colors"
|
||||
>
|
||||
Delete
|
||||
</button>
|
||||
</div>
|
||||
</motion.div>
|
||||
);
|
||||
}
|
||||
@@ -0,0 +1,20 @@
|
||||
"use client";
|
||||
|
||||
import { Search } from "lucide-react";
|
||||
|
||||
export default function SearchBar({ value, onChange }: { value: string; onChange: (v: string) => void }) {
|
||||
return (
|
||||
<div className="relative w-full md:w-1/3 mb-8">
|
||||
<Search className="absolute left-3 top-1/2 -translate-y-1/2 text-neutral-500" size={18} />
|
||||
<input
|
||||
type="text"
|
||||
placeholder="Search by title..."
|
||||
value={value}
|
||||
onChange={(e) => onChange(e.target.value)}
|
||||
className="cursor-text w-full pl-10 pr-4 py-2 rounded-xl bg-[#0f1320]/70 text-white
|
||||
placeholder:text-neutral-500 outline-none ring-1 ring-white/10
|
||||
focus:ring-2 focus:ring-blue-500/50 transition-all"
|
||||
/>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
@@ -0,0 +1,51 @@
|
||||
"use client";
|
||||
|
||||
import LogoutButton from "@/components/ui/LogoutButton";
|
||||
import { FileText } from "lucide-react";
|
||||
import Link from "next/link";
|
||||
import { usePathname } from "next/navigation";
|
||||
|
||||
export default function Sidebar() {
|
||||
const pathname = usePathname();
|
||||
|
||||
const navItems = [
|
||||
{ label: "My Pastes", href: "/dashboard", icon: FileText },
|
||||
];
|
||||
|
||||
return (
|
||||
<aside className="hidden md:flex flex-col w-64 bg-[#11131c] border-r border-white/10 p-6">
|
||||
{/* Header */}
|
||||
<div className="mb-10">
|
||||
<h2 className="text-xl font-bold text-white">AltBin</h2>
|
||||
<p className="text-xs text-neutral-500">Dashboard</p>
|
||||
</div>
|
||||
|
||||
{/* Navigation */}
|
||||
<nav className="flex flex-col gap-2">
|
||||
{navItems.map(({ label, href, icon: Icon }) => {
|
||||
const active = pathname === href;
|
||||
return (
|
||||
<Link
|
||||
key={href}
|
||||
href={href}
|
||||
className={`flex items-center gap-3 px-3 py-2 rounded-lg text-sm font-medium transition-colors
|
||||
${
|
||||
active
|
||||
? "bg-blue-500/20 text-blue-400 border border-blue-500/30"
|
||||
: "text-neutral-400 hover:text-white hover:bg-white/5"
|
||||
}`}
|
||||
>
|
||||
<Icon size={18} />
|
||||
{label}
|
||||
</Link>
|
||||
);
|
||||
})}
|
||||
</nav>
|
||||
|
||||
{/* Footer */}
|
||||
<div className="mt-auto pt-6 border-t border-white/5">
|
||||
<LogoutButton />
|
||||
</div>
|
||||
</aside>
|
||||
);
|
||||
}
|
||||
@@ -0,0 +1,36 @@
|
||||
"use client";
|
||||
|
||||
import { motion } from "framer-motion";
|
||||
import { useRef } from "react";
|
||||
import LordIcon from "./LordIcon";
|
||||
|
||||
export default function StatCard({
|
||||
label,
|
||||
value,
|
||||
icon,
|
||||
}: {
|
||||
label: string;
|
||||
value: any;
|
||||
icon: string;
|
||||
}) {
|
||||
const iconRef = useRef<any>(null);
|
||||
|
||||
return (
|
||||
<motion.div
|
||||
className="rounded-2xl bg-[#11131c] p-5 border border-white/10 hover:border-blue-500/40 transition-colors shadow-md"
|
||||
whileHover={{ scale: 1.03 }}
|
||||
onMouseEnter={() => iconRef.current?.playFromBeginning()}
|
||||
onMouseLeave={() => iconRef.current?.goToFirstFrame()}
|
||||
>
|
||||
<div className="flex items-center gap-3">
|
||||
<div className="p-3 rounded-xl bg-blue-500/20 text-blue-400">
|
||||
<LordIcon ref={iconRef} url={icon} size={28} colorize="#3b82f6" />
|
||||
</div>
|
||||
<div>
|
||||
<div className="text-sm text-neutral-400">{label}</div>
|
||||
<div className="text-xl font-bold text-white">{value}</div>
|
||||
</div>
|
||||
</div>
|
||||
</motion.div>
|
||||
);
|
||||
}
|
||||
Reference in New Issue
Block a user