tahamajs/IE / Projects /front /src /components /dashboard /widgets /QuickActionsWidget.tsx
tahamajs's picture
download
raw
2.11 kB
// src/components/dashboard/widgets/QuickActionsWidget.tsx
import { Plus, FileText, Users, Settings } from "lucide-react";
import { useNavigate } from "react-router-dom";
import { useEffect, useState } from "react";
const ACTIONS = [
{ label: "New Article", icon: Plus, path: "/create-article", color: "bg-primary", shortcut: "C" },
{ label: "Browse Papers", icon: FileText, path: "/articles", color: "bg-blue-500", shortcut: "B" },
{ label: "Find Collaborators", icon: Users, path: "/search-users", color: "bg-purple-500", shortcut: "F" },
{ label: "Settings", icon: Settings, path: "/settings", color: "bg-gray-500", shortcut: "S" },
];
export function QuickActionsWidget() {
const navigate = useNavigate();
const [hovered, setHovered] = useState<string | null>(null);
useEffect(() => {
const handleKeyDown = (e: KeyboardEvent) => {
if (e.ctrlKey || e.metaKey) return;
const action = ACTIONS.find((a) => a.shortcut.toLowerCase() === e.key.toLowerCase());
if (action) {
e.preventDefault();
navigate(action.path);
}
};
window.addEventListener("keydown", handleKeyDown);
return () => window.removeEventListener("keydown", handleKeyDown);
}, [navigate]);
return (
<div className="space-y-3">
<h3 className="font-semibold">Quick Actions</h3>
<div className="grid grid-cols-2 gap-2">
{ACTIONS.map((a) => (
<button
key={a.label}
onClick={() => navigate(a.path)}
onMouseEnter={() => setHovered(a.label)}
onMouseLeave={() => setHovered(null)}
className="relative flex flex-col items-center gap-1 p-3 rounded-xl border hover:shadow transition group"
>
<a.icon className="w-5 h-5" />
<span className="text-xs">{a.label}</span>
{hovered === a.label && (
<span className="absolute -top-2 -right-2 text-[9px] bg-gray-800 text-white px-1.5 py-0.5 rounded-full">
{a.shortcut}
</span>
)}
</button>
))}
</div>
</div>
);
}

Xet Storage Details

Size:
2.11 kB
·
Xet hash:
705ebc2420666d919208d197dc861bad34da1df3b9f2c6ff5fbdd8fb48b09aaa

Xet efficiently stores files, intelligently splitting them into unique chunks and accelerating uploads and downloads. More info.