diff --git a/src/App.tsx b/src/App.tsx
index 11d6e30..157fcb9 100644
--- a/src/App.tsx
+++ b/src/App.tsx
@@ -1,6 +1,6 @@
import { useEffect, useRef, useState } from "react";
import { Layer, Stage } from "react-konva";
-import { Hand, Pencil } from "lucide-react";
+import { Eraser, Hand, Pencil } from "lucide-react";
import {
Menubar,
@@ -92,15 +92,15 @@ function App() {
};
const onClick = (e) => {
+ const blockX = Math.floor(mousePosition.x / 16);
+ const blockY = Math.floor(mousePosition.y / 16);
+ const updatedBlocks = blocks.filter((b) => !(b.x === blockX && b.y === blockY));
+
switch (tool) {
case "hand":
setCssCursor("grabbing");
break;
case "pencil": {
- const blockX = Math.floor(mousePosition.x / 16);
- const blockY = Math.floor(mousePosition.y / 16);
- const updatedBlocks = blocks.filter((b) => !(b.x === blockX && b.y === blockY));
-
setBlocks([
...updatedBlocks,
{
@@ -109,6 +109,11 @@ function App() {
y: blockY,
},
]);
+ break;
+ }
+ case "eraser": {
+ setBlocks(updatedBlocks);
+ break;
}
}
};
@@ -158,10 +163,9 @@ function App() {