11import { LightbulbIcon , OpenIcon } from "@public/icons" ;
2- import { useEffect , useRef , useState } from "react" ;
3- import { fetchFromSemanticScholar , fetchNotionBlock , fetchNotionPage , getOpenUrl } from "./utils" ;
2+ import { useRef , useState } from "react" ;
3+ import { fetchFromSemanticScholar , getOpenUrl } from "./utils" ;
44import { useClickOutside } from "@hooks" ;
55import PaperCard from "./PaperCard" ;
66
@@ -13,20 +13,22 @@ export default function PaperDetail({ paper }: { paper: Paper | null }) {
1313 citations : RelatedPaper [ ] ,
1414 }
1515 } > ( { } ) ;
16- const [ lightbulbData , setLightbulbData ] = useState < {
16+ const [ suggestions , setSuggestions ] = useState < {
1717 references : any [ ] ,
1818 citations : any [ ] ,
1919 open : boolean ,
2020 } > ( { references : [ ] , citations : [ ] , open : false } ) ;
21+ const [ visibleReferenceCount , setVisibleReferenceCount ] = useState ( 10 ) ;
22+ const [ visibleCitationCount , setVisibleCitationCount ] = useState ( 10 ) ;
2123 const [ suggestionLoading , setSuggestionLoading ] = useState ( false ) ;
2224 const suggestionRef = useRef < HTMLDivElement > ( null ) ;
23- useClickOutside ( suggestionRef , ( ) => setLightbulbData ( d => ( { ...d , open : false } ) ) )
25+ useClickOutside ( suggestionRef , ( ) => setSuggestions ( d => ( { ...d , open : false } ) ) )
2426
2527 async function handleSuggest ( ) {
2628 if ( ! paper ) return ;
2729
2830 if ( cachedRelatedPapers [ paper . id ] ) {
29- setLightbulbData ( {
31+ setSuggestions ( {
3032 ...cachedRelatedPapers [ paper . id ] ,
3133 open : true ,
3234 } ) ;
@@ -47,7 +49,7 @@ export default function PaperDetail({ paper }: { paper: Paper | null }) {
4749 } ) ) ;
4850
4951 // Show modal
50- setLightbulbData ( {
52+ setSuggestions ( {
5153 ...newEntry ,
5254 open : true ,
5355 } ) ;
@@ -59,7 +61,7 @@ export default function PaperDetail({ paper }: { paper: Paper | null }) {
5961 paper
6062 ?
6163 < >
62- < div className = "paper-detail w-[30%] bg-slate-100 rounded-md p-2 h-full overflow-auto scrollbar-thin scrollbar-thumb-slate-400 scrollbar-track-slate-200" >
64+ < div className = "paper-detail bg-slate-100 rounded-md p-2 h-full overflow-auto scrollbar-thin scrollbar-thumb-slate-400 scrollbar-track-slate-200" >
6365 < div className = 'flex justify-between' >
6466 < span className = "font-semibold text-sm text-blue-700 truncate" >
6567 { paper . title }
@@ -101,38 +103,63 @@ export default function PaperDetail({ paper }: { paper: Paper | null }) {
101103 }
102104 </ div >
103105 }
104- { lightbulbData . open && (
106+ { suggestions . open && (
105107 < div className = "fixed inset-0 bg-black bg-opacity-50 flex items-center justify-center z-50" >
106- < div ref = { suggestionRef } className = "bg-white w-[1/2] max-h-[80vh] p-6 rounded shadow overflow-y-auto" >
107- < div className = "mb-4" >
108- < h3 className = "font-semibold text-gray-700" > References</ h3 >
109- { lightbulbData . references . length === 0 ? (
110- < p className = "text-sm text-gray-500" > No references found.</ p >
108+ < div ref = { suggestionRef } className = "bg-white w-[50vw] max-h-[80vh] p-6 rounded shadow overflow-y-auto" >
109+
110+ { /* References Section */ }
111+ < div className = "mb-6" >
112+ < h3 className = "font-semibold text-gray-700 mb-2" > References</ h3 >
113+ { suggestions . references . length === 0 ? (
114+ < p className = "text-sm text-gray-500" > No references found.</ p >
111115 ) : (
112116 < >
113- { lightbulbData . references
117+ { suggestions . references
114118 . sort ( ( a , b ) => b . citationCount - a . citationCount )
115- . map ( ( paper ) => < PaperCard key = { paper . id } paper = { paper } /> ) }
119+ . slice ( 0 , visibleReferenceCount )
120+ . map ( ( paper ) => (
121+ < PaperCard key = { paper . scid } paper = { paper } />
122+ ) ) }
123+ { visibleReferenceCount < suggestions . references . length && (
124+ < button
125+ className = "text-blue-600 text-sm mt-2"
126+ onClick = { ( ) => setVisibleReferenceCount ( c => c + 10 ) }
127+ >
128+ Show 10 more
129+ </ button >
130+ ) }
116131 </ >
117132 ) }
118133 </ div >
119134
135+ { /* Citations Section */ }
120136 < div >
121- < h3 className = "font-semibold text-gray-700" > Citations</ h3 >
122- { lightbulbData . citations . length === 0 ? (
137+ < h3 className = "font-semibold text-gray-700 mb-2 " > Citations</ h3 >
138+ { suggestions . citations . length === 0 ? (
123139 < p className = "text-sm text-gray-500" > No citations found.</ p >
124140 ) : (
125141 < >
126- { lightbulbData . citations
142+ { suggestions . citations
127143 . sort ( ( a , b ) => b . citationCount - a . citationCount )
128- . map ( ( paper ) =>
129- < PaperCard key = { paper . scid } paper = { paper } /> ) }
144+ . slice ( 0 , visibleCitationCount )
145+ . map ( ( paper ) => (
146+ < PaperCard key = { paper . scid } paper = { paper } />
147+ ) ) }
148+ { visibleCitationCount < suggestions . citations . length && (
149+ < button
150+ className = "text-blue-600 text-sm mt-2"
151+ onClick = { ( ) => setVisibleCitationCount ( c => c + 10 ) }
152+ >
153+ Show 10 more
154+ </ button >
155+ ) }
130156 </ >
131157 ) }
132158 </ div >
133159 </ div >
134160 </ div >
135161 ) }
162+
136163 </ div >
137164 </ >
138165 : < > </ >
0 commit comments