formatted email step, added input

This commit is contained in:
Ben Wheeler 2019-08-01 15:40:46 -04:00
parent ef78fe0748
commit e64dc60ae6
7 changed files with 53 additions and 2 deletions

View file

@ -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",

View file

@ -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');

View file

@ -0,0 +1,7 @@
@import "../../colors";
@import "../../frameless";
.input::placeholder {
font-style: italic;
color: $type-gray-75percent;
}

View file

@ -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>

View file

@ -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,

View file

@ -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;
}

View file

@ -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 doesnt 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:",