tahamajs/IE / Projects /front /src /pages /GraphNodePage.tsx
tahamajs's picture
download
raw
7.74 kB
import React, { useState, useEffect } from 'react';
import { useParams, Link } from 'react-router-dom';
import { motion } from 'framer-motion';
import { FileText, GitBranch, ArrowLeft, Calendar, User, BookOpen, Copy, Check, Star } from 'lucide-react';
import { toast } from 'react-toastify';
interface NodeDetail {
id: string;
title: string;
author: string;
coAuthors: string[];
year: number;
journal: string;
doi: string;
citations: number;
abstract: string;
inbound: Array<{ id: string; title: string; author: string; year: number }>;
outbound: Array<{ id: string; title: string; author: string; year: number }>;
}
export default function GraphNodePage() {
const { nodeId } = useParams<{ nodeId: string }>();
const [paper, setPaper] = useState<NodeDetail | null>(null);
const [copied, setCopied] = useState(false);
useEffect(() => {
// Simulated fetch of single node metadata details
const simulatedData: NodeDetail = {
id: nodeId || 'node-main',
title: 'Neural Message Passing for Quantum Chemistry',
author: 'Justin Gilmer',
coAuthors: ['Samuel S. Schoenholz', 'Patrick F. Riley', 'Oriol Vinyals', 'George E. Dahl'],
year: 2017,
journal: 'International Conference on Machine Learning (ICML)',
doi: '10.5281/zenodo.10398',
citations: 3410,
abstract: 'Supervised learning on molecular graphs has played an important role in drug discovery and physical chemistry. Message passing neural networks (MPNNs) generalize existing models and achieve state-of-the-art results on predicting molecular properties. We present a comprehensive framework and benchmark these models on key physical parameters.',
inbound: [
{ id: 'n-cite-1', title: 'Graph Attention Networks (GAT)', author: 'Velickovic et al.', year: 2018 },
{ id: 'n-cite-2', title: 'Directional Message Passing for Graph Neural Networks', author: 'Klicpera et al.', year: 2020 }
],
outbound: [
{ id: 'n-ref-1', title: 'Convolutional Networks on Graphs for Learning Molecular Fingerprints', author: 'Duvenaud et al.', year: 2015 },
{ id: 'n-ref-2', title: 'Semi-Supervised Classification with Graph Convolutional Networks', author: 'Kipf & Welling', year: 2016 }
]
};
setPaper(simulatedData);
}, [nodeId]);
const handleCopyCitation = () => {
if (!paper) return;
const format = `${paper.author} et al. (${paper.year}). "${paper.title}". ${paper.journal}. DOI: ${paper.doi}`;
navigator.clipboard.writeText(format);
setCopied(true);
toast.success('APA citation copied to clipboard');
setTimeout(() => setCopied(false), 2000);
};
if (!paper) {
return (
<div className="min-h-screen flex items-center justify-center bg-slate-950 text-white">
<p className="animate-pulse">Loading node metrics...</p>
</div>
);
}
return (
<div className="min-h-screen p-6 md:p-10 bg-slate-950 text-white">
<motion.div
initial={{ opacity: 0, y: 15 }}
animate={{ opacity: 1, y: 0 }}
className="max-w-5xl mx-auto space-y-8"
>
{/* Back Link */}
<Link to="/citationgraph" className="inline-flex items-center gap-2 text-slate-400 hover:text-white transition text-sm">
<ArrowLeft className="w-4 h-4" /> Back to Topology Graph
</Link>
{/* Paper Header */}
<div className="glass p-8 rounded-3xl border border-white/10 bg-slate-900/40 space-y-4">
<div className="flex justify-between items-start gap-4">
<span className="text-[10px] bg-indigo-500/10 text-indigo-300 border border-indigo-500/20 px-2.5 py-0.5 rounded font-mono uppercase font-semibold">Scientific Node</span>
<span className="text-xs text-slate-400 font-mono">DOI: {paper.doi}</span>
</div>
<h1 className="text-3xl font-extrabold tracking-tight leading-snug">{paper.title}</h1>
<div className="flex flex-wrap items-center gap-y-2 gap-x-6 text-sm text-slate-400">
<span className="flex items-center gap-1.5"><User className="w-4 h-4 text-indigo-400" /> {paper.author} et al.</span>
<span className="flex items-center gap-1.5"><Calendar className="w-4 h-4 text-cyan-400" /> {paper.year}</span>
<span>Journal: <strong className="text-slate-300">{paper.journal}</strong></span>
</div>
<p className="text-xs text-slate-500">
Co-Authors: {paper.coAuthors.join(', ')}
</p>
</div>
{/* Abstract */}
<div className="space-y-3">
<h3 className="text-lg font-bold flex items-center gap-2">
<FileText className="w-5 h-5 text-indigo-400" /> Executive Abstract
</h3>
<p className="text-slate-300 leading-relaxed text-sm md:text-base bg-white/[0.01] p-5 rounded-2xl border border-white/5">
{paper.abstract}
</p>
</div>
{/* Citation Topology Links */}
<div className="grid grid-cols-1 md:grid-cols-2 gap-8">
{/* Citing Papers */}
<div className="glass p-6 rounded-3xl border border-white/10 bg-slate-900/40 space-y-4">
<h3 className="text-base font-bold flex items-center gap-2 border-b border-white/5 pb-2">
<GitBranch className="w-4 h-4 text-cyan-400" /> Inbound Citations ({paper.inbound.length})
</h3>
<div className="space-y-3">
{paper.inbound.map(node => (
<div key={node.id} className="p-3 bg-slate-950/40 rounded-xl border border-white/5 hover:border-white/10 transition">
<h4 className="text-xs font-bold text-slate-200">{node.title}</h4>
<div className="flex justify-between items-center text-[10px] text-slate-500 mt-1 font-mono">
<span>{node.author}</span>
<span>{node.year}</span>
</div>
</div>
))}
</div>
</div>
{/* References */}
<div className="glass p-6 rounded-3xl border border-white/10 bg-slate-900/40 space-y-4">
<h3 className="text-base font-bold flex items-center gap-2 border-b border-white/5 pb-2">
<BookOpen className="w-4 h-4 text-violet-400" /> Outbound References ({paper.outbound.length})
</h3>
<div className="space-y-3">
{paper.outbound.map(node => (
<div key={node.id} className="p-3 bg-slate-950/40 rounded-xl border border-white/5 hover:border-white/10 transition">
<h4 className="text-xs font-bold text-slate-200">{node.title}</h4>
<div className="flex justify-between items-center text-[10px] text-slate-500 mt-1 font-mono">
<span>{node.author}</span>
<span>{node.year}</span>
</div>
</div>
))}
</div>
</div>
</div>
{/* Buttons */}
<div className="flex gap-4">
<button
onClick={handleCopyCitation}
className="flex-1 py-3 bg-gradient-to-r from-violet-600 to-indigo-600 hover:from-violet-500 hover:to-indigo-500 rounded-2xl font-bold shadow-lg transition active:scale-95 text-sm flex items-center justify-center gap-2"
>
{copied ? <Check className="w-4 h-4" /> : <Copy className="w-4 h-4" />} Copy Reference Cite
</button>
<button className="px-6 py-3 border border-white/10 hover:bg-white/5 rounded-2xl transition font-semibold text-sm">
<Star className="w-4 h-4" /> Bookmark Node
</button>
</div>
</motion.div>
</div>
);
}

Xet Storage Details

Size:
7.74 kB
·
Xet hash:
2455f06ceb35442bdb7dd69aed2705466e90dd01b01900a6e479ca036ed4d976

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