Prevent colour index from escaping the bounds of the palette

This commit is contained in:
Benji Grant 2023-06-14 13:09:32 +10:00
parent 08f6646339
commit 597fbddee8

View file

@ -74,7 +74,7 @@ const AvailabilityViewer = ({ times, people, table }: AvailabilityViewerProps) =
if (tempFocus) {
peopleHere = peopleHere.filter(p => p === tempFocus)
}
const color = palette[tempFocus && peopleHere.length ? max : peopleHere.length - min]
const color = palette[(tempFocus && peopleHere.length) ? Math.min(max, palette.length - 1) : Math.max(peopleHere.length - min, 0)]
return <div
key={y}