import React, { useState } from 'react'; import { getProgressBarColor, SUB_PROGRESS_COLOR } from './progressBar'; import { Label } from 'app/shared/components/text/text'; import { SvgWrapper } from 'app/shared/modules/chart/core'; import Measure from 'react-measure'; import cx from 'classnames'; export interface Props { labels: string[]; additionalLabel?: string; } const dotSize = { height: 8, width: 8, }; export const ProgressBarLegend = ({ labels, additionalLabel }: Props) => { const [ maxWidth, setMaxWidth ] = useState(0); const [ containerWidth, setContainerWidth ] = useState(0); const onResize = (contentRect) => { if (contentRect.bounds.width > maxWidth) { setMaxWidth(contentRect.bounds.width); } }; const onContainerResize = (contentRect) => { setContainerWidth(contentRect.bounds.width); }; return { (props) => { const allLabels = additionalLabel ? [ ...labels, additionalLabel ] : labels; return
{allLabels.map((label, index) => ( { (props) => { const isAdditionalLabel = index === allLabels.length - 1 && additionalLabel; const className = cx('o-layout', 'o-layout--aligned', 'u-margin-bottom', 'u-margin-right--medium', { 'u-animate-fade-in--fast': isAdditionalLabel, }); return
containerWidth ? { minWidth: maxWidth } : {}} > {/*@ts-ignore*/}
; } }
))}
; } }
; };