Skip to content

Commit 0aff754

Browse files
committed
Make paper clickable in tooltip overlay
Signed-off-by: Jay Wang <[email protected]>
1 parent 5509b35 commit 0aff754

File tree

4 files changed

+64
-22
lines changed

4 files changed

+64
-22
lines changed

src/components/page/page.css

+4
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,10 @@
4242
gap: var(--font-u7);
4343
}
4444

45+
a {
46+
text-decoration: none;
47+
}
48+
4549
a.button {
4650
padding-top: var(--font-d2);
4751
font-size: var(--font-u6);

src/components/page/page.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -53,12 +53,12 @@ export class RecRecPage extends LitElement {
5353
return html`
5454
<div class="page">
5555
<div class="headline">
56-
<div class="head-group">
56+
<a class="head-group" href="./">
5757
<div class="svg-icon">${unsafeHTML(recrecIcon)}</div>
5858
<div class="tag-line">
5959
Recommender for Recommendation Letter Writers
6060
</div>
61-
</div>
61+
</a>
6262
6363
<div class="head-group">
6464
<a href="https://zijie.wang" target="_blank" class="button"

src/components/recommender-view/recommender-view.css

+11-2
Original file line numberDiff line numberDiff line change
@@ -501,8 +501,6 @@ button {
501501

502502
padding: 2px 0;
503503
box-sizing: border-box;
504-
user-select: none;
505-
-webkit-user-select: none;
506504

507505
display: flex;
508506
flex-flow: column;
@@ -527,6 +525,7 @@ button {
527525
display: flex;
528526
justify-content: space-between;
529527
box-sizing: border-box;
528+
cursor: default;
530529
}
531530

532531
.separator {
@@ -564,6 +563,15 @@ button {
564563
}
565564
}
566565

566+
a.cell-paper {
567+
color: currentColor;
568+
text-decoration: none;
569+
570+
&:hover {
571+
color: color-mix(in lab, currentColor 100%, var(--gray-600) 30%);
572+
}
573+
}
574+
567575
.cell-paper {
568576
overflow: hidden;
569577
text-overflow: ellipsis;
@@ -572,6 +580,7 @@ button {
572580

573581
.cell-count {
574582
text-align: right;
583+
cursor: default;
575584
}
576585
}
577586

src/components/recommender-view/recommender-view.ts

+47-18
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,7 @@ export class RecRecRecommenderView extends LitElement {
117117
paperCitingAuthorCountMap: Map<string, Map<string, number>>;
118118
paperCitingAuthorCountSumMap: Map<string, number>;
119119

120-
authorPaperCiteTimesMap: Map<string, Map<string, number>>;
120+
authorPaperCiteTimesMap: Map<string, Map<string, [string, number]>>;
121121
authorPaperCiteTimesSumMap: Map<string, number>;
122122

123123
myCollaborators: Set<string>;
@@ -189,7 +189,7 @@ export class RecRecRecommenderView extends LitElement {
189189
descriptionOverlayElement: HTMLElement | undefined;
190190

191191
@state()
192-
overlayPaperCounts: [string, number][];
192+
overlayPaperCounts: [string, number, string][];
193193

194194
@state()
195195
overlayPaperCountsType: 'citeTimes' | 'paperCount' = 'citeTimes';
@@ -216,7 +216,10 @@ export class RecRecRecommenderView extends LitElement {
216216
this.paperCitingAuthorCountMap = new Map<string, Map<string, number>>();
217217
this.paperCitingAuthorCountSumMap = new Map<string, number>();
218218

219-
this.authorPaperCiteTimesMap = new Map<string, Map<string, number>>();
219+
this.authorPaperCiteTimesMap = new Map<
220+
string,
221+
Map<string, [string, number]>
222+
>();
220223
this.authorPaperCiteTimesSumMap = new Map<string, number>();
221224

222225
this.myCollaborators = new Set<string>();
@@ -232,7 +235,12 @@ export class RecRecRecommenderView extends LitElement {
232235
/**
233236
* This method is called when the DOM is added for the first time
234237
*/
235-
firstUpdated() {}
238+
firstUpdated() {
239+
// Cancel the overlay when user clicks any external area
240+
document.addEventListener('click', () => {
241+
this.citeTimeBlurred();
242+
});
243+
}
236244

237245
/**
238246
* This method is called before new DOM is updated and rendered
@@ -248,7 +256,10 @@ export class RecRecRecommenderView extends LitElement {
248256
this.allAuthors = new Map<string, Recommender>();
249257
this.paperCitingAuthorCountSumMap = new Map<string, number>();
250258
this.paperCitingAuthorCountMap = new Map<string, Map<string, number>>();
251-
this.authorPaperCiteTimesMap = new Map<string, Map<string, number>>();
259+
this.authorPaperCiteTimesMap = new Map<
260+
string,
261+
Map<string, [string, number]>
262+
>();
252263
this.authorPaperCiteTimesSumMap = new Map<string, number>();
253264
this.myCollaborators = new Set<string>();
254265

@@ -373,7 +384,10 @@ export class RecRecRecommenderView extends LitElement {
373384
const paperCitingAuthorCountSumMap = new Map<string, number>();
374385

375386
// Map author id => Map <paper (author's paper), number of times that paper cites my work>
376-
const authorPaperCiteTimesMap = new Map<string, Map<string, number>>();
387+
const authorPaperCiteTimesMap = new Map<
388+
string,
389+
Map<string, [string, number]>
390+
>();
377391
const paperCiteTimesMap = new Map<string, number>();
378392
const authorPaperMap = new Map<string, Set<string>>();
379393
const paperIDMap = new Map<string, string>();
@@ -458,10 +472,13 @@ export class RecRecRecommenderView extends LitElement {
458472
// Resolve the author => <author's paper title, citing times> map
459473
for (const author of authorPaperMap.keys()) {
460474
const papers = authorPaperMap.get(author)!;
461-
const curPaperCiteTimesMap = new Map<string, number>();
475+
const curPaperCiteTimesMap = new Map<string, [string, number]>();
462476
for (const paper of papers) {
463477
const paperTitle = paperIDMap.get(paper)!;
464-
curPaperCiteTimesMap.set(paperTitle, paperCiteTimesMap.get(paper)!);
478+
curPaperCiteTimesMap.set(paperTitle, [
479+
paper,
480+
paperCiteTimesMap.get(paper)!
481+
]);
465482
}
466483
authorPaperCiteTimesMap.set(author, curPaperCiteTimesMap);
467484

@@ -776,6 +793,8 @@ export class RecRecRecommenderView extends LitElement {
776793
e.stopPropagation();
777794
e.preventDefault();
778795

796+
this.citeTimeBlurred();
797+
779798
if (!this.paperOverlayElement) {
780799
console.error('paperOverlayElement are not initialized yet.');
781800
return;
@@ -919,12 +938,12 @@ export class RecRecRecommenderView extends LitElement {
919938
// Private Helpers ||
920939
//==========================================================================||
921940
getPaperCiteCounts(authorID: string) {
922-
const paperCounts: [string, number][] = [];
941+
const paperCounts: [string, number, string][] = [];
923942

924943
for (const paper of this.papers) {
925944
const countMap = this.paperCitingAuthorCountMap.get(paper.paperId);
926945
if (countMap !== undefined && countMap.has(authorID)) {
927-
paperCounts.push([paper.title, countMap.get(authorID)!]);
946+
paperCounts.push([paper.title, countMap.get(authorID)!, paper.paperId]);
928947
}
929948
}
930949

@@ -935,16 +954,16 @@ export class RecRecRecommenderView extends LitElement {
935954
}
936955

937956
getPaperCounts(authorID: string) {
938-
const paperCounts: [string, number][] = [];
957+
const paperCounts: [string, number, string][] = [];
939958

940959
const paperMap = this.authorPaperCiteTimesMap.get(authorID);
941960
if (paperMap === undefined) {
942961
console.error(`Can't find author ${authorID}`);
943962
throw Error(`Can't find author ${authorID}`);
944963
}
945964

946-
for (const [paper, count] of paperMap.entries()) {
947-
paperCounts.push([paper, count]);
965+
for (const [paper, info] of paperMap.entries()) {
966+
paperCounts.push([paper, info[1], info[0]]);
948967
}
949968

950969
// Sort the papers by the cite times
@@ -998,7 +1017,6 @@ export class RecRecRecommenderView extends LitElement {
9981017
@touchstart=${(e: TouchEvent) => {
9991018
e.stopPropagation();
10001019
}}
1001-
@blur=${() => this.citeTimeBlurred()}
10021020
>
10031021
<span class="svg-icon">${unsafeHTML(iconFile)}</span>
10041022
${recommender.paperCount}
@@ -1017,7 +1035,6 @@ export class RecRecRecommenderView extends LitElement {
10171035
@touchstart=${(e: TouchEvent) => {
10181036
e.stopPropagation();
10191037
}}
1020-
@blur=${() => this.citeTimeBlurred()}
10211038
>
10221039
<span class="svg-icon">${unsafeHTML(iconCiteTimes)}</span>
10231040
${recommender.citeTimes}
@@ -1074,9 +1091,14 @@ export class RecRecRecommenderView extends LitElement {
10741091

10751092
// Compile the paper overlay
10761093
let paperOverlayContent = html``;
1077-
for (const [paper, count] of this.overlayPaperCounts) {
1094+
for (const [paper, count, paperID] of this.overlayPaperCounts) {
10781095
paperOverlayContent = html`${paperOverlayContent}
1079-
<div class="cell-paper">${paper}</div>
1096+
<a
1097+
class="cell-paper"
1098+
target="_blank"
1099+
href=${`https://www.semanticscholar.org/paper/${paperID}`}
1100+
>${paper}</a
1101+
>
10801102
<div class="cell-count">${count}x</div> `;
10811103
}
10821104

@@ -1246,7 +1268,14 @@ export class RecRecRecommenderView extends LitElement {
12461268
</div>
12471269
</div>
12481270
1249-
<div id="paper-overlay" class="popper-tooltip hidden" role="tooltip">
1271+
<div
1272+
id="paper-overlay"
1273+
class="popper-tooltip hidden"
1274+
role="tooltip"
1275+
@click=${(e: MouseEvent) => {
1276+
e.stopPropagation();
1277+
}}
1278+
>
12501279
<div class="popper-content">
12511280
<div class="table-title">
12521281
<span

0 commit comments

Comments
 (0)