From 5f8ca30f4577dee33b247189cb326313fc4437d5 Mon Sep 17 00:00:00 2001 From: Clark Winkelmann Date: Fri, 11 May 2018 11:29:58 +0200 Subject: [PATCH] Use ItemList for signup and login modals (#1420) * Remove unused imports * Use body and footer methods * Use ItemList for signup and login inputs --- .../js/forum/src/components/LogInModal.js | 106 +++++++++++------- .../js/forum/src/components/SignUpModal.js | 72 ++++++------ 2 files changed, 103 insertions(+), 75 deletions(-) diff --git a/framework/core/js/forum/src/components/LogInModal.js b/framework/core/js/forum/src/components/LogInModal.js index 3a457bbd5..8578866be 100644 --- a/framework/core/js/forum/src/components/LogInModal.js +++ b/framework/core/js/forum/src/components/LogInModal.js @@ -1,10 +1,10 @@ import Modal from 'flarum/components/Modal'; import ForgotPasswordModal from 'flarum/components/ForgotPasswordModal'; import SignUpModal from 'flarum/components/SignUpModal'; -import Alert from 'flarum/components/Alert'; import Button from 'flarum/components/Button'; import LogInButtons from 'flarum/components/LogInButtons'; import extractText from 'flarum/utils/extractText'; +import ItemList from 'flarum/utils/ItemList'; /** * The `LogInModal` component displays a modal dialog with a login form. @@ -51,54 +51,74 @@ export default class LogInModal extends Modal { content() { return [
- - -
-
- -
- -
- -
- -
-
- -
-
- -
- {Button.component({ - className: 'Button Button--primary Button--block', - type: 'submit', - loading: this.loading, - children: app.translator.trans('core.forum.log_in.submit_button') - })} -
-
+ {this.body()}
,
-

- {app.translator.trans('core.forum.log_in.forgot_password_link')} -

- - {app.forum.attribute('allowSignUp') ? ( -

- {app.translator.trans('core.forum.log_in.sign_up_text', {a: })} -

- ) : ''} + {this.footer()}
]; } + body() { + return [ + , + +
+ {this.fields().toArray()} +
+ ]; + } + + fields() { + const items = new ItemList(); + + items.add('identification',
+ +
, 30); + + items.add('password',
+ +
, 20); + + items.add('remember',
+
+ +
+
, 10); + + items.add('submit',
+ {Button.component({ + className: 'Button Button--primary Button--block', + type: 'submit', + loading: this.loading, + children: app.translator.trans('core.forum.log_in.submit_button') + })} +
, -10); + + return items; + } + + footer() { + return [ +

+ {app.translator.trans('core.forum.log_in.forgot_password_link')} +

, + + app.forum.attribute('allowSignUp') ? ( +

+ {app.translator.trans('core.forum.log_in.sign_up_text', {a: })} +

+ ) : '' + ]; + } + /** * Open the forgot password modal, prefilling it with an email if the user has * entered one. diff --git a/framework/core/js/forum/src/components/SignUpModal.js b/framework/core/js/forum/src/components/SignUpModal.js index fa96c80c0..bf00c4c11 100644 --- a/framework/core/js/forum/src/components/SignUpModal.js +++ b/framework/core/js/forum/src/components/SignUpModal.js @@ -1,9 +1,9 @@ import Modal from 'flarum/components/Modal'; import LogInModal from 'flarum/components/LogInModal'; -import avatar from 'flarum/helpers/avatar'; import Button from 'flarum/components/Button'; import LogInButtons from 'flarum/components/LogInButtons'; import extractText from 'flarum/utils/extractText'; +import ItemList from 'flarum/utils/ItemList'; /** * The `SignUpModal` component displays a modal dialog with a singup form. @@ -69,41 +69,49 @@ export default class SignUpModal extends Modal { this.props.token ? '' : ,
-
- -
- -
- -
- - {this.props.token ? '' : ( -
- -
- )} - -
- -
+ {this.fields().toArray()}
]; } + fields() { + const items = new ItemList(); + + items.add('username',
+ +
, 30); + + items.add('email',
+ +
, 20); + + if (!this.props.token) { + items.add('password',
+ +
, 10); + } + + items.add('submit',
+ +
, -10); + + return items; + } + footer() { return [