From 0858738b5bac9d7e9ed463730d822161f1f1d121 Mon Sep 17 00:00:00 2001 From: Guarotav <163146825+Guarotav@users.noreply.github.com> Date: Mon, 23 Jun 2025 13:08:32 -0400 Subject: [PATCH 1/2] Update index.html --- public/index.html | 40 ++++++++++++++++++++++++++++++++++++++-- 1 file changed, 38 insertions(+), 2 deletions(-) diff --git a/public/index.html b/public/index.html index ec54be0..62dbf42 100644 --- a/public/index.html +++ b/public/index.html @@ -3,10 +3,46 @@ - React Mini + Grid Maker + -
+ +
+

Grid Maker

+ + + + + + + + + + + + + + + + + + +
+
+ + + + + + + + +
+
From ce2a00361b52dd41462b742ea63ed636d5615209 Mon Sep 17 00:00:00 2001 From: Dagostocsc Date: Mon, 23 Jun 2025 13:44:12 -0700 Subject: [PATCH 2/2] I hope it's okay --- src/app.jsx | 39 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 39 insertions(+) diff --git a/src/app.jsx b/src/app.jsx index 1eebc0c..f2d0a78 100644 --- a/src/app.jsx +++ b/src/app.jsx @@ -12,3 +12,42 @@ const App = () => { const root = createRoot(document.getElementById("root")); root.render(); + +const addRow = () => { + setNumRows(prevNumRows => { + const newNumRows = prevNumRows + 1; + const newRow = Array(numCols).fill('white'); + setGrid(prevGrid => [...prevGrid, newRow]); + return newNumRows; + }); + }; + + const deleteRow = () => { + setNumRows(prevNumRows => { + if (prevNumRows > 1) { + const newNumRows = prevNumRows - 1; + setGrid(prevGrid => prevGrid.slice(0, newNumRows)); + return newNumRows; + } + return prevNumRows; + }); + }; + + const addColumn = () => { + setNumCols(prevNumCols => { + const newNumCols = prevNumCols + 1; + setGrid(prevGrid => prevGrid.map(row => [...row, 'white'])); + return newNumCols; + }); + }; + + const deleteColumn = () => { + setNumCols(prevNumCols => { + if (prevNumCols > 1) { + const newNumCols = prevNumCols - 1; + setGrid(prevGrid => prevGrid.map(row => row.slice(0, newNumCols))); + return newNumCols; + } + return prevNumCols; + }); + }; \ No newline at end of file