Skip to content

Commit

Permalink
feat(core/presentation): Add "success" type to ValidationMessage (#7082)
Browse files Browse the repository at this point in the history
  • Loading branch information
christopherthielen committed Jun 4, 2019
1 parent 4e89a39 commit f89d97d
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 6 deletions.
7 changes: 7 additions & 0 deletions app/scripts/modules/core/src/presentation/main.less
Original file line number Diff line number Diff line change
Expand Up @@ -888,6 +888,13 @@ select:invalid {
color: var(--color-danger);
}

.success-message {
text-align: left;
display: block;
font-weight: 600;
color: var(--color-success);
}

.warning-message {
text-align: left;
display: block;
Expand Down
28 changes: 22 additions & 6 deletions app/scripts/modules/core/src/validation/ValidationMessage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,27 @@ import * as React from 'react';

export interface IValidationMessageProps {
message: React.ReactNode;
type: 'error' | 'warning' | 'message';
type: 'success' | 'error' | 'warning' | 'message' | 'none';
// default: true
showIcon?: boolean;
}

export const ValidationMessage = (props: IValidationMessageProps) => (
<div className={`${props.type}-message`}>
<span className="fa fa-exclamation-circle" /> {props.message}
</div>
);
const iconClassName = {
success: 'far fa-check-circle',
error: 'fa fa-exclamation-circle',
warning: 'fa fa-exclamation-circle',
message: 'icon-view-1',
none: '',
};

export const ValidationMessage = (props: IValidationMessageProps) => {
const divClassName = `${props.type}-message`;
const showIcon = props.showIcon === undefined ? true : props.showIcon;
const spanClassName = (showIcon && iconClassName[props.type]) || '';

return (
<div className={divClassName}>
<span className={spanClassName} /> {props.message}
</div>
);
};

0 comments on commit f89d97d

Please sign in to comment.