@@ -4,15 +4,14 @@ import { Fragment, useEffect, useRef, useState } from 'react';
44import { ResponsiveChart } from 'react-d3-utils' ;
55import type { CanvasEditorOnChangeMolecule } from 'react-ocl' ;
66import { CanvasMoleculeEditor } from 'react-ocl' ;
7- import { useAccordionControls } from 'react-science/ui' ;
7+ import { Button , useAccordionControls } from 'react-science/ui' ;
88
99import { predictSpectra } from '../../../data/PredictionManager.js' ;
1010import type { StateMoleculeExtended } from '../../../data/molecules/Molecule.js' ;
1111import { useChartData } from '../../context/ChartContext.js' ;
1212import { useDispatch } from '../../context/DispatchContext.js' ;
1313import { useLogger } from '../../context/LoggerContext.js' ;
1414import { useToaster } from '../../context/ToasterContext.js' ;
15- import Button from '../../elements/Button.js' ;
1615import { NextPrev } from '../../elements/NextPrev.js' ;
1716import { usePanelPreferences } from '../../hooks/usePanelPreferences.js' ;
1817import { useMoleculeEditor } from '../../modal/MoleculeStructureEditorModal.js' ;
@@ -26,10 +25,8 @@ import PredictionPreferences from './PredictionPreferences.js';
2625import PredictionSimpleOptions from './PredictionSimpleOptions.js' ;
2726
2827const 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
3532const 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
5348export 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