({
value,
onValueChange,
})
| 9 | } |
| 10 | |
| 11 | const SizeSelector: React.FC<SizeSelectorProps> = ({ |
| 12 | value, |
| 13 | onValueChange, |
| 14 | }) => { |
| 15 | const [open, setOpen] = useState(false) |
| 16 | |
| 17 | const handleOpen = () => { |
| 18 | setOpen(true) |
| 19 | } |
| 20 | const handleClose = () => { |
| 21 | setOpen(false) |
| 22 | } |
| 23 | return ( |
| 24 | <div className="relative inline-block text-left"> |
| 25 | <div> |
| 26 | <button |
| 27 | type="button" |
| 28 | onClick={() => handleOpen()} |
| 29 | className="inline-flex w-full mt-0 justify-center gap-x-1.5 rounded-md bg-white px-3 py-[1.12rem] text-sm font-semibold text-gray-700 shadow-sm ring-1 ring-inset ring-gray-300 hover:bg-gray-50" |
| 30 | > |
| 31 | {value} |
| 32 | <svg |
| 33 | className="-mr-1 h-5 w-5 text-gray-400" |
| 34 | viewBox="0 0 20 20" |
| 35 | fill="currentColor" |
| 36 | aria-hidden="true" |
| 37 | > |
| 38 | <path |
| 39 | fillRule="evenodd" |
| 40 | d="M5.23 7.21a.75.75 0 011.06.02L10 11.168l3.71-3.938a.75.75 0 111.08 1.04l-4.25 4.5a.75.75 0 01-1.08 0l-4.25-4.5a.75.75 0 01.02-1.06z" |
| 41 | clipRule="evenodd" |
| 42 | /> |
| 43 | </svg> |
| 44 | </button> |
| 45 | </div> |
| 46 | <div |
| 47 | className={`${ |
| 48 | open ? 'block' : 'hidden' |
| 49 | } absolute right-0 z-10 mt-2 w-56 origin-top-right rounded-md bg-white shadow-lg ring-1 ring-black ring-opacity-5 focus:outline-none transition ease-out duration-300`} |
| 50 | > |
| 51 | <ul className="py-1" role="none"> |
| 52 | {IMAGE_SIZES.map((size) => ( |
| 53 | <li |
| 54 | key={size.value} |
| 55 | className={`${ |
| 56 | value === size.value |
| 57 | ? 'bg-gray-100 text-gray-900' |
| 58 | : 'text-gray-700 ' |
| 59 | } block px-4 py-2 text-sm cursor-pointer`} |
| 60 | onClick={() => { |
| 61 | onValueChange(size.value) |
| 62 | handleClose() |
| 63 | }} |
| 64 | > |
| 65 | {size.label} |
| 66 | </li> |
| 67 | ))} |
| 68 | </ul> |
nothing calls this directly
no test coverage detected