-
Notifications
You must be signed in to change notification settings - Fork 63
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
16 changed files
with
380 additions
and
68 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
import React from 'react' | ||
import { ResizableBox } from 'react-resizable' | ||
import { observer } from 'mobx-react' | ||
import { AbstractViewModel, SessionWithDrawerWidgets } from '@jbrowse/core/util' | ||
import { SnackbarMessage } from '@jbrowse/core/ui/SnackbarModel' | ||
import { MenuItem as JBMenuItem } from '@jbrowse/core/ui/Menu' | ||
import DraggableDialog from '@jbrowse/core/ui/DraggableDialog' | ||
|
||
// locals | ||
import StaticViewPanel from './StaticViewPanel' | ||
import './test.css' | ||
|
||
type AppSession = SessionWithDrawerWidgets & { | ||
savedSessionNames: string[] | ||
menus: { label: string; menuItems: JBMenuItem[] }[] | ||
snackbarMessages: SnackbarMessage[] | ||
renameCurrentSession: (arg: string) => void | ||
popSnackbarMessage: () => unknown | ||
} | ||
|
||
const FloatingViewPanel = observer(function ({ | ||
view, | ||
session, | ||
}: { | ||
view: AbstractViewModel | ||
session: AppSession | ||
}) { | ||
const zIndex = session.focusedViewId === view.id ? 101 : 100 | ||
return ( | ||
<DraggableDialog zIndex={zIndex}> | ||
<ResizableBox | ||
className="box" | ||
height={200} | ||
resizeHandles={['se']} | ||
width={1000} | ||
> | ||
<StaticViewPanel view={view} session={session} /> | ||
</ResizableBox> | ||
</DraggableDialog> | ||
) | ||
}) | ||
|
||
export default FloatingViewPanel |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
import React, { useEffect, useRef } from 'react' | ||
import { observer } from 'mobx-react' | ||
|
||
const StaticViewWrapper = observer(function ({ | ||
children, | ||
}: { | ||
children: React.ReactNode | ||
}) { | ||
const scrollRef = useRef<HTMLDivElement>(null) | ||
|
||
// scroll the view into view when first mounted. note: this effect will run | ||
// only once, because of the empty array second param | ||
useEffect(() => { | ||
scrollRef.current?.scrollIntoView({ block: 'center' }) | ||
}, []) | ||
return <div>{children}</div> | ||
}) | ||
|
||
export default StaticViewWrapper |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
import React from 'react' | ||
import { IconButton } from '@mui/material' | ||
import { makeStyles } from 'tss-react/mui' | ||
import { observer } from 'mobx-react' | ||
import { IBaseViewModel } from '@jbrowse/core/pluggableElementTypes/models' | ||
|
||
// icons | ||
import CloseIcon from '@mui/icons-material/Close' | ||
import MinimizeIcon from '@mui/icons-material/Minimize' | ||
import AddIcon from '@mui/icons-material/Add' | ||
|
||
// locals | ||
import OpenInNew from '@mui/icons-material/OpenInNew' | ||
|
||
const useStyles = makeStyles()(theme => ({ | ||
icon: { | ||
color: theme.palette.secondary.contrastText, | ||
}, | ||
})) | ||
|
||
const ViewHeaderButtons = observer(function ({ | ||
view, | ||
onClose, | ||
onMinimize, | ||
}: { | ||
view: IBaseViewModel | ||
onClose: () => void | ||
onMinimize: () => void | ||
}) { | ||
const { classes } = useStyles() | ||
return ( | ||
<> | ||
<IconButton | ||
data-testid="open_in_new" | ||
onClick={() => { | ||
view.setFloating(!view.floating) | ||
}} | ||
> | ||
<OpenInNew className={classes.icon} fontSize="small" /> | ||
</IconButton> | ||
<IconButton data-testid="minimize_view" onClick={onMinimize}> | ||
{view.minimized ? ( | ||
<AddIcon className={classes.icon} fontSize="small" /> | ||
) : ( | ||
<MinimizeIcon className={classes.icon} fontSize="small" /> | ||
)} | ||
</IconButton> | ||
<IconButton data-testid="close_view" onClick={onClose}> | ||
<CloseIcon className={classes.icon} fontSize="small" /> | ||
</IconButton> | ||
</> | ||
) | ||
}) | ||
|
||
export default ViewHeaderButtons |
Oops, something went wrong.