-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathSectionRecentArticles.js
More file actions
192 lines (186 loc) · 5 KB
/
Copy pathSectionRecentArticles.js
File metadata and controls
192 lines (186 loc) · 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
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
// base imports
import React from "react";
import PropTypes from "prop-types";
import { DateTime } from "luxon";
// Material UI imports
import { makeStyles } from "@mui/styles";
import Grid from "@mui/material/Grid";
import Link from "@mui/material/Link";
import Typography from "@mui/material/Typography";
import Badge from "./Badge";
const useStyles = makeStyles(() => ({
article: {
borderBottom: "1px solid",
borderBottomColor: "#DCDCDC",
marginBottom: 20,
paddingBottom: 20,
},
lastArticle: {
marginBottom: 0,
},
articleTitleRecent: {
color: "#000 !important",
fontSize: "1em",
fontWeight: "700",
"&:hover": {
color: "#225C9D !important",
textDecoration: "none",
},
},
articlePublication: {
color: "rgba(0, 0, 0, 0.6)",
marginTop: 25,
marginBottom: 8,
position: "relative",
},
em: {
fontSize: "0.81em",
fontStyle: "italic",
},
authors: {
color: "rgba(0, 0, 0, 0.6)",
fontFamily: "Lexend",
fontSize: "10px",
fontWeight: "700",
textTransform: "uppercase",
},
grid: {
marginTop: 32,
background: "#efe9da80",
padding: "20px",
},
gridTitle: {
borderBottom: "1px solid #000",
marginBottom: 32,
width: "100%",
},
link: {
textDecoration: "none !important",
},
more: {
textDecoration: "none",
width: 200,
"&:active, & :focus, &:hover": {
color: "#FF0033",
textDecoration: "underline",
},
},
moreText: {
backgroundColor: "#FFE5EA",
borderRadius: 2,
color: "#FF0033",
fontWeight: 500,
padding: 6,
},
}));
const SectionRecentArticles = (props) => {
const { articles, viewMore } = props;
const classes = useStyles();
return (
<Grid container className={classes.grid}>
<Grid item className={classes.gridTitle}>
<Grid
container
alignItems={"flex-end"}
sx={{ justifyContent: "space-between" }}
>
<Grid item>
<Typography component="h2" variant="h4" sx={{ marginBottom: 1 }}>
Latest
</Typography>
</Grid>
{viewMore !== false && (
<Grid item>
<Link
href="/search"
sx={{
height: 24,
textDecoration: "none",
width: 162,
"&:hover": {
textDecoration: "underline",
},
}}
>
<Typography
component="div"
variant="h5"
sx={{
backgroundColor: "#FFF",
borderRadius: "4px",
color: "#FF0033",
fontWeight: 500,
paddingX: "10px",
paddingY: "6px",
boxShadow: "0px 2px 2px 0px #0000001F",
"&:active, & :focus, &:hover": {
color: "#FF0033",
textDecoration: "underline",
},
marginBottom: "7px",
}}
>
View more
</Typography>
</Link>
</Grid>
)}
</Grid>
</Grid>
<Grid container item flexDirection="column">
{articles && articles.length
? articles.map((article, idx) => (
<Grid
item
key={article._id}
className={
idx !== articles.length - 1
? classes.article
: classes.lastArticle
}
>
{article.badge && (
<Badge badge={article.badge} variant={"link"} />
)}
<Link
href={`/${article.slug.current}`}
className={classes.link}
>
<Typography
component="div"
variant="body1"
className={classes.articleTitleRecent}
>
{article.title}
</Typography>
</Link>
<Typography
component="span"
variant="body2"
sx={{
color: "#a7a7a7",
fontSize: 14,
fontWeight: 400,
marginTop: "8px",
textTransform: "uppercase",
lineHeight: 1.75,
display: "inline-block",
}}
>
{DateTime.fromISO(article.date)
.setZone("America/New_York")
.setLocale("en-us")
.toLocaleString(DateTime.DATE_FULL)}
</Typography>
</Grid>
))
: null}
</Grid>
</Grid>
);
};
SectionRecentArticles.propTypes = {
articles: PropTypes.array,
viewMore: PropTypes.boolean,
};
export default SectionRecentArticles;