mirror of
https://github.com/scratchfoundation/scratch-www.git
synced 2024-11-26 17:16:11 -05:00
formatted email step, added input
This commit is contained in:
parent
ef78fe0748
commit
e64dc60ae6
7 changed files with 53 additions and 2 deletions
|
@ -89,6 +89,7 @@
|
||||||
"glob": "5.0.15",
|
"glob": "5.0.15",
|
||||||
"google-libphonenumber": "3.2.3",
|
"google-libphonenumber": "3.2.3",
|
||||||
"html-webpack-plugin": "2.22.0",
|
"html-webpack-plugin": "2.22.0",
|
||||||
|
"isemail": "3.2.0",
|
||||||
"iso-3166-2": "0.4.0",
|
"iso-3166-2": "0.4.0",
|
||||||
"jest": "^23.6.0",
|
"jest": "^23.6.0",
|
||||||
"json-loader": "0.5.2",
|
"json-loader": "0.5.2",
|
||||||
|
|
|
@ -5,6 +5,7 @@ import {Field} from 'formik';
|
||||||
|
|
||||||
const ValidationMessage = require('../forms/validation-message.jsx');
|
const ValidationMessage = require('../forms/validation-message.jsx');
|
||||||
|
|
||||||
|
require('./input.scss');
|
||||||
require('../forms/input.scss');
|
require('../forms/input.scss');
|
||||||
require('../forms/row.scss');
|
require('../forms/row.scss');
|
||||||
|
|
||||||
|
|
7
src/components/formik-forms/input.scss
Normal file
7
src/components/formik-forms/input.scss
Normal file
|
@ -0,0 +1,7 @@
|
||||||
|
@import "../../colors";
|
||||||
|
@import "../../frameless";
|
||||||
|
|
||||||
|
.input::placeholder {
|
||||||
|
font-style: italic;
|
||||||
|
color: $type-gray-75percent;
|
||||||
|
}
|
|
@ -1,10 +1,13 @@
|
||||||
const bindAll = require('lodash.bindall');
|
const bindAll = require('lodash.bindall');
|
||||||
|
const classNames = require('classnames');
|
||||||
const React = require('react');
|
const React = require('react');
|
||||||
const PropTypes = require('prop-types');
|
const PropTypes = require('prop-types');
|
||||||
import {Formik} from 'formik';
|
import {Formik} from 'formik';
|
||||||
const {injectIntl, intlShape} = require('react-intl');
|
const {injectIntl, intlShape} = require('react-intl');
|
||||||
|
const isEmail = require('isemail');
|
||||||
|
|
||||||
const JoinFlowStep = require('./join-flow-step.jsx');
|
const JoinFlowStep = require('./join-flow-step.jsx');
|
||||||
|
const FormikInput = require('../../components/formik-forms/formik-input.jsx');
|
||||||
|
|
||||||
require('./join-flow-steps.scss');
|
require('./join-flow-steps.scss');
|
||||||
|
|
||||||
|
@ -13,9 +16,18 @@ class EmailStep extends React.Component {
|
||||||
super(props);
|
super(props);
|
||||||
bindAll(this, [
|
bindAll(this, [
|
||||||
'handleValidSubmit',
|
'handleValidSubmit',
|
||||||
|
'validateEmailIfPresent',
|
||||||
'validateForm'
|
'validateForm'
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
validateEmailIfPresent (email) {
|
||||||
|
if (!email) return null; // skip validation if email is blank; null indicates valid
|
||||||
|
const localResult = isEmail.validate(email);
|
||||||
|
if (localResult) {
|
||||||
|
return null; // TODO: validate email address remotely
|
||||||
|
}
|
||||||
|
return this.props.intl.formatMessage({id: 'registration.validationEmailInvalid'});
|
||||||
|
}
|
||||||
validateForm () {
|
validateForm () {
|
||||||
return {};
|
return {};
|
||||||
}
|
}
|
||||||
|
@ -35,17 +47,35 @@ class EmailStep extends React.Component {
|
||||||
>
|
>
|
||||||
{props => {
|
{props => {
|
||||||
const {
|
const {
|
||||||
|
errors,
|
||||||
handleSubmit,
|
handleSubmit,
|
||||||
isSubmitting
|
isSubmitting,
|
||||||
|
validateField
|
||||||
} = props;
|
} = props;
|
||||||
return (
|
return (
|
||||||
<JoinFlowStep
|
<JoinFlowStep
|
||||||
description={this.props.intl.formatMessage({id: 'registration.emailStepDescription'})}
|
description={this.props.intl.formatMessage({id: 'registration.emailStepDescription'})}
|
||||||
headerImgSrc="/images/hoc/getting-started.jpg"
|
headerImgSrc="/images/hoc/getting-started.jpg"
|
||||||
|
innerContentClassName="modal-inner-content-email"
|
||||||
title={this.props.intl.formatMessage({id: 'registration.emailStepTitle'})}
|
title={this.props.intl.formatMessage({id: 'registration.emailStepTitle'})}
|
||||||
waiting={isSubmitting}
|
waiting={isSubmitting}
|
||||||
onSubmit={handleSubmit}
|
onSubmit={handleSubmit}
|
||||||
/>
|
>
|
||||||
|
<FormikInput
|
||||||
|
className={classNames(
|
||||||
|
'join-flow-input',
|
||||||
|
'join-flow-input-tall',
|
||||||
|
{fail: errors.email}
|
||||||
|
)}
|
||||||
|
error={errors.email}
|
||||||
|
id="email"
|
||||||
|
name="email"
|
||||||
|
placeholder="Email address"
|
||||||
|
validate={this.validateEmailIfPresent}
|
||||||
|
validationClassName="validation-full-width-input"
|
||||||
|
onBlur={() => validateField('email')} // eslint-disable-line react/jsx-no-bind
|
||||||
|
/>
|
||||||
|
</JoinFlowStep>
|
||||||
);
|
);
|
||||||
}}
|
}}
|
||||||
</Formik>
|
</Formik>
|
||||||
|
|
|
@ -13,6 +13,7 @@ const JoinFlowStep = ({
|
||||||
className,
|
className,
|
||||||
description,
|
description,
|
||||||
headerImgSrc,
|
headerImgSrc,
|
||||||
|
innerContentClassName,
|
||||||
nextButton,
|
nextButton,
|
||||||
onSubmit,
|
onSubmit,
|
||||||
title,
|
title,
|
||||||
|
@ -29,6 +30,7 @@ const JoinFlowStep = ({
|
||||||
className={classNames(
|
className={classNames(
|
||||||
'join-flow-inner-content',
|
'join-flow-inner-content',
|
||||||
className
|
className
|
||||||
|
innerContentClassName
|
||||||
)}
|
)}
|
||||||
>
|
>
|
||||||
{title && (
|
{title && (
|
||||||
|
@ -57,6 +59,7 @@ JoinFlowStep.propTypes = {
|
||||||
className: PropTypes.string,
|
className: PropTypes.string,
|
||||||
description: PropTypes.string,
|
description: PropTypes.string,
|
||||||
headerImgSrc: PropTypes.string,
|
headerImgSrc: PropTypes.string,
|
||||||
|
innerContentClassName: PropTypes.string,
|
||||||
nextButton: PropTypes.node,
|
nextButton: PropTypes.node,
|
||||||
onSubmit: PropTypes.func,
|
onSubmit: PropTypes.func,
|
||||||
title: PropTypes.string,
|
title: PropTypes.string,
|
||||||
|
|
|
@ -13,6 +13,10 @@
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.join-flow-input-tall {
|
||||||
|
height: 3rem;
|
||||||
|
}
|
||||||
|
|
||||||
.join-flow-input-title {
|
.join-flow-input-title {
|
||||||
font-weight: bold;
|
font-weight: bold;
|
||||||
margin-bottom: .5rem;
|
margin-bottom: .5rem;
|
||||||
|
@ -93,3 +97,7 @@
|
||||||
height: 2rem;
|
height: 2rem;
|
||||||
margin-left: .5rem;
|
margin-left: .5rem;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.modal-inner-content-email {
|
||||||
|
padding-top: 2.9rem;
|
||||||
|
}
|
||||||
|
|
|
@ -196,6 +196,7 @@
|
||||||
"registration.validationUsernameExists": "Sorry, that username already exists",
|
"registration.validationUsernameExists": "Sorry, that username already exists",
|
||||||
"registration.validationUsernameVulgar": "Hmm, that looks inappropriate",
|
"registration.validationUsernameVulgar": "Hmm, that looks inappropriate",
|
||||||
"registration.validationUsernameInvalid": "Invalid username",
|
"registration.validationUsernameInvalid": "Invalid username",
|
||||||
|
"registration.validationEmailInvalid": "Email doesn’t look right. Try another?",
|
||||||
"registration.waitForApproval": "Wait for Approval",
|
"registration.waitForApproval": "Wait for Approval",
|
||||||
"registration.waitForApprovalDescription": "You can log into your Scratch Account now, but the features specific to Teachers are not yet available. Your information is being reviewed. Please be patient, the approval process can take up to one day. You will receive an email indicating your account has been upgraded once your account has been approved.",
|
"registration.waitForApprovalDescription": "You can log into your Scratch Account now, but the features specific to Teachers are not yet available. Your information is being reviewed. Please be patient, the approval process can take up to one day. You will receive an email indicating your account has been upgraded once your account has been approved.",
|
||||||
"registration.welcomeStepDescription": "You have successfully set up a Scratch account! You are now a member of the class:",
|
"registration.welcomeStepDescription": "You have successfully set up a Scratch account! You are now a member of the class:",
|
||||||
|
|
Loading…
Reference in a new issue