-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
aca7b0a
commit c736e6e
Showing
11 changed files
with
390 additions
and
86 deletions.
There are no files selected for viewing
57 changes: 37 additions & 20 deletions
57
src/components/field-validation-message/FieldValidationMessage.js
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,31 +1,48 @@ | ||
import React from "react"; | ||
import PropTypes from "prop-types"; | ||
|
||
import { Form, Label } from "semantic-ui-react"; | ||
import { Form, Label, Icon } from "semantic-ui-react"; | ||
|
||
import { Component as Responsive } from "src/components/responsive"; | ||
|
||
import "./fieldValidationMessage.css"; | ||
|
||
export const FieldValidationMessage = ({ message }) => ( | ||
<React.Fragment> | ||
<Responsive device="desktop"> | ||
<Form.Field className="form__field-validation__container"> | ||
<Label basic color="red" pointing="left"> | ||
{message} | ||
</Label> | ||
</Form.Field> | ||
</Responsive> | ||
<Responsive device="mobile"> | ||
<Form.Field className="form__field-validation__container--mobile"> | ||
<Label basic color="red" pointing> | ||
{message} | ||
</Label> | ||
</Form.Field> | ||
</Responsive> | ||
</React.Fragment> | ||
); | ||
const ErrorLabel = ({ message, pointing }) => { | ||
return ( | ||
<Label basic color="red" pointing={pointing}> | ||
{message} | ||
</Label> | ||
); | ||
}; | ||
|
||
ErrorLabel.propTypes = { | ||
message: PropTypes.string, | ||
pointing: PropTypes.any | ||
}; | ||
|
||
const ValidLabel = () => { | ||
return <Icon name="thumbs up" color="green" />; | ||
}; | ||
|
||
export const FieldValidationMessage = ({ message, valid }) => { | ||
const Message = !valid ? ErrorLabel : ValidLabel; | ||
return ( | ||
<React.Fragment> | ||
<Responsive device="desktop"> | ||
<Form.Field className="form__field-validation__container"> | ||
<Message pointing="left" message={message} /> | ||
</Form.Field> | ||
</Responsive> | ||
<Responsive device="mobile"> | ||
<Form.Field className="form__field-validation__container--mobile"> | ||
{!valid ? <Message pointing message={message} /> : null} | ||
</Form.Field> | ||
</Responsive> | ||
</React.Fragment> | ||
); | ||
}; | ||
|
||
FieldValidationMessage.propTypes = { | ||
message: PropTypes.string | ||
message: PropTypes.string, | ||
valid: PropTypes.bool | ||
}; |
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
Oops, something went wrong.