Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

revert changes and build frontend #274

Merged
merged 2 commits into from
Nov 21, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
45 changes: 20 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,26 @@ 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 +297,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
Loading