Skip to content

Commit

Permalink
feat: add field FCheckbox
Browse files Browse the repository at this point in the history
  • Loading branch information
masb0ymas committed May 28, 2021
1 parent 68978c4 commit 09fd472
Showing 1 changed file with 35 additions and 0 deletions.
35 changes: 35 additions & 0 deletions src/@nexys/fields/FCheckbox/FCheckbox.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
/* eslint-disable react/destructuring-assignment */
import React from 'react'
import { Checkbox } from 'antd'
import { CheckboxProps } from 'antd/lib/checkbox'
import { FormikContextType, useField } from 'formik'
import useTitleAndError, {
UseTitleAndErrorProps,
} from '@nexys/fields/useTitleAndError/useTitleAndError'
import Text from '@nexys/components/Typography/Text'

export type FCheckboxProps = CheckboxProps &
UseTitleAndErrorProps & {
/**
* Formik Context
*/
formik?: FormikContextType<any>
}

function FCheckbox(props: FCheckboxProps) {
const [field] = useField(props as any)
const [, error] = useTitleAndError(props)

return (
<React.Fragment>
<Checkbox {...field} {...props}>
<Text style={{ lineHeight: '30px', fontWeight: 'bold' }}>
{props.title}
</Text>
</Checkbox>
{error}
</React.Fragment>
)
}

export default FCheckbox

0 comments on commit 09fd472

Please sign in to comment.