Skip to content

Commit

Permalink
MolstarViewer -> Molstar
Browse files Browse the repository at this point in the history
  • Loading branch information
samirelanduk committed Aug 3, 2021
1 parent 14597f2 commit b5f8e44
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 56 deletions.
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,5 @@ dist
build
lib
.DS_Store
.vscode
.vscode
molstar.md
36 changes: 13 additions & 23 deletions src/Molstar.jsx
Original file line number Diff line number Diff line change
@@ -1,40 +1,30 @@
import React, { useEffect, useRef } from "react";
import PropTypes from "prop-types";
import { createPluginAsync } from "molstar/lib/mol-plugin-ui/index";
import { DefaultPluginUISpec } from "molstar/lib/mol-plugin-ui/spec";

import "molstar/build/viewer/molstar.css";
import { Viewer } from "molstar/build/viewer/molstar";

const Molstar = props => {

const parent = useRef(null);
const plugin = useRef(null);
const { pdbId, url, options } = props;
const viewerElement = useRef(null);
const viewer = useRef(null);

useEffect(() => {
const defaultSpec = DefaultPluginUISpec();
const init = async () => {
plugin.current = await createPluginAsync(parent.current, {
...defaultSpec,
layout: {
initial: {
isExpanded: false,
showControls: false
},
},
});
}
init();
viewer.current = new Viewer(viewerElement.current, options || {});
if (pdbId) viewer.current.loadPdb(pdbId);
if (url) viewer.current.loadStructureFromUrl(url);
return () => viewer.current = null;
}, [])

return (
<div
ref={parent}
style={{ width: 640, height: 480, position: "absolute", overflow: "hidden" }}
/>
<div ref={viewerElement} />
);
};

Molstar.propTypes = {

pdbId: PropTypes.string,
url: PropTypes.string,
options: PropTypes.object
};

export default Molstar;
30 changes: 0 additions & 30 deletions src/MolstarViewer.jsx

This file was deleted.

3 changes: 1 addition & 2 deletions src/index.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@

import MolstarViewer from "./MolstarViewer.jsx";
import Molstar from "./Molstar.jsx";
export { Molstar };
export default MolstarViewer;
export default Molstar;

0 comments on commit b5f8e44

Please sign in to comment.