@jbrowse/plugin-wiggle
Version:
JBrowse 2 wiggle adapters, tracks, etc.
15 lines (14 loc) • 1.25 kB
JavaScript
import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
import RectBg from './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 (_jsxs(_Fragment, { children: [needsFullHeightScalebar ? null : (_jsx(RectBg, { y: idx * rowHeight + 1, x: extraOffset, width: legendWidth, height: boxHeight })), source.color ? (_jsx(RectBg, { y: idx * rowHeight + 1, x: extraOffset, width: colorBoxWidth, height: needsCustomLegend ? rowHeight : boxHeight, color: source.color })) : null, canDisplayLabel ? (_jsx("text", { y: idx * rowHeight + 13, x: extraOffset + colorBoxWidth + 2, fontSize: svgFontSize, children: source.name })) : null] }));
};
export default LegendItem;