2021-09-24 05:24:17 -07:00
|
|
|
import React from 'react'
|
|
|
|
import { CheckIcon } from '@heroicons/react/solid'
|
|
|
|
|
2021-10-11 11:02:20 -07:00
|
|
|
const Checkbox = ({ checked, children, disabled = false, ...props }) => (
|
2021-11-04 05:25:11 -07:00
|
|
|
<label className="cursor-pointer flex items-center text-th-fgd-3">
|
2021-10-26 11:58:49 -07:00
|
|
|
<input
|
2021-10-11 11:02:20 -07:00
|
|
|
checked={checked}
|
|
|
|
{...props}
|
|
|
|
disabled={disabled}
|
|
|
|
type="checkbox"
|
2021-10-26 11:58:49 -07:00
|
|
|
style={{
|
|
|
|
border: '0',
|
|
|
|
clip: 'rect(0 0 0 0)',
|
|
|
|
clipPath: 'inset(50%)',
|
|
|
|
height: '1px',
|
|
|
|
margin: '-1px',
|
|
|
|
overflow: 'hidden',
|
|
|
|
padding: '0',
|
|
|
|
position: 'absolute',
|
|
|
|
whiteSpace: 'nowrap',
|
|
|
|
width: '1px',
|
|
|
|
}}
|
2021-10-11 11:02:20 -07:00
|
|
|
/>
|
2021-09-24 05:24:17 -07:00
|
|
|
<div
|
|
|
|
className={`${
|
2021-10-11 11:02:20 -07:00
|
|
|
checked && !disabled ? 'border-th-primary' : 'border-th-fgd-4'
|
2021-09-25 05:41:04 -07:00
|
|
|
} border cursor-pointer default-transition flex items-center justify-center rounded h-4 w-4`}
|
2021-09-24 05:24:17 -07:00
|
|
|
>
|
|
|
|
<CheckIcon
|
2021-10-11 11:02:20 -07:00
|
|
|
className={`${checked ? 'block' : 'hidden'} h-4 w-4 ${
|
|
|
|
disabled ? 'text-th-fgd-4' : 'text-th-primary'
|
|
|
|
}`}
|
2021-09-24 05:24:17 -07:00
|
|
|
/>
|
|
|
|
</div>
|
2021-10-31 04:21:22 -07:00
|
|
|
<span className="ml-2 text-xs">{children}</span>
|
2021-09-26 06:20:51 -07:00
|
|
|
</label>
|
2021-09-24 05:24:17 -07:00
|
|
|
)
|
|
|
|
|
|
|
|
export default Checkbox
|