UNPKG

@jbrowse/plugin-linear-genome-view

Version:

JBrowse 2 linear genome view

39 lines (38 loc) 1.65 kB
import { jsxs as _jsxs, jsx as _jsx } from "react/jsx-runtime"; import { useRef } from 'react'; import { makeStyles } from '@jbrowse/core/util/tss-react'; import { observer } from 'mobx-react'; const useStyles = makeStyles()(theme => ({ centerLineContainer: { background: 'transparent', height: '100%', zIndex: 4, position: 'absolute', left: 0, border: `1px ${theme.palette.action.active} dashed`, borderTop: 'none', borderBottom: 'none', pointerEvents: 'none', }, centerLineText: { position: 'absolute', left: 0, pointerEvents: 'none', whiteSpace: 'nowrap', fontWeight: 'bold', }, })); const CenterLine = observer(function CenterLine({ model }) { const { bpPerPx, centerLineInfo, trackHeights, tracks, width } = model; const ref = useRef(null); const { classes } = useStyles(); const startingPosition = width / 2; return tracks.length ? (_jsx("div", { "data-testid": "centerline_container", className: classes.centerLineContainer, role: "presentation", ref: ref, style: { transform: `translateX(${startingPosition}px)`, width: Math.max(1 / bpPerPx, 1), }, children: centerLineInfo && (_jsxs("div", { "data-testid": "centerline_text", className: classes.centerLineText, role: "presentation", style: { transform: `translateX(${Math.max(1 / bpPerPx, 1) + 5}px)`, top: trackHeights, }, children: [centerLineInfo.refName, ":", ' ', Math.max(Math.round(centerLineInfo.offset) + 1, 0)] })) })) : null; }); export default CenterLine;