@jbrowse/plugin-linear-genome-view
Version:
JBrowse 2 linear genome view
45 lines (44 loc) • 2.2 kB
JavaScript
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
import { forwardRef } from 'react';
import { getConf } from '@jbrowse/core/configuration';
import { SanitizedHTML } from '@jbrowse/core/ui';
import { getContainingView, getSession } from '@jbrowse/core/util';
import { getTrackName } from '@jbrowse/core/util/tracks';
import CloseIcon from '@mui/icons-material/Close';
import { IconButton, Paper, Typography, alpha } from '@mui/material';
import { observer } from 'mobx-react';
import { makeStyles } from 'tss-react/mui';
import TrackLabelDragHandle from './TrackLabelDragHandle';
import TrackLabelMenu from './TrackLabelMenu';
const useStyles = makeStyles()(theme => ({
root: {
zIndex: 200,
background: alpha(theme.palette.background.paper, 0.8),
'&:hover': {
background: theme.palette.background.paper,
},
},
trackName: {
fontSize: '0.8rem',
},
iconButton: {
padding: theme.spacing(1),
},
}));
const TrackLabel = observer(forwardRef(function TrackLabel2({ track, className }, ref) {
const { classes, cx } = useStyles();
const view = getContainingView(track);
const session = getSession(track);
const trackConf = track.configuration;
const { minimized } = track;
const trackId = getConf(track, 'trackId');
const trackName = getTrackName(trackConf, session);
return (_jsxs(Paper, { ref: ref, className: cx(className, classes.root), onClick: event => {
event.stopPropagation();
}, children: [_jsx(TrackLabelDragHandle, { track: track, trackId: trackId, view: view }), _jsx(IconButton, { onClick: () => view.hideTrack(trackId), className: classes.iconButton, title: "close this track", children: _jsx(CloseIcon, { fontSize: "small" }) }), _jsx(Typography, { variant: "body1", component: "span", className: classes.trackName, onMouseDown: event => {
event.stopPropagation();
}, children: _jsx(SanitizedHTML, { html: [trackName, minimized ? '(minimized)' : '']
.filter(f => !!f)
.join(' ') }) }), _jsx(TrackLabelMenu, { track: track })] }));
}));
export default TrackLabel;