| 1 |
import classNames from 'classnames'; |
| 2 |
|
| 3 |
export const CheckboxInput = ({ |
| 4 |
label, |
| 5 |
slug, |
| 6 |
checked, |
| 7 |
onChange, |
| 8 |
locked = false, |
| 9 |
}) => { |
| 10 |
return ( |
| 11 |
<label |
| 12 |
className={classNames( |
| 13 |
'flex items-center px-4 py-3 text-base leading-none', |
| 14 |
{ |
| 15 |
'focus-within:text-design-main hover:text-design-main': !locked, |
| 16 |
}, |
| 17 |
)} |
| 18 |
htmlFor={slug} |
| 19 |
> |
| 20 |
<span className="flex mr-3 relative rtl:ml-3 rtl:mr-0"> |
| 21 |
<input |
| 22 |
id={slug} |
| 23 |
className={classNames( |
| 24 |
'm-0 border rounded-xs before:content-none shadow-none', |
| 25 |
{ |
| 26 |
'border-gray-300': !checked || locked, |
| 27 |
'bg-design-main border-design-main': checked && !locked, |
| 28 |
}, |
| 29 |
)} |
| 30 |
style={{ |
| 31 |
'--color-design-main': locked ? '#BBBBBB' : undefined, |
| 32 |
}} |
| 33 |
disabled={locked} |
| 34 |
type="checkbox" |
| 35 |
onChange={locked ? undefined : onChange} |
| 36 |
checked={locked ? true : checked} |
| 37 |
/> |
| 38 |
<svg |
| 39 |
className={classNames('absolute inset-0 block -mt-px', { |
| 40 |
'text-white': checked, |
| 41 |
'text-transparent': !checked, |
| 42 |
})} |
| 43 |
viewBox="1 0 20 20" |
| 44 |
fill="none" |
| 45 |
xmlns="http://www.w3.org/2000/svg" |
| 46 |
role="presentation" |
| 47 |
> |
| 48 |
<path |
| 49 |
d="M8.72912 13.7449L5.77536 10.7911L4.76953 11.7899L8.72912 15.7495L17.2291 7.24948L16.2304 6.25073L8.72912 13.7449Z" |
| 50 |
fill="currentColor" |
| 51 |
/> |
| 52 |
</svg> |
| 53 |
</span> |
| 54 |
<span className="flex grow flex-col overflow-hidden"> |
| 55 |
<span className="truncate text-base font-medium leading-tight"> |
| 56 |
{label} |
| 57 |
</span> |
| 58 |
</span> |
| 59 |
</label> |
| 60 |
); |
| 61 |
}; |
| 62 |
|