UNPKG

@jbrowse/plugin-linear-genome-view

Version:

JBrowse 2 linear genome view

47 lines (46 loc) 2.13 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); const jsx_runtime_1 = require("react/jsx-runtime"); const material_1 = require("@mui/material"); const mobx_react_1 = require("mobx-react"); const mui_1 = require("tss-react/mui"); const useStyles = (0, mui_1.makeStyles)()(theme => ({ refLabel: { fontSize: 11, position: 'absolute', left: 2, top: -1, fontWeight: 'bold', lineHeight: 'normal', zIndex: 1, background: theme.palette.background.paper, }, b0: { left: 0, zIndex: 100, }, })); const ScalebarRefNameLabels = (0, mobx_react_1.observer)(function ({ model }) { const { classes, cx } = useStyles(); const { staticBlocks, offsetPx, scaleBarDisplayPrefix } = model; let lastLeftBlock = 0; staticBlocks.forEach((block, i) => { if (block.offsetPx - offsetPx < 0) { lastLeftBlock = i; } }); const val = scaleBarDisplayPrefix(); const b0 = staticBlocks.blocks[0]; return ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(b0 === null || b0 === void 0 ? void 0 : b0.type) !== 'ContentBlock' && val ? ((0, jsx_runtime_1.jsx)(material_1.Typography, { className: cx(classes.b0, classes.refLabel), children: val })) : null, staticBlocks.map((block, index) => { const { offsetPx: blockOffsetPx, isLeftEndOfDisplayedRegion, key, type, refName, } = block; const last = index === lastLeftBlock; return type === 'ContentBlock' && (isLeftEndOfDisplayedRegion || last) ? ((0, jsx_runtime_1.jsxs)(material_1.Typography, { style: { left: last ? Math.max(0, -offsetPx) : blockOffsetPx - offsetPx - 1, paddingLeft: last ? 0 : 1, }, className: classes.refLabel, "data-testid": `refLabel-${refName}`, children: [last && val ? `${val}:` : '', refName] }, `refLabel-${key}-${index}`)) : null; })] })); }); exports.default = ScalebarRefNameLabels;