mirror of
https://github.com/elyby/accounts-frontend.git
synced 2025-01-04 11:12:49 +05:30
Defer Captcha initialization. Add loader for Captcha
This commit is contained in:
parent
86a17fc99b
commit
6fc83505db
@ -54,7 +54,7 @@ export default class RegisterBody extends BaseAuthBody {
|
|||||||
placeholder={messages.repeatPassword}
|
placeholder={messages.repeatPassword}
|
||||||
/>
|
/>
|
||||||
|
|
||||||
<Captcha {...this.bindField('captcha')} />
|
<Captcha {...this.bindField('captcha')} delay={600} />
|
||||||
|
|
||||||
<Checkbox {...this.bindField('rulesAgreement')}
|
<Checkbox {...this.bindField('rulesAgreement')}
|
||||||
color="blue"
|
color="blue"
|
||||||
|
@ -34,7 +34,7 @@ export default class ResendActivation extends BaseAuthBody {
|
|||||||
defaultValue={this.context.user.email}
|
defaultValue={this.context.user.email}
|
||||||
/>
|
/>
|
||||||
|
|
||||||
<Captcha {...this.bindField('captcha')} />
|
<Captcha {...this.bindField('captcha')} delay={600} />
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
@ -4,6 +4,7 @@ import classNames from 'classnames';
|
|||||||
|
|
||||||
import captcha from 'services/captcha';
|
import captcha from 'services/captcha';
|
||||||
import { skins, SKIN_DARK } from 'components/ui';
|
import { skins, SKIN_DARK } from 'components/ui';
|
||||||
|
import { ComponentLoader } from 'components/ui/loader';
|
||||||
|
|
||||||
import styles from './form.scss';
|
import styles from './form.scss';
|
||||||
import FormInputComponent from './FormInputComponent';
|
import FormInputComponent from './FormInputComponent';
|
||||||
@ -12,25 +13,30 @@ export default class Captcha extends FormInputComponent {
|
|||||||
static displayName = 'Captcha';
|
static displayName = 'Captcha';
|
||||||
|
|
||||||
static propTypes = {
|
static propTypes = {
|
||||||
skin: PropTypes.oneOf(skins)
|
skin: PropTypes.oneOf(skins),
|
||||||
|
delay: PropTypes.number
|
||||||
};
|
};
|
||||||
|
|
||||||
static defaultProps = {
|
static defaultProps = {
|
||||||
skin: SKIN_DARK
|
skin: SKIN_DARK,
|
||||||
|
delay: 0
|
||||||
};
|
};
|
||||||
|
|
||||||
componentDidMount() {
|
componentDidMount() {
|
||||||
captcha.render(this.el, {
|
setTimeout(() => captcha.render(this.el, {
|
||||||
skin: this.props.skin,
|
skin: this.props.skin,
|
||||||
onSetCode: this.setCode
|
onSetCode: this.setCode
|
||||||
});
|
}), this.props.delay);
|
||||||
}
|
}
|
||||||
|
|
||||||
render() {
|
render() {
|
||||||
const {skin} = this.props;
|
const {skin} = this.props;
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div>
|
<div className={styles.captchaContainer}>
|
||||||
|
<div className={styles.captchaLoader}>
|
||||||
|
<ComponentLoader />
|
||||||
|
</div>
|
||||||
<div ref={this.setEl} className={classNames(
|
<div ref={this.setEl} className={classNames(
|
||||||
styles.captcha,
|
styles.captcha,
|
||||||
styles[`${skin}Captcha`]
|
styles[`${skin}Captcha`]
|
||||||
|
@ -295,7 +295,12 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.captchaContainer {
|
||||||
|
position: relative;
|
||||||
|
}
|
||||||
|
|
||||||
.captcha {
|
.captcha {
|
||||||
|
position: relative;
|
||||||
box-sizing: border-box;
|
box-sizing: border-box;
|
||||||
width: 100%;
|
width: 100%;
|
||||||
max-width: 302px;
|
max-width: 302px;
|
||||||
@ -327,6 +332,13 @@
|
|||||||
border-color: #dcd8cd;
|
border-color: #dcd8cd;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.captchaLoader {
|
||||||
|
position: absolute;
|
||||||
|
top: 50%;
|
||||||
|
transform: translateY(-50%);
|
||||||
|
width: 100%;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Form validation
|
* Form validation
|
||||||
*/
|
*/
|
||||||
|
Loading…
Reference in New Issue
Block a user