mirror of
https://github.com/opensupports/opensupports.git
synced 2025-07-30 01:05:18 +02:00
Ivan - Create message component and implement in password recover page [skip ci]
This commit is contained in:
parent
3dd27fbb3e
commit
8ec2fb73e5
@ -11,6 +11,7 @@ import Widget from 'core-components/widget';
|
|||||||
import Form from 'core-components/form';
|
import Form from 'core-components/form';
|
||||||
import Input from 'core-components/input';
|
import Input from 'core-components/input';
|
||||||
import Button from 'core-components/button';
|
import Button from 'core-components/button';
|
||||||
|
import Message from 'core-components/message';
|
||||||
|
|
||||||
const MainRecoverPasswordPage = React.createClass({
|
const MainRecoverPasswordPage = React.createClass({
|
||||||
|
|
||||||
@ -59,9 +60,9 @@ const MainRecoverPasswordPage = React.createClass({
|
|||||||
renderRecoverStatus() {
|
renderRecoverStatus() {
|
||||||
switch (this.state.recoverStatus) {
|
switch (this.state.recoverStatus) {
|
||||||
case 'valid':
|
case 'valid':
|
||||||
return <div className="recover-password__text_valid">{i18n('VALID_RECOVER')}</div>;
|
return <Message type="success">{i18n('VALID_RECOVER')}</Message>;
|
||||||
case 'invalid':
|
case 'invalid':
|
||||||
return <div className="recover-password__text_invalid">{i18n('INVALID_RECOVER')}</div>;
|
return <Message type="error">{i18n('INVALID_RECOVER')}</Message>;
|
||||||
case 'waiting':
|
case 'waiting':
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
@ -9,6 +9,10 @@
|
|||||||
margin: 10px 0 0 0;
|
margin: 10px 0 0 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
&__submit-button {
|
||||||
|
margin-bottom: 40px;
|
||||||
|
}
|
||||||
|
|
||||||
&__text_valid {
|
&__text_valid {
|
||||||
color: green;
|
color: green;
|
||||||
}
|
}
|
||||||
|
@ -5,12 +5,12 @@ const Icon = React.createClass({
|
|||||||
|
|
||||||
propTypes: {
|
propTypes: {
|
||||||
name: React.PropTypes.string.isRequired,
|
name: React.PropTypes.string.isRequired,
|
||||||
size: React.PropTypes.number
|
size: React.PropTypes.string
|
||||||
},
|
},
|
||||||
|
|
||||||
getDefaultProps() {
|
getDefaultProps() {
|
||||||
return {
|
return {
|
||||||
size: 0
|
size: 'lg'
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
|
|
||||||
|
79
client/src/core-components/message.js
Normal file
79
client/src/core-components/message.js
Normal file
@ -0,0 +1,79 @@
|
|||||||
|
import React from 'react';
|
||||||
|
import classNames from 'classnames';
|
||||||
|
|
||||||
|
import {Motion, spring} from 'react-motion';
|
||||||
|
import Icon from 'core-components/icon';
|
||||||
|
|
||||||
|
const Message = React.createClass({
|
||||||
|
|
||||||
|
propTypes: {
|
||||||
|
title: React.PropTypes.string,
|
||||||
|
children: React.PropTypes.node,
|
||||||
|
type: React.PropTypes.oneOf(['success', 'error', 'info'])
|
||||||
|
},
|
||||||
|
|
||||||
|
getDefaultProps() {
|
||||||
|
return {
|
||||||
|
type: 'info'
|
||||||
|
};
|
||||||
|
},
|
||||||
|
|
||||||
|
render() {
|
||||||
|
return (
|
||||||
|
<Motion {...this.getAnimationProps()}>
|
||||||
|
{this.renderMessage}
|
||||||
|
</Motion>
|
||||||
|
);
|
||||||
|
},
|
||||||
|
|
||||||
|
getAnimationProps() {
|
||||||
|
return {
|
||||||
|
defaultStyle: {
|
||||||
|
opacity: spring(0, [100, 30])
|
||||||
|
},
|
||||||
|
style: {
|
||||||
|
opacity: spring(1, [100, 30])
|
||||||
|
}
|
||||||
|
};
|
||||||
|
},
|
||||||
|
|
||||||
|
renderMessage(style) {
|
||||||
|
return (
|
||||||
|
<div className={this.getClass()} style={style} aria-live="assertive">
|
||||||
|
<Icon className="message__icon" name={this.getIconName()} size={this.getIconSize()} />
|
||||||
|
<div className="message__title">{this.props.title}</div>
|
||||||
|
<div className="message__content">{this.props.children}</div>
|
||||||
|
</div>
|
||||||
|
)
|
||||||
|
},
|
||||||
|
|
||||||
|
getClass() {
|
||||||
|
let classes = {
|
||||||
|
'message': true,
|
||||||
|
'message_success': (this.props.type === 'success'),
|
||||||
|
'message_error': (this.props.type === 'error'),
|
||||||
|
'message_info': (this.props.type === 'info'),
|
||||||
|
'message_with-title': (this.props.title),
|
||||||
|
|
||||||
|
[this.props.className]: (this.props.className)
|
||||||
|
};
|
||||||
|
|
||||||
|
return classNames(classes);
|
||||||
|
},
|
||||||
|
|
||||||
|
getIconName() {
|
||||||
|
let iconNames = {
|
||||||
|
'success': 'check-circle',
|
||||||
|
'error': 'exclamation-circle',
|
||||||
|
'info': 'info-circle'
|
||||||
|
};
|
||||||
|
|
||||||
|
return iconNames[this.props.type];
|
||||||
|
},
|
||||||
|
|
||||||
|
getIconSize() {
|
||||||
|
return (this.props.title) ? '2x' : 'lg';
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
export default Message;
|
86
client/src/core-components/message.scss
Normal file
86
client/src/core-components/message.scss
Normal file
@ -0,0 +1,86 @@
|
|||||||
|
@import "../scss/vars";
|
||||||
|
|
||||||
|
.message {
|
||||||
|
padding: 10px;
|
||||||
|
text-align: center;
|
||||||
|
position: relative;
|
||||||
|
overflow: hidden;
|
||||||
|
|
||||||
|
&__icon {
|
||||||
|
position: absolute;
|
||||||
|
top: 13px;
|
||||||
|
left: 13px;
|
||||||
|
}
|
||||||
|
|
||||||
|
&__title {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
&__content {
|
||||||
|
color: white;
|
||||||
|
}
|
||||||
|
|
||||||
|
&_success {
|
||||||
|
background-color: #d8f7b3;
|
||||||
|
|
||||||
|
.message__icon {
|
||||||
|
color: #189e1e;
|
||||||
|
}
|
||||||
|
|
||||||
|
.message__title {
|
||||||
|
color: $primary-blue;
|
||||||
|
}
|
||||||
|
|
||||||
|
.message__content {
|
||||||
|
color: $primary-blue;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
&_error {
|
||||||
|
background-color: #ffb4b4;
|
||||||
|
|
||||||
|
.message__icon {
|
||||||
|
color: red;
|
||||||
|
}
|
||||||
|
|
||||||
|
.message__title {
|
||||||
|
color: #bb4242;
|
||||||
|
}
|
||||||
|
|
||||||
|
.message__content {
|
||||||
|
color: white;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
&_info {
|
||||||
|
background-color: #a2e1ff;
|
||||||
|
|
||||||
|
.message__icon {
|
||||||
|
color: #4c80ff;
|
||||||
|
}
|
||||||
|
|
||||||
|
.message__title {
|
||||||
|
color: $primary-blue;
|
||||||
|
}
|
||||||
|
|
||||||
|
.message__content {
|
||||||
|
color: $primary-blue;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
&_with-title {
|
||||||
|
text-align: left;
|
||||||
|
|
||||||
|
.message__title {
|
||||||
|
font-size: $font-size--md;
|
||||||
|
font-weight: bold;
|
||||||
|
}
|
||||||
|
|
||||||
|
.message__icon {
|
||||||
|
position: initial;
|
||||||
|
float: left;
|
||||||
|
margin-top: 7px;
|
||||||
|
margin-right: 20px;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -60,7 +60,7 @@ const UserStore = Reflux.createStore({
|
|||||||
data: recoverData
|
data: recoverData
|
||||||
}).then(() => {
|
}).then(() => {
|
||||||
this.trigger('VALID_RECOVER');
|
this.trigger('VALID_RECOVER');
|
||||||
setTimeout(CommonActions.loggedOut, 2000);
|
//setTimeout(CommonActions.loggedOut, 2000);
|
||||||
}, () => {
|
}, () => {
|
||||||
this.trigger('INVALID_RECOVER')
|
this.trigger('INVALID_RECOVER')
|
||||||
});
|
});
|
||||||
|
Loading…
x
Reference in New Issue
Block a user