Skip to content

Commit

Permalink
turn functions to boolean constants
Browse files Browse the repository at this point in the history
  • Loading branch information
interim17 committed Nov 22, 2023
1 parent dba1710 commit c4e554b
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 26 deletions.
19 changes: 6 additions & 13 deletions src/components/DownloadTrajectoryMenu/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -53,33 +53,26 @@ const DownloadTrajectoryMenu = ({
downloadFile(simulariumFile.name);
};

const isDisabled = () => {
return !fileIsLoaded() || isBuffering;
};

const getTooltipOffset = () => {
if (isDisabled()) {
return [25, -30];
} else return [40, -18];
};
const isDisabled = !fileIsLoaded() || isBuffering;
const tooltipOffset = isDisabled ? [25, -30] : [40, -18];

return (
<div className={styles.container}>
<Tooltip
placement="bottomLeft"
title={
isDisabled()
isDisabled
? "Load a model to perform this action"
: "Download trajectory"
}
color={TOOLTIP_COLOR}
align={{ offset: getTooltipOffset() }}
align={{ offset: tooltipOffset }}
>
<Button
className={isDisabled() ? styles.disabled : undefined}
className={isDisabled ? styles.disabled : undefined}
onClick={onClick}
type="primary"
disabled={isDisabled()}
disabled={isDisabled}
>
Download {Download}
</Button>
Expand Down
19 changes: 6 additions & 13 deletions src/components/ShareTrajectoryButton/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -26,15 +26,8 @@ const ShareTrajectoryButton = ({
setIsSharing(!isSharing);
};

const isDisabled = () => {
return !simulariumFile.name || isSharing || isBuffering;
};

const getTooltipOffset = () => {
if (isDisabled()) {
return [0, -30];
} else return [0, -18];
};
const isDisabled = !simulariumFile.name || isSharing || isBuffering;
const tooltipOffset = isDisabled ? [0, -30] : [0, -18];

return (
<div className={styles.container}>
Expand All @@ -48,19 +41,19 @@ const ShareTrajectoryButton = ({
) : null}
<Tooltip
title={
isDisabled()
isDisabled
? "Load a model to perform this action"
: "Share trajectory"
}
placement="bottomLeft"
color={TOOLTIP_COLOR}
align={{ offset: getTooltipOffset() }}
align={{ offset: tooltipOffset }}
>
<Button
className={isDisabled() ? styles.disabled : undefined}
className={isDisabled ? styles.disabled : undefined}
onClick={handleShare}
type="primary"
disabled={isDisabled()}
disabled={isDisabled}
>
Share {Share}
</Button>
Expand Down

0 comments on commit c4e554b

Please sign in to comment.