-
Notifications
You must be signed in to change notification settings - Fork 900
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(core/presentation): Migrate ValidationMessage to new CSS styles (#…
…7481) mockups of new styles from here: https://gallery.io/projects/MCHbtQVoQ2HCZcM1NWkzJjWA/files/MCGOQ33-FuyCnqx3ZnbHf9sO
- Loading branch information
1 parent
523c6bb
commit 3c08b38
Showing
8 changed files
with
115 additions
and
116 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
42 changes: 42 additions & 0 deletions
42
app/scripts/modules/core/src/validation/ValidationMessage.less
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
.ValidationMessage { | ||
min-height: 40px; | ||
display: flex; | ||
margin-bottom: 2px; | ||
|
||
&.errorMessage { | ||
color: var(--color-validation-error); | ||
background-color: var(--color-validation-error-light); | ||
} | ||
|
||
&.infoMessage { | ||
color: var(--color-validation-info); | ||
background-color: var(--color-validation-info-light); | ||
} | ||
|
||
&.previewMessage { | ||
color: var(--color-validation-info); | ||
background-color: var(--color-validation-info-light); | ||
} | ||
|
||
&.successMessage { | ||
color: var(--color-validation-success); | ||
background-color: var(--color-validation-success-light); | ||
} | ||
|
||
&.warningMessage { | ||
color: var(--color-validation-black); | ||
background-color: var(--color-validation-warning-light); | ||
} | ||
|
||
i { | ||
flex: 0 0 40px; | ||
height: 40px; | ||
font-size: 24px; | ||
padding: 7px; | ||
} | ||
|
||
.message { | ||
margin: 8px 8px 8px 0; | ||
align-self: center; | ||
} | ||
} |
54 changes: 37 additions & 17 deletions
54
app/scripts/modules/core/src/validation/ValidationMessage.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,30 +1,50 @@ | ||
import * as React from 'react'; | ||
import { IValidationCategory } from '../presentation/forms/validation'; | ||
import { ICategorizedErrors, IValidationCategory } from '../presentation/forms/validation'; | ||
|
||
export interface IValidationMessageProps { | ||
message: React.ReactNode; | ||
type: IValidationCategory | undefined; | ||
// default: true | ||
showIcon?: boolean; | ||
} | ||
import './ValidationMessage.less'; | ||
|
||
const iconClassName = { | ||
success: 'far fa-check-circle', | ||
const containerClassNames: ICategorizedErrors = { | ||
async: 'infoMessage', | ||
error: 'errorMessage', | ||
info: 'infoMessage', | ||
message: 'infoMessage', | ||
success: 'successMessage', | ||
warning: 'warningMessage', | ||
}; | ||
|
||
const iconClassNames: ICategorizedErrors = { | ||
async: 'fa fa-spinner fa-spin', | ||
error: 'fa fa-exclamation-circle', | ||
warning: 'fa fa-exclamation-circle', | ||
info: 'fa fa-info-circle', | ||
message: 'icon-view-1', | ||
async: 'fa fa-spinner fa-spin', | ||
none: '', | ||
success: 'far fa-check-circle', | ||
warning: 'fa icon-alert-triangle', | ||
}; | ||
|
||
export interface IValidationMessageProps { | ||
message: React.ReactNode; | ||
type: IValidationCategory | undefined; | ||
/** | ||
* The (optional) class name to apply to the icon. | ||
* If none is provided, the icon is determined by the value of category. | ||
* If false to provided, no icon will be rendered | ||
*/ | ||
iconClassName?: string | false; | ||
/** | ||
* The (optional) class name to apply to the ValidationMessage. | ||
* If none is provided, the class is determined by the value of category. | ||
*/ | ||
containerClassName?: string; | ||
} | ||
|
||
export const ValidationMessage = (props: IValidationMessageProps) => { | ||
const divClassName = `${props.type}-message`; | ||
const showIcon = props.showIcon === undefined ? true : props.showIcon; | ||
const spanClassName = (showIcon && iconClassName[props.type]) || ''; | ||
const { type, message, iconClassName, containerClassName } = props; | ||
const showIcon = iconClassName !== false; | ||
|
||
return ( | ||
<div className={divClassName}> | ||
<span className={spanClassName} /> {props.message} | ||
<div className={`ValidationMessage ${containerClassName || containerClassNames[type] || ''}`}> | ||
{showIcon && <i className={iconClassName || iconClassNames[type] || ''} />} | ||
<div className="message">{message}</div> | ||
</div> | ||
); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters