-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathadvanced.js
More file actions
276 lines (267 loc) · 10 KB
/
Copy pathadvanced.js
File metadata and controls
276 lines (267 loc) · 10 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
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
// base imports
import React from "react";
import _ from "lodash";
import PropTypes from "prop-types";
// Material UI imports
import Box from "@mui/material/Box";
import Container from "@mui/material/Container";
import Grid from "@mui/material/Grid";
import Typography from "@mui/material/Typography";
// components
import components, { Layout } from "../components/index";
import SectionHero from "../components/SectionHero";
import SectionHeroTracker from "../components/SectionHeroTracker";
import SectionRecentArticles from "../components/SectionRecentArticles";
// utils
import FeaturedHero from "../components/Homepage/FeaturedHero";
import FeaturedStories from "../components/Homepage/FeatureStories";
import Podcast from "../components/Homepage/Podcast";
import LatestFromFellows from "../components/Homepage/LatestFromFellows";
import RecentArticles from "../components/Homepage/RecentArticles";
import SpotlightArticles from "../components/Homepage/SpotlightArticles";
import AroundGlobe from "../components/Homepage/AroundGlobe";
import PolicyTracker from "../components/Homepage/PolicyTracker";
import Announcements from "../components/Homepage/Announcements";
import MoreArticles from "../components/SpecialProjects/MoreArticles";
const Advanced = (props) => {
const { path, page, featured, articles } = props;
const latest =
(path === "/" || (page && page.layout === "project")) && articles
? articles.filter(
(article) => featured.find((a) => a._id === article._id) == null
)
: undefined;
const excludeIds = [
...(featured?.map((f) => f._id) || []),
...(latest?.slice(0, 11).map((a) => a._id) || []),
];
return (
<Layout {...props} isHomepage>
<Box>
{path === "/" ? (
<>
<div
id="mlb2-5983540"
className="ml-form-embedContainer ml-subscribe-form ml-subscribe-form-5983540"
>
<div className="ml-form-align-center">
<div className="ml-form-embedWrapper embedForm">
<div
className="ml-form-embedBody ml-form-embedBodyDefault row-form"
style={{ justifyContent: "center", columnGap: "60px" }}
>
<div className="ml-form-embedContent">
<h4>
Join our newsletter on issues and ideas at the
intersection of tech & democracy
</h4>
</div>
<form
className="ml-block-form"
action="https://static.mailerlite.com/webforms/submit/v2f5x1"
data-code="v2f5x1"
method="post"
target="_blank"
style={{
maxWidth: "360px",
marginLeft: 0,
display: "flex",
columnGap: "10px",
justifySelf: "center",
}}
>
<div
className="ml-form-formContent"
style={{ maxWidth: "250px" }}
>
<div className="ml-form-fieldRow ml-last-item">
<div className="ml-field-group ml-field-email ml-validate-email ml-validate-required">
<input
aria-label="email"
aria-required="true"
type="email"
className="form-control"
data-inputmask=""
name="fields[email]"
placeholder="Enter email address"
autoComplete="email"
/>
</div>
</div>
</div>
<input type="hidden" name="ml-submit" value="1" />
<div className="ml-form-embedSubmit">
<button type="submit" className="primary">
Subscribe
</button>
<button
disabled="disabled"
style={{ display: "none" }}
type="button"
className="loading"
>
<div className="ml-form-embedSubmitLoad" />
<span className="sr-only">Loading...</span>
</button>
</div>
<input type="hidden" name="anticsrf" value="true" />
</form>
</div>
<div
className="ml-form-successBody row-success"
style={{ display: "none" }}
>
<div className="ml-form-successContent">
<h4>Thank you!</h4>
<p style={{ textAlign: "center" }}>
<br />
</p>
<p style={{ textAlign: "center" }}>
You have successfully joined our mailing list.
</p>
<p style={{ textAlign: "center" }}>
More to come in January 2021 !
</p>
<p style={{ textAlign: "center" }}>
Want to get in touch now?{" "}
<a href="mailto:justin@techpolicy.press">Email us</a>
.
</p>
</div>
</div>
</div>
</div>
</div>
<Container>
<Grid
container
spacing={4}
alignItems="flex-start"
justifyContent="space-between"
>
{featured && (
<Grid item xs={12} md={8}>
<FeaturedHero article={featured[0]} />
<FeaturedStories articles={featured.slice(1)} />
</Grid>
)}
<Grid container item xs={12} md={4}>
<Grid item>
<SectionRecentArticles articles={latest.slice(0, 5)} />
</Grid>
</Grid>
</Grid>
<Grid container spacing={4} sx={{ marginTop: 1 }}>
<Grid item xs={12} md={6}>
<Podcast />
</Grid>
<Grid item xs={12} md={6}>
<LatestFromFellows />
</Grid>
</Grid>
<Grid container spacing={4} sx={{ marginTop: 1 }}>
<Grid item xs={12} md={4}>
<RecentArticles articles={latest.slice(5, 11)} />
</Grid>
<Grid item xs={12} md={4}>
<AroundGlobe exclude={excludeIds} />
</Grid>
<Grid item xs={12} md={4}>
<SpotlightArticles />
</Grid>
</Grid>
<Grid
container
spacing={4}
sx={{ marginTop: 7, marginBottom: 7 }}
>
<Grid item xs={12} md={8}>
<PolicyTracker
trackerText={page.trackerText ? page.trackerText : ""}
/>
</Grid>
<Grid item xs={12} md={4}>
<Box sx={{ backgroundColor: "#efe9da80", padding: "24px" }}>
<Announcements />
</Box>
</Grid>
</Grid>
</Container>
</>
) : page && page.layout === "project" ? (
<>
<Container>
<Typography
component="h1"
variant="h2_article"
sx={{ borderBottom: "1px solid #8AA29D", paddingBottom: 2 }}
>
{page.title}
</Typography>
<Grid
container
spacing={4}
alignItems="flex-start"
justifyContent="space-between"
>
{featured && (
<Grid item xs={12} md={8}>
<FeaturedHero article={featured[0]} />
<FeaturedStories articles={featured.slice(1)} />
</Grid>
)}
<Grid container item xs={12} md={4}>
<Grid item>
<SectionRecentArticles
articles={latest.slice(0, 5)}
viewMore={false}
/>
</Grid>
</Grid>
</Grid>
<MoreArticles
articles={latest.slice(5, 23)}
topics={page.projectTopics}
/>
</Container>
</>
) : (
<>
{path === "/tracker" ? (
<SectionHeroTracker {...props} />
) : (
<SectionHero {...props} />
)}
<Container>
{_.map(
_.get(props, "page.sections", null),
(section, section_idx) => {
let component = _.upperFirst(
_.camelCase(_.get(section, "type", null))
);
let Component = components[component];
return (
<Component
key={section_idx}
{...props}
section={section}
site={props}
/>
);
}
)}
</Container>
</>
)}
</Box>
</Layout>
);
};
Advanced.propTypes = {
citations: PropTypes.array,
path: PropTypes.string,
page: PropTypes.object,
featured: PropTypes.array,
articles: PropTypes.array,
};
export default Advanced;