|
@@ -1,12 +1,11 @@
|
|
|
-import { StyleFn, makeStyles } from '../../utils'
|
|
|
-import { typography, colors, spacing } from './../../theme'
|
|
|
+import { makeStyles, StyleFn } from '../../utils'
|
|
|
+import { colors, spacing, typography } from './../../theme'
|
|
|
|
|
|
export type TextFieldStyleProps = {
|
|
|
disabled?: boolean
|
|
|
focus?: boolean
|
|
|
error?: boolean
|
|
|
isActive?: boolean
|
|
|
- iconPosition?: 'right' | 'left'
|
|
|
}
|
|
|
|
|
|
const FIELD_WIDTH = '250px'
|
|
@@ -52,19 +51,17 @@ const borderColor: StyleFn = (styles, { disabled, error, isActive, focus }) => {
|
|
|
borderColor,
|
|
|
}
|
|
|
}
|
|
|
-const label: StyleFn = (_, { error, iconPosition }) => ({
|
|
|
+const label: StyleFn = (_, { error }) => ({
|
|
|
color: error ? colors.error : colors.gray[400],
|
|
|
padding: `0 ${spacing.s}`,
|
|
|
backgroundColor: colors.black,
|
|
|
- [`padding-${iconPosition}`]: spacing.xxxxxl,
|
|
|
fontSize: typography.sizes.body2,
|
|
|
transition: `all 0.1s linear`,
|
|
|
})
|
|
|
-const input: StyleFn = (_, { iconPosition }) => ({
|
|
|
+const input: StyleFn = () => ({
|
|
|
display: 'none',
|
|
|
width: '100%',
|
|
|
margin: `0 ${spacing.s}`,
|
|
|
- [`margin-${iconPosition}`]: spacing.xxxxxl,
|
|
|
background: 'none',
|
|
|
border: 'none',
|
|
|
outline: 'none',
|
|
@@ -72,32 +69,18 @@ const input: StyleFn = (_, { iconPosition }) => ({
|
|
|
fontSize: typography.sizes.body2,
|
|
|
padding: `5px 0`,
|
|
|
})
|
|
|
-const icon: StyleFn = (_, { iconPosition }) => ({
|
|
|
- color: colors.gray[300],
|
|
|
- fontSize: typography.sizes.icon.xlarge,
|
|
|
- position: 'absolute',
|
|
|
- top: spacing.s,
|
|
|
- [`${iconPosition}`]: spacing.s,
|
|
|
-})
|
|
|
const helper: StyleFn = (_, { error }) => ({
|
|
|
color: error ? colors.error : colors.gray[400],
|
|
|
})
|
|
|
|
|
|
-export const useCSS = ({
|
|
|
- disabled = false,
|
|
|
- focus = false,
|
|
|
- error = false,
|
|
|
- isActive = false,
|
|
|
- iconPosition = 'right',
|
|
|
-}: TextFieldStyleProps) => {
|
|
|
- const props = { disabled, focus, error, isActive, iconPosition }
|
|
|
+export const useCSS = ({ disabled = false, focus = false, error = false, isActive = false }: TextFieldStyleProps) => {
|
|
|
+ const props = { disabled, focus, error, isActive }
|
|
|
return {
|
|
|
wrapper: makeStyles([wrapper])(props),
|
|
|
container: makeStyles([container])(props),
|
|
|
border: makeStyles([border, borderColor])(props),
|
|
|
label: makeStyles([label])(props),
|
|
|
input: makeStyles([input])(props),
|
|
|
- icon: makeStyles([icon])(props),
|
|
|
helper: makeStyles([helper])(props),
|
|
|
}
|
|
|
}
|