update checklist component
All checks were successful
Deploy Sokko G / deploy (push) Successful in 7s
All checks were successful
Deploy Sokko G / deploy (push) Successful in 7s
This commit is contained in:
parent
772b9951de
commit
d9d22683dc
13 changed files with 709 additions and 65 deletions
|
|
@ -1,5 +1,6 @@
|
|||
import { useState } from "react";
|
||||
import { useCallback, useState } from "react";
|
||||
import { Icon } from "../../../components/Icon.jsx";
|
||||
import { TextImportModal } from "./TextImportModal.jsx";
|
||||
import { parseColonImportLines } from "./textImport.js";
|
||||
|
||||
export function LinksModule({ toolboxId, moduleId, context, editing }) {
|
||||
|
|
@ -8,7 +9,9 @@ export function LinksModule({ toolboxId, moduleId, context, editing }) {
|
|||
const [title, setTitle] = useState("");
|
||||
const [url, setUrl] = useState("");
|
||||
const [textImport, setTextImport] = useState("");
|
||||
const [importOpen, setImportOpen] = useState(false);
|
||||
const [copiedId, setCopiedId] = useState("");
|
||||
const closeImportModal = useCallback(() => setImportOpen(false), []);
|
||||
|
||||
function save(links) {
|
||||
context.setModuleData(toolboxId, moduleId, { links });
|
||||
|
|
@ -43,6 +46,7 @@ export function LinksModule({ toolboxId, moduleId, context, editing }) {
|
|||
if (!imported.length) return;
|
||||
save([...data.links, ...imported]);
|
||||
setTextImport("");
|
||||
setImportOpen(false);
|
||||
}
|
||||
|
||||
async function copyUrl(link) {
|
||||
|
|
@ -61,17 +65,25 @@ export function LinksModule({ toolboxId, moduleId, context, editing }) {
|
|||
<input name="url" placeholder={textContent.urlPlaceholder || "https://..."} value={url} onChange={(event) => setUrl(event.target.value)} />
|
||||
<button className="primary">{textContent.addButton || "Ajouter"}</button>
|
||||
</form>
|
||||
<form className="text-import-form" onSubmit={importLinks}>
|
||||
<textarea
|
||||
value={textImport}
|
||||
onChange={(event) => setTextImport(event.target.value)}
|
||||
placeholder={textContent.importPlaceholder || "Importer plusieurs liens...\nBuild:https://example.com/build?class=rogue\nMap:https://example.com/map"}
|
||||
rows={3}
|
||||
/>
|
||||
<button type="submit">{textContent.importButton || "Importer le texte"}</button>
|
||||
</form>
|
||||
<div className="text-import-actions">
|
||||
<button type="button" onClick={() => setImportOpen(true)}>
|
||||
<Icon name="import" />
|
||||
<span>{textContent.importOpenButton || "Importer du texte"}</span>
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
)}
|
||||
{importOpen && (
|
||||
<TextImportModal
|
||||
title={textContent.importModalTitle || "Importer des liens"}
|
||||
value={textImport}
|
||||
onChange={setTextImport}
|
||||
placeholder={textContent.importPlaceholder || "Importer plusieurs liens...\nBuild:https://example.com/build?class=rogue\nMap:https://example.com/map"}
|
||||
submitLabel={textContent.importButton || "Importer le texte"}
|
||||
onSubmit={importLinks}
|
||||
onClose={closeImportModal}
|
||||
/>
|
||||
)}
|
||||
<ul className="links-list">
|
||||
{data.links.map((link) => (
|
||||
<li className="link-item" key={link.id}>
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue