Update code
This commit is contained in:
@@ -0,0 +1,76 @@
|
||||
"use client";
|
||||
|
||||
import AuthSection from "@/components/paste-form/AuthSection";
|
||||
import Editor from "@/components/paste-form/Editor";
|
||||
import SidebarPanel from "@/components/paste-form/SidebarPanel";
|
||||
import { useSession } from "next-auth/react";
|
||||
import { useRouter } from "next/navigation";
|
||||
import { useCallback, useEffect, useState } from "react";
|
||||
|
||||
export default function PasteForm() {
|
||||
const router = useRouter();
|
||||
const { data: session } = useSession();
|
||||
|
||||
const [title, setTitle] = useState("");
|
||||
const [content, setContent] = useState("");
|
||||
const [password, setPassword] = useState("");
|
||||
const [maxViews, setMaxViews] = useState("");
|
||||
const [isSaving, setIsSaving] = useState(false);
|
||||
const [advanced, setAdvanced] = useState(true);
|
||||
|
||||
const handleSave = useCallback(async () => {
|
||||
if (!content.trim()) return;
|
||||
setIsSaving(true);
|
||||
|
||||
const res = await fetch("/api/paste", {
|
||||
method: "POST",
|
||||
headers: { "Content-Type": "application/json" },
|
||||
body: JSON.stringify({
|
||||
title: title.trim() || null,
|
||||
content,
|
||||
password: password || null,
|
||||
maxViews: maxViews ? parseInt(maxViews, 10) : null,
|
||||
createdBy: session?.user?.id || null,
|
||||
}),
|
||||
});
|
||||
|
||||
if (res.ok) {
|
||||
const data = await res.json();
|
||||
router.push(`/${data.id}`);
|
||||
}
|
||||
|
||||
setIsSaving(false);
|
||||
}, [title, content, password, maxViews, session, router]);
|
||||
|
||||
// Raccourci clavier Ctrl+S
|
||||
useEffect(() => {
|
||||
const onKeyDown = (e: KeyboardEvent) => {
|
||||
if ((e.ctrlKey || e.metaKey) && e.key.toLowerCase() === "s") {
|
||||
e.preventDefault();
|
||||
if (!isSaving && content.trim()) handleSave();
|
||||
}
|
||||
};
|
||||
window.addEventListener("keydown", onKeyDown);
|
||||
return () => window.removeEventListener("keydown", onKeyDown);
|
||||
}, [handleSave, isSaving, content]);
|
||||
|
||||
return (
|
||||
<div className="w-screen h-screen bg-[#0e0f13] text-white relative">
|
||||
<Editor content={content} setContent={setContent} />
|
||||
<SidebarPanel
|
||||
title={title}
|
||||
setTitle={setTitle}
|
||||
maxViews={maxViews}
|
||||
setMaxViews={setMaxViews}
|
||||
password={password}
|
||||
setPassword={setPassword}
|
||||
content={content}
|
||||
isSaving={isSaving}
|
||||
handleSave={handleSave}
|
||||
advanced={advanced}
|
||||
setAdvanced={setAdvanced}
|
||||
/>
|
||||
<AuthSection />
|
||||
</div>
|
||||
);
|
||||
}
|
||||
@@ -0,0 +1,8 @@
|
||||
'use client';
|
||||
|
||||
import { SessionProvider } from 'next-auth/react';
|
||||
import { ReactNode } from 'react';
|
||||
|
||||
export default function AuthProvider({ children }: { children: ReactNode }) {
|
||||
return <SessionProvider>{children}</SessionProvider>;
|
||||
}
|
||||
@@ -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>
|
||||
);
|
||||
}
|
||||
@@ -0,0 +1,75 @@
|
||||
"use client";
|
||||
|
||||
import * as Dialog from "@radix-ui/react-dialog";
|
||||
import { motion } from "framer-motion";
|
||||
import { X } from "lucide-react";
|
||||
|
||||
interface ConfirmDeleteModalProps {
|
||||
open: boolean;
|
||||
onOpenChange: (open: boolean) => void;
|
||||
onConfirm: () => void;
|
||||
title?: string;
|
||||
description?: string;
|
||||
}
|
||||
|
||||
export default function ConfirmDeleteModal({
|
||||
open,
|
||||
onOpenChange,
|
||||
onConfirm,
|
||||
title = "Delete paste?",
|
||||
description = "This action cannot be undone. Are you sure you want to delete this paste?",
|
||||
}: ConfirmDeleteModalProps) {
|
||||
return (
|
||||
<Dialog.Root open={open} onOpenChange={onOpenChange}>
|
||||
<Dialog.Portal>
|
||||
{/* Overlay noir semi-transparent */}
|
||||
<Dialog.Overlay className="fixed inset-0 bg-black/60 backdrop-blur-sm z-40" />
|
||||
|
||||
{/* Contenu centré */}
|
||||
<Dialog.Content asChild>
|
||||
<div className="fixed inset-0 z-50 flex items-center justify-center">
|
||||
<motion.div
|
||||
initial={{ opacity: 0, scale: 0.95 }}
|
||||
animate={{ opacity: 1, scale: 1 }}
|
||||
exit={{ opacity: 0, scale: 0.95 }}
|
||||
className="bg-[#11131c] rounded-2xl p-6 shadow-xl w-[90%] max-w-md border border-white/10"
|
||||
>
|
||||
{/* Header */}
|
||||
<div className="flex justify-between items-center mb-4">
|
||||
<Dialog.Title className="text-lg font-semibold text-white">
|
||||
{title}
|
||||
</Dialog.Title>
|
||||
<Dialog.Close className="text-neutral-400 hover:text-white">
|
||||
<X size={18} />
|
||||
</Dialog.Close>
|
||||
</div>
|
||||
|
||||
{/* Description */}
|
||||
<Dialog.Description className="text-sm text-neutral-400 mb-6">
|
||||
{description}
|
||||
</Dialog.Description>
|
||||
|
||||
{/* Actions */}
|
||||
<div className="flex justify-end gap-3">
|
||||
<Dialog.Close asChild>
|
||||
<button className="cursor-pointer px-4 py-2 rounded-lg bg-neutral-700 text-white text-sm hover:bg-neutral-600 transition-colors">
|
||||
Cancel
|
||||
</button>
|
||||
</Dialog.Close>
|
||||
<button
|
||||
onClick={() => {
|
||||
onConfirm();
|
||||
onOpenChange(false);
|
||||
}}
|
||||
className="cursor-pointer px-4 py-2 rounded-lg bg-red-600 text-white text-sm hover:bg-red-500 transition-colors"
|
||||
>
|
||||
Delete
|
||||
</button>
|
||||
</div>
|
||||
</motion.div>
|
||||
</div>
|
||||
</Dialog.Content>
|
||||
</Dialog.Portal>
|
||||
</Dialog.Root>
|
||||
);
|
||||
}
|
||||
@@ -0,0 +1,61 @@
|
||||
"use client";
|
||||
|
||||
import { Info, Shield } from "lucide-react";
|
||||
import { signIn, signOut, useSession } from "next-auth/react";
|
||||
|
||||
export default function AuthSection() {
|
||||
const { data: session, status } = useSession();
|
||||
|
||||
if (status === "loading") return null;
|
||||
|
||||
return (
|
||||
<div className="fixed bottom-6 right-6 z-50 flex flex-col items-end gap-3 text-sm">
|
||||
{!session?.user ? (
|
||||
<div className="flex items-center gap-3">
|
||||
{/* Bouton About */}
|
||||
<a
|
||||
href="/about"
|
||||
className="cursor-pointer flex items-center gap-2 bg-[#0d1117] hover:bg-[#1c2230] border border-white/10 text-neutral-300 px-4 py-2 rounded-lg shadow-md transition-all"
|
||||
>
|
||||
<Info size={16} />
|
||||
<span>About</span>
|
||||
</a>
|
||||
|
||||
{/* Bouton Login */}
|
||||
<button
|
||||
onClick={() => signIn("discord")}
|
||||
className="cursor-pointer flex items-center gap-2 bg-[#0d1117] hover:bg-[#1c2230] border border-blue-500 text-blue-400 px-4 py-2 rounded-lg shadow-md transition-all"
|
||||
>
|
||||
<Shield className="animate-pulse" size={18} />
|
||||
<span>Login</span>
|
||||
</button>
|
||||
</div>
|
||||
) : (
|
||||
<div className="bg-[#0d1117] border border-white/10 rounded-xl p-4 shadow-lg space-y-2 min-w-[220px]">
|
||||
<div className="flex items-center gap-2 text-green-400 font-medium">
|
||||
<Shield size={18} />
|
||||
<span>Connected as</span>
|
||||
<span className="truncate font-semibold text-white">
|
||||
{session.user.name || "User"}
|
||||
</span>
|
||||
</div>
|
||||
|
||||
<div className="flex justify-between gap-2 mt-2">
|
||||
<a
|
||||
href="/dashboard"
|
||||
className="flex-1 text-center bg-blue-600 hover:bg-blue-500 text-white px-4 py-2 rounded-lg transition-colors"
|
||||
>
|
||||
Dashboard
|
||||
</a>
|
||||
<button
|
||||
onClick={() => signOut()}
|
||||
className="cursor-pointer flex-1 text-center bg-red-600 hover:bg-red-500 text-white px-4 py-2 rounded-lg transition-colors"
|
||||
>
|
||||
Logout
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
);
|
||||
}
|
||||
@@ -0,0 +1,48 @@
|
||||
"use client";
|
||||
|
||||
import { ChevronRight } from "lucide-react";
|
||||
import { useRef } from "react";
|
||||
|
||||
interface EditorProps {
|
||||
content: string;
|
||||
setContent: (v: string) => void;
|
||||
}
|
||||
|
||||
export default function Editor({ content, setContent }: EditorProps) {
|
||||
const textareaRef = useRef<HTMLTextAreaElement>(null);
|
||||
const lineNumbersRef = useRef<HTMLDivElement>(null);
|
||||
|
||||
const handleScroll = () => {
|
||||
if (lineNumbersRef.current && textareaRef.current) {
|
||||
lineNumbersRef.current.scrollTop = textareaRef.current.scrollTop;
|
||||
}
|
||||
};
|
||||
|
||||
return (
|
||||
<div className="flex w-full h-full overflow-hidden font-mono text-sm text-white">
|
||||
{/* Numéros de lignes */}
|
||||
<div
|
||||
ref={lineNumbersRef}
|
||||
className="flex flex-col items-end pr-4 pl-3 pt-6 text-neutral-600 select-none shrink-0 overflow-hidden"
|
||||
>
|
||||
{content.split("\n").map((_, i) => (
|
||||
<div key={i} className="flex items-center gap-2 leading-6 tabular-nums">
|
||||
{i === 0 && <ChevronRight size={14} className="text-blue-400 opacity-0" />}
|
||||
<span>{i + 1}</span>
|
||||
</div>
|
||||
))}
|
||||
</div>
|
||||
|
||||
{/* Zone d’édition */}
|
||||
<textarea
|
||||
ref={textareaRef}
|
||||
value={content}
|
||||
onChange={(e) => setContent(e.target.value)}
|
||||
onScroll={handleScroll}
|
||||
placeholder={`Insert or paste your content here...\n\n// Supported content types:\n// – Source code (any language)\n// – Config files\n// – Text documents\n// – Logs and debug output\n\nShortcut: Ctrl+S (or Cmd+S) to save your paste`}
|
||||
className="w-full flex-1 bg-transparent text-white resize-none outline-none py-6 pr-4 pl-0 caret-blue-400 placeholder:text-sm placeholder:text-gray-500 leading-6 whitespace-pre overflow-auto"
|
||||
aria-label="Paste editor"
|
||||
/>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
@@ -0,0 +1,28 @@
|
||||
"use client";
|
||||
|
||||
import { Lock } from "lucide-react";
|
||||
|
||||
export default function SaveButton({
|
||||
handleSave,
|
||||
isSaving,
|
||||
content,
|
||||
}: {
|
||||
handleSave: () => void;
|
||||
isSaving: boolean;
|
||||
content: string;
|
||||
}) {
|
||||
return (
|
||||
<button
|
||||
onClick={handleSave}
|
||||
disabled={!content.trim() || isSaving}
|
||||
className={`mt-6 w-full flex items-center justify-center gap-2 rounded-xl py-2 text-sm font-medium
|
||||
${!content.trim() || isSaving
|
||||
? "bg-[#151826] text-neutral-500 ring-1 ring-white/10 cursor-not-allowed"
|
||||
: "bg-gradient-to-b from-[#1b2135] to-[#141a2a] text-white ring-1 ring-white/10 hover:from-[#232a41] hover:to-[#161d2f]"}
|
||||
`}
|
||||
>
|
||||
<Lock size={16} />
|
||||
<span>Save Paste</span>
|
||||
</button>
|
||||
);
|
||||
}
|
||||
@@ -0,0 +1,111 @@
|
||||
"use client";
|
||||
|
||||
import SaveButton from "@/components/paste-form/SaveButton";
|
||||
import { ChevronDown, ChevronRight, Eye, Lock, Plus, Settings } from "lucide-react";
|
||||
|
||||
interface SidebarPanelProps {
|
||||
title: string;
|
||||
setTitle: (v: string) => void;
|
||||
maxViews: string;
|
||||
setMaxViews: (v: string) => void;
|
||||
password: string;
|
||||
setPassword: (v: string) => void;
|
||||
content: string;
|
||||
isSaving: boolean;
|
||||
handleSave: () => void;
|
||||
advanced: boolean;
|
||||
setAdvanced: (v: boolean) => void;
|
||||
}
|
||||
|
||||
export default function SidebarPanel({
|
||||
title,
|
||||
setTitle,
|
||||
maxViews,
|
||||
setMaxViews,
|
||||
password,
|
||||
setPassword,
|
||||
content,
|
||||
isSaving,
|
||||
handleSave,
|
||||
advanced,
|
||||
setAdvanced,
|
||||
}: SidebarPanelProps) {
|
||||
return (
|
||||
<aside className="absolute top-4 right-4 w-[300px] rounded-2xl p-5 text-sm z-10 backdrop-blur-xl shadow-2xl bg-[linear-gradient(to_bottom_right,rgba(20,24,38,0.9),rgba(14,16,24,0.9))] ring-1 ring-white/10 mr-4">
|
||||
<h2 className="text-lg font-bold text-center">
|
||||
Alt<span className="text-blue-400">Bin</span>
|
||||
</h2>
|
||||
|
||||
{/* Actions */}
|
||||
<div className="mt-4 flex items-center justify-center gap-2">
|
||||
<button
|
||||
onClick={handleSave}
|
||||
disabled={!content.trim() || isSaving}
|
||||
className="inline-flex items-center gap-1 rounded-full px-3 py-1 text-xs font-semibold bg-green-600 text-white shadow-sm hover:bg-green-500 disabled:opacity-50"
|
||||
>
|
||||
<Plus size={14} /> CREATE
|
||||
</button>
|
||||
|
||||
<button
|
||||
onClick={() => setAdvanced(!advanced)}
|
||||
className="inline-flex items-center gap-1 rounded-full px-3 py-1 text-xs font-medium bg-[#0f1320]/70 text-neutral-200 ring-1 ring-white/15 hover:bg-[#151a2a] hover:ring-white/25"
|
||||
>
|
||||
<Settings size={14} />
|
||||
<span>Advanced</span>
|
||||
{advanced ? <ChevronDown size={14} /> : <ChevronRight size={14} />}
|
||||
</button>
|
||||
</div>
|
||||
|
||||
{/* Options avancées */}
|
||||
{advanced && (
|
||||
<div className="space-y-6 mt-4">
|
||||
{/* Title */}
|
||||
<div>
|
||||
<label className="block text-[11px] font-semibold text-neutral-400 mb-2">Title</label>
|
||||
<input
|
||||
value={title}
|
||||
onChange={(e) => setTitle(e.target.value)}
|
||||
placeholder="Optional title"
|
||||
className="w-full rounded-xl bg-[#0f1320]/60 px-4 py-2 text-white ring-1 ring-white/10"
|
||||
/>
|
||||
</div>
|
||||
|
||||
{/* Max Views */}
|
||||
<div>
|
||||
<label className="flex items-center gap-2 text-[11px] font-semibold text-neutral-400 mb-2">
|
||||
<Eye size={14} /> Max Views
|
||||
</label>
|
||||
<input
|
||||
type="number"
|
||||
value={maxViews}
|
||||
onChange={(e) => setMaxViews(e.target.value)}
|
||||
placeholder="∞"
|
||||
className="w-full rounded-xl bg-[#0f1320]/60 px-4 py-2 text-white ring-1 ring-white/10"
|
||||
/>
|
||||
</div>
|
||||
|
||||
{/* Password */}
|
||||
<div>
|
||||
<label className="flex items-center gap-2 text-[11px] font-semibold text-neutral-400 mb-2">
|
||||
<Lock size={14} /> Password
|
||||
</label>
|
||||
<input
|
||||
type="password"
|
||||
value={password}
|
||||
onChange={(e) => setPassword(e.target.value)}
|
||||
placeholder="Optional password"
|
||||
className="w-full rounded-xl bg-[#0f1320]/60 px-4 py-2 text-white ring-1 ring-white/10"
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
)}
|
||||
|
||||
{/* Save principal */}
|
||||
<SaveButton
|
||||
handleSave={handleSave}
|
||||
isSaving={isSaving}
|
||||
content={content}
|
||||
/>
|
||||
</aside>
|
||||
);
|
||||
}
|
||||
@@ -0,0 +1,24 @@
|
||||
"use client";
|
||||
|
||||
import { motion } from "framer-motion";
|
||||
import { LogOut } from "lucide-react";
|
||||
import { signOut } from "next-auth/react";
|
||||
|
||||
export default function LogOutButton() {
|
||||
return (
|
||||
<motion.button
|
||||
whileHover={{ scale: 1.05 }}
|
||||
whileTap={{ scale: 0.97 }}
|
||||
onClick={() => signOut()}
|
||||
className="cursor-pointer group inline-flex items-center gap-2 px-6 py-3 rounded-xl text-base font-medium
|
||||
text-white bg-gradient-to-r from-red-600 to-red-500 shadow-lg shadow-red-500/30
|
||||
hover:shadow-red-500/50 transition-all duration-300 focus:outline-none focus:ring-2 focus:ring-red-400/60"
|
||||
>
|
||||
<LogOut
|
||||
size={20}
|
||||
className="text-red-200 group-hover:-rotate-90 transition-transform duration-300"
|
||||
/>
|
||||
<span>LogOut</span>
|
||||
</motion.button>
|
||||
);
|
||||
}
|
||||
@@ -0,0 +1,30 @@
|
||||
"use client";
|
||||
|
||||
import { Toaster } from "react-hot-toast";
|
||||
|
||||
export default function ToasterProvider() {
|
||||
return (
|
||||
<Toaster
|
||||
position="top-right"
|
||||
toastOptions={{
|
||||
style: {
|
||||
background: "#11131c",
|
||||
color: "#fff",
|
||||
border: "1px solid #2a2f3a",
|
||||
},
|
||||
success: {
|
||||
iconTheme: {
|
||||
primary: "#22c55e", // green
|
||||
secondary: "#11131c",
|
||||
},
|
||||
},
|
||||
error: {
|
||||
iconTheme: {
|
||||
primary: "#ef4444", // red
|
||||
secondary: "#11131c",
|
||||
},
|
||||
},
|
||||
}}
|
||||
/>
|
||||
);
|
||||
}
|
||||
Reference in New Issue
Block a user