Skip to content

Commit 88bfbeb

Browse files
committed
fix(ui): pad song card grid to always display minimum number of columns
1 parent 45081d2 commit 88bfbeb

File tree

1 file changed

+11
-1
lines changed

1 file changed

+11
-1
lines changed

apps/frontend/src/modules/browse/components/SongCardGroup.tsx

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,17 @@
11
const SongCardGroup = ({ children }: { children: React.ReactNode }) => {
2+
// Ensure at least 4 items in the grid to prevent single cards from taking up full width
3+
const childrenArray = Array.isArray(children) ? children : [children];
4+
const itemsToDisplay = Math.max(childrenArray.length, 4);
5+
const paddedSongs = [
6+
...childrenArray,
7+
...Array.from({ length: itemsToDisplay - childrenArray.length }, (_, i) => (
8+
<div key={`placeholder-${i}`} aria-hidden='true' />
9+
)),
10+
];
11+
212
return (
313
<div className='grid grid-auto-fit-md w-full items-center gap-4'>
4-
{children}
14+
{paddedSongs}
515
</div>
616
);
717
};

0 commit comments

Comments
 (0)