|
| 1 | +import React from 'react'; |
| 2 | +import styled from 'styled-components'; |
| 3 | +import PropTypes from 'prop-types'; |
| 4 | +import Container from 'src/Components/Container'; |
| 5 | + |
| 6 | +const arrowDown = 'static/icons/arrow_solid_black.svg'; |
| 7 | + |
| 8 | +const StyledInputField = styled(Container)` |
| 9 | + appearance: none; |
| 10 | + outline: 0; |
| 11 | + flex-grow: 1; |
| 12 | + box-shadow: none; |
| 13 | + border-radius: ${props => props.theme.radius[1]}; |
| 14 | + padding: ${props => props.theme.space[2]}px; |
| 15 | + border: 1px solid ${props => props.theme.colors.secondary}; |
| 16 | +
|
| 17 | + &::placeholder { |
| 18 | + color: ${props => props.theme.colors.grey}; |
| 19 | + } |
| 20 | +
|
| 21 | + &:focus { |
| 22 | + border: 1.2px solid ${props => props.theme.colors.primary}; |
| 23 | + transition: all .3s ease-out; |
| 24 | + } |
| 25 | +
|
| 26 | + &[type="date"] { |
| 27 | + position: relative; |
| 28 | + &::-webkit-inner-spin-button { |
| 29 | + display: none; |
| 30 | + } |
| 31 | +
|
| 32 | + &::-webkit-calendar-picker-indicator { |
| 33 | + color: rgba(0, 0, 0, 0); |
| 34 | + opacity: 0; |
| 35 | + z-index: 1; |
| 36 | + cursor: pointer; |
| 37 | + } |
| 38 | +
|
| 39 | + &:after { |
| 40 | + content: ''; |
| 41 | + width: 48px; |
| 42 | + height: 100%; |
| 43 | + position: absolute; |
| 44 | + top: 0; |
| 45 | + right: 0; |
| 46 | + background-image: url(${arrowDown}); |
| 47 | + background-repeat: no-repeat; |
| 48 | + background-size: 40%; |
| 49 | + background-position: center; |
| 50 | + transform: rotate(-90deg); |
| 51 | + } |
| 52 | + } |
| 53 | +`; |
| 54 | + |
| 55 | +const StyledContainerInput = StyledInputField.withComponent('input'); |
| 56 | + |
| 57 | +const InputField = ({ |
| 58 | + id, placeholder, type, ...rest |
| 59 | +}) => ( |
| 60 | + <StyledContainerInput id={id} placeholder={placeholder} type={type} {...rest} /> |
| 61 | +); |
| 62 | + |
| 63 | +InputField.defaultProps = { |
| 64 | + placeholder: '', |
| 65 | + type: 'text', |
| 66 | + id: '', |
| 67 | +}; |
| 68 | + |
| 69 | +InputField.propTypes = { |
| 70 | + id: PropTypes.string, |
| 71 | + placeholder: PropTypes.string, |
| 72 | + type: PropTypes.oneOf(['password', 'date', 'text', 'email']), |
| 73 | +}; |
| 74 | + |
| 75 | +export default InputField; |
0 commit comments