Skip to content

Commit

Permalink
[pre-commit.ci] auto fixes from pre-commit.com hooks
Browse files Browse the repository at this point in the history
for more information, see https://pre-commit.ci
  • Loading branch information
pre-commit-ci[bot] committed Sep 16, 2023
1 parent 32f638a commit 10cb383
Show file tree
Hide file tree
Showing 2 changed files with 91 additions and 89 deletions.
175 changes: 89 additions & 86 deletions taxonium_website/src/components/InputSupplier.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,8 @@ export const InputSupplier = ({ inputHelper, className }) => {
const [tempURL, setTempURL] = useState("");

const { inputs, setInputs } = inputHelper;
const [addingText,setAddingText] = useState(false);
const [text,setText] = useState("")
const [addingText, setAddingText] = useState(false);
const [text, setText] = useState("");

const addFromTempURL = useCallback(() => {
if (tempURL) {
Expand Down Expand Up @@ -84,7 +84,6 @@ export const InputSupplier = ({ inputHelper, className }) => {
);
})}
</Select>


<Button
className="inline-block bg-gray-100 text-sm mx-auto p-1 rounded border-gray-300 border m-5 text-gray-700"
Expand Down Expand Up @@ -159,98 +158,102 @@ export const InputSupplier = ({ inputHelper, className }) => {
</div>
)}
<div className="mb-3">

Select, drag-and-drop, or enter the URL for tree or metadata files
(jsonl, newick, nextstrain, tsv, etc.):
</div>
{ !addingText && <>
<div>

<input
className="text-sm mb-3"
type="file"
multiple="multiple"
onChange={(e) => {
for (const file of e.target.files) {
inputHelper.readFile(file);
}

// empty this
e.target.value = "";
}}
/>
</div>
<div>
<input
placeholder="https://"
type="text"
value={tempURL}
className="border p-1 mr-1 text-sm "
onChange={(e) => {
setTempURL(
e.target.value
.replace("http://", "")
.replace("http://", "https://")
);
}}
onKeyUp={(e) => {
if (e.key === "Enter") {
addFromTempURL();
}
}}
/>{" "}
<Button onClick={addFromTempURL} className="">
Add
</Button>
</div>
</>}
<div className="mt-3">
<div className="text-xs text-gray-500">
{
addingText ? <>
<div>
<textarea className="border p-1 mr-1 text-sm md:w-1/2 w-full"
placeholder="Paste e.g. Newick tree here.."
{!addingText && (
<>
<div>
<input
className="text-sm mb-3"
type="file"
multiple="multiple"
onChange={(e) => {
setText(e.target.value)
for (const file of e.target.files) {
inputHelper.readFile(file);
}

// empty this
e.target.value = "";
}}
value={text}
/>
<div className="mt-2">
<button className="background-gray-100 text-sm p-1 rounded border-gray-300 border text-gray-700"
onClick={() => {
inputHelper.addFromText(text)
setAddingText(false)
setText("")
/>
</div>
<div>
<input
placeholder="https://"
type="text"
value={tempURL}
className="border p-1 mr-1 text-sm "
onChange={(e) => {
setTempURL(
e.target.value
.replace("http://", "")
.replace("http://", "https://")
);
}}
>Add</button> <button
className="background-gray-100 text-sm p-1 rounded border-gray-300 border ml-3 text-gray-700"
onClick={() => {
setAddingText(false)
setText("")
onKeyUp={(e) => {
if (e.key === "Enter") {
addFromTempURL();
}
}}
>Cancel</button>

/>{" "}
<Button onClick={addFromTempURL} className="">
Add
</Button>
</div>
</>
)}
<div className="mt-3">
<div className="text-xs text-gray-500">
{addingText ? (
<>
<div>
<textarea
className="border p-1 mr-1 text-sm md:w-1/2 w-full"
placeholder="Paste e.g. Newick tree here.."
onChange={(e) => {
setText(e.target.value);
}}
value={text}
/>
<div className="mt-2">
<button
className="background-gray-100 text-sm p-1 rounded border-gray-300 border text-gray-700"
onClick={() => {
inputHelper.addFromText(text);
setAddingText(false);
setText("");
}}
>
Add
</button>{" "}
<button
className="background-gray-100 text-sm p-1 rounded border-gray-300 border ml-3 text-gray-700"
onClick={() => {
setAddingText(false);
setText("");
}}
>
Cancel
</button>
</div>
</div>






</div></> : <div className="text-sm">
..or use <button className="text-gray-700 hover:text-gray-700 hover:underline"
onClick={() => {
setAddingText(true)
}}>text entry</button>.
</>
) : (
<div className="text-sm">
..or use{" "}
<button
className="text-gray-700 hover:text-gray-700 hover:underline"
onClick={() => {
setAddingText(true);
}}
>
text entry
</button>
.
</div>
}
</div>





)}
</div>
</div>
</div>
);
Expand Down
5 changes: 2 additions & 3 deletions taxonium_website/src/hooks/useInputHelper.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -166,11 +166,11 @@ export const useInputHelper = ({
addInput(file_obj);
}

function addFromText(text){
function addFromText(text) {
const file_obj = { name: "text.nwk", supplyType: "file" };
file_obj.filetype = "nwk";
file_obj.data = text;
addInput(file_obj,text);
addInput(file_obj, text);
}

const finaliseInputs = useCallback(() => {
Expand Down Expand Up @@ -294,6 +294,5 @@ export const useInputHelper = ({
finaliseInputs,
validity,
validityMessage,

};
};

0 comments on commit 10cb383

Please sign in to comment.