diff --git a/src/components/GalleyGrid/index.tsx b/src/components/GalleyGrid/index.tsx index dd0cd3eac3d6..f8c9d03ff1cb 100644 --- a/src/components/GalleyGrid/index.tsx +++ b/src/components/GalleyGrid/index.tsx @@ -21,7 +21,7 @@ const GalleyGrid = memo(({ items, renderItem: Render }) => { }; } - const firstCol = items.length % 3 === 0 ? 3 : items.length % 3; + const firstCol = items.length > 4 ? 3 : items.length; return { firstRow: items.slice(0, firstCol), @@ -29,13 +29,16 @@ const GalleyGrid = memo(({ items, renderItem: Render }) => { }; }, [items]); - const { gap, max } = useMemo( - () => ({ + const { gap, max } = useMemo(() => { + let scale = firstRow.length * (firstRow.length / items.length); + + scale = scale < 1 ? 1 : scale; + + return { gap: mobile ? 4 : 6, - max: (mobile ? MAX_SIZE_MOBILE : MAX_SIZE_DESKTOP) * firstRow.length, - }), - [mobile], - ); + max: (mobile ? MAX_SIZE_MOBILE : MAX_SIZE_DESKTOP) * scale, + }; + }, [mobile, items]); return ( @@ -45,7 +48,7 @@ const GalleyGrid = memo(({ items, renderItem: Render }) => { ))} {lastRow.length > 0 && ( - 2 ? 3 : lastRow.length} gap={gap} max={max}> + {lastRow.map((i, index) => ( ))}