añadido soporte pantallas pequeñas
This commit is contained in:
@@ -1,4 +1,4 @@
|
|||||||
export default function Barra ({active, setType}) {
|
export default function Barra({ active, setType }) {
|
||||||
return (
|
return (
|
||||||
<nav class="navbar navbar-expand-lg bg-dark-subtle h-fit w-100">
|
<nav class="navbar navbar-expand-lg bg-dark-subtle h-fit w-100">
|
||||||
<div class="container-fluid">
|
<div class="container-fluid">
|
||||||
@@ -6,33 +6,87 @@ export default function Barra ({active, setType}) {
|
|||||||
Coords-Keeper
|
Coords-Keeper
|
||||||
</a>
|
</a>
|
||||||
|
|
||||||
<div class="justify-content-end">
|
<button
|
||||||
<ul class="navbar-nav">
|
class="navbar-toggler"
|
||||||
<li className="nav-item">
|
type="button"
|
||||||
<button
|
data-bs-toggle="offcanvas"
|
||||||
className={`btn bg-primary mx-2 ${active === "overworld" ? "text-black active" : "text-gray-100"}`}
|
data-bs-target="#offcanvasNavbar"
|
||||||
onClick={() => setType("overworld")}
|
aria-controls="offcanvasNavbar"
|
||||||
>
|
>
|
||||||
Overworld
|
<span class="navbar-toggler-icon"></span>
|
||||||
</button>
|
</button>
|
||||||
</li>
|
|
||||||
<li className="nav-item">
|
<div class="offcanvas offcanvas-end" tabindex="-1" id="offcanvasNavbar">
|
||||||
<button
|
<div class="offcanvas-header">
|
||||||
className={`btn bg-danger mx-2 ${active === "nether" ? "text-black active" : "text-gray-100"}`}
|
<h5 class="offcanvas-title">Coords-Keeper</h5>
|
||||||
onClick={() => setType("nether")}
|
<button
|
||||||
>
|
type="button"
|
||||||
Nether
|
class="btn-close"
|
||||||
</button>
|
data-bs-dismiss="offcanvas"
|
||||||
</li>
|
aria-label="Close"
|
||||||
<li className="nav-item">
|
></button>
|
||||||
<button
|
</div>
|
||||||
className={`btn bg-success mx-2 ${active === "end" ? "text-black active" : "text-gray-100"}`}
|
<div class="offcanvas-body">
|
||||||
onClick={() => setType("end")}
|
<ul class="navbar-nav justify-content-end flex-grow-1">
|
||||||
>
|
<li className="nav-item">
|
||||||
End
|
<a
|
||||||
</button>
|
className={`nav-link d-lg-none ${active === "overworld" ? "active" : ""}`}
|
||||||
</li>
|
onClick={() => {
|
||||||
</ul>
|
setType("overworld");
|
||||||
|
document
|
||||||
|
.querySelector('[data-bs-dismiss="offcanvas"]')
|
||||||
|
.click();
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
Overworld
|
||||||
|
</a>
|
||||||
|
<button
|
||||||
|
className={`btn bg-primary mx-2 d-none d-lg-block ${active === "overworld" ? "text-black active" : "text-gray-100"}`}
|
||||||
|
onClick={() => setType("overworld")}
|
||||||
|
>
|
||||||
|
Overworld
|
||||||
|
</button>
|
||||||
|
</li>
|
||||||
|
<li className="nav-item">
|
||||||
|
<a
|
||||||
|
className={`nav-link d-lg-none ${active === "nether" ? "active" : ""}`}
|
||||||
|
onClick={() => {
|
||||||
|
setType("nether");
|
||||||
|
document
|
||||||
|
.querySelector('[data-bs-dismiss="offcanvas"]')
|
||||||
|
.click();
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
Nether
|
||||||
|
</a>
|
||||||
|
<button
|
||||||
|
className={`btn bg-danger mx-2 d-none d-lg-block ${active === "nether" ? "text-black active" : "text-gray-100"}`}
|
||||||
|
onClick={() => setType("nether")}
|
||||||
|
>
|
||||||
|
Nether
|
||||||
|
</button>
|
||||||
|
</li>
|
||||||
|
<li className="nav-item">
|
||||||
|
<a
|
||||||
|
className={`nav-link d-lg-none ${active === "end" ? "active" : ""}`}
|
||||||
|
onClick={() => {
|
||||||
|
setType("end");
|
||||||
|
document
|
||||||
|
.querySelector('[data-bs-dismiss="offcanvas"]')
|
||||||
|
.click();
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
End
|
||||||
|
</a>
|
||||||
|
<button
|
||||||
|
className={`btn bg-success mx-2 d-none d-lg-block ${active === "end" ? "text-black active" : "text-gray-100"}`}
|
||||||
|
onClick={() => setType("end")}
|
||||||
|
>
|
||||||
|
End
|
||||||
|
</button>
|
||||||
|
</li>
|
||||||
|
</ul>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</nav>
|
</nav>
|
||||||
|
|||||||
22
src/components/BotonAdd.jsx
Normal file
22
src/components/BotonAdd.jsx
Normal file
@@ -0,0 +1,22 @@
|
|||||||
|
export default function BotonAdd({ show, setshow }) {
|
||||||
|
if (!show) return null;
|
||||||
|
|
||||||
|
return (
|
||||||
|
<button
|
||||||
|
className="btn btn-primary rounded-circle position-fixed bottom-0 end-0 m-4 d-flex align-items-center justify-content-center"
|
||||||
|
style={{ width: "60px", height: "60px" }}
|
||||||
|
onClick={() => setshow(true)}
|
||||||
|
>
|
||||||
|
<svg
|
||||||
|
xmlns="http://www.w3.org/2000/svg"
|
||||||
|
width="24"
|
||||||
|
height="24"
|
||||||
|
fill="currentColor"
|
||||||
|
className="bi bi-plus"
|
||||||
|
viewBox="0 0 16 16"
|
||||||
|
>
|
||||||
|
<path d="M8 4a.5.5 0 0 1 .5.5v3h3a.5.5 0 0 1 0 1h-3v3a.5.5 0 0 1-1 0v-3h-3a.5.5 0 0 1 0-1h3v-3A.5.5 0 0 1 8 4z" />
|
||||||
|
</svg>
|
||||||
|
</button>
|
||||||
|
);
|
||||||
|
}
|
||||||
52
src/components/ModalImport.jsx
Normal file
52
src/components/ModalImport.jsx
Normal file
@@ -0,0 +1,52 @@
|
|||||||
|
export default function ModalImport({ show, handleAddCoord, close }) {
|
||||||
|
if (!show) return null;
|
||||||
|
let coord = "";
|
||||||
|
return (
|
||||||
|
<div
|
||||||
|
className="modal"
|
||||||
|
tabIndex="-1"
|
||||||
|
style={{ display: "block", backgroundColor: "rgba(0,0,0,0.3)" }}
|
||||||
|
>
|
||||||
|
<div className="modal-dialog">
|
||||||
|
<div className="modal-content">
|
||||||
|
<div className="modal-header">
|
||||||
|
<h5 className="modal-title">Añadir Coordenadas</h5>
|
||||||
|
<button
|
||||||
|
type="button"
|
||||||
|
className="btn-close"
|
||||||
|
onClick={() => close(false)}
|
||||||
|
></button>
|
||||||
|
</div>
|
||||||
|
<div className="modal-body">
|
||||||
|
<div className="form-floating mb-3">
|
||||||
|
<input
|
||||||
|
type="text"
|
||||||
|
className="form-control"
|
||||||
|
id="coordInput"
|
||||||
|
placeholder="Coordenadas"
|
||||||
|
onChange={(event) => (coord = event.target.value)}
|
||||||
|
/>
|
||||||
|
<label htmlFor="coordInput">Pega la coord</label>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div className="modal-footer d-flex justify-content-between">
|
||||||
|
<button
|
||||||
|
type="button"
|
||||||
|
className="btn btn-secondary"
|
||||||
|
onClick={() => close(false)}
|
||||||
|
>
|
||||||
|
Close
|
||||||
|
</button>
|
||||||
|
<button
|
||||||
|
type="button"
|
||||||
|
className="btn btn-primary"
|
||||||
|
onClick={() => handleAddCoord(coord)}
|
||||||
|
>
|
||||||
|
Guardar Coord
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
}
|
||||||
@@ -6,6 +6,8 @@ import RemoveIcon from "./RemoveIcon";
|
|||||||
import StaticModal from "./StaticModal";
|
import StaticModal from "./StaticModal";
|
||||||
import EditarModal from "./EditarModal";
|
import EditarModal from "./EditarModal";
|
||||||
import TimedToast from "./TimedToast";
|
import TimedToast from "./TimedToast";
|
||||||
|
import BotonAdd from "./BotonAdd";
|
||||||
|
import ModalImport from "./ModalImport";
|
||||||
|
|
||||||
function Modall({ show, CloseModal, Coord, Coords, EliminarCoord, tipo }) {
|
function Modall({ show, CloseModal, Coord, Coords, EliminarCoord, tipo }) {
|
||||||
if (show === true && Coord !== null) {
|
if (show === true && Coord !== null) {
|
||||||
@@ -34,6 +36,7 @@ export default function Keeper({ tipo }) {
|
|||||||
const [showEditar, setEditar] = useState(false);
|
const [showEditar, setEditar] = useState(false);
|
||||||
const [showToast, setShowToast] = useState(false);
|
const [showToast, setShowToast] = useState(false);
|
||||||
const [selCoord, setCoord] = useState(null);
|
const [selCoord, setCoord] = useState(null);
|
||||||
|
const [showImport, setShowImport] = useState(false);
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
const storedCoords = JSON.parse(localStorage.getItem(tipo) || "[]");
|
const storedCoords = JSON.parse(localStorage.getItem(tipo) || "[]");
|
||||||
@@ -43,6 +46,28 @@ export default function Keeper({ tipo }) {
|
|||||||
}
|
}
|
||||||
}, [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(() => {
|
useEffect(() => {
|
||||||
const handlePaste = async () => {
|
const handlePaste = async () => {
|
||||||
const text = await navigator.clipboard.readText();
|
const text = await navigator.clipboard.readText();
|
||||||
@@ -73,8 +98,8 @@ export default function Keeper({ tipo }) {
|
|||||||
});
|
});
|
||||||
|
|
||||||
/*return () => {
|
/*return () => {
|
||||||
document.removeEventListener("keydown", handlePaste);
|
document.removeEventListener("keydown", handlePaste);
|
||||||
};*/
|
};*/
|
||||||
}, [coords, tipo]);
|
}, [coords, tipo]);
|
||||||
|
|
||||||
const Editar = (coord) => {
|
const Editar = (coord) => {
|
||||||
@@ -103,6 +128,15 @@ export default function Keeper({ tipo }) {
|
|||||||
};
|
};
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
|
<div className="d-lg-none">
|
||||||
|
<BotonAdd show={true} setshow={setShowImport} />
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<ModalImport
|
||||||
|
show={showImport}
|
||||||
|
handleAddCoord={añadirCoord}
|
||||||
|
close={setShowImport}
|
||||||
|
/>
|
||||||
<Modall
|
<Modall
|
||||||
show={showModal}
|
show={showModal}
|
||||||
CloseModal={() => setModal(false)}
|
CloseModal={() => setModal(false)}
|
||||||
@@ -111,7 +145,6 @@ export default function Keeper({ tipo }) {
|
|||||||
EliminarCoord={setCoords}
|
EliminarCoord={setCoords}
|
||||||
tipo={tipo}
|
tipo={tipo}
|
||||||
/>
|
/>
|
||||||
|
|
||||||
<EditarModal
|
<EditarModal
|
||||||
show={showEditar}
|
show={showEditar}
|
||||||
close={() => setEditar(false)}
|
close={() => setEditar(false)}
|
||||||
@@ -119,14 +152,12 @@ export default function Keeper({ tipo }) {
|
|||||||
coord={selCoord}
|
coord={selCoord}
|
||||||
setCoords={setCoords}
|
setCoords={setCoords}
|
||||||
/>
|
/>
|
||||||
|
|
||||||
<TimedToast
|
<TimedToast
|
||||||
durationMs={5000}
|
durationMs={5000}
|
||||||
setShow={setShowToast}
|
setShow={setShowToast}
|
||||||
show={showToast}
|
show={showToast}
|
||||||
message={`Copiada Coordenada [${selCoord?.descripcion}]`}
|
message={`Copiada Coordenada [${selCoord?.descripcion}]`}
|
||||||
/>
|
/>
|
||||||
|
|
||||||
<div className="accordion" id="accordionNuevaCoord">
|
<div className="accordion" id="accordionNuevaCoord">
|
||||||
<div className="accordion-item">
|
<div className="accordion-item">
|
||||||
<h2 className="accordion-header" id="headingNuevaCoord">
|
<h2 className="accordion-header" id="headingNuevaCoord">
|
||||||
@@ -161,13 +192,11 @@ export default function Keeper({ tipo }) {
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<hr />
|
<hr />
|
||||||
|
|
||||||
{coords.length == 0 && (
|
{coords.length == 0 && (
|
||||||
<h2 className="list-group-item text-center">
|
<h2 className="list-group-item text-center">
|
||||||
No hay Coordenadas que Mostrar.
|
No hay Coordenadas que Mostrar.
|
||||||
</h2>
|
</h2>
|
||||||
)}
|
)}
|
||||||
|
|
||||||
<table class="table table-hover table-striped">
|
<table class="table table-hover table-striped">
|
||||||
<thead>
|
<thead>
|
||||||
<tr>
|
<tr>
|
||||||
|
|||||||
Reference in New Issue
Block a user