From cbb31ee1fdab16930a4f2007b288f0a13df873a4 Mon Sep 17 00:00:00 2001 From: Rory Bourdon Date: Wed, 2 Aug 2023 20:43:15 -0400 Subject: [PATCH] Fix key error for skills with less than 3 projects --- components/Projects/ProjectsScroller.js | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) diff --git a/components/Projects/ProjectsScroller.js b/components/Projects/ProjectsScroller.js index 8f16a14..c7418ba 100644 --- a/components/Projects/ProjectsScroller.js +++ b/components/Projects/ProjectsScroller.js @@ -121,13 +121,26 @@ export default function ProjectScroller({ projects, bgColor, primaryColor }) { onPanStart={handlePanStart} onPan={handlePan} onPanEnd={handlePanEnd} - style={{ cursor: panning ? "grabbing" : "grab" }} + style={{ + cursor: panning ? "grabbing" : "grab", + gridTemplateColumns: `repeat(${Math.min( + 3, + projects.length + )}, 340px)`, + }} > {[ - ...projects.slice(rollerPos, rollerPos + 3), + ...projects.slice( + rollerPos, + rollerPos + Math.min(3, projects.length) + ), ...projects.slice( 0, - 3 - projects.slice(rollerPos, rollerPos + 3).length + Math.min(3, projects.length) - + projects.slice( + rollerPos, + rollerPos + Math.min(3, projects.length) + ).length ), ].map((project, index) => { return (