Skip to content

Commit

Permalink
Merge pull request #531 from theosanderson/textentry
Browse files Browse the repository at this point in the history
Text entry
  • Loading branch information
theosanderson authored Sep 16, 2023
2 parents d28701c + 10cb383 commit 4d2a414
Show file tree
Hide file tree
Showing 3 changed files with 169 additions and 58 deletions.
149 changes: 94 additions & 55 deletions taxonium_website/src/components/InputSupplier.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +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 addFromTempURL = useCallback(() => {
if (tempURL) {
Expand Down Expand Up @@ -82,25 +84,6 @@ export const InputSupplier = ({ inputHelper, className }) => {
);
})}
</Select>
{/*}
<label>
Is Gzipped{" "}
<input
type="checkbox"
checked={input.gzipped}
className="border p-1 mr-4"
onChange={(e) => {
setInputs(
inputs.map((input, this_index) => {
if (this_index === index) {
input.gzipped = e.target.checked;
}
return input;
})
);
}}
/>
</label>*/}

<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 @@ -178,43 +161,99 @@ export const InputSupplier = ({ inputHelper, className }) => {
Select, drag-and-drop, or enter the URL for tree or metadata files
(jsonl, newick, nextstrain, tsv, etc.):
</div>
<div>
<input
className="text-sm mb-3"
type="file"
multiple="multiple"
onChange={(e) => {
for (const file of e.target.files) {
inputHelper.readFile(file);
}
{!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>
// 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.."
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 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>
);
Expand Down
8 changes: 8 additions & 0 deletions taxonium_website/src/hooks/useInputHelper.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -166,6 +166,13 @@ export const useInputHelper = ({
addInput(file_obj);
}

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

const finaliseInputs = useCallback(() => {
// if everything is a URL:
if (inputs.every((input) => input.supplyType === "url")) {
Expand Down Expand Up @@ -283,6 +290,7 @@ export const useInputHelper = ({
removeInput,
addInput,
addFromURL,
addFromText,
finaliseInputs,
validity,
validityMessage,
Expand Down
70 changes: 67 additions & 3 deletions taxonium_website/yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -1508,6 +1508,13 @@
resolved "https://registry.yarnpkg.com/@gmod/vcf/-/vcf-5.0.10.tgz#6c2d7952b15f61642454be90119ea89fd3c227de"
integrity sha512-o7QuPcOeXlJpzwQaFmgojhNvJE4yB9fhrfVEDKpkDjV27pAqwMy89367vtXu4JfBFE9t4zZ6sQRkqYaJ+cIheg==

"@headlessui/react@^1.7.17":
version "1.7.17"
resolved "https://registry.yarnpkg.com/@headlessui/react/-/react-1.7.17.tgz#a0ec23af21b527c030967245fd99776aa7352bc6"
integrity sha512-4am+tzvkqDSSgiwrsEpGWqgGo9dz8qU5M3znCkC4PgkpY4HcCZzEDEvozltGGGHIKl9jbXbZPSH5TWn4sWJdow==
dependencies:
client-only "^0.0.1"

"@humanwhocodes/config-array@^0.11.8":
version "0.11.8"
resolved "https://registry.yarnpkg.com/@humanwhocodes/config-array/-/config-array-0.11.8.tgz#03595ac2075a4dc0f191cc2131de14fbd7d410b9"
Expand All @@ -1527,6 +1534,11 @@
resolved "https://registry.yarnpkg.com/@humanwhocodes/object-schema/-/object-schema-1.2.1.tgz#b520529ec21d8e5945a1851dfd1c32e94e39ff45"
integrity sha512-ZnQMnLV4e7hDlUvw8H+U8ASL02SS2Gn6+9Ac3wGGLIe7+je2AeAOxPY+izIPJDfFDb7eDjev0Us8MO1iFRN8hA==

"@icons/material@^0.2.4":
version "0.2.4"
resolved "https://registry.yarnpkg.com/@icons/material/-/material-0.2.4.tgz#e90c9f71768b3736e76d7dd6783fc6c2afa88bc8"
integrity sha512-QPcGmICAPbGLGb6F/yNf/KzKqvFx8z5qx3D1yFqVAjoFmXK35EgyW+cJ57Te3CNsmzblwtzakLGFqHPqrfb4Tw==

"@jbrowse/core@^2.5.0":
version "2.5.0"
resolved "https://registry.yarnpkg.com/@jbrowse/core/-/core-2.5.0.tgz#850c83597cf09742ec8e9f2143fa7e75df6a9183"
Expand Down Expand Up @@ -3424,6 +3436,11 @@ cli-table3@^0.6.1:
optionalDependencies:
"@colors/colors" "1.5.0"

client-only@^0.0.1:
version "0.0.1"
resolved "https://registry.yarnpkg.com/client-only/-/client-only-0.0.1.tgz#38bba5d403c41ab150bff64a95c85013cf73bca1"
integrity sha512-IV3Ou0jSMzZrd3pZ48nLkT9DA7Ag1pnPzaiQhpW7c3RbcqqzvzzVu+L8gfqMp/8IM2MQtSiqaCxrrcfu8I8rMA==

clone-deep@^4.0.1:
version "4.0.1"
resolved "https://registry.yarnpkg.com/clone-deep/-/clone-deep-4.0.1.tgz#c19fd9bdbbf85942b4fd979c84dcf7d5f07c2387"
Expand Down Expand Up @@ -5508,6 +5525,11 @@ locate-path@^6.0.0:
dependencies:
p-locate "^5.0.0"

lodash-es@^4.17.15:
version "4.17.21"
resolved "https://registry.yarnpkg.com/lodash-es/-/lodash-es-4.17.21.tgz#43e626c46e6591b7750beb2b50117390c609e3ee"
integrity sha512-mKnC+QJ9pWVzv+C4/U3rRsHapFfHvQFoFB92e52xeyGMcX6/OlIl78je1u8vePzYZSkkogMPJ2yjxxsb89cxyw==

lodash.debounce@^4, lodash.debounce@^4.0.8:
version "4.0.8"
resolved "https://registry.yarnpkg.com/lodash.debounce/-/lodash.debounce-4.0.8.tgz#82d79bff30a67c4005ffd5e2515300ad9ca4d7af"
Expand All @@ -5518,7 +5540,7 @@ lodash.merge@^4.6.2:
resolved "https://registry.yarnpkg.com/lodash.merge/-/lodash.merge-4.6.2.tgz#558aa53b43b661e1925a0afdfa36a9a1085fe57a"
integrity sha512-0KpjqXRVvrYyCsX1swR/XTK0va6VQkQM6MNo7PqW77ByjAhoARA8EfrP1N4+KlKj8YS0ZUCtRT/YUuhyYDujIQ==

lodash@^4.17.21:
lodash@^4.0.1, lodash@^4.17.15, lodash@^4.17.21:
version "4.17.21"
resolved "https://registry.yarnpkg.com/lodash/-/lodash-4.17.21.tgz#679591c564c3bffaae8454cf0b3df370c3d6911c"
integrity sha512-v2kDEe57lecTulaDIuNTPy3Ry4gLGJ6Z1O3vE1krgXZNrsQ+LFTGHVxVjcXPs17LhbZVGedAJv8XZ1tvj5FvSg==
Expand Down Expand Up @@ -5594,6 +5616,11 @@ map-or-similar@^1.5.0:
resolved "https://registry.yarnpkg.com/map-or-similar/-/map-or-similar-1.5.0.tgz#6de2653174adfb5d9edc33c69d3e92a1b76faf08"
integrity sha512-0aF7ZmVon1igznGI4VS30yugpduQW3y3GkcgGJOp7d8x8QrizhigUxjI/m2UojsXXto+jLAH3KSz+xOJTiORjg==

material-colors@^1.2.1:
version "1.2.6"
resolved "https://registry.yarnpkg.com/material-colors/-/material-colors-1.2.6.tgz#6d1958871126992ceecc72f4bcc4d8f010865f46"
integrity sha512-6qE4B9deFBIa9YSpOc9O0Sgc43zTeVYbgDT5veRKSlB2+ZuHNoVVxA1L/ckMUayV9Ay9y7Z/SZCLcGteW9i7bg==

material-ui-popup-state@^5.0.0:
version "5.0.8"
resolved "https://registry.yarnpkg.com/material-ui-popup-state/-/material-ui-popup-state-5.0.8.tgz#b35f7878b994590a55bf1e7a5a1ed4687f75fdc4"
Expand Down Expand Up @@ -6356,7 +6383,7 @@ prompts@^2.4.0:
kleur "^3.0.3"
sisteransi "^1.0.5"

prop-types@^15.0.0, prop-types@^15.6.0, prop-types@^15.6.2, prop-types@^15.7.2, prop-types@^15.8.1:
prop-types@^15.0.0, prop-types@^15.5.0, prop-types@^15.5.10, prop-types@^15.6.0, prop-types@^15.6.2, prop-types@^15.7.2, prop-types@^15.8.1:
version "15.8.1"
resolved "https://registry.yarnpkg.com/prop-types/-/prop-types-15.8.1.tgz#67d87bf1a694f48435cf332c24af10214a3140b5"
integrity sha512-oj87CgZICdulUohogVAR7AjlC0327U4el4L6eAvOqCeudMDVU0NThNaV+b9Df4dXgSP1gXMTnPdhfe/2qDH5cg==
Expand Down Expand Up @@ -6495,6 +6522,19 @@ react-circular-progressbar@^2.1.0:
resolved "https://registry.yarnpkg.com/react-circular-progressbar/-/react-circular-progressbar-2.1.0.tgz#99e5ae499c21de82223b498289e96f66adb8fa3a"
integrity sha512-xp4THTrod4aLpGy68FX/k1Q3nzrfHUjUe5v6FsdwXBl3YVMwgeXYQKDrku7n/D6qsJA9CuunarAboC2xCiKs1g==

react-color@^2.19.3:
version "2.19.3"
resolved "https://registry.yarnpkg.com/react-color/-/react-color-2.19.3.tgz#ec6c6b4568312a3c6a18420ab0472e146aa5683d"
integrity sha512-LEeGE/ZzNLIsFWa1TMe8y5VYqr7bibneWmvJwm1pCn/eNmrabWDh659JSPn9BuaMpEfU83WTOJfnCcjDZwNQTA==
dependencies:
"@icons/material" "^0.2.4"
lodash "^4.17.15"
lodash-es "^4.17.15"
material-colors "^1.2.1"
prop-types "^15.5.10"
reactcss "^1.2.0"
tinycolor2 "^1.4.1"

react-d3-axis-mod@^0.1.9:
version "0.1.9"
resolved "https://registry.yarnpkg.com/react-d3-axis-mod/-/react-d3-axis-mod-0.1.9.tgz#4c38ab2e21f1135ed43604bb9fbae52a4cac0447"
Expand Down Expand Up @@ -6624,6 +6664,14 @@ react-spinners@^0.13.8:
resolved "https://registry.yarnpkg.com/react-spinners/-/react-spinners-0.13.8.tgz#5262571be0f745d86bbd49a1e6b49f9f9cb19acc"
integrity sha512-3e+k56lUkPj0vb5NDXPVFAOkPC//XyhKPJjvcGjyMNPWsBKpplfeyialP74G7H7+It7KzhtET+MvGqbKgAqpZA==

react-tabs@4:
version "4.3.0"
resolved "https://registry.yarnpkg.com/react-tabs/-/react-tabs-4.3.0.tgz#9f4db0fd209ba4ab2c1e78993ff964435f84af62"
integrity sha512-2GfoG+f41kiBIIyd3gF+/GRCCYtamC8/2zlAcD8cqQmqI9Q+YVz7fJLHMmU9pXDVYYHpJeCgUSBJju85vu5q8Q==
dependencies:
clsx "^1.1.0"
prop-types "^15.5.0"

react-tooltip@^4.2.21:
version "4.5.1"
resolved "https://registry.yarnpkg.com/react-tooltip/-/react-tooltip-4.5.1.tgz#77eccccdf16adec804132e558ec20ca5783b866a"
Expand Down Expand Up @@ -6670,6 +6718,13 @@ react@^18.2.0:
dependencies:
loose-envify "^1.1.0"

reactcss@^1.2.0:
version "1.2.3"
resolved "https://registry.yarnpkg.com/reactcss/-/reactcss-1.2.3.tgz#c00013875e557b1cf0dfd9a368a1c3dab3b548dd"
integrity sha512-KiwVUcFu1RErkI97ywr8nvx8dNOpT03rbnma0SSalTYjkrPYaEajR4a/MRt6DZ46K6arDRbWMNHF+xH7G7n/8A==
dependencies:
lodash "^4.0.1"

read-cache@^1.0.0:
version "1.0.0"
resolved "https://registry.yarnpkg.com/read-cache/-/read-cache-1.0.0.tgz#e664ef31161166c9751cdbe8dbcf86b5fb58f774"
Expand Down Expand Up @@ -7391,6 +7446,7 @@ tar@^6.1.13:
version "0.0.0"
dependencies:
"@fontsource/roboto" "^5.0.1"
"@headlessui/react" "^1.7.17"
"@jbrowse/core" "^2.5.0"
"@jbrowse/plugin-data-management" "^2.5.0"
"@jbrowse/react-linear-genome-view" "^2.5.0"
Expand All @@ -7399,15 +7455,18 @@ tar@^6.1.13:
classnames "^2.3.2"
deck.gl "=8.6.6"
react-circular-progressbar "^2.1.0"
react-color "^2.19.3"
react-debounce-input "^3.3.0"
react-hot-toast "^2.4.1"
react-icons "^4.8.0"
react-modal "^3.16.1"
react-spinners "^0.13.8"
react-tabs "4"
react-tooltip "^4.2.21"
readable-web-to-node-stream "^3.0.2"
sb "^7.0.14"
scale-color-perceptual "^1.1.2"
taxonium_data_handling "file:../../../Library/Caches/Yarn/v6/npm-taxonium-component-0.0.0-b542a2fa-ab81-4f51-b543-91dba60d97d6-1684941173998/node_modules/taxonium_data_handling"
taxonium_data_handling "file:../../../../Library/Caches/Yarn/v6/npm-taxonium-component-0.0.0-029ee0ff-9a4e-4868-83ff-eed48aa56d72-1694821384497/node_modules/taxonium_data_handling"

"taxonium_data_handling@file:../taxonium_data_handling":
version "1.0.1"
Expand Down Expand Up @@ -7489,6 +7548,11 @@ tiny-warning@^1.0.0:
resolved "https://registry.yarnpkg.com/tiny-warning/-/tiny-warning-1.0.3.tgz#94a30db453df4c643d0fd566060d60a875d84754"
integrity sha512-lBN9zLN/oAf68o3zNXYrdCt1kP8WsiGW8Oo2ka41b2IM5JL/S1CTyX1rW0mb/zSuJun0ZUrDxx4sqvYS2FWzPA==

tinycolor2@^1.4.1:
version "1.6.0"
resolved "https://registry.yarnpkg.com/tinycolor2/-/tinycolor2-1.6.0.tgz#f98007460169b0263b97072c5ae92484ce02d09e"
integrity sha512-XPaBkWQJdsf3pLKJV9p4qN/S+fm2Oj8AIPo1BTUhg5oxkvm9+SVEGFdhyOz7tTdUTfvxMiAs4sp6/eZO2Ew+pw==

to-fast-properties@^2.0.0:
version "2.0.0"
resolved "https://registry.yarnpkg.com/to-fast-properties/-/to-fast-properties-2.0.0.tgz#dc5e698cbd079265bc73e0377681a4e4e83f616e"
Expand Down

1 comment on commit 4d2a414

@vercel
Copy link

@vercel vercel bot commented on 4d2a414 Sep 16, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.