This repository was archived by the owner on Mar 7, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 77
Expand file tree
/
Copy pathSideBar.js
More file actions
112 lines (104 loc) · 2.5 KB
/
SideBar.js
File metadata and controls
112 lines (104 loc) · 2.5 KB
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
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
import React from 'react';
import PropTypes from 'prop-types';
import { Container, Typography, makeStyles, Box } from '@material-ui/core';
import { Link } from 'react-router-dom';
const useStyles = makeStyles(theme => ({
root: {
background: 'linear-gradient(180deg, #2A185A 0%, #000000 100%)',
paddingTop: theme.spacing(1),
borderRadius: '5px',
width: '340px'
},
centerCls: {
paddingLeft: '5px',
paddingRight: '5px'
},
box: {
margin: '8px',
padding: '8px 0px',
color: '#fff'
},
img: {
width: '276px',
height: '100%',
marginBottom: '8px'
}
}));
function SideBar({ blog }) {
return <SideBarItems blogs={blog} />;
}
function SideBarItems({ blogs, flat }) {
const classes = useStyles();
return (
<div className={classes.root}>
<Container
maxWidth="lg"
style={{
width: flat ? '100%' : '360px'
}}
>
<Box
display="flex"
flexDirection="column"
style={{
flexWrap: flat ? 'nowrap' : 'wrap'
}}
>
<Typography
variant="h4"
style={{
margin: '12px 0px 12px 8px',
color: '#fff'
}}
>
Popular Among Readers
</Typography>
{blogs.map((blog, index) => {
return <Blog blog={blog} index={index} />;
})}
</Box>
</Container>
</div>
);
}
function Blog({ blog, index }) {
const classes = useStyles();
return (
<Box display="inline-flex" flexDirection="column" className={classes.box}>
<img alt={blog.title} src={blog.thumbnail} className={classes.img} />
<Typography variant="h6" color="secondary">
{blog.categories[0]}
</Typography>
<Link
to={`blog/${index + 5}`}
style={{ textDecoration: 'none', color: '#fff' }}
>
<Typography
variant="body1"
style={{
fontWeight: 600,
fontSize: '20px',
padding: '8px 12px 8px 0'
}}
>
{blog.title}
</Typography>
<Typography variant="caption">
{'Published on '}
{blog.pubDate.split(' ')[0]}
</Typography>
<Typography
variant="caption"
display="block"
style={{ fontWeight: 700, paddingTop: '8px' }}
>
By {blog.author}
</Typography>
</Link>
</Box>
);
}
SideBar.propTypes = {
className: PropTypes.string
};
export default SideBar;