-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: Create internal news page and update existing external news page (
#711) * Update news page layout * Update tests * Update test * Add widget-related jsx and styles back * Update styles * Update tests * Remove unnecessary code * Update links to open new tab * Update Label Source color * Update date * Add LoadingWidget * Add internal news page and query * Update styles * Update tests * Update external news page to use ArticleListItem * Add comment * Fix link * Remove unnecessary code * Remove unnecessary tests * Update query * Update Label display * Update loading state * Remove comments * Update tests
- Loading branch information
Showing
21 changed files
with
324 additions
and
230 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
28 changes: 11 additions & 17 deletions
28
src/components/ArticleListItem/ArticleListItem.module.scss
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,23 +1,17 @@ | ||
@import 'styles/uswdsDependencies'; | ||
@import 'styles/sfds/sfdsDependencies'; | ||
|
||
.ArticleListItem { | ||
display: flex; | ||
align-items: flex-start; | ||
.articleTitle { | ||
margin-bottom: 0.5em; | ||
margin-top: 0; | ||
|
||
time { | ||
flex-shrink: 0; | ||
} | ||
|
||
time + div { | ||
margin-left: units(3); | ||
} | ||
|
||
h4, | ||
p { | ||
margin: 0; | ||
a { | ||
color: $theme-black; | ||
text-decoration: none; | ||
} | ||
} | ||
|
||
h4 + p { | ||
margin-top: units(1); | ||
} | ||
.categoryAndLabel { | ||
margin-left: 0 !important; | ||
margin-right: 0 !important; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,29 +1,81 @@ | ||
import React from 'react' | ||
|
||
import { Grid } from '@trussworks/react-uswds' | ||
import styles from './ArticleListItem.module.scss' | ||
|
||
import { Category, Label } from 'components/Tag/Tag' | ||
import type { ArticleListItemRecord } from 'types' | ||
import { ArticleDateIcon } from 'components/ArticleDateIcon/ArticleDateIcon' | ||
import LinkTo from 'components/util/LinkTo/LinkTo' | ||
import { CONTENT_CATEGORIES } from 'constants/index' | ||
|
||
export const ArticleListItem = ({ | ||
article, | ||
}: { | ||
article: ArticleListItemRecord | ||
}) => { | ||
const { slug, title, preview, publishedDate } = article | ||
const { | ||
title, | ||
preview, | ||
publishedDate, | ||
slug, | ||
sourceLink, | ||
source = 'CMS', | ||
sourceName, | ||
labels, | ||
} = article | ||
|
||
const publishedDateObj = new Date(publishedDate) | ||
|
||
return ( | ||
<article className={styles.ArticleListItem}> | ||
<ArticleDateIcon date={publishedDateObj} /> | ||
<div> | ||
<h4> | ||
<LinkTo href={`/articles/${slug}`}>{title}</LinkTo> | ||
</h4> | ||
<p>{preview}</p> | ||
</div> | ||
<article> | ||
<Grid row gap={4}> | ||
<Grid col="auto"> | ||
<ArticleDateIcon date={publishedDateObj} /> | ||
</Grid> | ||
|
||
<Grid col="fill" gap="05"> | ||
<h3 className={styles.articleTitle}> | ||
<LinkTo | ||
href={sourceLink ? sourceLink : `/articles/${slug}`} | ||
target="_blank" | ||
rel="noreferrer noopener"> | ||
{title} | ||
</LinkTo> | ||
</h3> | ||
<LinkTo | ||
href={sourceLink ? sourceLink : `/articles/${slug}`} | ||
target="_blank" | ||
rel="noreferrer noopener" | ||
data-testid="article-slug"> | ||
{sourceLink ? sourceLink : `/articles/${slug}`} | ||
</LinkTo> | ||
<p> | ||
<span>{preview}</span> | ||
</p> | ||
<Grid row gap={4} className={styles.categoryAndLabel}> | ||
<Category | ||
category={ | ||
source === 'RSS' | ||
? CONTENT_CATEGORIES.EXTERNAL_NEWS | ||
: CONTENT_CATEGORIES.INTERNAL_NEWS | ||
} | ||
/> | ||
|
||
{source === 'CMS' && labels && labels.length > 0 && ( | ||
<> | ||
{labels.map((label) => { | ||
return ( | ||
<Label key={label.id} type={label.type}> | ||
{label.name} | ||
</Label> | ||
) | ||
})} | ||
</> | ||
)} | ||
|
||
{source === 'RSS' && <Label type="Source">{sourceName}</Label>} | ||
</Grid> | ||
</Grid> | ||
</Grid> | ||
</article> | ||
) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.