Skip to content

Commit

Permalink
Added "New datasets" page + conditionally rendering of external link …
Browse files Browse the repository at this point in the history
…icon in banners via configuration (#158)

* Added new datasets page, components, and config + banner config

* Added config change, new prop isExternalLink to banner, can conditionally render external link icon via config now

* removed NewDatasetsPageContent.tsx and added new studies to config. Will need to rename ResourcePageContent.tsx to something more generic

* refactored ResourcePageContent to CardedPageContent since both the resource and recently added datasets page use the same HTML structure

* Only external links in banner will open in a new tab, internal links will open in the same tab now

* fixing es lint build error removing an introduced white space

* still fighting eslint due to indentation issue

* changing verbiage to newly available datasets

* changing from _target to _blank
  • Loading branch information
piotrsenkow authored Apr 3, 2024
1 parent fd03f96 commit 9b80f43
Show file tree
Hide file tree
Showing 6 changed files with 124 additions and 10 deletions.
8 changes: 8 additions & 0 deletions packages/portal/config/banner.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,14 @@
"message": "[View the winners of the HEAL Data Ecosystem 2024 Raffle!](https://www.healdatafair.org/events/AAMkAGJiYjdiMDk4LTI2NjktNDQ0Yy1iN2NkLTk0ODE5NTkwZGMwYwBGAAAAAADFCfsravpISIJULhJ6kUB2BwDT2LgfOzJeR4d6_-DuvpGaAAAAAAENAACStECWrhwlT6Ftc2zjZMptAAJFxaAGAAA=)",
"level": "MESSAGE",
"dismissible": true,
"isExternalLink": true,
"id": 0
},
{
"message": "[View the latest studies who have shared their data!](/landing/newly-available-datasets)",
"level": "MESSAGE",
"dismissible": true,
"isExternalLink": false,
"id": 1
}
]
64 changes: 64 additions & 0 deletions packages/portal/config/newDatasets.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
{
"title": "Newly Available Datasets",
"introduction": [
{
"type": "text",
"content": "The "
},
{
"type": "boldText",
"content": "HEAL Data Platform "
},
{
"type": "text",
"content": "connects to HEAL-compliant repositories where data are stored, providing a single point of access to the diverse array of studies and data funded by the NIH HEAL Initiative®. "
},
{
"type": "text",
"content": "Here are some of the latest studies to share their data so that they are accessible on the HEAL Data Platform."
}
],
"sections": [
{
"title" : "Jan - Mar 2024",
"cards": [
{
"title": "Regulation of neuropathic pain by exercise: effects on nociceptor plasticity and inflammation",
"content": "MEGAN R DETLOFF, DREXEL UNIVERSITY",
"linkText": "View Study",
"link": "https://healdata.org/portal/discovery/HDP01265"
},
{
"title": "Multi-organ human-on-a-chip system to address overdose and acute and chronic efficacy and off-target toxicity",
"content": "James J Hickman, MICHAEL L SHULER, UNIVERSITY OF CENTRAL FLORIDA",
"linkText": "View Study",
"link": "https://healdata.org/portal/discovery/HDP00054"
},
{
"title": "Modeling temporomandibular joint disorders pain: role of transient receptor potential ion channels",
"content": "Yong Chen, DUKE UNIVERSITY",
"linkText": "View Study",
"link": "https://healdata.org/portal/discovery/HDP00538"
},
{
"title": "Collaborating to Heal Addiction and Mental Health in Primary care (CHAMP)",
"content": "JOHN C. FORTNEY, Anna Ratzliff, ANDREW J SAXON, UNIVERSITY OF WASHINGTON",
"linkText": "View Study",
"link": "https://healdata.org/portal/discovery/HDP00201"
},
{
"title": "Sleep, opiate withdrawal and the N/OFQ - NOP system",
"content": "Michael R Bruchas, Thomas S Kilduff, SRI INTERNATIONAL",
"linkText": "View Study",
"link": "https://healdata.org/portal/discovery/HDP00397"
},
{
"title": "Improving health and employment outcomes through workplace opioid policies",
"content": "Ann Marie Dale, WASHINGTON UNIVERSITY",
"linkText": "View Study",
"link": "https://healdata.org/portal/discovery/HDP00331"
}
]
}
]
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import CardGrid, { CardGridItem } from '../CardGrid';
import MultiPartText, { MultiPartTextPart } from '../MultiPartText';


export interface ResourcePageConfig {
export interface CardedPageConfig {
readonly title: string;
readonly introduction: ReadonlyArray<MultiPartTextPart>;
readonly sections: ReadonlyArray<{
Expand All @@ -15,7 +15,7 @@ export interface ResourcePageConfig {



const ResourcePageContent = ({title, introduction, sections}: ResourcePageConfig) => {
const CardedPageContent = ({title, introduction, sections}: CardedPageConfig) => {
return (
<React.Fragment>
<div className='py-10 text-sm px-10'>
Expand Down Expand Up @@ -48,4 +48,4 @@ const ResourcePageContent = ({title, introduction, sections}: ResourcePageConfig
);
};

export default ResourcePageContent;
export default CardedPageContent;
10 changes: 7 additions & 3 deletions packages/portal/src/components/Navigation/Banner.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ export interface BannerProps {
readonly message: string;
readonly level: 'INFO' | 'WARNING' | 'ERROR';
readonly dismissible: boolean;
readonly isExternalLink: boolean;
readonly id: number;
}

Expand Down Expand Up @@ -40,11 +41,14 @@ const icon = {
),
};



export const Banner: React.FC<BannerProps> = ({
message,
level,
isExternalLink
}: BannerProps) => {

const linkTarget = isExternalLink ? '_blank': '_self';
return (
<div
className={`w-full p-1 flex justify-between ${backgroundColor[level]}`}
Expand All @@ -56,9 +60,9 @@ export const Banner: React.FC<BannerProps> = ({
components={{
// eslint-disable-next-line react/prop-types
a: ({ children, ...props }) => (
<a className='underline' {...props} target='_blank' rel='noreferrer'>
<a className='underline' {...props} target={linkTarget} rel='noreferrer'>
{children}
<FaExternalLinkAlt className='pl-1 inline-block' title='External Link'/>
{isExternalLink && <FaExternalLinkAlt className='pl-1 inline-block' title='External Link'/>}
</a>
),
}}
Expand Down
38 changes: 38 additions & 0 deletions packages/portal/src/pages/landing/newly-available-datasets.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
import {GetStaticProps} from 'next';
import ContentSource from '../../lib/content';

import NavPageLayout, { NavPageLayoutProps } from '../../components/Navigation/NavPageLayout';
import CardedPageContent, {CardedPageConfig} from '../../components/Contents/CardedPageContent';
import { getNavPageLayoutPropsFromConfig } from '../../common/staticProps';

interface ResourcePageProps extends NavPageLayoutProps {
newDatasetsPageConfig: CardedPageConfig
}

const ResourcePage = ({headerProps, footerProps, newDatasetsPageConfig}: ResourcePageProps) => {

return (
<NavPageLayout {...{headerProps, footerProps}}>
<div className='flex flex-row justify-items-center'>
<div className='sm:prose-base lg:prose-lg xl:prose-xl 2xl:prose-xl mx-20'>
<CardedPageContent {...newDatasetsPageConfig}/>
</div>
</div>
</NavPageLayout>
);
};


// should move this thing into _app.tsx and make a dedicated layout component after https://github.com/vercel/next.js/discussions/10949 is addressed
export const getStaticProps: GetStaticProps<ResourcePageProps> = async ( ) => {
const navPageLayoutProps = await getNavPageLayoutPropsFromConfig();
const newDatasetsPageConfig = await ContentSource.get('config/newDatasets.json') as unknown as CardedPageConfig;
return {
props: {
...navPageLayoutProps,
newDatasetsPageConfig
}
};
};

export default ResourcePage;
8 changes: 4 additions & 4 deletions packages/portal/src/pages/landing/resource.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@ import {GetStaticProps} from 'next';
import ContentSource from '../../lib/content';

import NavPageLayout, { NavPageLayoutProps } from '../../components/Navigation/NavPageLayout';
import ResourcePageContent, {ResourcePageConfig} from '../../components/Contents/ResourcePageContent';
import CardedPageContent, {CardedPageConfig} from '../../components/Contents/CardedPageContent';
import { getNavPageLayoutPropsFromConfig } from '../../common/staticProps';

interface ResourcePageProps extends NavPageLayoutProps {
resourcePageConfig: ResourcePageConfig
resourcePageConfig: CardedPageConfig
}

const ResourcePage = ({headerProps, footerProps, resourcePageConfig}: ResourcePageProps) => {
Expand All @@ -15,7 +15,7 @@ const ResourcePage = ({headerProps, footerProps, resourcePageConfig}: ResourcePa
<NavPageLayout {...{headerProps, footerProps}}>
<div className='flex flex-row justify-items-center'>
<div className='sm:prose-base lg:prose-lg xl:prose-xl 2xl:prose-xl mx-20'>
<ResourcePageContent {...resourcePageConfig}/>
<CardedPageContent {...resourcePageConfig}/>
</div>
</div>
</NavPageLayout>
Expand All @@ -26,7 +26,7 @@ const ResourcePage = ({headerProps, footerProps, resourcePageConfig}: ResourcePa
// should move this thing into _app.tsx and make a dedicated layout component after https://github.com/vercel/next.js/discussions/10949 is addressed
export const getStaticProps: GetStaticProps<ResourcePageProps> = async ( ) => {
const navPageLayoutProps = await getNavPageLayoutPropsFromConfig();
const resourcePageConfig = await ContentSource.get('config/resource.json') as unknown as ResourcePageConfig;
const resourcePageConfig = await ContentSource.get('config/resource.json') as unknown as CardedPageConfig;
return {
props: {
...navPageLayoutProps,
Expand Down

0 comments on commit 9b80f43

Please sign in to comment.