Advertisement
Guest User

Untitled

a guest
Mar 21st, 2019
69
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.96 KB | None | 0 0
  1. export const Search = React.forwardRef((props, ref) => {
  2. const [isFocused, setFocus] = useState(false);
  3. const [isHovered, setHover] = useState(false);
  4.  
  5. return (
  6. <InputContainer
  7. onMouseEnter={() => setHover(true)}
  8. onMouseLeave={() => setHover(false)}
  9. >
  10. <StyledInput
  11. onFocus={() => setFocus(true)}
  12. onBlur={() => setFocus(false)}
  13. isHovered={isHovered}
  14. ref={ref}
  15. {...props}
  16. />
  17. {isFocused && !props.value && (
  18. <StyledMagnifyingGlass
  19. isHovered={isHovered}
  20. isFocused={isFocused}
  21. onClick={props.onSearch}
  22. />
  23. )}
  24. {isFocused && props.value && (
  25. <StyledCloseCircle onClick={() => console.log("THIS DOES NOT FIRE")} />
  26. )}
  27. {!isFocused && (
  28. <StyledMagnifyingGlass
  29. isHovered={isHovered}
  30. isFocused={isFocused}
  31. onClick={props.onSearch}
  32. />
  33. )}
  34. </InputContainer>
  35. );
  36. });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement