-
Notifications
You must be signed in to change notification settings - Fork 262
/
Copy pathAuthForm.js
110 lines (96 loc) · 2.41 KB
/
AuthForm.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
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
import React, { Component } from "react";
import PropTypes from "prop-types";
import configs from "../configs";
import styled from "styled-components";
import Input from "../ui/inputs/Input";
import { PRIVACY, TERMS } from "../constants";
const StyledAuthForm = styled.form`
display: flex;
flex-direction: column;
justify-content: center;
text-align: center;
max-width: 400px;
align-self: center;
& > * {
margin-bottom: 20px;
}
button {
display: inline-block;
border: none;
border-radius: 4px;
background: ${props => props.theme.blue};
color: ${props => props.theme.white};
white-space: nowrap;
min-height: 36px;
font-size: 16px;
padding: 1px 6px;
&:hover,
&:active {
background-color: ${props => props.theme.bluePressed};
}
}
h3 {
font-size: 2em;
color: ${props => props.theme.text};
}
h4 {
font-size: 1.1em;
color: ${props => props.theme.text};
}
`;
const FormInput = styled(Input)`
font-size: 20px;
padding: 8px;
height: 36px;
`;
const ErrorMessage = styled.p`
color: ${props => props.theme.red};
margin-bottom: 20px;
`;
const LegalText = styled.p`
margin-bottom: 20px;
`;
export default class AuthForm extends Component {
static propTypes = {
error: PropTypes.string,
onSubmit: PropTypes.func.isRequired
};
state = {
email: ""
};
onSubmit = e => {
e.preventDefault();
this.props.onSubmit(this.state.email);
};
onEmailChange = e => {
this.setState({ email: e.target.value });
};
render() {
return (
<StyledAuthForm onSubmit={this.onSubmit}>
{this.props.error && <ErrorMessage>{this.props.error}</ErrorMessage>}
<h3>Register or Login</h3>
<h4>Login to save projects and publish scenes{configs.isMoz() && " to Hubs"}.</h4>
<FormInput
type="email"
name="email"
placeholder="Email"
value={this.state.email}
onChange={this.onEmailChange}
/>
<LegalText>
By proceeding, you agree to the{" "}
<a rel="noopener noreferrer" target="_blank" href={TERMS}>
terms of use (TBD)
</a>{" "}
and{" "}
<a rel="noopener noreferrer" target="_blank" href={PRIVACY}>
privacy notice (TBD)
</a>{" "}
.
</LegalText>
<button type="submit">Send Magic Link</button>
</StyledAuthForm>
);
}
}