|
|
@@ -2,6 +2,8 @@ import React from 'react';
|
|
|
import { Link } from 'react-router-dom';
|
|
|
import { Motion, spring } from 'react-motion';
|
|
|
|
|
|
+import { TextArea, Warning, Input, Label } from './style';
|
|
|
+
|
|
|
import './style.css';
|
|
|
|
|
|
export default class Form extends React.Component {
|
|
|
@@ -20,9 +22,7 @@ export default class Form extends React.Component {
|
|
|
const warning = (
|
|
|
<Motion defaultStyle={{ x: 0 }} style={{ x: spring(1) }} key="isRequired">
|
|
|
{({ x }) =>
|
|
|
- <span className="warning" style={{ opacity: x }}>
|
|
|
- This field is required.
|
|
|
- </span>}
|
|
|
+ <Warning style={{ opacity: x }}>This field is required.</Warning>}
|
|
|
</Motion>
|
|
|
);
|
|
|
const color = this.state[name].color;
|
|
|
@@ -53,11 +53,7 @@ export default class Form extends React.Component {
|
|
|
validatePasswordMatch = (name1, name2) => {
|
|
|
const password1 = this.state[name1].message;
|
|
|
const password2 = this.state[name2].message;
|
|
|
- const warning = (
|
|
|
- <span className="warning" key="isPwdMatch">
|
|
|
- Password don't match.
|
|
|
- </span>
|
|
|
- );
|
|
|
+ const warning = <Warning key="isPwdMatch">Password don't match.</Warning>;
|
|
|
const color1 = this.state[name1].color;
|
|
|
return password1 === password2 && color1 !== 'grey' ? null : warning;
|
|
|
};
|
|
|
@@ -201,28 +197,28 @@ export default class Form extends React.Component {
|
|
|
};
|
|
|
|
|
|
if (type === 'textarea') {
|
|
|
- return <textarea {...props} />;
|
|
|
+ return <TextArea {...props} />;
|
|
|
}
|
|
|
- return <input {...props} />;
|
|
|
+ return <Input {...props} />;
|
|
|
};
|
|
|
|
|
|
render() {
|
|
|
return (
|
|
|
<form onSubmit={this.handleSubmit} action={<Link to="/tabss" />}>
|
|
|
- <label htmlFor="name">Name:</label>
|
|
|
+ <Label htmlFor="name">Name:</Label>
|
|
|
{this.renderInput('text', 'name')}
|
|
|
{this.state.name.warnings}
|
|
|
- <label htmlFor="password">Password:</label>
|
|
|
+ <Label htmlFor="password">Password:</Label>
|
|
|
{this.renderInput('password', 'password')}
|
|
|
{this.state.password.warnings}
|
|
|
- <label htmlFor="password2">Password:</label>
|
|
|
+ <Label htmlFor="password2">Password:</Label>
|
|
|
{this.renderInput('password', 'password2')}
|
|
|
{this.state.password2.warnings}
|
|
|
|
|
|
- <label htmlFor="comments">Comments:</label>
|
|
|
+ <Label htmlFor="comments">Comments:</Label>
|
|
|
{this.renderInput('textarea', 'comments')}
|
|
|
{this.state.comments.warnings}
|
|
|
- <input type="submit" value="Submit" />
|
|
|
+ <Input type="submit" value="Submit" />
|
|
|
</form>
|
|
|
);
|
|
|
}
|