Skip to content

Commit c828b04

Browse files
ronlavi2412jeff-phillips-18
authored andcommitted
fix(LoginPage): improve form's error style and behavior (#942)
1 parent d3f415c commit c828b04

File tree

8 files changed

+30
-15
lines changed

8 files changed

+30
-15
lines changed
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
.login-form-error {
2+
color: @color-pf-red-100;
3+
margin-bottom: 10px;
4+
}

packages/patternfly-3/patternfly-react/less/patternfly-react.less

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,4 +14,4 @@
1414
@import 'treeview';
1515
@import 'pagination';
1616
@import 'expand-collapse';
17-
17+
@import 'login-page';
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
.login-form-error {
2+
color: $color-pf-red-100;
3+
margin-bottom: 10px;
4+
}

packages/patternfly-3/patternfly-react/sass/patternfly-react/_patternfly-react.scss

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,4 +14,4 @@
1414
@import 'treeview';
1515
@import 'pagination';
1616
@import 'expand-collapse';
17-
17+
@import 'login-page';

packages/patternfly-3/patternfly-react/src/components/LoginPage/__snapshots__/LoginPage.test.js.snap

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -125,9 +125,6 @@ exports[`Component matches snapshot 1`] = `
125125
class=""
126126
novalidate=""
127127
>
128-
<div
129-
class="login-form-error "
130-
/>
131128
<div
132129
class="login_card_input form-group"
133130
>

packages/patternfly-3/patternfly-react/src/components/LoginPage/__snapshots__/SocialLoginPage.test.js.snap

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -114,8 +114,15 @@ exports[`Component matches snapshot 1`] = `
114114
novalidate=""
115115
>
116116
<div
117-
class="login-form-error "
118-
/>
117+
class="login-form-error"
118+
style="overflow: hidden; height: 0px;"
119+
>
120+
<div
121+
class="ReactCollapse--content"
122+
>
123+
Your account has been blocked. Contact your administrator to unblock it.
124+
</div>
125+
</div>
119126
<div
120127
class="login_card_input form-group"
121128
>

packages/patternfly-3/patternfly-react/src/components/LoginPage/components/LoginCardComponents/LoginCardWithValidation.js

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ class LoginCardWithValidation extends React.Component {
2020
},
2121
isCapsLock: false,
2222
form: {
23-
showError: false,
23+
showError: this.props.showError,
2424
submitError: this.props.submitError,
2525
disableSubmit: this.props.disableSubmit,
2626
isSubmitting: this.props.isSubmitting
@@ -260,7 +260,8 @@ LoginCardWithValidation.propTypes = {
260260
onSubmit: PropTypes.func,
261261
submitError: PropTypes.oneOfType([PropTypes.string, PropTypes.node]),
262262
disableSubmit: PropTypes.bool,
263-
isSubmitting: PropTypes.bool
263+
isSubmitting: PropTypes.bool,
264+
showError: PropTypes.bool
264265
};
265266

266267
LoginCardWithValidation.defaultProps = {
@@ -270,7 +271,8 @@ LoginCardWithValidation.defaultProps = {
270271
onSubmit: e => e.target.submit(),
271272
submitError: null,
272273
disableSubmit: false,
273-
isSubmitting: false
274+
isSubmitting: false,
275+
showError: false
274276
};
275277

276278
export default LoginCardWithValidation;

packages/patternfly-3/patternfly-react/src/components/LoginPage/components/LoginCardComponents/LoginFormError.js

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,15 @@
11
import React from 'react';
22
import PropTypes from 'prop-types';
33
import Collapse from 'react-collapse';
4+
import { default as cx } from 'classnames';
5+
import { excludeKeys } from '../../../../common/helpers';
46

5-
const LoginFormError = ({ children, show, className, ...props }) => (
6-
<div className={`login-form-error ${className}`}>
7-
<Collapse {...props} isOpened={show}>
7+
const LoginFormError = ({ children, show, className, ...props }) =>
8+
children && (
9+
<Collapse {...excludeKeys(props, ['className'])} isOpened={show} className={cx('login-form-error', className)}>
810
{children}
911
</Collapse>
10-
</div>
11-
);
12+
);
1213

1314
LoginFormError.propTypes = {
1415
className: PropTypes.string,

0 commit comments

Comments
 (0)