aboutsummaryrefslogtreecommitdiff
path: root/src/test/fixtures/simple-150x.jsx
blob: 64cb88b1b8ec9383a76eef707e7930511269c1f1 (plain) (blame)
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
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
import { Link } from "../routes";
import Head from "../components/head";
import Nav from "../components/nav";
import withRedux from "next-redux-wrapper";
import Header from "../components/Header";
import Button from "../components/Button";
import cookies from "next-cookies";
import Text from "../components/Text";
import _ from "lodash";
import { updateEntities, setCurrentUser, initStore } from "../redux/store";
import { getFeaturedProfiles, getCurrentUser } from "../api";
import { bindActionCreators } from "redux";
import { Router } from "../routes";
import PageFooter from "../components/PageFooter";
import withLogin from "../lib/withLogin";
import qs from "qs";
import LazyLoad from "react-lazyload";
import { buildImgSrcSet } from "../lib/imgUri";
import { buildProfileURL } from "../lib/routeHelpers";
import LoginGate, { LOGIN_STATUSES } from "../components/LoginGate";
import Divider from "../components/Divider";
import { SPACING } from "../helpers/styles";

// This is not saved in git 150x over because I don't want this repo to be huge.
(function () {
  const FeaturedProfile = ({ profile }) => {
    return (
      <Link route={buildProfileURL(profile.id)}>
        <a className="Profile">
          <img
            src={_.first(profile.photos)}
            srcSet={buildImgSrcSet(_.first(profile.photos), 250)}
          />
          <div className="Text">
            <div className="Title">
              <Text
                font="sans-serif"
                lineHeight="20px"
                weight="semiBold"
                size="18px"
                color="#000"
              >
                {profile.name}
              </Text>
            </div>

            <div className="Tagline">
              <Text size="14px">{(profile.tagline || "").substr(0, 100)}</Text>
            </div>
          </div>
          <style jsx>{`
            .Profile {
              background-color: #ffffff;
              cursor: pointer;
              text-decoration: none;
              text-align: left;
              width: 100%;
              height: 100%;
              border-radius: 6px;
              display: flex;
              flex-shrink: 0;
              flex-grow: 0;
              flex-direction: column;
            }

            .Text {
              flex: 1;
            }

            .Profile:hover img {
              opacity: 0.85;
            }

            .Title {
              margin-top: 1rem;
              margin-bottom: 0.5rem;
            }

            .Tagline {
              margin-bottom: 1.5rem;
            }

            img {
              object-fit: cover;
              flex: 0 0 250px;
              flex-shrink: 0;
              display: flex;
              width: 250px;
              height: 250px;
              opacity: 1;
              transition: opacity 0.1s linear;
            }

            @media (max-width: 500px) {
              .Profile {
                margin-bottom: 2em;
              }
            }
          `}</style>
        </a>
      </Link>
    );
  };

  class SignupForm extends React.Component {
    constructor(props) {
      super(props);

      this.state = {
        email: this.props.email || "",
      };
    }

    setEmail = (evt) => this.setState({ email: evt.target.value });

    componentDidMount() {
      Router.prefetchRoute(`/sign-up/verify`);
    }

    handleSubmit = (evt) => {
      evt.preventDefault();

      Router.pushRoute(
        `/sign-up/verify?${qs.stringify({ email: this.state.email })}`,
      );
    };

    render() {
      return (
        <form onSubmit={this.handleSubmit}>
          <input
            type="email"
            name="email"
            autoComplete="email"
            onChange={this.setEmail}
            placeholder="Your email"
            value={this.state.email}
          />
          <Button componentType="button" inline>
            CREATE MY PAGE
          </Button>

          <style jsx>{`
            form {
              display: flex;
            }

            input {
              font-size: 14px;
              padding: 14px 22px;
              border-radius: 33px;
              border-top-right-radius: 0;
              border-bottom-right-radius: 0;
              border: 1px solid #bababa;
              border-right: 0px;
              line-height: 18px;
              color: #000;
              outline: none;
              width: auto;
              display: flex;
              flex: 1;
            }

            input::-webkit-input-placeholder {
              color: #c5cbd4;
            }

            input:focus {
              border-color: #b0b0b0;
            }
          `}</style>
        </form>
      );
    }
  }

  class Homepage extends React.Component {
    constructor(props) {
      super(props);

      this.state = {
        isLoadingProfiles: true,
        profiles: [],
      };
    }

    static async getInitialProps(ctx) {
      if (ctx.isServer && ctx.req.path === "/") {
        const { currentUserId } = cookies(ctx);

        if (currentUserId) {
          ctx.res.writeHead(302, {
            Location: `${process.env.DOMAIN}/welcome`,
          });

          ctx.res.end();
          ctx.res.finished = true;
        }
      }
    }

    async componentDidMount() {
      const profileResponse = await getFeaturedProfiles();
      this.props.updateEntities(profileResponse.body);

      this.setState({
        isLoadingProfiles: false,
        profiles: profileResponse.body.data,
      });

      Router.prefetchRoute(`/lucy`);
    }

    render() {
      return (
        <div>
          <Head
            title="Apply to Date – your own game of The Bachelor(ette)"
            url={`${process.env.DOMAIN}/`}
            disableGoogle={false}
          />
          <Header />
          <article>
            <main>
              <div className="Copy">
                <img
                  className="Logo Logo-Home"
                  src="/static/animatedlogo.gif"
                />
                <div className="Copy-title">
                  <Text
                    font="serif"
                    size="36px"
                    lineHeight="44px"
                    weight="bold"
                  >
                    Your own game of The Bachelor(ette)
                  </Text>
                </div>
                <div className="Copy-body">
                  <Text size="16px" lineHeight="24px" font="sans-serif">
                    Create a page where people apply to go on a date with you.
                    You pick the winners.
                  </Text>
                </div>

                {!this.props.currentUserId && <SignupForm />}

                <div className="AppStoreContainer">
                  <Divider height={`${SPACING.normal}px`} color="transparent" />
                  <a
                    className="AppStore AppStore--ios"
                    target="_blank"
                    href="https://itunes.apple.com/us/app/apply-to-date/id1357419725?mt=8"
                  >
                    <img src="https://devimages-cdn.apple.com/app-store/marketing/guidelines/images/badge-download-on-the-app-store.svg" />
                  </a>

                  <a
                    target="_blank"
                    className="AppStore AppStore--android"
                    href="https://play.google.com/store/apps/details?id=com.shipfirstlabs.applytodate&utm_source=homepage&pcampaignid=MKT-Other-global-all-co-prtnr-py-PartBadge-Mar2515-1"
                  >
                    <img
                      alt="Get it on Google Play"
                      src="https://play.google.com/intl/en_us/badges/images/generic/en_badge_web_generic.png"
                    />
                  </a>
                </div>
              </div>
            </main>
          </article>

          <footer>
            <div className="divider" />

            <Text size="36px" font="sans-serif" color="#000">
              Featured pages
            </Text>

            <div className="FeaturedProfiles-wrapper">
              {this.state.isLoadingProfiles && <div className="Spinner" />}
              <div className="FeaturedProfiles">
                {!_.isEmpty(this.state.profiles) &&
                  this.state.profiles.map((profile) => (
                    <FeaturedProfile key={profile.id} profile={profile} />
                  ))}
              </div>
            </div>
          </footer>

          <article>
            <PageFooter center />
          </article>
          <style jsx>{`
            article {
              max-width: 710px;
              margin-left: auto;
              margin-right: auto;
              padding-left: 14px;
              padding-right: 14px;
              overflow-x: hidden;
            }

            main {
              display: flex;
              margin-top: 6rem;
              margin-bottom: 6rem;

              justify-content: center;
            }

            footer {
              display: flex;
              flex-direction: column;
              text-align: center;
              overflow-x: hidden;
            }

            .divider {
              height: 2px;
              width: 269px;
              margin-bottom: 6rem;
              margin-left: auto;
              margin-right: auto;
              background-color: #0aca9b;
            }

            .Logo-Home {
              margin-left: auto;
              margin-right: auto;
              width: 97px;
              height: 152.02px;
              margin-bottom: 28px;
            }

            .Copy {
              max-width: 710px;
              margin: 0 auto;
              text-align: center;
            }

            .Copy-body {
              margin-top: 1rem;
              margin-bottom: 2rem;
              font-weight: 200;
            }

            .FeaturedProfiles-wrapper {
              padding-top: 4rem;
              padding-bottom: 6rem;
              padding-left: 28px;
              padding-right: 28px;

              overflow-x: auto;
              width: 100vw;
            }

            .Spinner {
              display: flex;
              content: "";
              margin: 84px auto;
              height: 28px;
              width: 28px;
              animation: rotate 0.8s infinite linear;
              border: 4px solid #4be1ab;
              border-right-color: transparent;
              border-radius: 50%;
            }

            .AppStoreContainer {
              display: flex;
              justify-content: center;
              align-items: center;
            }

            .AppStore--ios img {
              width: 180px;
            }

            .AppStore--android img {
              width: 230px;
            }

            @keyframes rotate {
              0% {
                transform: rotate(0deg);
              }
              100% {
                transform: rotate(360deg);
              }
            }

            .FeaturedProfiles {
              display: grid;
              grid-column-gap: 2rem;
              grid-row-gap: 2rem;
              text-align: center;
              justify-content: center;
              margin-left: auto;
              margin-right: auto;
              grid-template-columns: 250px 250px 250px 250px;
            }

            @media (max-width: 1100px) {
              .FeaturedProfiles {
                grid-template-columns: 250px 250px 250px;
              }
            }

            @media (max-width: 900px) {
              .FeaturedProfiles {
                grid-template-columns: 250px 250px;
              }
            }

            @media (max-width: 554px) {
              .FeaturedProfiles-wrapper {
                padding-left: 14px;
                padding-right: 14px;
              }

              .AppStoreContainer {
                flex-direction: column;
              }

              .FeaturedProfiles {
                grid-auto-flow: row dense;
                grid-auto-rows: auto;
                grid-template-columns: 250px;
                grid-template-rows: 1fr;
                justify-content: center;
              }
            }
          `}</style>
        </div>
      );
    }
  }

  const HomepageWithStore = withRedux(initStore, null, (dispatch) =>
    bindActionCreators({ updateEntities, setCurrentUser }, dispatch),
  )(LoginGate(Homepage));
})();