From 14b0f1b805504d0c3dc90b3e5619e405be7c7d5c Mon Sep 17 00:00:00 2001 From: fede Date: Mon, 24 Mar 2025 15:12:05 -0300 Subject: [PATCH] =?UTF-8?q?a=C3=B1adido=20soporte=20pantallas=20peque?= =?UTF-8?q?=C3=B1as?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/components/Barra.jsx | 110 ++++++++++++++++++++++++--------- src/components/BotonAdd.jsx | 22 +++++++ src/components/ModalImport.jsx | 52 ++++++++++++++++ src/components/coordkeeper.jsx | 43 ++++++++++--- 4 files changed, 192 insertions(+), 35 deletions(-) create mode 100644 src/components/BotonAdd.jsx create mode 100644 src/components/ModalImport.jsx diff --git a/src/components/Barra.jsx b/src/components/Barra.jsx index bb027a6..8f81d0c 100644 --- a/src/components/Barra.jsx +++ b/src/components/Barra.jsx @@ -1,4 +1,4 @@ -export default function Barra ({active, setType}) { +export default function Barra({ active, setType }) { return ( diff --git a/src/components/BotonAdd.jsx b/src/components/BotonAdd.jsx new file mode 100644 index 0000000..2daecfd --- /dev/null +++ b/src/components/BotonAdd.jsx @@ -0,0 +1,22 @@ +export default function BotonAdd({ show, setshow }) { + if (!show) return null; + + return ( + + ); +} diff --git a/src/components/ModalImport.jsx b/src/components/ModalImport.jsx new file mode 100644 index 0000000..6700141 --- /dev/null +++ b/src/components/ModalImport.jsx @@ -0,0 +1,52 @@ +export default function ModalImport({ show, handleAddCoord, close }) { + if (!show) return null; + let coord = ""; + return ( +
+
+
+
+
Añadir Coordenadas
+ +
+
+
+ (coord = event.target.value)} + /> + +
+
+
+ + +
+
+
+
+ ); +} diff --git a/src/components/coordkeeper.jsx b/src/components/coordkeeper.jsx index 5d52ad7..212a014 100644 --- a/src/components/coordkeeper.jsx +++ b/src/components/coordkeeper.jsx @@ -6,6 +6,8 @@ import RemoveIcon from "./RemoveIcon"; import StaticModal from "./StaticModal"; import EditarModal from "./EditarModal"; import TimedToast from "./TimedToast"; +import BotonAdd from "./BotonAdd"; +import ModalImport from "./ModalImport"; function Modall({ show, CloseModal, Coord, Coords, EliminarCoord, tipo }) { if (show === true && Coord !== null) { @@ -34,6 +36,7 @@ export default function Keeper({ tipo }) { const [showEditar, setEditar] = useState(false); const [showToast, setShowToast] = useState(false); const [selCoord, setCoord] = useState(null); + const [showImport, setShowImport] = useState(false); useEffect(() => { const storedCoords = JSON.parse(localStorage.getItem(tipo) || "[]"); @@ -43,6 +46,28 @@ export default function Keeper({ tipo }) { } }, [tipo]); + const añadirCoord = (coord) => { + const regex = /- (.*), X: (-?\d+)(?:\s*Y:\s*(-?\d+))?\s*Z:\s*(-?\d+)/; + const match = coord.match(regex); + + if (match) { + const [_, descripcion, x, y, z] = match; + const newCoord = { + descripcion, + x: parseInt(x), + y: y ? parseInt(y) : null, + z: parseInt(z), + num: coords.length + 1, + }; + + const newCoords = [...coords, newCoord]; + setCoords(newCoords); + localStorage.setItem(tipo, JSON.stringify(newCoords)); + setShowToast(true); + setShowImport(false); + } + }; + useEffect(() => { const handlePaste = async () => { const text = await navigator.clipboard.readText(); @@ -73,8 +98,8 @@ export default function Keeper({ tipo }) { }); /*return () => { - document.removeEventListener("keydown", handlePaste); - };*/ + document.removeEventListener("keydown", handlePaste); + };*/ }, [coords, tipo]); const Editar = (coord) => { @@ -103,6 +128,15 @@ export default function Keeper({ tipo }) { }; return ( <> +
+ +
+ + setModal(false)} @@ -111,7 +145,6 @@ export default function Keeper({ tipo }) { EliminarCoord={setCoords} tipo={tipo} /> - setEditar(false)} @@ -119,14 +152,12 @@ export default function Keeper({ tipo }) { coord={selCoord} setCoords={setCoords} /> - -

@@ -161,13 +192,11 @@ export default function Keeper({ tipo }) {


- {coords.length == 0 && (

No hay Coordenadas que Mostrar.

)} -