UNPKG

@jbrowse/plugin-wiggle

Version:

JBrowse 2 wiggle adapters, tracks, etc.

20 lines (19 loc) 1.57 kB
"use strict"; var __importDefault = (this && this.__importDefault) || function (mod) { return (mod && mod.__esModule) ? mod : { "default": mod }; }; Object.defineProperty(exports, "__esModule", { value: true }); const jsx_runtime_1 = require("react/jsx-runtime"); const RectBg_1 = __importDefault(require("./RectBg")); const LegendItem = function ({ source, idx, rowHeight, labelWidth, model, exportSVG, }) { const boxHeight = Math.min(20, rowHeight); const { needsCustomLegend, graphType, needsFullHeightScalebar, rowHeightTooSmallForScalebar, renderColorBoxes, } = model; const svgFontSize = Math.min(rowHeight, 12); const canDisplayLabel = rowHeight > 11; const colorBoxWidth = renderColorBoxes ? 15 : 0; const legendWidth = labelWidth + colorBoxWidth + 5; const svgOffset = exportSVG ? 10 : 0; const extraOffset = svgOffset || (graphType && !rowHeightTooSmallForScalebar ? 50 : 0); return ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [needsFullHeightScalebar ? null : ((0, jsx_runtime_1.jsx)(RectBg_1.default, { y: idx * rowHeight + 1, x: extraOffset, width: legendWidth, height: boxHeight })), source.color ? ((0, jsx_runtime_1.jsx)(RectBg_1.default, { y: idx * rowHeight + 1, x: extraOffset, width: colorBoxWidth, height: needsCustomLegend ? rowHeight : boxHeight, color: source.color })) : null, canDisplayLabel ? ((0, jsx_runtime_1.jsx)("text", { y: idx * rowHeight + 13, x: extraOffset + colorBoxWidth + 2, fontSize: svgFontSize, children: source.name })) : null] })); }; exports.default = LegendItem;