From 99540cfe78c8f26db68d52b47c185f90c0d676ee Mon Sep 17 00:00:00 2001 From: Theo Sanderson Date: Tue, 14 Feb 2023 22:02:09 +0000 Subject: [PATCH] update --- package.json | 2 ++ src/App.js | 98 +++++++++++++++++++++++++++++++++++++++++++++++++--- yarn.lock | 10 ++++++ 3 files changed, 105 insertions(+), 5 deletions(-) diff --git a/package.json b/package.json index 0a414ae..aecbd27 100644 --- a/package.json +++ b/package.json @@ -11,6 +11,8 @@ "postcss": "^8.4.21", "react": "^18.2.0", "react-dom": "^18.2.0", + "react-icon": "^1.0.0", + "react-icons": "^4.7.1", "react-scripts": "5.0.1", "react-tooltip": "^5.7.5", "react-use": "^17.4.0", diff --git a/src/App.js b/src/App.js index 2f92b2a..5411edb 100644 --- a/src/App.js +++ b/src/App.js @@ -4,7 +4,7 @@ import './App.css'; import { genbankToJson } from "bio-parsers"; import { useMeasure } from 'react-use'; // or just 'react-use-measure' - +import {FaSearch,FaTimes} from 'react-icons/fa'; const Tooltip = ({ hoveredInfo }) => { @@ -82,6 +82,8 @@ const getColor = (feature) => { return "#ddffdd"; case "nsp16": return "#ffeeee"; + case "nsp13": + return "#ff7f50"; default: return "#c39797"; @@ -191,7 +193,7 @@ const codonToAminoAcid = (codon) => { } }; -const SingleRow = ({ parsedSequence, rowStart, rowEnd, setHoveredInfo, rowWidth }) => { +const SingleRow = ({ parsedSequence, rowStart, rowEnd, setHoveredInfo, rowId }) => { const fullSequence = parsedSequence.sequence; const rowSequence = fullSequence.slice(rowStart, rowEnd); @@ -390,7 +392,7 @@ const SingleRow = ({ parsedSequence, rowStart, rowEnd, setHoveredInfo, rowWidth // Concatenate sequence characters and ticks with SVG return ( -
+
{ + setInputValue(event.target.value); + goToNucleotide(event.target.value); + }; + + return ( +
+ {searchPanelOpen ? ((<> + + + )) : ( + + )} +
+ ); +} + + + function App() { + + const [searchPanelOpen, setSearchPanelOpen] = useState(false); + // detect ctrl-F and open search panel + useEffect(() => { + const handleKeyDown = (e) => { + if ((e.ctrlKey || e.metaKey) && e.keyCode === 70) { + e.preventDefault(); + setSearchPanelOpen(true); + // focus on search input + setTimeout(() => { + document.getElementById("search-input").focus(); + } + , 100); + } + + }; + window.addEventListener("keydown", handleKeyDown); + return () => { + window.removeEventListener("keydown", handleKeyDown); + }; + }, []); const [ref, { width }] = useMeasure(); //console.log("width", width); const [hoveredInfo, setHoveredInfo] = useState(null); const [genbankData, setGenbankData] = useState(null); + useEffect(() => { const loadGenbankFile = async () => { try { @@ -468,9 +531,33 @@ function App() { } return ( -
+
+ {true && ( +
+ { + const row = Math.floor(nucleotide / rowWidth); + console.log("row", row); + + const rowElement = document.getElementById(`row-${row}`); + const yPos = rowElement.getBoundingClientRect().top; + setTimeout(() => { + window.scrollTo({ + top: yPos, + behavior: "smooth" + }); + }, 100); + } + } + /> +
+ )} + + -
+
{genbankData && (
@@ -488,6 +575,7 @@ function App() { ))}
diff --git a/yarn.lock b/yarn.lock index cbc6f6a..4ea65d7 100644 --- a/yarn.lock +++ b/yarn.lock @@ -7653,6 +7653,16 @@ react-error-overlay@^6.0.11: resolved "https://registry.yarnpkg.com/react-error-overlay/-/react-error-overlay-6.0.11.tgz#92835de5841c5cf08ba00ddd2d677b6d17ff9adb" integrity sha512-/6UZ2qgEyH2aqzYZgQPxEnz33NJ2gNsnHA2o5+o4wW9bLM/JYQitNP9xPhsXwC08hMMovfGe/8retsdDsczPRg== +react-icon@^1.0.0: + version "1.0.0" + resolved "https://registry.yarnpkg.com/react-icon/-/react-icon-1.0.0.tgz#6038598eb07fb3e64b3e7865d271f79f3559de0b" + integrity sha512-VzSlpBHnLanVw79mOxyq98hWDi6DlxK9qPiZ1bAK6bLurMBCaxO/jjyYUrRx9+JGLc/NbnwOmyE/W5Qglbb2QA== + +react-icons@^4.7.1: + version "4.7.1" + resolved "https://registry.yarnpkg.com/react-icons/-/react-icons-4.7.1.tgz#0f4b25a5694e6972677cb189d2a72eabea7a8345" + integrity sha512-yHd3oKGMgm7zxo3EA7H2n7vxSoiGmHk5t6Ou4bXsfcgWyhfDKMpyKfhHR6Bjnn63c+YXBLBPUql9H4wPJM6sXw== + react-is@^16.13.1: version "16.13.1" resolved "https://registry.yarnpkg.com/react-is/-/react-is-16.13.1.tgz#789729a4dc36de2999dc156dd6c1d9c18cea56a4"