Skip to content

Commit

Permalink
fix: improve consistency of labels (#2970)
Browse files Browse the repository at this point in the history
- Do not use uppercase in wrong places.
- Remove unnecessary whitespaces.
- Refactor Label component to wrap the form element with `<label>` to
  remove the need for `htmlFor` and automatically bind it to the element.
- Drive-by: correct spelling error (spectrums instead of spectra).
  • Loading branch information
targos committed Mar 19, 2024
1 parent 544c2cc commit 92fd75d
Show file tree
Hide file tree
Showing 74 changed files with 195 additions and 248 deletions.
2 changes: 1 addition & 1 deletion src/component/1d/LinesSeries.tsx
Expand Up @@ -44,7 +44,7 @@ function LinesSeries() {

const { setActiveSpectrum } = useSetActiveSpectrumAction();
return (
<g clipPath={`url(#${displayerKey}clip-chart-1d)`} className="spectrums">
<g clipPath={`url(#${displayerKey}clip-chart-1d)`} className="spectra">
{spectra.map((d, i) => (
<g key={d.id}>
<Line display={d.display} id={d.id} data={get1DDataXY(d)} index={i} />
Expand Down
6 changes: 3 additions & 3 deletions src/component/EventsTrackers/KeysListenerTracker.tsx
Expand Up @@ -42,7 +42,7 @@ function KeysListenerTracker(props: KeysListenerTrackerProps) {
const {
handleChangeOption,
handleFullZoomOut,
alignSpectrumsVerticallyHandler,
alignSpectraVerticallyHandler,
changeDisplayViewModeHandler,
} = useToolsFunctions();

Expand Down Expand Up @@ -398,7 +398,7 @@ function KeysListenerTracker(props: KeysListenerTrackerProps) {
}
case 'c': {
if (allow1DTool && isToolVisible('spectraCenterAlignments')) {
alignSpectrumsVerticallyHandler();
alignSpectraVerticallyHandler();
}
break;
}
Expand Down Expand Up @@ -455,7 +455,7 @@ function KeysListenerTracker(props: KeysListenerTrackerProps) {
}
},
[
alignSpectrumsVerticallyHandler,
alignSpectraVerticallyHandler,
allow1DTool,
changeDisplayViewModeHandler,
dispatch,
Expand Down
2 changes: 1 addition & 1 deletion src/component/context/DispatchContext.tsx
Expand Up @@ -12,8 +12,8 @@ import { MoleculeActions } from '../reducer/actions/MoleculeActions';
import { PeaksActions } from '../reducer/actions/PeaksActions';
import { PreferencesActions } from '../reducer/actions/PreferencesActions';
import { RangesActions } from '../reducer/actions/RangesActions';
import { SpectrumActions } from '../reducer/actions/SpectraActions';
import { SpectraAnalysisActions } from '../reducer/actions/SpectraAnalysisAction';
import { SpectrumActions } from '../reducer/actions/SpectrumsActions';
import { ToolsActions } from '../reducer/actions/ToolsActions';
import { ZonesActions } from '../reducer/actions/ZonesActions';
import { ActionType } from '../reducer/types/ActionType';
Expand Down
11 changes: 7 additions & 4 deletions src/component/elements/Label.tsx
Expand Up @@ -32,8 +32,11 @@ export default function Label(props: LabelProps) {
...otherProps
} = props;
return (
<div style={{ display: 'flex', alignItems: 'center', ...style?.container }}>
<label
<label
style={{ display: 'flex', alignItems: 'center', ...style?.container }}
{...otherProps}
>
<span
className={className}
style={{
fontSize: '12px',
Expand Down Expand Up @@ -63,8 +66,8 @@ export default function Label(props: LabelProps) {
color={{ base: 'gray', hover: 'black' }}
/>
)}
</label>
</span>
<div style={style?.wrapper}>{children}</div>
</div>
</label>
);
}
18 changes: 7 additions & 11 deletions src/component/header/ApodizationOptionsPanel.tsx
Expand Up @@ -93,8 +93,8 @@ function ApodizationOptionsInnerPanel(
{({ submitForm }) => (
<>
<Label
title="Line broadening : "
shortTitle="LB :"
title="Line broadening:"
shortTitle="LB:"
style={headerLabelStyle}
>
<FormikInput
Expand All @@ -108,8 +108,8 @@ function ApodizationOptionsInnerPanel(
/>
</Label>
<Label
title="Gauss broadening :"
shortTitle="GB :"
title="Gauss broadening:"
shortTitle="GB:"
style={headerLabelStyle}
>
<FormikInput
Expand All @@ -123,8 +123,8 @@ function ApodizationOptionsInnerPanel(
/>
</Label>
<Label
title="lineBroadeningCenter [0 - 1] : "
shortTitle="LB Center :"
title="Line broadening center [0 - 1]:"
shortTitle="LB center:"
style={headerLabelStyle}
>
<FormikInput
Expand All @@ -137,11 +137,7 @@ function ApodizationOptionsInnerPanel(
debounceTime={250}
/>
</Label>
<Label
title="Live preview "
htmlFor="livePreview"
style={{ label: { padding: '0 5px' } }}
>
<Label title="Live preview" style={{ label: { padding: '0 5px' } }}>
<FormikCheckBox name="livePreview" />
</Label>

Expand Down
14 changes: 7 additions & 7 deletions src/component/header/AutoPeakPickingOptionPanel.tsx
Expand Up @@ -80,16 +80,16 @@ function AutoPeakPickingOptionPanel() {
>
{({ handleSubmit, isValid }) => (
<>
<Label title="Direction : " shortTitle="" style={headerLabelStyle}>
<Label title="Direction:" shortTitle="" style={headerLabelStyle}>
<FormikSelect
name="direction"
items={LookFor}
style={{ width: '85px' }}
/>
</Label>
<Label
title="Max Number Of Peaks :"
shortTitle="Peaks number :"
title="Max number of peaks:"
shortTitle="Max peaks:"
style={headerLabelStyle}
>
<FormikInput
Expand All @@ -101,8 +101,8 @@ function AutoPeakPickingOptionPanel() {
/>
</Label>
<Label
title="Noise factor :"
shortTitle="Noise :"
title="Noise factor:"
shortTitle="Noise:"
style={headerLabelStyle}
>
<FormikInput
Expand All @@ -113,8 +113,8 @@ function AutoPeakPickingOptionPanel() {
/>
</Label>
<Label
title="Min Max Ratio :"
shortTitle="Ratio :"
title="Min/max Ratio:"
shortTitle="Ratio:"
style={headerLabelStyle}
>
<FormikInput
Expand Down
14 changes: 5 additions & 9 deletions src/component/header/BaseLineCorrectionPanel.tsx
Expand Up @@ -151,15 +151,15 @@ function BaseLineCorrectionInnerPanel(
<>
{algorithm && algorithm === 'airpls' && (
<div style={{ display: 'flex' }}>
<Label title="maxIterations:" style={headerLabelStyle}>
<Label title="Max iterations:" style={headerLabelStyle}>
<FormikInput
type="number"
name="maxIterations"
debounceTime={250}
style={inputStyle}
/>
</Label>
<Label title="tolerance:" style={headerLabelStyle}>
<Label title="Tolerance:" style={headerLabelStyle}>
<FormikInput
type="number"
name="tolerance"
Expand All @@ -173,8 +173,8 @@ function BaseLineCorrectionInnerPanel(
{algorithm &&
['autoPolynomial', 'polynomial'].includes(algorithm) && (
<Label
title="degree [ 1 - 6 ]:"
shortTitle="degree :"
title="Degree [1 - 6]:"
shortTitle="Degree:"
style={headerLabelStyle}
>
<FormikInput
Expand All @@ -188,11 +188,7 @@ function BaseLineCorrectionInnerPanel(
</Label>
)}

<Label
title="live preview "
htmlFor="livePreview"
style={headerLabelStyle}
>
<Label title="Live preview" style={headerLabelStyle}>
<FormikCheckBox name="livePreview" />
</Label>

Expand Down
2 changes: 1 addition & 1 deletion src/component/header/Header.tsx
Expand Up @@ -201,7 +201,7 @@ function HeaderInner(props: HeaderInnerProps) {
<Toolbar.Item
id="full-screen"
onClick={fullscreen.toggle}
title="Full Screen"
title="Full screen"
className="windowButton"
icon={<FaRegWindowMaximize />}
/>
Expand Down
4 changes: 2 additions & 2 deletions src/component/header/PhaseCorrectionPanel.tsx
Expand Up @@ -191,7 +191,7 @@ export default function PhaseCorrectionPanel() {
</div>
{phaseCorrectionTypeItem?.value === 'manual' && (
<>
<Label title="PH0 :" style={headerLabelStyle}>
<Label title="PH0:" style={headerLabelStyle}>
<Input
name="ph0"
style={inputStyle}
Expand All @@ -201,7 +201,7 @@ export default function PhaseCorrectionPanel() {
debounceTime={250}
/>
</Label>
<Label title="PH1 :" style={headerLabelStyle}>
<Label title="PH1:" style={headerLabelStyle}>
<Input
name="ph1"
style={inputStyle}
Expand Down
6 changes: 3 additions & 3 deletions src/component/header/PhaseCorrectionTwoDimensionsPanel.tsx
Expand Up @@ -193,7 +193,7 @@ export default function PhaseCorrectionTwoDimensionsPanel() {

return (
<HeaderContainer style={{ padding: '0 5px' }}>
<Label title="Direction :" style={headerLabelStyle}>
<Label title="Direction:" style={headerLabelStyle}>
<Toolbar>
<Toolbar.Item
css={css`
Expand Down Expand Up @@ -226,7 +226,7 @@ export default function PhaseCorrectionTwoDimensionsPanel() {
</Toolbar>
</div>

<Label title="PH0 :" style={headerLabelStyle}>
<Label title="PH0:" style={headerLabelStyle}>
<Input
name="ph0"
style={inputStyle}
Expand All @@ -236,7 +236,7 @@ export default function PhaseCorrectionTwoDimensionsPanel() {
debounceTime={250}
/>
</Label>
<Label title="PH1 :" style={headerLabelStyle}>
<Label title="PH1:" style={headerLabelStyle}>
<Input
name="ph1"
style={inputStyle}
Expand Down
8 changes: 2 additions & 6 deletions src/component/header/RangesPickingOptionPanel.tsx
Expand Up @@ -52,14 +52,10 @@ function RangesPickingOptionPanel() {
>
{({ handleSubmit, isValid }) => (
<>
<Label
title="Detect negative:"
htmlFor="lookNegative"
style={headerLabelStyle}
>
<Label title="Detect negative" style={headerLabelStyle}>
<FormikCheckBox name="lookNegative" />
</Label>
<Label title="Min Max Ratio:" style={headerLabelStyle}>
<Label title="Min/max ratio:" style={headerLabelStyle}>
<FormikInput
type="number"
name="minMaxRatio"
Expand Down
8 changes: 2 additions & 6 deletions src/component/header/ZeroFillingOptionsPanel.tsx
Expand Up @@ -82,18 +82,14 @@ function ZeroFillingOptionsInnerPanel(props: { size: number }) {
>
{({ submitForm }) => (
<>
<Label title="Size: " style={headerLabelStyle}>
<Label title="Size:" style={headerLabelStyle}>
<FormikSelect
items={Sizes}
style={{ marginLeft: 10, marginRight: 10 }}
name="nbPoints"
/>
</Label>
<Label
title="Live preview "
htmlFor="livePreview"
style={{ label: { padding: '0 5px' } }}
>
<Label title="Live preview" style={{ label: { padding: '0 5px' } }}>
<FormikCheckBox name="livePreview" />
</Label>
<FormikOnChange
Expand Down
12 changes: 2 additions & 10 deletions src/component/header/Zones2DOptionPanel.tsx
Expand Up @@ -49,11 +49,7 @@ function Zones2DOptionPanel() {
>
{({ handleSubmit, isValid }) => (
<>
<Label
title="Noise factor :"
htmlFor="livePreview"
style={headerLabelStyle}
>
<Label title="Noise factor:" style={headerLabelStyle}>
<FormikInput
type="number"
name="zonesNoiseFactor"
Expand All @@ -65,11 +61,7 @@ function Zones2DOptionPanel() {
step={1}
/>
</Label>
<Label
title="MinMaxRatio :"
htmlFor="livePreview"
style={headerLabelStyle}
>
<Label title="Min/max ratio:" style={headerLabelStyle}>
<FormikInput
type="number"
name="zonesMinMaxRatio"
Expand Down
6 changes: 3 additions & 3 deletions src/component/hooks/useToolsFunctions.ts
Expand Up @@ -89,9 +89,9 @@ export default function useToolsFunctions() {
setIsRealSpectrumShown(!isRealSpectrumShown);
}, [dispatch, isRealSpectrumShown]);

const alignSpectrumsVerticallyHandler = useCallback(() => {
const alignSpectraVerticallyHandler = useCallback(() => {
dispatch({
type: 'SET_SPECTRUMS_VERTICAL_ALIGN',
type: 'SET_SPECTRA_VERTICAL_ALIGN',
});
}, [dispatch]);

Expand All @@ -100,7 +100,7 @@ export default function useToolsFunctions() {
handleFullZoomOut,
changeDisplayViewModeHandler,
changeSpectrumViewHandler,
alignSpectrumsVerticallyHandler,
alignSpectraVerticallyHandler,
isRealSpectrumShown,
};
}
4 changes: 2 additions & 2 deletions src/component/modal/AboutPredictionModal.tsx
Expand Up @@ -46,12 +46,12 @@ function AboutPredictionModal() {
<Toolbar.Item
icon={<FaInfo />}
onClick={openDialog}
title="About Prediction"
title="About prediction"
/>
<Dialog
isOpen={isOpenDialog}
onClose={closeDialog}
title="About Prediction"
title="About prediction"
style={{ width: '600px' }}
>
<DialogBody css={styles}>
Expand Down
2 changes: 1 addition & 1 deletion src/component/modal/AboutSpectrumSimulationModal.tsx
Expand Up @@ -46,7 +46,7 @@ function AboutSpectrumSimulationModal() {
<Toolbar>
<Toolbar.Item
onClick={openDialog}
title="About Prediction"
title="About prediction"
icon={<FaInfo />}
/>
</Toolbar>
Expand Down
6 changes: 3 additions & 3 deletions src/component/modal/EditPeakShapeModal.tsx
Expand Up @@ -127,7 +127,7 @@ function EditPeakShapeModal({
onSubmit={changePeakShapeHandler}
>
<>
<Label title="kind : " style={labelStyle}>
<Label title="Kind:" style={labelStyle}>
<Select
items={KINDS}
style={{ margin: 0, height: 30 }}
Expand All @@ -136,12 +136,12 @@ function EditPeakShapeModal({
/>
</Label>

<Label title="fwhm: " style={labelStyle}>
<Label title="FWHM:" style={labelStyle}>
<FormikInput name="fwhm" style={inputStyle} />
</Label>

{kind === 'pseudoVoigt' && (
<Label title="mu: " style={labelStyle}>
<Label title="Mu:" style={labelStyle}>
<FormikInput name="mu" style={inputStyle} />
</Label>
)}
Expand Down
2 changes: 1 addition & 1 deletion src/component/modal/LoadJCAMPModal.tsx
Expand Up @@ -78,7 +78,7 @@ export function LoadJCAMPModal({ onCloseDialog, isOpen }: LoadJCAMPModalProps) {
<Dialog
isOpen
onClose={onCloseDialog}
title="Load JCAMP Dialog"
title="Load JCAMP"
style={{ minWidth: '400px' }}
>
<DialogBody
Expand Down

0 comments on commit 92fd75d

Please sign in to comment.