Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
transition: '0.2s box-shadow, 0.2s border-color',
padding: spacingNumbers.xxs, // Compensate for border
margin: 0, // Fix Safari
'&::webkit-resizer': {
display: 'none',
},
'&::placeholder': {
color: inputColors.placeholder,
},
'&:focus:not([disabled])': {
borderColor: inputColors.focusBorder,
boxShadow: `inset 0 0 0 1px ${inputColors.focusBorder}`,
outline: 'none',
},
'&:disabled': {
backgroundColor: inputColors.disabled.background,
borderColor: inputColors.disabled.border,
color: inputColors.disabled.text,
'&::placeholder': {
color: inputColors.disabled.text,
},
},
},
({error}) => ({
...errorRing(error),
}),
({resize, grow}) => ({
width: grow ? '100%' : undefined,
resize: grow ? TextAreaResizeDirection.Vertical : resize,
})
);
margin: 0, // Fix Safari
'&::webkit-resizer': {
display: 'none',
},
'&::placeholder': {
color: inputColors.placeholder,
},
'&:focus:not([disabled])': {
borderColor: inputColors.focusBorder,
boxShadow: `inset 0 0 0 1px ${inputColors.focusBorder}`,
outline: 'none',
},
'&:disabled': {
backgroundColor: inputColors.disabled.background,
borderColor: inputColors.disabled.border,
color: inputColors.disabled.text,
'&::placeholder': {
color: inputColors.disabled.text,
},
},
},
({error}) => ({
...errorRing(error),
}),
({resize, grow}) => ({
width: grow ? '100%' : undefined,
resize: grow ? TextAreaResizeDirection.Vertical : resize,
})
);
export default class TextArea extends React.Component {
static ErrorType = ErrorType;
opacity: 0,
'&:not(:disabled)': {
cursor: 'pointer',
},
// States
'&:not(:checked):not(:disabled):not(:focus):hover ~ div:first-of-type': {
borderColor: inputColors.hoverBorder,
},
'&:checked ~ div:first-of-type': {
borderColor: colors.blueberry400,
backgroundColor: colors.blueberry400,
},
'&:disabled ~ div:first-of-type': {
borderColor: inputColors.disabled.border,
backgroundColor: inputColors.disabled.background,
},
'&:disabled:checked ~ div:first-of-type': {
borderColor: colors.blueberry200,
backgroundColor: colors.blueberry200,
},
// Focus
'&:focus, &:active': {
outline: 'none',
},
'&:focus ~ div:first-of-type': {
borderColor: colors.blueberry400,
borderWidth: '2px',
zIndex: 2,
boxShadow: 'none',
padding: spacingNumbers.xxs, // Compensate for border
margin: 0, // Fix Safari
'&::placeholder': {
color: inputColors.placeholder,
},
'&:hover': {
borderColor: inputColors.hoverBorder,
},
'&:focus:not([disabled])': {
borderColor: inputColors.focusBorder,
boxShadow: `inset 0 0 0 1px ${inputColors.focusBorder}`,
outline: 'none',
},
'&:disabled': {
backgroundColor: inputColors.disabled.background,
borderColor: inputColors.disabled.border,
color: inputColors.disabled.text,
'&::placeholder': {
color: inputColors.disabled.text,
},
},
},
({error}) => ({
...errorRing(error),
}),
({grow}) =>
grow && {
width: '100%',
}
);
export default class TextInput extends React.Component {
'&:not(:disabled)': {
cursor: 'pointer',
},
// States
'&:not(:checked):not(:disabled):not(:focus):hover ~ div:first-of-type': {
borderColor: inputColors.hoverBorder,
},
'&:checked ~ div:first-of-type': {
borderColor: colors.blueberry400,
backgroundColor: colors.blueberry400,
},
'&:disabled ~ div:first-of-type': {
borderColor: inputColors.disabled.border,
backgroundColor: inputColors.disabled.background,
},
'&:disabled:checked ~ div:first-of-type': {
borderColor: colors.blueberry200,
backgroundColor: colors.blueberry200,
},
// Focus
'&:focus, &:active': {
outline: 'none',
},
'&:focus ~ div:first-of-type': {
borderColor: colors.blueberry400,
borderWidth: '2px',
zIndex: 2,
boxShadow: 'none',
},
margin: 0, // Fix Safari
MozAppearance: 'none', // FF bugfix: hide arrow so it doesn't show under ours
WebkitAppearance: 'none',
'&::placeholder': {
color: inputColors.placeholder,
},
'&:hover': {
borderColor: inputColors.hoverBorder,
},
'&:focus:not([disabled])': {
borderColor: inputColors.focusBorder,
boxShadow: `inset 0 0 0 1px ${inputColors.focusBorder}`,
outline: 'none',
},
'&:disabled': {
backgroundColor: inputColors.disabled.background,
borderColor: inputColors.disabled.border,
color: inputColors.disabled.text,
'&::placeholder': {
color: inputColors.disabled.text,
},
},
},
({error}) => ({
...errorRing(error),
}),
({grow}) =>
grow && {
width: '100%',
}
);
WebkitAppearance: 'none',
'&::placeholder': {
color: inputColors.placeholder,
},
'&:hover': {
borderColor: inputColors.hoverBorder,
},
'&:focus:not([disabled])': {
borderColor: inputColors.focusBorder,
boxShadow: `inset 0 0 0 1px ${inputColors.focusBorder}`,
outline: 'none',
},
'&:disabled': {
backgroundColor: inputColors.disabled.background,
borderColor: inputColors.disabled.border,
color: inputColors.disabled.text,
'&::placeholder': {
color: inputColors.disabled.text,
},
},
},
({error}) => ({
...errorRing(error),
}),
({grow}) =>
grow && {
width: '100%',
}
);
const SelectDropdownIcon = styled(SystemIcon)({
position: 'absolute',
({checked, disabled}) => ({
borderColor: checked
? colors.blueberry400
: disabled
? inputColors.disabled.border
: inputColors.border,
backgroundColor: checked
? colors.blueberry400
: disabled
? inputColors.disabled.background
: 'white',
})
);
({disabled}) => ({
color: disabled ? inputColors.disabled.text : undefined,
})
);
({disabled}) => (disabled ? {color: inputColors.disabled.text} : {cursor: 'pointer'})
);