Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: spectra colors customization and show/hide the values of integrals #2819

Merged
merged 5 commits into from
Jan 11, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@
"ml-stat": "^1.3.3",
"multiplet-analysis": "^2.1.2",
"nmr-correlation": "^2.3.3",
"nmr-load-save": "^0.23.11",
"nmr-load-save": "^0.24.0",
"nmr-processing": "^11.7.0",
"nmredata": "^0.9.9",
"numeral": "^2.0.6",
Expand Down Expand Up @@ -148,4 +148,4 @@
"vite": "^5.0.10",
"vitest": "^1.0.4"
}
}
}
11 changes: 7 additions & 4 deletions src/component/1d/integral/Integration.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
const { x, y } = integral;
const { scaleRatio } = useActiveSpectrumIntegralsViewState();
const path = useIntegralPath({ x, y, max, scaleRatio });
const { showIntegralsValues } = useActiveSpectrumIntegralsViewState();

Check warning on line 18 in src/component/1d/integral/Integration.tsx

View check run for this annotation

Codecov / codecov/patch

src/component/1d/integral/Integration.tsx#L18

Added line #L18 was not covered by tests
const integralPreferences = usePanelPreferences('integrals', nucleus);

return (
Expand All @@ -27,10 +28,12 @@
d={path}
/>

<IntegralResizable
integralData={integral}
integralFormat={integralPreferences.relative.format}
/>
{showIntegralsValues && (
<IntegralResizable
integralData={integral}
integralFormat={integralPreferences.relative.format}
/>
)}

Check warning on line 36 in src/component/1d/integral/Integration.tsx

View check run for this annotation

Codecov / codecov/patch

src/component/1d/integral/Integration.tsx#L31-L36

Added lines #L31 - L36 were not covered by tests
</g>
);
}
16 changes: 10 additions & 6 deletions src/component/1d/ranges/Range.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
import { useDispatch } from '../../context/DispatchContext';
import { ResizerWithScale } from '../../elements/ResizerWithScale';
import { HighlightEventSource, useHighlight } from '../../highlight';
import { useActiveSpectrumRangesViewState } from '../../hooks/useActiveSpectrumRangesViewState';

Check warning on line 15 in src/component/1d/ranges/Range.tsx

View check run for this annotation

Codecov / codecov/patch

src/component/1d/ranges/Range.tsx#L15

Added line #L15 was not covered by tests
import { useResizerStatus } from '../../hooks/useResizerStatus';
import { options } from '../../toolbar/ToolTypes';
import { IntegralIndicator } from '../integral/IntegralIndicator';
Expand Down Expand Up @@ -60,6 +61,7 @@

const scaleX = useScaleX();
const dispatch = useDispatch();
const { showIntegralsValues } = useActiveSpectrumRangesViewState();

Check warning on line 64 in src/component/1d/ranges/Range.tsx

View check run for this annotation

Codecov / codecov/patch

src/component/1d/ranges/Range.tsx#L64

Added line #L64 was not covered by tests

const isBlockedByEditing =
selectedTool && selectedTool === options.editRange.id;
Expand Down Expand Up @@ -145,12 +147,14 @@
data-no-export="true"
/>

<IntegralIndicator
value={integration}
format={relativeFormat}
width={width}
opacity={isNotSignal ? 0.5 : 1}
/>
{showIntegralsValues && (
<IntegralIndicator
value={integration}
format={relativeFormat}
width={width}
opacity={isNotSignal ? 0.5 : 1}
/>
)}

Check warning on line 157 in src/component/1d/ranges/Range.tsx

View check run for this annotation

Codecov / codecov/patch

src/component/1d/ranges/Range.tsx#L150-L157

Added lines #L150 - L157 were not covered by tests
</g>
);
}}
Expand Down
34 changes: 0 additions & 34 deletions src/component/elements/formik/FormikColorInput.tsx

This file was deleted.

28 changes: 28 additions & 0 deletions src/component/elements/formik/FormikColorPickerDropdown.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
import { useFormikContext } from 'formik';
import lodashGet from 'lodash/get';
import { ColorPickerDropdown, ColorPickerProps } from 'react-science/ui';

interface FormikColorPickerDropdownProps extends ColorPickerProps {
name: string;
}

function FormikColorPickerDropdown(props: FormikColorPickerDropdownProps) {
const { onChangeComplete = () => null, name, ...colorPickerProps } = props;

const { values, setFieldValue } = useFormikContext();

function colorChangeHandler(color) {
onChangeComplete(color);
void setFieldValue(name, color.hex);
}

return (
<ColorPickerDropdown
{...colorPickerProps}
onChangeComplete={colorChangeHandler}
color={{ hex: lodashGet(values, name) }}
/>
);
}

export default FormikColorPickerDropdown;

Check warning on line 28 in src/component/elements/formik/FormikColorPickerDropdown.tsx

View check run for this annotation

Codecov / codecov/patch

src/component/elements/formik/FormikColorPickerDropdown.tsx#L2-L28

Added lines #L2 - L28 were not covered by tests
1 change: 1 addition & 0 deletions src/component/hooks/useActiveSpectrumIntegralsViewState.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@

export const defaultIntegralsViewState: IntegralsViewState = {
scaleRatio: 1,
showIntegralsValues: true,

Check warning on line 9 in src/component/hooks/useActiveSpectrumIntegralsViewState.ts

View check run for this annotation

Codecov / codecov/patch

src/component/hooks/useActiveSpectrumIntegralsViewState.ts#L9

Added line #L9 was not covered by tests
};

export function useActiveSpectrumIntegralsViewState() {
Expand Down
1 change: 1 addition & 0 deletions src/component/hooks/useActiveSpectrumRangesViewState.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
showPeaks: false,
showMultiplicityTrees: false,
showIntegrals: false,
showIntegralsValues: true,

Check warning on line 11 in src/component/hooks/useActiveSpectrumRangesViewState.ts

View check run for this annotation

Codecov / codecov/patch

src/component/hooks/useActiveSpectrumRangesViewState.ts#L11

Added line #L11 was not covered by tests
showJGraph: false,
displayingMode: 'spread',
integralsScaleRatio: 1,
Expand Down
7 changes: 5 additions & 2 deletions src/component/loader/DropZone.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,8 @@
function DropZone(props) {
const { width, height } = useChartData();
const dispatch = useDispatch();
const { dispatch: dispatchPreferences, current } = usePreferences();
const { dispatch: dispatchPreferences, current: workspacePreferences } =
usePreferences();

Check warning on line 58 in src/component/loader/DropZone.tsx

View check run for this annotation

Codecov / codecov/patch

src/component/loader/DropZone.tsx#L57-L58

Added lines #L57 - L58 were not covered by tests
const preferences = usePreferences();
const isToolEnabled = useCheckToolsVisibility();
const openImportMetaInformationModal = useMetaInformationImportationModal();
Expand All @@ -76,12 +77,13 @@
parseMetaFileResult = await parseMetaFile(metaFile);
}
const { nmrLoaders: sourceSelector } = preferences.current;
const { onLoadProcessing, spectraColors } = workspacePreferences;

Check warning on line 80 in src/component/loader/DropZone.tsx

View check run for this annotation

Codecov / codecov/patch

src/component/loader/DropZone.tsx#L80

Added line #L80 was not covered by tests
const { nmriumState, containsNmrium } = await readDropFiles(
fileCollection,
{
sourceSelector,
logger: logger.child({ context: 'nmr-processing' }),
onLoadProcessing: current.onLoadProcessing,
onLoadProcessing,

Check warning on line 86 in src/component/loader/DropZone.tsx

View check run for this annotation

Codecov / codecov/patch

src/component/loader/DropZone.tsx#L86

Added line #L86 was not covered by tests
experimentalFeatures,
},
);
Expand All @@ -101,6 +103,7 @@
nmriumState,
containsNmrium,
parseMetaFileResult,
spectraColors,

Check warning on line 106 in src/component/loader/DropZone.tsx

View check run for this annotation

Codecov / codecov/patch

src/component/loader/DropZone.tsx#L106

Added line #L106 was not covered by tests
},
});
}
Expand Down
6 changes: 6 additions & 0 deletions src/component/modal/setting/GeneralSettings.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
import ImportationFiltersTabContent from './settings-tabs/ImportationFiltersTabContent';
import InfoBlockTabContent from './settings-tabs/InfoBlockTabContent';
import OnLoadProcessingTabContent from './settings-tabs/OnLoadProcessingTabContent';
import SpectraColorsTabContent from './settings-tabs/SpectraColorsTabContent';

Check warning on line 36 in src/component/modal/setting/GeneralSettings.tsx

View check run for this annotation

Codecov / codecov/patch

src/component/modal/setting/GeneralSettings.tsx#L36

Added line #L36 was not covered by tests
import ToolsTabContent from './settings-tabs/ToolsTabContent';
import { validation } from './settingsValidation';

Expand Down Expand Up @@ -422,6 +423,11 @@
<OnLoadProcessingTabContent />
</div>
</Tab>
<Tab title="Spectra colors" tabid="spectra-colors">
<div className="inner-content">
<SpectraColorsTabContent />
</div>
</Tab>

Check warning on line 430 in src/component/modal/setting/GeneralSettings.tsx

View check run for this annotation

Codecov / codecov/patch

src/component/modal/setting/GeneralSettings.tsx#L426-L430

Added lines #L426 - L430 were not covered by tests
</Tabs>
</Formik>
</div>
Expand Down
Loading
Loading