Skip to content

Commit

Permalink
revert changes and build frontend
Browse files Browse the repository at this point in the history
  • Loading branch information
bprize15 committed Nov 21, 2024
1 parent 19645ce commit 687e7da
Show file tree
Hide file tree
Showing 3 changed files with 38 additions and 44 deletions.
44 changes: 19 additions & 25 deletions web/src/main/javascript/src/components/SearchBar/SearchBar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -226,7 +226,7 @@ export default function SearchBar({
}}
options={options}
components={{
ClearIndicator: (props) => <ClearIndicator {...props} searchResults={cancerTypeResults} searchResultsIndex={cancerTypeResultsIndex} />,
ClearIndicator,
Control,
}}
styles={{
Expand Down Expand Up @@ -259,31 +259,25 @@ export default function SearchBar({
</div>
);

interface IClearIndicatorProps extends ClearIndicatorProps<
OncoTreeSearchOption,
false,
GroupBase<OncoTreeSearchOption>
> {
searchResults: D3OncoTreeNode[] | undefined,
searchResultsIndex: number | undefined
}

function ClearIndicator(
{searchResults, searchResultsIndex, ...props}: IClearIndicatorProps,
props: ClearIndicatorProps<
OncoTreeSearchOption,
false,
GroupBase<OncoTreeSearchOption>>,
) {
const inputStyle = props.getStyles("input", { ...props, isHidden: false });
const inputColor = inputStyle.color ?? "black";
const clearIndicatorClass = css(props.getStyles("clearIndicator", props));

const resultsAndIndexDefined =
searchResults !== undefined && searchResultsIndex !== undefined;
cancerTypeResults !== undefined && cancerTypeResultsIndex !== undefined;

function getResultsNumberSpan() {
if (!resultsAndIndexDefined) {
return undefined;
}

if (searchResults.length === 0) {
if (cancerTypeResults.length === 0) {
return (
<span
className={clearIndicatorClass}
Expand All @@ -302,45 +296,45 @@ export default function SearchBar({
style={{
color: Array.isArray(inputColor) ? inputColor[0] : inputColor,
}}
>{`${searchResultsIndex + 1}/${searchResults.length}`}</span>
>{`${cancerTypeResultsIndex + 1}/${cancerTypeResults.length}`}</span>
);
}

const getPreviousResult = useCallback(() => {
const getPreviousResult = () => {
if (!resultsAndIndexDefined) {
return;
}

let newIndex = searchResults.length - 1;
let newIndex = cancerTypeResults.length - 1;
if (cancerTypeResultsIndex !== 0) {
newIndex = searchResultsIndex - 1;
newIndex = cancerTypeResultsIndex - 1;
}
oncoTree?.focus(searchResults[newIndex]);
oncoTree?.focus(cancerTypeResults[newIndex]);
setCancerTypeResultsIndex(newIndex);
}, [resultsAndIndexDefined, searchResults, searchResultsIndex]);
}

const getNextResult = useCallback(() => {
const getNextResult = () => {
if (!resultsAndIndexDefined) {
return;
}

let newIndex = 0;
if (
cancerTypeResultsIndex !==
searchResults.length - 1
cancerTypeResults.length - 1
) {
newIndex = searchResultsIndex + 1;
newIndex = cancerTypeResultsIndex + 1;
}
oncoTree?.focus(searchResults[newIndex]);
oncoTree?.focus(cancerTypeResults[newIndex]);
setCancerTypeResultsIndex(newIndex);
}, [resultsAndIndexDefined, searchResults, searchResultsIndex]);
}

const isMobile = 'ontouchstart' in window || navigator.maxTouchPoints > 0;

return (
<>
{getResultsNumberSpan()}
{resultsAndIndexDefined && searchResults.length > 0 && (
{resultsAndIndexDefined && cancerTypeResults.length > 0 && (
<div style={{ userSelect: "none", display: "flex" }}>
<div
data-type={PREV_BUTTON_DATA_TYPE}
Expand Down

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion web/src/main/resources/static/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<link rel="icon" type="image/svg+xml" href="/assets/favicon-DLSGxvBL.svg" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>OncoTree</title>
<script type="module" crossorigin src="/assets/index-Bt2IFtk3.js"></script>
<script type="module" crossorigin src="/assets/index-BtFrCp6B.js"></script>
<link rel="stylesheet" crossorigin href="/assets/index-B7wOa-XQ.css">
</head>
<body>
Expand Down

0 comments on commit 687e7da

Please sign in to comment.