({
checked,
defaultChecked,
onChange,
title,
description,
className,
image,
...others
}: ImageCheckboxProps & ElementProps<'div', keyof ImageCheckboxProps>)
| 13 | } |
| 14 | |
| 15 | export function ImageCheckbox({ |
| 16 | checked, |
| 17 | defaultChecked, |
| 18 | onChange, |
| 19 | title, |
| 20 | description, |
| 21 | className, |
| 22 | image, |
| 23 | ...others |
| 24 | }: ImageCheckboxProps & ElementProps<'div', keyof ImageCheckboxProps>) { |
| 25 | const [value, handleChange] = useUncontrolled({ |
| 26 | value: checked, |
| 27 | defaultValue: defaultChecked, |
| 28 | finalValue: false, |
| 29 | onChange, |
| 30 | }); |
| 31 | |
| 32 | return ( |
| 33 | <UnstyledButton |
| 34 | {...others} |
| 35 | onClick={() => handleChange(!value)} |
| 36 | data-checked={value || undefined} |
| 37 | className={classes.button} |
| 38 | component="div" |
| 39 | > |
| 40 | <Image src={image} alt={title} w={40} h={40} /> |
| 41 | |
| 42 | <div className={classes.body}> |
| 43 | <Text c="dimmed" size="xs" lh={1} mb={5}> |
| 44 | {description} |
| 45 | </Text> |
| 46 | <Text fw={500} size="sm" lh={1}> |
| 47 | {title} |
| 48 | </Text> |
| 49 | </div> |
| 50 | |
| 51 | <Checkbox |
| 52 | checked={value} |
| 53 | onChange={() => {}} |
| 54 | tabIndex={-1} |
| 55 | styles={{ input: { cursor: 'pointer' } }} |
| 56 | aria-label={title} |
| 57 | /> |
| 58 | </UnstyledButton> |
| 59 | ); |
| 60 | } |
| 61 | |
| 62 | const mockdata = [ |
| 63 | { description: 'Sun and sea', title: 'Beach vacation', image: icons.sea }, |
nothing calls this directly
no test coverage detected