paperswithcode / assets /FeedView-Ti-ljGuF.js
nielsr's picture
nielsr HF Staff
Sync paperswithcode.co frontend
7b9cf70 verified
Raw
History Blame Contribute Delete
4.96 kB
import{u as S,r as N,j as e,L as d,a as y}from"./index-BzfLml0t.js";import{P as I}from"./components-Bt8j-Ti3.js";import{t as L,d as b}from"./transform-DGxuYrgz.js";import{u as R}from"./usePapers-BPKC8iFX.js";import{u as A}from"./useIntersectionObserver-78X4w5YJ.js";import{P as D}from"./usePeriodFilter-CAqcWkXB.js";import{S as t}from"./skeleton-DWgX1Pkq.js";import{A as E,a as M}from"./alert-ByP9KeSr.js";import{u as T}from"./useQuery-B9_VgOir.js";import"./LatexTitle-becjMI_d.js";import"./katex.min-BSBacQyE.js";import"./useInfiniteQuery-Cb9t-FBv.js";const C=[["trending","trending"],["date_published","newest"],["citation_count","most cited"]],W={Today:"today","This Week":"week","This Month":"month","All Time":"all_time"},q={today:"Today",week:"This Week",month:"This Month",all_time:"All Time"},$=i=>i==="trending"||i==="date_published"||i==="citation_count"?i:"trending",B=i=>i==="today"||i==="week"||i==="month"||i==="all_time"?i:"all_time",se=()=>{var x,g,u,j,f;const[i,o]=S(),c=$(i.get("order_by")),m=B(i.get("time")),v=q[m],_=s=>{const a=new URLSearchParams(i);a.set("order_by",s),o(a)},w=s=>{const a=new URLSearchParams(i);a.set("time",W[s]),o(a)},h=T({queryKey:["top-tasks-sidebar"],queryFn:()=>y.getTopTasks({limit:8}),staleTime:10*60*1e3}),n=T({queryKey:["trending-tasks-sidebar"],queryFn:()=>y.getTrendingTasks({limit:8}),staleTime:10*60*1e3}),r=R({page_size:30,order_by:c,order_dir:"desc",time:m,include_resources:!0}),l=N.useMemo(()=>{var a;return(((a=r.data)==null?void 0:a.pages.flatMap(O=>O.results))||[]).map(L)},[r.data]),{targetRef:P,isIntersecting:p}=A({rootMargin:"400px"});N.useEffect(()=>{p&&r.hasNextPage&&!r.isFetchingNextPage&&r.fetchNextPage()},[p,r.hasNextPage,r.isFetchingNextPage]);const k=r.isLoading,F=r.error;return e.jsxs("div",{className:"page",children:[e.jsxs("div",{className:"feed-header",children:[e.jsxs("div",{children:[e.jsxs("h1",{className:"feed-title",children:["Trending ",e.jsx("em",{children:"Research"})]}),e.jsx("div",{className:"feed-subtitle",children:"Curated daily from arXiv and Hugging Face"})]}),e.jsx("div",{style:{display:"flex",gap:16,alignItems:"center",flexWrap:"wrap"},children:e.jsx("div",{className:"period-switch",children:D.map(s=>e.jsx("button",{className:`period-btn ${v===s?"active":""}`,onClick:()=>w(s),children:s},s))})})]}),e.jsxs("div",{className:"layout-with-sidebar",children:[e.jsxs("aside",{className:"sidebar",children:[e.jsxs("div",{className:"sidebar-section",children:[e.jsx("div",{className:"sidebar-label",children:"Top Domains"}),h.isLoading&&e.jsx("div",{style:{display:"flex",flexDirection:"column",gap:8},children:Array.from({length:6}).map((s,a)=>e.jsx(t,{className:"h-5 w-full"},a))}),(x=h.data)==null?void 0:x.map(s=>e.jsxs(d,{to:`/tasks/${s.slug}`,className:"sidebar-link",children:[b(s.name,s.slug),s.paper_count!=null&&e.jsx("span",{className:"count",children:s.paper_count})]},s.id)),e.jsx(d,{to:"/tasks",className:"sidebar-link",style:{marginTop:8,fontStyle:"italic"},children:"all domains →"})]}),e.jsxs("div",{className:"sidebar-section",children:[e.jsx("div",{className:"sidebar-label",children:"Trending Domains"}),n.isLoading&&e.jsx("div",{style:{display:"flex",flexDirection:"column",gap:8},children:Array.from({length:6}).map((s,a)=>e.jsx(t,{className:"h-5 w-full"},a))}),((u=(g=n.data)==null?void 0:g.results)==null?void 0:u.length)===0&&!n.isLoading&&e.jsx("div",{style:{fontSize:12,color:"var(--ink-faint)"},children:"No domains gaining momentum right now."}),(f=(j=n.data)==null?void 0:j.results)==null?void 0:f.map(s=>e.jsxs(d,{to:`/tasks/${s.slug}`,className:"sidebar-link",children:[b(s.name,s.slug),e.jsxs("span",{className:"count",children:[s.share_lift.toFixed(1),"x"]})]},s.id))]})]}),e.jsxs("div",{children:[e.jsxs("div",{className:"sort-bar",children:[e.jsx("div",{className:"sort-options",children:C.map(([s,a])=>e.jsx("button",{className:`sort-btn ${c===s?"active":""}`,onClick:()=>_(s),children:a},s))}),e.jsxs("div",{className:"results-count",children:[l.length," papers"]})]}),F&&e.jsx(E,{variant:"destructive",className:"mb-4",children:e.jsx(M,{children:"Failed to load papers. Please try again."})}),k?e.jsx("div",{className:"paper-list",children:Array.from({length:6}).map((s,a)=>e.jsxs("div",{className:"paper-card",children:[e.jsx("div",{className:"paper-thumb-wrap",children:e.jsx(t,{className:"paper-thumb-skeleton"})}),e.jsxs("div",{className:"paper-body",style:{flex:1,gap:12},children:[e.jsx(t,{className:"h-6 w-3/4"}),e.jsx(t,{className:"h-4 w-1/2"}),e.jsx(t,{className:"h-12 w-full"})]})]},a))}):l.length===0?e.jsx("div",{className:"no-results",children:"No papers in this window."}):e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"paper-list",children:l.map((s,a)=>e.jsx(I,{paper:s,rank:a+1},s.id))}),e.jsx("div",{ref:P,style:{height:1}}),r.isFetchingNextPage&&e.jsx("div",{style:{padding:"20px 0",textAlign:"center",color:"var(--ink-faint)"},children:"Loading more…"})]})]})]})]})};export{se as default};