Skip to content

Commit f6761ce

Browse files
refactor: make footer float above editor content
1 parent 5c8a937 commit f6761ce

File tree

1 file changed

+65
-73
lines changed

1 file changed

+65
-73
lines changed

src/component/panels/predictionPanel/PredictionPanel.tsx

Lines changed: 65 additions & 73 deletions
Original file line numberDiff line numberDiff line change
@@ -4,15 +4,14 @@ import { Fragment, useEffect, useRef, useState } from 'react';
44
import { ResponsiveChart } from 'react-d3-utils';
55
import type { CanvasEditorOnChangeMolecule } from 'react-ocl';
66
import { CanvasMoleculeEditor } from 'react-ocl';
7-
import { useAccordionControls } from 'react-science/ui';
7+
import { Button, useAccordionControls } from 'react-science/ui';
88

99
import { predictSpectra } from '../../../data/PredictionManager.js';
1010
import type { StateMoleculeExtended } from '../../../data/molecules/Molecule.js';
1111
import { useChartData } from '../../context/ChartContext.js';
1212
import { useDispatch } from '../../context/DispatchContext.js';
1313
import { useLogger } from '../../context/LoggerContext.js';
1414
import { useToaster } from '../../context/ToasterContext.js';
15-
import Button from '../../elements/Button.js';
1615
import { NextPrev } from '../../elements/NextPrev.js';
1716
import { usePanelPreferences } from '../../hooks/usePanelPreferences.js';
1817
import { useMoleculeEditor } from '../../modal/MoleculeStructureEditorModal.js';
@@ -26,10 +25,8 @@ import PredictionPreferences from './PredictionPreferences.js';
2625
import PredictionSimpleOptions from './PredictionSimpleOptions.js';
2726

2827
const Container = styled.div`
29-
display: flex;
30-
flex-direction: column;
31-
flex: 1;
32-
min-height: 0;
28+
position: relative;
29+
height: 100%;
3330
`;
3431

3532
const Overflow = styled.div<{ height: number }>`
@@ -42,12 +39,10 @@ const StickyFooter = styled.div`
4239
padding: 5px;
4340
display: flex;
4441
justify-content: flex-end;
45-
background-color: #fff;
46-
border-top: 1px solid #ccc;
4742
z-index: 2;
48-
`;
49-
const Content = styled.div`
50-
flex: 1;
43+
position: absolute;
44+
bottom: 0;
45+
right: 10px;
5146
`;
5247

5348
export default function PredictionPanel() {
@@ -182,79 +177,76 @@ export default function PredictionPanel() {
182177
</MoleculePanelHeader>
183178

184179
<Container>
185-
<Content>
186-
<ResponsiveChart>
187-
{({ height, width }) => {
188-
return (
189-
<NextPrev
190-
onChange={(slideIndex) => {
191-
setCurrentIndex(slideIndex);
192-
setMolfile(molecules[slideIndex].molfile);
193-
}}
194-
index={currentIndex}
195-
style={{
196-
arrowContainer: {
197-
top: '40px',
198-
padding: '0 10px 0 55px',
199-
},
200-
}}
201-
>
202-
{molecules && molecules.length > 0 ? (
203-
molecules.map(
204-
(mol: StateMoleculeExtended, molIndex) => (
205-
<Fragment key={mol.id}>
206-
<MoleculeHeader
207-
currentMolecule={mol}
208-
molecules={molecules}
209-
/>
210-
211-
{molIndex === currentIndex && (
212-
<Overflow height={height}>
213-
<CanvasMoleculeEditor
214-
width={width}
215-
inputFormat="molfile"
216-
inputValue={mol.molfile}
217-
fragment={false}
218-
onChange={changeHandler}
219-
height={400}
220-
/>
221-
</Overflow>
222-
)}
223-
</Fragment>
224-
),
225-
)
226-
) : (
227-
<Overflow height={height}>
228-
<CanvasMoleculeEditor
229-
inputFormat="molfile"
230-
inputValue={initialMolfile}
231-
width={width}
232-
fragment={false}
233-
onChange={changeHandler}
234-
height={400}
180+
<ResponsiveChart>
181+
{({ height, width }) => {
182+
return (
183+
<NextPrev
184+
onChange={(slideIndex) => {
185+
setCurrentIndex(slideIndex);
186+
setMolfile(molecules[slideIndex].molfile);
187+
}}
188+
index={currentIndex}
189+
style={{
190+
arrowContainer: {
191+
top: '40px',
192+
padding: '0 10px 0 55px',
193+
},
194+
}}
195+
>
196+
{molecules && molecules.length > 0 ? (
197+
molecules.map((mol: StateMoleculeExtended, molIndex) => (
198+
<Fragment key={mol.id}>
199+
<MoleculeHeader
200+
currentMolecule={mol}
201+
molecules={molecules}
235202
/>
236-
</Overflow>
237-
)}
238-
</NextPrev>
239-
);
240-
}}
241-
</ResponsiveChart>
242-
</Content>
243203

204+
{molIndex === currentIndex && (
205+
<Overflow height={height}>
206+
<CanvasMoleculeEditor
207+
width={width}
208+
inputFormat="molfile"
209+
inputValue={mol.molfile}
210+
fragment={false}
211+
onChange={changeHandler}
212+
height={400}
213+
/>
214+
</Overflow>
215+
)}
216+
</Fragment>
217+
))
218+
) : (
219+
<Overflow height={height}>
220+
<CanvasMoleculeEditor
221+
inputFormat="molfile"
222+
inputValue={initialMolfile}
223+
width={width}
224+
fragment={false}
225+
onChange={changeHandler}
226+
height={400}
227+
/>
228+
</Overflow>
229+
)}
230+
</NextPrev>
231+
);
232+
}}
233+
</ResponsiveChart>
244234
<StickyFooter>
245-
<Button.Done
235+
<Button
246236
onClick={() => predictHandler('save')}
247237
disabled={!molfile}
238+
intent="success"
239+
style={{ marginLeft: '5px' }}
248240
>
249241
{isPredictedBefore ? 'Replace prediction' : 'Predict spectra'}
250-
</Button.Done>
242+
</Button>
251243
{isPredictedBefore && (
252-
<Button.Action
253-
style={{ marginLeft: '5px' }}
244+
<Button
245+
style={{ marginLeft: '5px', opacity: '0.8' }}
254246
onClick={() => predictHandler('add')}
255247
>
256248
Add prediction
257-
</Button.Action>
249+
</Button>
258250
)}
259251
</StickyFooter>
260252
</Container>

0 commit comments

Comments
 (0)