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

feat: Add internal news carousel for news and announcements page #744

Merged
merged 30 commits into from
Aug 23, 2022
Merged
Show file tree
Hide file tree
Changes from 5 commits
Commits
Show all changes
30 commits
Select commit Hold shift + click to select a range
dfd2ad8
Change current news path to news-announcments
jcbcapps Jul 28, 2022
e3cecb4
Update test
jcbcapps Aug 2, 2022
bd02b3d
Add NewsCarousel and NewsCarouselItem components
jcbcapps Aug 4, 2022
03cdf50
Update storybook component
jcbcapps Aug 4, 2022
728db43
Add CTA
jcbcapps Aug 4, 2022
66672cc
Add query for carousel articles
jcbcapps Aug 4, 2022
ba3009e
Add NewsCarousel component to page
jcbcapps Aug 4, 2022
c657ce9
Add custom ellipses and custom arrows
jcbcapps Aug 9, 2022
a902eff
Update styles
jcbcapps Aug 9, 2022
077e442
Move class to module
jcbcapps Aug 9, 2022
e403e9c
fix: resolve type error from useRef return
gidjin Aug 11, 2022
b6520be
test: add article mock to NewsAnnouncements component
gidjin Aug 11, 2022
444466a
fix a11y violation in carousel, update mock in test
abbyoung Aug 11, 2022
aa417ab
Style updates
jcbcapps Aug 12, 2022
afd2d18
Add test
jcbcapps Aug 15, 2022
684bc33
Add test
jcbcapps Aug 15, 2022
c958f99
Add news page from main
jcbcapps Aug 15, 2022
823e7b4
Add view older internal news link
jcbcapps Aug 15, 2022
9b1914c
Add comment
jcbcapps Aug 15, 2022
67fd32b
Update styles
jcbcapps Aug 15, 2022
e037e7a
Add conditional render for link
jcbcapps Aug 16, 2022
4de79e5
Merge branch 'main' into sc-589/internal-news-carousel
jcbcapps Aug 16, 2022
39cde4b
Merge branch 'main' into sc-589/internal-news-carousel
jcbcapps Aug 18, 2022
fd8bf16
Remove unnecessary importants
jcbcapps Aug 18, 2022
dd943d4
Update default image
jcbcapps Aug 18, 2022
034b37f
Update tests
jcbcapps Aug 19, 2022
82989b8
Merge branch 'main' into sc-589/internal-news-carousel
jcbcapps Aug 19, 2022
4d98c22
Merge branch 'main' into sc-589/internal-news-carousel
jcbcapps Aug 23, 2022
ff84f0e
Remove flex styles
jcbcapps Aug 23, 2022
679c517
Add comment
jcbcapps Aug 23, 2022
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
194 changes: 194 additions & 0 deletions public/assets/images/Seal_of_the_United_States_Space_Force.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
9 changes: 5 additions & 4 deletions src/components/NewsCarousel/NewsCarousel.module.scss
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,11 @@
@import 'styles/sfds/sfdsDependencies';

.carouselContainer {
display: flex !important;
display: flex;
flex-direction: row;
align-items: center;
justify-content: center;
width: 100%;
height: 100%;
background-color: #161f2f;
border-radius: 4px;

Expand All @@ -20,15 +19,15 @@
}

button::before {
color: transparent !important;
color: transparent;
}
}

> :global(.slick-dots
li.slick-active
div.news-carousel-container
button::before) {
color: transparent !important;
color: transparent;
background: #112548;
width: 16.17px;
height: 16px;
Expand All @@ -37,6 +36,8 @@
}

.carouselArrow {
background: transparent;
border: none;
&:hover {
cursor: pointer;
}
Expand Down
14 changes: 7 additions & 7 deletions src/components/NewsCarousel/NewsCarousel.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,14 @@ describe('NewsCarousel component', () => {
it('renders the component with mock articles', () => {
render(<NewsCarousel articles={cmsPortalNewsArticlesMock} />)

// Slider component in react-slick clones each item in the carousel,
// so a length of 2 is accurate
expect(screen.getAllByText('Announcing the dev blog')).toHaveLength(2)
const prevButton = screen.getByTestId('slick-prev')
const nextButton = screen.getByTestId('slick-next')

fireEvent.click(screen.getByTestId('slick-next'))
expect(screen.getAllByText('Welcome and Overview')).toHaveLength(2)
expect(prevButton).toBeInTheDocument()
expect(nextButton).toBeInTheDocument()

fireEvent.click(screen.getByTestId('slick-prev'))
expect(screen.getAllByText('Announcing the dev blog')).toHaveLength(2)
// TODO: verify that this actually changes the current slide in the carousel
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

praise: I'm sad this todo doesn't reflect the valiant effort to make it happen. So the praise is for that valiant effort and being willing to set it aside for now.

fireEvent.click(prevButton)
fireEvent.click(nextButton)
})
})
46 changes: 22 additions & 24 deletions src/components/NewsCarousel/NewsCarousel.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -44,18 +44,17 @@ const NewsCarousel = ({ articles }: { articles: ArticleListItemRecord[] }) => {
paddingLeft: '8rem',
paddingRight: '8rem',
}}>
<div className={styles.carouselArrow}>
<FontAwesomeIcon
size="lg"
icon="angle-left"
data-testid="slick-prev"
onClick={() => {
if (sliderRef.current) {
return sliderRef.current.slickPrev()
}
}}
/>
</div>
<button
type="button"
className={styles.carouselArrow}
data-testid="slick-prev"
onClick={() => {
if (sliderRef.current) {
return sliderRef.current.slickPrev()
}
}}>
<FontAwesomeIcon size="lg" icon="angle-left" />
</button>
<ul
style={{
margin: '0px',
Expand All @@ -64,18 +63,17 @@ const NewsCarousel = ({ articles }: { articles: ArticleListItemRecord[] }) => {
{' '}
{dots}{' '}
</ul>
<div className={styles.carouselArrow}>
<FontAwesomeIcon
size="lg"
icon="angle-right"
data-testid="slick-next"
onClick={() => {
if (sliderRef.current) {
return sliderRef.current.slickNext()
}
}}
/>
</div>
<button
type="button"
className={styles.carouselArrow}
data-testid="slick-next"
onClick={() => {
if (sliderRef.current) {
return sliderRef.current.slickNext()
}
}}>
<FontAwesomeIcon size="lg" icon="angle-right" />
</button>
</div>
)
},
Expand Down
21 changes: 15 additions & 6 deletions src/components/NewsCarouselItem/NewsCarouselItem.module.scss
Original file line number Diff line number Diff line change
@@ -1,15 +1,24 @@
@import 'styles/uswdsDependencies';
@import 'styles/sfds/sfdsDependencies';

.carouselImage {
margin: 0;
.carouselItemContainer {
min-height: 534px;
}

.imageContainer {
@media screen and (max-width: 1024px) {
display: flex;
justify-content: center;
width: 100%;
display: flex;
justify-content: center;
min-height: 534px;
background: rgb(7, 15, 29);
background: linear-gradient(
180deg,
rgba(7, 15, 29, 1) 3%,
rgba(17, 37, 72, 1) 46%,
rgba(101, 114, 180, 1) 100%
);

.carouselImage {
width: 50%;
}
}

Expand Down
23 changes: 10 additions & 13 deletions src/components/NewsCarouselItem/NewsCarouselItem.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,22 +6,19 @@ import LinkTo from 'components/util/LinkTo/LinkTo'

const NewsCarouselItem = ({ article }: { article: ArticleListItemRecord }) => {
return (
<Grid row>
<Grid
tablet={{ col: 'fill' }}
desktop={{ col: 'auto' }}
className={styles.imageContainer}>
{/* TODO: current image is a placeholder and will need to be updated */}
<Grid row className={styles.carouselItemContainer}>
<Grid col={5} className={styles.imageContainer}>
{/*
TODO: current image is a placeholder. Will need to add a check
for determining if the article has an image.
*/}
<img
src="https://media.defense.gov/2021/Aug/23/2002905775/670/394/0/210823-F-GO452-0001.JPG"
alt="test"
src="/assets/images/Seal_of_the_United_States_Space_Force.svg"
alt="USSF logo"
className={styles.carouselImage}
/>
</Grid>
<Grid
tablet={{ col: 'auto' }}
desktop={{ col: 'fill' }}
className={styles.gridContainer}>
<Grid col={'fill'} className={styles.gridContainer}>
<Grid className={styles.textContainer}>
<h1 className={styles.articleTitle}>{article.title}</h1>
<div className={styles.articlePreview}>{article.preview}</div>
Expand All @@ -30,7 +27,7 @@ const NewsCarouselItem = ({ article }: { article: ArticleListItemRecord }) => {
target="_blank"
rel="noreferrer"
className="usa-button">
View Full Announcement
View Article
</LinkTo>
</Grid>
</Grid>
Expand Down