Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refactor phase 1 centers and cleanup legacy content #732

Merged
merged 4 commits into from
Dec 26, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 29 additions & 0 deletions components/HtaCenterPage.module.scss
Original file line number Diff line number Diff line change
@@ -1,5 +1,34 @@
.header {
display: flex;
justify-content: space-evenly;
}

.headerImg100 {
height: 100%;
}

.headerImg50 {
width: 50%;
height: 100%;
}

.headerImg30 {
width: 30%;
height: 100%;
}

.headerImg20 {
width: 20%;
height: 100%;
}

.headshot {
margin: 0 15px 15px 0;
float: left;
width: 200px;
}

.overviewImg {
width: 100%;
max-width: 600px;
}
159 changes: 155 additions & 4 deletions components/HtaCenterPage.tsx
Original file line number Diff line number Diff line change
@@ -1,14 +1,138 @@
import _ from 'lodash';
import { useEffect, useState } from 'react';
import { Container, Row } from 'react-bootstrap';

import { HtaCenter, PrincipalInvestigator } from '../types';
import styles from './HtaCenterPage.module.scss';

export interface HtaCenterPageProps {
id: string;
hta: HtaCenter;
showGrantNumber?: boolean;
}

const HeaderLogos = (props: {
imgSources: string[];
headerImgClassname?: string;
}) => {
return (
<div className={styles.header}>
{props.imgSources.map((src, index) => (
<img
src={src}
key={index}
alt={src
.toLowerCase()
.split('.')[0]
.replace(/\//g, '')
.replace(/_/g, '-')}
className={props.headerImgClassname || styles.headerImg30}
/>
))}
</div>
);
};

const customHeaderContent: { [centerId: string]: JSX.Element } = {
hta1: (
<>
<HeaderLogos
imgSources={[
'/phase1/Broad-Inst-Logo.webp',
'/phase1/DFCI-Logo-with-Flag.webp',
'/phase1/HMS_Logo.webp',
]}
/>
<br />
<a href="https://humantumoratlas.org/htapp-webinar-series/">
View the HTAPP Webinar Series
</a>
</>
),
hta3: (
<HeaderLogos
imgSources={[
'/phase1/BU-Logo.webp',
'/phase1/Janseen-Logo.webp',
'/phase1/UCLA-Logo.webp',
]}
/>
),
hta4: (
<HeaderLogos
imgSources={[
"/phase1/children's-hospital-of-philadelphia-logo.webp",
'/phase1/university-of-pennsylvania-penn-vector-logo.webp',
]}
/>
),
hta5: (
<HeaderLogos
imgSources={[
'/phase1/DFCI-logo.webp',
'/phase1/BroadInstLogoforDigitalRGB.webp',
]}
/>
),
hta6: (
<HeaderLogos
imgSources={[
'/phase1/Duke-SOM-logo.webp',
'/phase1/ASU-full_logo.webp',
'/phase1/Stanford-Logo.webp',
]}
/>
),
hta7: (
<HeaderLogos
imgSources={['/phase1/HMS_Logo.webp', '/phase1/BWH-logo.webp']}
/>
),
hta8: (
<HeaderLogos
imgSources={['/phase1/MSK_logo.webp']}
headerImgClassname={styles.headerImg50}
/>
),
hta9: (
<HeaderLogos
imgSources={['/phase1/OHSU_logo.webp']}
headerImgClassname={styles.headerImg100}
/>
),
hta10: (
<HeaderLogos
imgSources={['/phase1/Stanford-Logo.webp']}
headerImgClassname={styles.headerImg100}
/>
),
hta11: (
<HeaderLogos
imgSources={[
'/phase1/VUMC-logo.webp',
'/phase1/vanderbilt-university-logo.webp',
]}
/>
),
hta12: (
<HeaderLogos
imgSources={['/phase1/WUSM-logo.webp']}
headerImgClassname={styles.headerImg100}
/>
),
'htan-dcc': (
<HeaderLogos
imgSources={[
'/phase1/DFCI-Logo-with-Flag.webp',
'/dcc/sage_bionetworks_logo.webp',
'/phase1/MSK_logo.webp',
'/dcc/isb_color_logo1.webp',
]}
headerImgClassname={styles.headerImg20}
/>
),
};

const PrincipalInvestigators = (props: {
principalInvestigators: PrincipalInvestigator[];
phase: string;
Expand All @@ -22,6 +146,7 @@ const PrincipalInvestigators = (props: {
.split(',')[0]
.replace(/\s/g, '_')
.replace('à', 'a')
.replace('é', 'e')
.replace(/[.’]/g, '');
};

Expand Down Expand Up @@ -62,20 +187,43 @@ const PrincipalInvestigators = (props: {
}
};

const Overview = (props: { description: string | string[] }) => {
const description = [...[props.description]].flat();
const Overview = (props: { hta: HtaCenter; id: string }) => {
const description = [...[props.hta.description]].flat();
const [hasOverviewImg, setHasOverviewImg] = useState<boolean>(false);
const imgSrc = `/${props.hta.phase}/${props.id}_overview.png`;

// overview image may not exist for all centers
// we need to hide the section in case no image found
useEffect(() => {
fetch(imgSrc)
.then((response) => {
if (response.status === 200) {
setHasOverviewImg(true);
}
})
.catch(() => setHasOverviewImg(false));
}, []);

return (
<>
<h2>Overview</h2>
{description.map((d, index) => (
<p key={index}>{d}</p>
))}
{hasOverviewImg && (
<div className="text-center">
<img
className={styles.overviewImg}
src={imgSrc}
alt={`${props.id}_overview`}
/>
</div>
)}
</>
);
};

const HtaCenterPage = ({ hta, showGrantNumber }: HtaCenterPageProps) => {
const HtaCenterPage = ({ id, hta, showGrantNumber }: HtaCenterPageProps) => {
if (!hta) {
return <div>Loading...</div>;
}
Expand All @@ -85,7 +233,10 @@ const HtaCenterPage = ({ hta, showGrantNumber }: HtaCenterPageProps) => {
<Row className={'contentWrapper'}>
<div className="col">
<h1>{hta.title}</h1>
<Overview description={hta.description} />
{customHeaderContent[id]}
{!_.isEmpty(hta.description) && (
<Overview hta={hta} id={id} />
)}
{showGrantNumber && hta.grantNumber && (
<p>
<b>Grant Number</b>: {hta.grantNumber}
Expand Down
6 changes: 4 additions & 2 deletions components/HtanNavbar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ export const HtanNavbar: React.FunctionComponent<{}> = () => {

<NavSection text={'About HTAN'}>
<NavDropdown.Item href="/overview">Overview</NavDropdown.Item>
<NavDropdown.Item href="/htan-dcc">
<NavDropdown.Item href="/center/htan-dcc">
Data Coordinating Center
</NavDropdown.Item>
<NavDropdown.Item href="/research-network">
Expand Down Expand Up @@ -105,7 +105,9 @@ export const HtanNavbar: React.FunctionComponent<{}> = () => {
</NavDropdown.Item>
<NavDropdown.Item href="/events">Events</NavDropdown.Item>
<Dropdown.Divider />
<Nav.Link href="https://groups.google.com/g/htan-news">Newsletter</Nav.Link>
<Nav.Link href="https://groups.google.com/g/htan-news">
Newsletter
</Nav.Link>
<Nav.Link href="https://twitter.com/ncihtan">Twitter</Nav.Link>
</NavSection>,
];
Expand Down
Loading