Skip to content
Merged
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
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
import { ResponsiveChart } from 'react-d3-utils';
import { BsArrowsMove } from 'react-icons/bs';
import { FaTimes } from 'react-icons/fa';
import type { MolfileSvgRendererProps } from 'react-ocl';
import { MolfileSvgRenderer } from 'react-ocl';
import OCLnmr from 'react-ocl-nmr';
import { Rnd } from 'react-rnd';

Expand All @@ -24,6 +26,7 @@
interface DraggableMoleculeProps extends DraggableStructureProps {
width: number;
height: number;
renderAsSVG?: boolean;
}

interface DraggableStructureProps {
Expand Down Expand Up @@ -60,7 +63,7 @@
const [isMoveActive, setIsMoveActive] = useState(false);

useEffect(() => {
setBounding({ ...moleculeView.floating.bounding });

Check warning on line 66 in src/component/1d-2d/components/FloatMoleculeStructures/DraggableStructure.tsx

View workflow job for this annotation

GitHub Actions / nodejs / lint-eslint

Avoid storing derived state. Compute "bounding" directly during render, optionally with `useMemo` if it's expensive
}, [moleculeView.floating.bounding]);

function floatMoleculeHandler() {
Expand Down Expand Up @@ -126,7 +129,7 @@
if (isExportProcessStart) {
return (
<g transform={`translate(${x} ${y})`}>
<DraggableMolecule {...{ width, height }} {...props} />
<DraggableMolecule renderAsSVG {...{ width, height }} {...props} />
</g>
);
}
Expand Down Expand Up @@ -188,7 +191,14 @@
}

function DraggableMolecule(props: DraggableMoleculeProps) {
const { molecule, index, moleculeView, width, height } = props;
const {
molecule,
index,
moleculeView,
width,
height,
renderAsSVG = false,
} = props;
const {
currentDiaIDsToHighlight,
handleOnAtomHover,
Expand All @@ -198,20 +208,29 @@
const highlightColor = useHighlightColor();
const dispatch = useDispatch();

const atomHighlightColor =
currentDiaIDsToHighlight?.length > 0 ? '#ff000080' : highlightColor;
const baseProps: MolfileSvgRendererProps = {
id: `molSVG${index || ''}`,
height,
width,
label: molecule.label,
labelFontSize: 15,
labelColor: 'rgb(0,0,0)',
molfile: molecule.molfile,
atomHighlightColor,
atomHighlightOpacity: 1,
showAtomNumber: moleculeView.showAtomNumber,
};

if (renderAsSVG) {
return <MolfileSvgRenderer {...baseProps} />;
}

return (
<OCLnmr
id={`molSVG${index || ''}`}
height={height}
width={width}
label={molecule.label}
labelFontSize={15}
labelColor="rgb(0,0,0)"
molfile={molecule.molfile}
{...baseProps}
setSelectedAtom={handleOnClickAtom}
atomHighlightColor={
currentDiaIDsToHighlight?.length > 0 ? '#ff000080' : highlightColor
}
atomHighlightOpacity={1}
highlights={
currentDiaIDsToHighlight?.length > 0
? currentDiaIDsToHighlight
Expand All @@ -229,7 +248,6 @@
},
});
}}
showAtomNumber={moleculeView.showAtomNumber}
/>
);
}
Loading