@@ -7,17 +7,19 @@ import { SvgNmrResetScale, SvgNmrSameTop } from 'cheminfo-font';
77import { memo , useCallback } from 'react' ;
88import { FaCreativeCommonsSamplingPlus } from 'react-icons/fa' ;
99import { IoColorPaletteOutline } from 'react-icons/io5' ;
10- import { MdFormatColorFill } from 'react-icons/md' ;
10+ import { MdFormatColorFill , MdOutlineFormatColorText } from 'react-icons/md' ;
1111
1212import { useChartData } from '../../context/ChartContext.js' ;
1313import { useDispatch } from '../../context/DispatchContext.js' ;
1414import { usePreferences } from '../../context/PreferencesContext.js' ;
1515import { useToaster } from '../../context/ToasterContext.js' ;
1616import { useAlert } from '../../elements/Alert.js' ;
1717import { useActiveSpectra } from '../../hooks/useActiveSpectra.js' ;
18+ import { usePanelPreferences } from '../../hooks/usePanelPreferences.ts' ;
1819import useSpectrum from '../../hooks/useSpectrum.js' ;
1920import { useToggleSpectraVisibility } from '../../hooks/useToggleSpectraVisibility.js' ;
2021import type { DisplayerMode } from '../../reducer/Reducer.js' ;
22+ import { booleanToString } from '../../utility/booleanToString.ts' ;
2123import { getSpectraByNucleus } from '../../utility/getSpectraByNucleus.js' ;
2224import type { ToolbarItemProps } from '../header/DefaultPanelHeader.js' ;
2325import DefaultPanelHeader from '../header/DefaultPanelHeader.js' ;
@@ -60,7 +62,9 @@ function SpectraPanelHeaderInner({
6062 const dispatch = useDispatch ( ) ;
6163 const {
6264 current : { spectraColors } ,
65+ dispatch : dispatchPreferences ,
6366 } = usePreferences ( ) ;
67+ const { enableSpectraLabel } = usePanelPreferences ( 'spectra' , activeTab ) ;
6468
6569 const handleDelete = useCallback ( ( ) => {
6670 alert . showAlert ( {
@@ -116,6 +120,14 @@ function SpectraPanelHeaderInner({
116120 payload : { } ,
117121 } ) ;
118122 }
123+
124+ function toggleSpectraLabelHandler ( ) {
125+ dispatchPreferences ( {
126+ type : 'TOGGLE_SPECTRA_LABEL' ,
127+ payload : { nucleus : activeTab } ,
128+ } ) ;
129+ }
130+
119131 const hasActiveSpectra = activeSpectra && activeSpectra ?. length > 0 ;
120132 const spectraLengthPerTab = getSpectraByNucleus ( activeTab , data ) ?. length ;
121133 const { getToggleVisibilityButtons } = useToggleSpectraVisibility (
@@ -168,6 +180,12 @@ function SpectraPanelHeaderInner({
168180 tooltip : 'Distinct spectra recoloring' ,
169181 onClick : distinctReColorSpectraHandler ,
170182 } ,
183+ {
184+ icon : < MdOutlineFormatColorText /> ,
185+ tooltip : `${ booleanToString ( ! enableSpectraLabel ) } spectra label` ,
186+ active : enableSpectraLabel ,
187+ onClick : toggleSpectraLabelHandler ,
188+ } ,
171189 ] ) ;
172190
173191 return (
0 commit comments