-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathNewsCards.js
48 lines (42 loc) · 2 KB
/
NewsCards.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
import React from 'react';
import { Grid, Grow, Typography } from '@material-ui/core';
import NewsCard from '../NewsCard/NewsCard';
import useStyles from './styles.js';
const infoCards = [
{ color: '#00838f', title: 'Latest News', text: 'Give me the latest news' },
{ color: '#1565c0', title: 'News by Categories', info: 'Business, Entertainment, General, Health, Science, Sports, Technology', text: 'Give me the latest Technology news' },
{ color: '#4527a0', title: 'News by Terms', info: 'Bitcoin, PlayStation 5, Smartphones, Donald Trump...', text: 'What\'s up with PlayStation 5' },
{ color: '#283593', title: 'News by Sources', info: 'CNN, Wired, BBC News, Time, IGN, Buzzfeed, ABC News...', text: 'Give me the news from CNN' },
];
const NewsCards = ({ articles, activeArticle }) => {
const classes = useStyles();
if (!articles.length) {
return (
<Grow in>
<Grid className={classes.container} container alignItems="stretch" spacing={3}>
{infoCards.map((infoCard) => (
<Grid item xs={12} sm={6} md={4} lg={3} className={classes.infoCard}>
<div className={classes.card} style={{ backgroundColor: infoCard.color }}>
<Typography variant="h5" component="h5">{infoCard.title}</Typography>
{infoCard.info ? <Typography variant="h6" component="h6"><strong>{infoCard.title.split(' ')[2]}</strong>: <br />{infoCard.info}</Typography> : null}
<Typography variant="h6" component="h6">Try saying: <br /> <i>{infoCard.text}</i></Typography>
</div>
</Grid>
))}
</Grid>
</Grow>
);
}
return (
<Grow in>
<Grid className={classes.container} container alignItems="stretch" spacing={3}>
{articles.map((article, i) => (
<Grid item xs={12} sm={6} md={4} lg={3} style={{ display: 'flex' }}>
<NewsCard activeArticle={activeArticle} i={i} article={article} />
</Grid>
))}
</Grid>
</Grow>
);
};
export default NewsCards;