-
Notifications
You must be signed in to change notification settings - Fork 18
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
Showing
9 changed files
with
149 additions
and
84 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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,95 +1,91 @@ | ||
import PropTypes from 'prop-types'; | ||
import styled, { css } from 'styled-components'; | ||
import Colors from '../../Colors'; | ||
import { spacing } from '../../shared/theme'; | ||
import styled from 'styled-components'; | ||
import { spacing, colors } from '../../shared/theme'; | ||
import { shadow } from '../../shared'; | ||
|
||
const TextInput = styled.input.attrs({ | ||
type: 'text', | ||
})` | ||
box-sizing: border-box; | ||
${({ | ||
hasIcon, | ||
theme: { | ||
spacing: { xsmall, small, xxlarge }, | ||
}, | ||
}) => ` | ||
margin-top: ${xsmall}px; | ||
padding: ${small}px; | ||
${hasIcon && `padding-right: ${xxlarge}px;`} | ||
&::-webkit-inner-spin-button, | ||
&::-webkit-outer-spin-button { | ||
-webkit-appearance: none; | ||
margin: 0; | ||
} | ||
`} | ||
background-color: ${Colors.WHITE}; | ||
border-radius: 4px; | ||
border: 1.5px solid ${Colors.BLACK['400']}; | ||
box-sizing: border-box; | ||
color: ${Colors.BLACK['700']}; | ||
box-sizing: border-box; | ||
font-size: initial; | ||
height: 44px; | ||
min-height: 44px; | ||
letter-spacing: 0.2px; | ||
min-height: 44px; | ||
outline: none; | ||
transition: all 0.2s ease-in-out; | ||
width: 100%; | ||
:hover, | ||
:focus { | ||
border-color: ${Colors.BLUE['500']}; | ||
box-shadow: 0 2px 6px 0 ${Colors.BLUE['50']}; | ||
&::-webkit-inner-spin-button, | ||
&::-webkit-outer-spin-button { | ||
-webkit-appearance: none; | ||
margin: 0; | ||
} | ||
${({ error }) => | ||
error && | ||
css` | ||
border-color: ${Colors.ERROR['500']}; | ||
&::-webkit-calendar-picker-indicator { | ||
display: none; | ||
} | ||
:hover, | ||
:focus { | ||
border-color: ${Colors.ERROR['500']}; | ||
box-shadow: 0 2px 6px 0 ${Colors.ERROR['500']}; | ||
} | ||
`}; | ||
${({ error, placeholder, defaultValue, value, hasIcon, theme }) => { | ||
const { | ||
colors: { | ||
primary: { 500: primaryColor }, | ||
error: { 100: error100, 500: error500 }, | ||
neutral: { | ||
100: neutral100, | ||
300: neutral300, | ||
500: neutral500, | ||
700: neutral700, | ||
}, | ||
}, | ||
spacing: { xsmall, small, xxlarge }, | ||
} = theme; | ||
&[disabled] { | ||
background-color: ${Colors.BLACK['100']}; | ||
border-color: ${Colors.BLACK['400']}; | ||
box-shadow: none; | ||
color: ${Colors.BLACK['400']}; | ||
cursor: not-allowed; | ||
} | ||
const mainColor = error ? error500 : primaryColor; | ||
${({ placeholder, defaultValue, value }) => | ||
placeholder && | ||
!defaultValue && | ||
!value && | ||
` | ||
color: ${Colors.BLACK['400']}; | ||
`} | ||
return ` | ||
background-color: ${neutral100}; | ||
border: 2px solid ${neutral500}; | ||
color: ${neutral700}; | ||
margin-top: ${xsmall}px; | ||
padding: ${small}px; | ||
&::-webkit-calendar-picker-indicator { | ||
display: none; | ||
} | ||
${hasIcon ? `padding-right: ${xxlarge}px;` : ''} | ||
${error ? `border-color: ${mainColor};` : ''} | ||
${placeholder && !defaultValue && !value ? `color: ${neutral500};` : ''} | ||
:-webkit-autofill { | ||
box-shadow: 0 0 0px 1000px ${Colors.BLUE['200']} inset; | ||
} | ||
:hover, :focus { | ||
border-color: ${mainColor}; | ||
${shadow(5, mainColor)({ theme })} | ||
} | ||
&[disabled] { | ||
background-color: ${neutral300}; | ||
border-color: ${neutral500}; | ||
box-shadow: none; | ||
color: ${neutral500}; | ||
cursor: not-allowed; | ||
} | ||
:-webkit-autofill { | ||
box-shadow: 0 0 0px 1000px ${error100} inset; | ||
} | ||
`; | ||
}} | ||
`; | ||
|
||
TextInput.displayName = 'TextInput'; | ||
|
||
TextInput.propTypes = { | ||
theme: PropTypes.shape({ | ||
spacing: PropTypes.object, | ||
colors: PropTypes.object, | ||
}), | ||
}; | ||
|
||
TextInput.defaultProps = { | ||
theme: { spacing }, | ||
theme: { spacing, colors }, | ||
}; | ||
|
||
export default TextInput; |
Oops, something went wrong.