Skip to content

Commit

Permalink
Misc refactors
Browse files Browse the repository at this point in the history
  • Loading branch information
cmdcolin committed Aug 31, 2024
1 parent 719e8f3 commit 9baea49
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 19 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -29,14 +29,15 @@ const SetMaxHeightDialog = observer(function (props: {
const [max, setMax] = useState(`${maxHeight}`)

return (
<Dialog open onClose={handleClose} title="Filter options">
<Dialog open onClose={handleClose} title="Set max height">
<DialogContent className={classes.root}>
<Typography>
Set max height for the track. For example, you can increase this if
the layout says &quot;Max height reached&quot;
</Typography>
<TextField
value={max}
autoFocus
onChange={event => {
setMax(event.target.value)
}}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,6 @@ export function onSynClick(
const unitMultiplier = Math.floor(MAX_COLOR_RANGE / model.numFeats)
const id = getId(r1!, g1!, b1!, unitMultiplier)
const feat = model.featPositions[id]
console.log('WOWOWOWOW')
if (feat) {
const { f } = feat
model.setClickId(f.id())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ const useStyles = makeStyles()({
})

type Coord = [number, number]

const BaseLinearDisplay = observer(function (props: {
model: BaseLinearDisplayModel
children?: React.ReactNode
Expand All @@ -33,14 +34,8 @@ const BaseLinearDisplay = observer(function (props: {
const [clientMouseCoord, setClientMouseCoord] = useState<Coord>([0, 0])
const [contextCoord, setContextCoord] = useState<Coord>()
const { model, children } = props
const {
TooltipComponent,
DisplayMessageComponent,
contextMenuItems,
height,
setContextMenuFeature,
} = model

const { TooltipComponent, DisplayMessageComponent, height } = model
const items = model.contextMenuItems()
return (
<div
ref={ref}
Expand Down Expand Up @@ -83,19 +78,19 @@ const BaseLinearDisplay = observer(function (props: {
/>

<Menu
open={Boolean(contextCoord) && Boolean(contextMenuItems().length)}
open={Boolean(contextCoord) && items.length > 0}
onMenuItemClick={(_, callback) => {
callback()
setContextCoord(undefined)
}}
onClose={() => {
setContextCoord(undefined)
setContextMenuFeature(undefined)
model.setContextMenuFeature(undefined)
}}
TransitionProps={{
onExit: () => {
setContextCoord(undefined)
setContextMenuFeature(undefined)
model.setContextMenuFeature(undefined)
},
}}
anchorReference="anchorPosition"
Expand All @@ -104,8 +99,10 @@ const BaseLinearDisplay = observer(function (props: {
? { top: contextCoord[1], left: contextCoord[0] }
: undefined
}
style={{ zIndex: theme.zIndex.tooltip }}
menuItems={contextMenuItems()}
style={{
zIndex: theme.zIndex.tooltip,
}}
menuItems={items}
/>
</div>
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ const SetMaxHeightDialog = observer(function ({
const { classes } = useStyles()
const { maxHeight = '' } = model
const [max, setMax] = useState(`${maxHeight}`)

const ok = max !== '' && !Number.isNaN(+max)
return (
<Dialog open onClose={handleClose} title="Set max height">
<DialogContent className={classes.root}>
Expand All @@ -44,17 +44,17 @@ const SetMaxHeightDialog = observer(function ({
}}
placeholder="Enter max score"
/>
{!ok ? <div style={{ color: 'red' }}>Invalid number</div> : null}
</DialogContent>
<DialogActions>
<Button
variant="contained"
color="primary"
type="submit"
autoFocus
disabled={!ok}
onClick={() => {
model.setMaxHeight(
max !== '' && !Number.isNaN(+max) ? +max : undefined,
)
model.setMaxHeight(+max)
handleClose()
}}
>
Expand Down

0 comments on commit 9baea49

Please sign in to comment.