import styled from '@emotion/styled'; import { useCallback } from 'react'; import { usePreferences } from '../../context/PreferencesContext.js'; import { useScaleChecked } from '../../context/ScaleContext.js'; import { ResizerWithScale } from '../../elements/ResizerWithScale.js'; import type { Position } from '../../elements/resizer/SVGResizer.js'; import { useHighlight } from '../../highlight/index.js'; import { useResizerStatus } from '../../hooks/useResizerStatus.js'; const Rect = styled.rect<{ isActive: boolean }>` fill: ${({ isActive }) => (isActive ? '#ff6f0057' : 'green')}; height: ${({ isActive }) => (isActive ? '100%' : '6px')}; `; interface AnalysisRangeProps { columnKey: string; activeTab: string; rangeData: { from: number; to: number; }; } function AnalysisRange({ rangeData, columnKey, activeTab, }: AnalysisRangeProps) { const highlight = useHighlight([columnKey], { type: 'MULTIPLE_ANALYSIS_ZONE', extra: { colKey: columnKey }, }); const { scaleX } = useScaleChecked(); const { dispatch } = usePreferences(); const resizeEndHandler = useCallback( (resized: Position) => { const { x1, x2 } = resized; const start = scaleX().invert(x2); const end = scaleX().invert(x1); dispatch({ type: 'ANALYZE_SPECTRA', payload: { start, end, columnKey, nucleus: activeTab }, }); }, [activeTab, columnKey, dispatch, scaleX], ); const { from, to } = rangeData; const isResizingActive = useResizerStatus('multipleSpectraAnalysis'); return ( {({ x1, x2 }, isActive) => ( {columnKey} )} ); } export default AnalysisRange;