import React from 'react'; import { ContainerStylesAddon } from '../../types/plots'; import PlotListLegend, { PlotListLegendProps } from './PlotListLegend'; import PlotGradientLegend, { PlotLegendGradientProps, } from './PlotGradientLegend'; interface PlotLegendBaseProps extends ContainerStylesAddon { legendTitle?: string; } export type PlotLegendProps = PlotLegendBaseProps & ( | ({ type: 'list' } & PlotListLegendProps) | ({ type: 'colorscale' } & PlotLegendGradientProps) ); export default function PlotLegend({ type, legendTitle, containerStyles, ...otherProps }: PlotLegendProps) { const legendTextSize = '1.0em'; return ( <> {/* add a condition to show legend for single overlay data */} {((type === 'list' && ((otherProps as PlotListLegendProps).legendItems.length > 1 || (otherProps as PlotListLegendProps).showOverlayLegend)) || type === 'colorscale') && (