only show delete icon if big enough

This commit is contained in:
Mary Hipp 2023-07-05 10:47:20 -04:00 committed by psychedelicious
parent 405054d802
commit 984121d682

View File

@ -23,9 +23,11 @@ export const makeSelector = (image_name: string) =>
({ gallery }) => { ({ gallery }) => {
const isSelected = gallery.selection.includes(image_name); const isSelected = gallery.selection.includes(image_name);
const selectionCount = gallery.selection.length; const selectionCount = gallery.selection.length;
const galleryImageMinimumWidth = gallery.galleryImageMinimumWidth;
return { return {
isSelected, isSelected,
selectionCount, selectionCount,
galleryImageMinimumWidth,
}; };
}, },
defaultSelectorOptions defaultSelectorOptions
@ -44,7 +46,8 @@ const GalleryImage = (props: HoverableImageProps) => {
const localSelector = useMemo(() => makeSelector(image_name), [image_name]); const localSelector = useMemo(() => makeSelector(image_name), [image_name]);
const { isSelected, selectionCount } = useAppSelector(localSelector); const { isSelected, selectionCount, galleryImageMinimumWidth } =
useAppSelector(localSelector);
const dispatch = useAppDispatch(); const dispatch = useAppDispatch();
@ -113,7 +116,9 @@ const GalleryImage = (props: HoverableImageProps) => {
draggableData={draggableData} draggableData={draggableData}
isSelected={isSelected} isSelected={isSelected}
minSize={0} minSize={0}
onClickReset={handleDelete} onClickReset={
galleryImageMinimumWidth > 60 ? handleDelete : undefined
}
resetIcon={<FaTrash />} resetIcon={<FaTrash />}
resetTooltip="Delete image" resetTooltip="Delete image"
imageSx={{ w: 'full', h: 'full' }} imageSx={{ w: 'full', h: 'full' }}