@jbrowse/plugin-wiggle
Version:
JBrowse 2 wiggle adapters, tracks, etc.
20 lines (19 loc) • 1.6 kB
JavaScript
import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
import { useMemo } from 'react';
import { getFillProps } from '@jbrowse/core/util';
import { useTheme } from '@mui/material';
import { observer } from 'mobx-react';
import LegendItem from "./LegendItem.js";
import LegendItemText from "./LegendItemText.js";
import RectBg from "./RectBg.js";
const ColorLegend = observer(function ColorLegend({ model, rowHeight, exportSVG, }) {
const { graphType, needsFullHeightScalebar, rowHeightTooSmallForScalebar, renderColorBoxes, sources, labelWidth, } = model;
const colorBoxWidth = renderColorBoxes ? 20 : 0;
const legendWidth = labelWidth + colorBoxWidth + 5;
const svgOffset = exportSVG ? 10 : 0;
const extraOffset = svgOffset || (graphType && !rowHeightTooSmallForScalebar ? 50 : 0);
const theme = useTheme();
const textFillProps = useMemo(() => getFillProps(theme.palette.text.primary), [theme.palette.text.primary]);
return sources ? (_jsxs(_Fragment, { children: [needsFullHeightScalebar ? (_jsx(RectBg, { y: 0, x: extraOffset, width: legendWidth, height: (sources.length + 0.25) * rowHeight })) : null, sources.map((source, idx) => (_jsx(LegendItem, { source: source, idx: idx, model: model, rowHeight: rowHeight, exportSVG: exportSVG, labelWidth: legendWidth }, `${source.name}-${idx}`))), sources.map((source, idx) => (_jsx(LegendItemText, { source: source, idx: idx, model: model, rowHeight: rowHeight, exportSVG: exportSVG, textFillProps: textFillProps }, `${source.name}-text-${idx}`)))] })) : null;
});
export default ColorLegend;