Skip to content

Commit 261e9b8

Browse files
authored
Add a couple papers to the adoption page, make the order less dumb (#228)
* Add a couple papers to the adoption page, make the order less dumb * cleanup
1 parent 95e541d commit 261e9b8

2 files changed

Lines changed: 98 additions & 81 deletions

File tree

src/pages/adoption/index.tsx

Lines changed: 91 additions & 76 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,15 @@
1-
import clsx from 'clsx';
2-
import React, { useEffect, useState } from 'react';
3-
import Link from '@docusaurus/Link';
4-
import useDocusaurusContext from '@docusaurus/useDocusaurusContext';
5-
import Layout from '@theme/Layout';
6-
import Heading from '@theme/Heading';
7-
import EditThisPage from '@theme/EditThisPage';
1+
import clsx from "clsx";
2+
import React, { useEffect, useState } from "react";
3+
import Link from "@docusaurus/Link";
4+
import useDocusaurusContext from "@docusaurus/useDocusaurusContext";
5+
import Layout from "@theme/Layout";
6+
import Heading from "@theme/Heading";
7+
import EditThisPage from "@theme/EditThisPage";
88

9-
import { faExternalLink } from '@fortawesome/free-solid-svg-icons';
10-
import { FontAwesomeIcon } from '@fortawesome/react-fontawesome';
11-
import Papa from 'papaparse';
12-
import styles from './adoption.module.css';
9+
import { faExternalLink } from "@fortawesome/free-solid-svg-icons";
10+
import { FontAwesomeIcon } from "@fortawesome/react-fontawesome";
11+
import Papa from "papaparse";
12+
import styles from "./adoption.module.css";
1313

1414
interface Adoption {
1515
title: string;
@@ -28,85 +28,79 @@ interface Adoption {
2828
function Adoption({ adoption }: { adoption: Adoption }) {
2929
const normalizedDoi = adoption.doi?.trim();
3030
const doiHref = normalizedDoi
31-
? (normalizedDoi.startsWith('http') ? normalizedDoi : `https://dx.doi.org/${normalizedDoi.replace(/^doi:\s*/i, '')}`)
31+
? normalizedDoi.startsWith("http")
32+
? normalizedDoi
33+
: `https://dx.doi.org/${normalizedDoi.replace(/^doi:\s*/i, "")}`
3234
: undefined;
3335

3436
return (
3537
<div className={styles.adoptionContainer}>
36-
<div className={styles.title}>
37-
{adoption.title}
38-
</div>
38+
<div className={styles.title}>{adoption.title}</div>
3939
<div className={styles.authors}>
40-
{adoption.authors}
41-
.
42-
{' '}
43-
{adoption.venue !== '' ? adoption.venue : 'Preprint'}
40+
{adoption.authors}.{" "}
41+
{adoption.venue !== "" ? adoption.venue : "Preprint"}
4442
{doiHref ? (
4543
<>
46-
{', '}
44+
{", "}
4745
<Link href={doiHref} target="_blank" rel="noreferrer">
48-
DOI:
49-
{' '}
50-
{normalizedDoi}
46+
DOI: {normalizedDoi}
5147
</Link>
5248
</>
5349
) : null}
5450
{`, ${adoption.year}`}
5551
</div>
56-
<p className={styles.description}>
57-
{adoption.subtitle}
58-
</p>
52+
<p className={styles.description}>{adoption.subtitle}</p>
5953
<div className={styles.buttonContainer}>
6054
<div className={styles.primaryButtons}>
6155
{adoption.revisitStudyUrl ? (
6256
<Link
63-
className={clsx('button button--primary', styles.buttonDesktop)}
64-
style={{ color: 'white' }}
57+
className={clsx("button button--primary", styles.buttonDesktop)}
58+
style={{ color: "white" }}
6559
to={adoption.revisitStudyUrl}
6660
>
6761
See ReVISit Study
6862
</Link>
6963
) : null}
70-
{adoption.paperUrl === '#' ? null
71-
: (
72-
<Link
73-
className={clsx('button button--secondary', styles.buttonDesktop)}
74-
to={adoption.paperUrl}
75-
>
76-
See the paper
77-
</Link>
78-
)}
64+
{adoption.paperUrl === "#" ? null : (
65+
<Link
66+
className={clsx("button button--secondary", styles.buttonDesktop)}
67+
to={adoption.paperUrl}
68+
>
69+
See the paper
70+
</Link>
71+
)}
7972
{adoption.revisitStudyUrl ? (
8073
<Link
81-
className={clsx('button button--primary button--sm', styles.buttonMobile)}
82-
style={{ color: 'white' }}
74+
className={clsx(
75+
"button button--primary button--sm",
76+
styles.buttonMobile,
77+
)}
78+
style={{ color: "white" }}
8379
to={adoption.revisitStudyUrl}
8480
>
8581
See ReVISit Study
8682
</Link>
8783
) : null}
88-
{adoption.paperUrl === '#' ? null
89-
: (
90-
<Link
91-
className={clsx('button button--secondary button--sm', styles.buttonMobile)}
92-
to={adoption.paperUrl}
93-
>
94-
See the paper
95-
</Link>
96-
)}
84+
{adoption.paperUrl === "#" ? null : (
85+
<Link
86+
className={clsx(
87+
"button button--secondary button--sm",
88+
styles.buttonMobile,
89+
)}
90+
to={adoption.paperUrl}
91+
>
92+
See the paper
93+
</Link>
94+
)}
9795
</div>
9896
<div className={styles.secondaryButtons}>
9997
{adoption.sourceCodeLink ? (
10098
<Link href={adoption.sourceCodeLink}>
10199
<span>Source Code</span>
102100
<FontAwesomeIcon icon={faExternalLink} />
103101
</Link>
104-
)
105-
: null}
106-
<span>
107-
Uses ReVISit v
108-
{adoption.revisitVersion}
109-
</span>
102+
) : null}
103+
<span>Uses ReVISit v{adoption.revisitVersion}</span>
110104
</div>
111105
</div>
112106
</div>
@@ -116,39 +110,45 @@ function Adoption({ adoption }: { adoption: Adoption }) {
116110
export default function Home() {
117111
const { siteConfig } = useDocusaurusContext();
118112

119-
const [adoption, setAdoption] = useState([]);
113+
const [adoption, setAdoption] = useState<Adoption[]>([]);
120114

121115
useEffect(() => {
122116
const fetchData = async () => {
123-
const response = await fetch('/adoption.csv');
117+
const response = await fetch("/adoption.csv");
124118
if (!response.ok) {
125-
console.error('Error fetching the CSV file:', response.statusText);
119+
console.error("Error fetching the CSV file:", response.statusText);
126120
return;
127121
}
128122
const text = await response.text();
129123
Papa.parse(text, {
130124
header: true,
131-
complete: (results) => {
132-
const parsedAdoption = results.data.map((entry) => ({
133-
title: entry['Paper Title'],
134-
authors: entry['List of Authors'],
135-
year: entry['Year of Publication'],
136-
revisitStudyUrl: entry['Study URL'],
137-
paperUrl: entry['Paper URL'],
138-
subtitle: entry['Short Description'],
139-
revisitVersion: entry['ReVISit Version'],
140-
sourceCodeLink: entry['Source Code Link'],
141-
published: entry['Has this paper been published?'] === 'Yes',
142-
venue: entry['Journal, Conference or Veune'],
125+
complete: (results: { data: any[] }) => {
126+
const parsedAdoption = results.data.map((entry, idx) => ({
127+
title: entry["Paper Title"],
128+
authors: entry["List of Authors"],
129+
year: entry["Year of Publication"],
130+
revisitStudyUrl: entry["Study URL"],
131+
paperUrl: entry["Paper URL"],
132+
subtitle: entry["Short Description"],
133+
revisitVersion: entry["ReVISit Version"],
134+
sourceCodeLink: entry["Source Code Link"],
135+
published: entry["Has this paper been published?"] === "Yes",
136+
venue: entry["Journal, Conference or Venue"],
143137
doi: entry.DOI,
138+
initialIndex: idx,
144139
}));
145140
// Sort based on Published then year (descending year).
146141
parsedAdoption.sort((a: Adoption, b: Adoption) => {
147142
if (a.published !== b.published) {
148143
return a.published ? -1 : 1;
149144
}
150145

151-
return Number(b.year) - Number(a.year);
146+
const yearDiff = Number(b.year) - Number(a.year);
147+
if (yearDiff !== 0) {
148+
return yearDiff;
149+
}
150+
// otherwise sort based on the order in the CSV file (assuming more recent entries are added to the bottom of the CSV file).
151+
return (b as any).initialIndex - (a as any).initialIndex;
152152
});
153153
setAdoption(parsedAdoption);
154154
},
@@ -163,14 +163,29 @@ export default function Home() {
163163
<main className="container container--fluid margin-vert--lg">
164164
<div className="row">
165165
<div className="col col--10">
166-
<Heading as="h1" className={styles.pageTitle}>Studies Using reVISit</Heading>
166+
<Heading as="h1" className={styles.pageTitle}>
167+
Studies Using reVISit
168+
</Heading>
167169
<div className={styles.pageIntro}>
168-
Many people have already gotten started using reVISit in their data visualization research. Check out all the different ways people are using reVISit to produce novel research. If you&apos;ve used reVISit as part of your research, we strongly encourage you to fill out
169-
{' '}
170-
<Link href="https://forms.gle/CE82n3V1bcmZ4ahY9" target="_blank" rel="noreferrer">this Google form</Link>
171-
. Once we verify your work, your research will be added to the list of papers using reVISit below.
170+
Many people have already gotten started using reVISit in their
171+
data visualization research. Check out all the different ways
172+
people are using reVISit to produce novel research. It's already
173+
been used in {adoption.length} published studies. If you&apos;ve
174+
used reVISit as part of your research, we strongly encourage you
175+
to fill out{" "}
176+
<Link
177+
href="https://forms.gle/CE82n3V1bcmZ4ahY9"
178+
target="_blank"
179+
rel="noreferrer"
180+
>
181+
this Google form
182+
</Link>
183+
. Once we verify your work, your research will be added to the
184+
list of papers using reVISit below.
172185
</div>
173-
{adoption.map((adoption: Adoption, index: number) => <Adoption key={index} adoption={adoption} />)}
186+
{adoption.map((adoption: Adoption, index: number) => (
187+
<Adoption key={index} adoption={adoption} />
188+
))}
174189
<div className="margin-top--md">
175190
<EditThisPage editUrl="https://github.com/revisit-studies/reVISit-studies.github.io/edit/main/src/pages/adoption/index.tsx" />
176191
</div>

0 commit comments

Comments
 (0)