-
Notifications
You must be signed in to change notification settings - Fork 25
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor: phase correction panel and have simple and advance options
- Loading branch information
1 parent
991455a
commit 0d1d9b7
Showing
5 changed files
with
248 additions
and
100 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
68 changes: 68 additions & 0 deletions
68
src/component/header/SimplePhaseCorrectionOptionsPanel.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
import { Select } from '@blueprintjs/select'; | ||
import { Filters } from 'nmr-processing'; | ||
import { Button } from 'react-science/ui'; | ||
|
||
import ActionButtons from '../elements/ActionButtons'; | ||
import InputRange from '../elements/InputRange'; | ||
import { useFilter } from '../hooks/useFilter'; | ||
import { | ||
algorithms, | ||
AlgorithmItem, | ||
usePhaseCorrection, | ||
} from '../panels/filtersPanel/Filters/usePhaseCorrection'; | ||
|
||
import { HeaderContainer } from './HeaderContainer'; | ||
|
||
export function SimplePhaseCorrectionOptionsPanel() { | ||
const filter = useFilter(Filters.phaseCorrection.id); | ||
|
||
const { | ||
handleApplyFilter, | ||
handleCancelFilter, | ||
handleRangeChange, | ||
defaultSelectProps, | ||
phaseCorrectionTypeItem, | ||
ph0Ref, | ||
ph1Ref, | ||
} = usePhaseCorrection(filter); | ||
|
||
return ( | ||
<HeaderContainer> | ||
<div style={{ padding: '0 5px' }}> | ||
<Select<AlgorithmItem> | ||
items={algorithms} | ||
filterable={false} | ||
itemsEqual="value" | ||
{...defaultSelectProps} | ||
> | ||
<Button | ||
text={phaseCorrectionTypeItem?.label} | ||
rightIcon="double-caret-vertical" | ||
/> | ||
</Select> | ||
</div> | ||
{phaseCorrectionTypeItem?.value === 'manual' && ( | ||
<> | ||
<InputRange | ||
ref={ph0Ref} | ||
name="ph0" | ||
label="Change PH0 (click and drag)" | ||
shortLabel="Ph0" | ||
style={{ width: '20%' }} | ||
onChange={handleRangeChange} | ||
/> | ||
<InputRange | ||
ref={ph1Ref} | ||
name="ph1" | ||
label="Change PH1 (click and drag)" | ||
shortLabel="Ph1" | ||
style={{ width: '20%' }} | ||
onChange={handleRangeChange} | ||
/> | ||
</> | ||
)} | ||
|
||
<ActionButtons onDone={handleApplyFilter} onCancel={handleCancelFilter} /> | ||
</HeaderContainer> | ||
); | ||
} |
123 changes: 123 additions & 0 deletions
123
src/component/panels/filtersPanel/Filters/PhaseCorrectionOptionsPanel.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,123 @@ | ||
import { Button } from '@blueprintjs/core'; | ||
import { Select } from '@blueprintjs/select'; | ||
import { Filter } from 'nmr-processing'; | ||
import { CSSProperties } from 'react'; | ||
|
||
import InputRange from '../../../elements/InputRange'; | ||
import Label, { LabelStyle } from '../../../elements/Label'; | ||
import { NumberInput2 } from '../../../elements/NumberInput2'; | ||
import { Sections } from '../../../elements/Sections'; | ||
|
||
import { FilterActionButtons } from './FilterActionButtons'; | ||
import { HeaderContainer, StickyHeader } from './InnerFilterHeader'; | ||
import { | ||
algorithms, | ||
usePhaseCorrection, | ||
AlgorithmItem, | ||
} from './usePhaseCorrection'; | ||
|
||
interface PhaseCorrectionOptionsPanelProps { | ||
filter: Filter; | ||
} | ||
|
||
const inputRangeStyle: CSSProperties = { | ||
padding: '5px 10px', | ||
}; | ||
|
||
const formLabelStyle: LabelStyle = { | ||
label: { | ||
flex: 2, | ||
}, | ||
wrapper: { | ||
flex: 10, | ||
display: 'flex', | ||
}, | ||
container: { | ||
marginBottom: '5px', | ||
}, | ||
}; | ||
|
||
export default function PhaseCorrectionOptionsPanel( | ||
props: PhaseCorrectionOptionsPanelProps, | ||
) { | ||
const { filter } = props; | ||
const { | ||
handleApplyFilter, | ||
handleCancelFilter, | ||
handleInput, | ||
handleRangeChange, | ||
value, | ||
defaultSelectProps, | ||
phaseCorrectionTypeItem, | ||
ph0Ref, | ||
ph1Ref, | ||
} = usePhaseCorrection(filter); | ||
|
||
return ( | ||
<> | ||
<StickyHeader> | ||
<HeaderContainer> | ||
<div /> | ||
<FilterActionButtons | ||
onConfirm={handleApplyFilter} | ||
onCancel={handleCancelFilter} | ||
/> | ||
</HeaderContainer> | ||
</StickyHeader> | ||
<Sections.Body> | ||
<div style={{ display: 'flex', flexDirection: 'column' }}> | ||
<Label title="Algorithm:" style={formLabelStyle}> | ||
<Select<AlgorithmItem> | ||
items={algorithms} | ||
filterable={false} | ||
itemsEqual="value" | ||
{...defaultSelectProps} | ||
> | ||
<Button | ||
text={phaseCorrectionTypeItem?.label} | ||
rightIcon="double-caret-vertical" | ||
outlined | ||
/> | ||
</Select> | ||
</Label> | ||
{phaseCorrectionTypeItem?.value === 'manual' && ( | ||
<> | ||
<Label title="PH0:" style={formLabelStyle}> | ||
<NumberInput2 | ||
name="ph0" | ||
onValueChange={handleInput} | ||
value={value.ph0} | ||
debounceTime={250} | ||
style={{ width: '100px' }} | ||
/> | ||
<InputRange | ||
ref={ph0Ref} | ||
name="ph0" | ||
label="Change PH0 (click and drag)" | ||
onChange={handleRangeChange} | ||
style={inputRangeStyle} | ||
/> | ||
</Label> | ||
<Label title="PH1:" style={formLabelStyle}> | ||
<NumberInput2 | ||
name="ph1" | ||
onValueChange={handleInput} | ||
value={value.ph1} | ||
debounceTime={250} | ||
style={{ width: '100px' }} | ||
/> | ||
<InputRange | ||
ref={ph1Ref} | ||
name="ph1" | ||
label="Change PH1 (click and drag)" | ||
onChange={handleRangeChange} | ||
style={inputRangeStyle} | ||
/> | ||
</Label> | ||
</> | ||
)} | ||
</div> | ||
</Sections.Body> | ||
</> | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.