feat(system): add label to Input component
This commit is contained in:
parent
d428554d94
commit
db47a0aeb0
|
@ -1,6 +1,7 @@
|
||||||
import React, { forwardRef } from 'react'
|
import React, { forwardRef } from 'react'
|
||||||
|
|
||||||
import { Box } from '../box'
|
import { Box } from '../box'
|
||||||
|
import { Text } from '../text'
|
||||||
import { Base } from './styles'
|
import { Base } from './styles'
|
||||||
|
|
||||||
import type { Ref } from 'react'
|
import type { Ref } from 'react'
|
||||||
|
@ -10,11 +11,13 @@ type InputProps = React.InputHTMLAttributes<HTMLInputElement>
|
||||||
interface Props {
|
interface Props {
|
||||||
id?: string
|
id?: string
|
||||||
name?: string
|
name?: string
|
||||||
|
label?: string
|
||||||
type?: InputProps['type']
|
type?: InputProps['type']
|
||||||
value?: string
|
value?: string
|
||||||
defaultValue?: string
|
defaultValue?: string
|
||||||
onChange?: InputProps['onChange']
|
onChange?: InputProps['onChange']
|
||||||
onBlur?: InputProps['onBlur']
|
onBlur?: InputProps['onBlur']
|
||||||
|
onClick?: InputProps['onClick']
|
||||||
disabled?: boolean
|
disabled?: boolean
|
||||||
readOnly?: boolean
|
readOnly?: boolean
|
||||||
required?: boolean
|
required?: boolean
|
||||||
|
@ -28,9 +31,16 @@ interface Props {
|
||||||
}
|
}
|
||||||
|
|
||||||
const TextInput = (props: Props, ref: Ref<HTMLInputElement>) => {
|
const TextInput = (props: Props, ref: Ref<HTMLInputElement>) => {
|
||||||
|
const { label, ...inputProps } = props
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Box>
|
<Box>
|
||||||
<Base ref={ref} {...props} />
|
{label && (
|
||||||
|
<Text size={13} weight={500} css={{ marginBottom: 6 }}>
|
||||||
|
{label}
|
||||||
|
</Text>
|
||||||
|
)}
|
||||||
|
<Base ref={ref} {...inputProps} />
|
||||||
</Box>
|
</Box>
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue