UNPKG

@jbrowse/plugin-linear-genome-view

Version:

JBrowse 2 linear genome view

37 lines (36 loc) 1.51 kB
import { jsx as _jsx } from "react/jsx-runtime"; import { getTickDisplayStr } from '@jbrowse/core/util'; import { Typography } from '@mui/material'; import { makeStyles } from 'tss-react/mui'; import { ContentBlock as ContentBlockComponent } from '../../BaseLinearDisplay/components/Block'; import { makeTicks } from '../util'; const useStyles = makeStyles()(theme => ({ majorTickLabel: { fontSize: 11, zIndex: 1, background: theme.palette.background.paper, lineHeight: 'normal', pointerEvents: 'none', }, tick: { position: 'absolute', width: 0, display: 'flex', justifyContent: 'center', pointerEvents: 'none', }, })); const ScalebarCoordinateTicks = function ({ block, bpPerPx, }) { const { classes } = useStyles(); const { reversed, start, end } = block; const ticks = makeTicks(start, end, bpPerPx, true, false); return (_jsx(ContentBlockComponent, { block: block, children: ticks.map(({ type, base }) => { if (type === 'major') { const x = (reversed ? end - base : base - start) / bpPerPx; const baseNumber = base + 1; return (_jsx("div", { className: classes.tick, style: { left: x }, children: baseNumber ? (_jsx(Typography, { className: classes.majorTickLabel, children: getTickDisplayStr(baseNumber, bpPerPx) })) : null }, base)); } return null; }) })); }; export default ScalebarCoordinateTicks;