Guest User

Untitled

a guest
Mar 21st, 2018
90
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.25 KB | None | 0 0
  1. import React from 'react';
  2.  
  3. const InputItem = ({ spec, input, meta: { touched, error } }) => {
  4.  
  5. const successIconRight = {
  6. color: '#2ecc71'
  7. };
  8.  
  9. const errorIconRight = {
  10. color: '#e74c3c'
  11. };
  12.  
  13. const { label, type, placeholder, iconLeft, iconRight } = spec;
  14.  
  15. const renderIcon = () => {
  16. console.log(touched, error);
  17.  
  18. if (touched && error != undefined) {
  19. return <i className={iconRight} style={errorIconRight} />
  20. } else if (touched && (error === undefined)) {
  21. return <i className={iconRight} style={successIconRight} />
  22. }
  23.  
  24. }
  25.  
  26. return (
  27. <div className="field">
  28. {label && <label className="label">{label}</label>}
  29. <p className="control has-icons-left has-icons-right">
  30. <input
  31. {...input}
  32. className="input"
  33. type={type}
  34. placeholder={placeholder}
  35. />
  36. <span className="icon is-small is-left">
  37. <i className={iconLeft} />
  38. </span>
  39. <span className="icon is-small is-right">
  40. {(touched && error && <i className={iconRight} style={errorIconRight} />) || (touched && <i className={iconRight} style={successIconRight} />) }
  41. {/* { renderIcon() } */}
  42. </span>
  43. </p>
  44. </div>
  45. );
  46. };
  47.  
  48. export default InputItem;
Add Comment
Please, Sign In to add comment