mc-react-structure-visualizer 0.4.3 → 0.6.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,100 +0,0 @@
1
- // from https://en.wikipedia.org/wiki/Covalent_radius
2
- // unit: angstrom
3
- export const covalentRadii = {
4
- H: 0.31,
5
- He: 0.28,
6
- Li: 1.28,
7
- Be: 0.96,
8
- B: 0.84,
9
- C: 0.76,
10
- N: 0.71,
11
- O: 0.66,
12
- F: 0.57,
13
- Ne: 0.58,
14
- Na: 1.66,
15
- Mg: 1.41,
16
- Al: 1.21,
17
- Si: 1.11,
18
- P: 1.07,
19
- S: 1.05,
20
- Cl: 1.02,
21
- Ar: 1.06,
22
- K: 2.03,
23
- Ca: 1.76,
24
- Sc: 1.7,
25
- Ti: 1.6,
26
- V: 1.53,
27
- Cr: 1.39,
28
- Mn: 1.61,
29
- Fe: 1.52,
30
- Co: 1.5,
31
- Ni: 1.24,
32
- Cu: 1.32,
33
- Zn: 1.22,
34
- Ga: 1.22,
35
- Ge: 1.2,
36
- As: 1.19,
37
- Se: 1.2,
38
- Br: 1.2,
39
- Kr: 1.16,
40
- Rb: 2.2,
41
- Sr: 1.95,
42
- Y: 1.9,
43
- Zr: 1.75,
44
- Nb: 1.64,
45
- Mo: 1.54,
46
- Tc: 1.47,
47
- Ru: 1.46,
48
- Rh: 1.42,
49
- Pd: 1.39,
50
- Ag: 1.45,
51
- Cd: 1.44,
52
- In: 1.42,
53
- Sn: 1.39,
54
- Sb: 1.39,
55
- Te: 1.38,
56
- I: 1.39,
57
- Xe: 1.4,
58
- Cs: 2.44,
59
- Ba: 2.15,
60
- La: 2.07,
61
- Ce: 2.04,
62
- Pr: 2.03,
63
- Nd: 2.01,
64
- Pm: 1.99,
65
- Sm: 1.98,
66
- Eu: 1.98,
67
- Gd: 1.96,
68
- Tb: 1.94,
69
- Dy: 1.92,
70
- Ho: 1.92,
71
- Er: 1.89,
72
- Tm: 1.9,
73
- Yb: 1.87,
74
- Lu: 1.75,
75
- Hf: 1.87,
76
- Ta: 1.7,
77
- W: 1.62,
78
- Re: 1.51,
79
- Os: 1.44,
80
- Ir: 1.41,
81
- Pt: 1.36,
82
- Au: 1.36,
83
- Hg: 1.32,
84
- Tl: 1.45,
85
- Pb: 1.46,
86
- Bi: 1.48,
87
- Po: 1.4,
88
- At: 1.5,
89
- Rn: 1.5,
90
- Fr: 2.6,
91
- Ra: 2.21,
92
- Ac: 2.15,
93
- Th: 2.06,
94
- Pa: 2.0,
95
- U: 1.96,
96
- Np: 1.9,
97
- Pu: 1.87,
98
- Am: 1.8,
99
- Cm: 1.69,
100
- };
@@ -1,43 +0,0 @@
1
- .structure-window-outer {
2
- position: relative;
3
- }
4
-
5
- .structure-window {
6
- position: relative;
7
- z-index: 2;
8
- height: 370px;
9
- width: 450px;
10
- background: white;
11
- text-align: center;
12
- border: 1px solid #999;
13
- display: flex;
14
- justify-content: center;
15
- align-items: center;
16
- border-radius: 5px;
17
- }
18
-
19
- .disable-mouse {
20
- pointer-events: none;
21
- }
22
-
23
- .mouse-disabled-note {
24
- background-color: #fff1f1;
25
- border: 1px solid black;
26
- color: #353434;
27
- padding: 2px 6px;
28
- border-radius: 5px;
29
- position: absolute;
30
- top: 10px;
31
- left: 10px;
32
- z-index: 3;
33
- cursor: pointer;
34
- user-select: none;
35
- }
36
-
37
- .on {
38
- background-color: #e9ffe7;
39
- }
40
-
41
- .mouse-disabled-note:hover {
42
- filter: brightness(90%);
43
- }
@@ -1,46 +0,0 @@
1
- import React from "react";
2
-
3
- import Visualizer3dmol from "./3dmol/Visualizer3dmol";
4
-
5
- import "./index.css";
6
-
7
- class StructureWindow extends React.Component {
8
- constructor(props) {
9
- super(props);
10
- }
11
-
12
- render() {
13
- let swClassName = "structure-window";
14
- if (!this.props.mouseEnabled) swClassName += " disable-mouse";
15
-
16
- let mouseNoteText = "Interaction off";
17
- let mouseNoteClass = "mouse-disabled-note";
18
- if (this.props.mouseEnabled) {
19
- mouseNoteText = "Interaction on";
20
- mouseNoteClass = "mouse-disabled-note on";
21
- }
22
- return (
23
- <div className="structure-window-outer">
24
- <div onClick={() => this.props.setMouseEnabledState(true)}>
25
- <div className={swClassName}>
26
- <Visualizer3dmol
27
- ref={this.props.visualizerRef}
28
- viewerParams={this.props.viewerParams}
29
- cifText={this.props.cifText}
30
- />
31
- </div>
32
- </div>
33
- <div
34
- className={mouseNoteClass}
35
- onClick={() =>
36
- this.props.setMouseEnabledState(!this.props.mouseEnabled)
37
- }
38
- >
39
- {mouseNoteText}
40
- </div>
41
- </div>
42
- );
43
- }
44
- }
45
-
46
- export default StructureWindow;
@@ -1,3 +0,0 @@
1
- .structure-visualizer {
2
- width: 450px;
3
- }
@@ -1,87 +0,0 @@
1
- import React from "react";
2
-
3
- import ControlBox from "./ControlBox";
4
-
5
- import StructureWindow from "./StructureWindow";
6
-
7
- import "./index.css";
8
-
9
- class StructureVisualizer extends React.Component {
10
- constructor(props) {
11
- super(props);
12
-
13
- this.state = {
14
- viewerParams: {
15
- supercell: [2, 2, 2],
16
- bonds: true,
17
- atomLabels: false,
18
- packedCell: false,
19
- vdwRadius: false,
20
- },
21
- mouseEnabled: false,
22
- };
23
-
24
- // use Ref to send events to the visualizer backend
25
- this.visualizerRef = React.createRef();
26
-
27
- // Ref to detect click outside
28
- this.wrapperRef = React.createRef();
29
- this.handleClickOutside = this.handleClickOutside.bind(this);
30
-
31
- this.handleViewerParamChange = this.handleViewerParamChange.bind(this);
32
- this.handleViewerEvent = this.handleViewerEvent.bind(this);
33
- this.setMouseEnabledState = this.setMouseEnabledState.bind(this);
34
- }
35
-
36
- componentDidMount() {
37
- document.addEventListener("mousedown", this.handleClickOutside);
38
- }
39
-
40
- componentWillUnmount() {
41
- document.removeEventListener("mousedown", this.handleClickOutside);
42
- }
43
-
44
- handleClickOutside(event) {
45
- if (this.wrapperRef && !this.wrapperRef.current.contains(event.target)) {
46
- this.setState({ mouseEnabled: false });
47
- }
48
- }
49
-
50
- setMouseEnabledState(state) {
51
- this.setState({ mouseEnabled: state });
52
- }
53
-
54
- handleViewerParamChange(param, value) {
55
- this.setState({
56
- viewerParams: {
57
- ...this.state.viewerParams,
58
- [param]: value,
59
- },
60
- });
61
- }
62
-
63
- handleViewerEvent(param, value) {
64
- this.visualizerRef.current.handleEvent(param, value);
65
- }
66
-
67
- render() {
68
- return (
69
- <div ref={this.wrapperRef} className="structure-visualizer">
70
- <StructureWindow
71
- visualizerRef={this.visualizerRef}
72
- viewerParams={this.state.viewerParams}
73
- cifText={this.props.cifText}
74
- mouseEnabled={this.state.mouseEnabled}
75
- setMouseEnabledState={this.setMouseEnabledState}
76
- />
77
- <ControlBox
78
- viewerParams={this.state.viewerParams}
79
- onViewerParamChange={this.handleViewerParamChange}
80
- onViewerEvent={this.handleViewerEvent}
81
- />
82
- </div>
83
- );
84
- }
85
- }
86
-
87
- export default StructureVisualizer;
package/src/index.css DELETED
@@ -1,13 +0,0 @@
1
- body {
2
- margin: 0;
3
- font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', 'Oxygen',
4
- 'Ubuntu', 'Cantarell', 'Fira Sans', 'Droid Sans', 'Helvetica Neue',
5
- sans-serif;
6
- -webkit-font-smoothing: antialiased;
7
- -moz-osx-font-smoothing: grayscale;
8
- }
9
-
10
- code {
11
- font-family: source-code-pro, Menlo, Monaco, Consolas, 'Courier New',
12
- monospace;
13
- }
package/src/index.js DELETED
@@ -1,17 +0,0 @@
1
- import React from 'react';
2
- import ReactDOM from 'react-dom/client';
3
- import './index.css';
4
- import App from './App';
5
- import reportWebVitals from './reportWebVitals';
6
-
7
- const root = ReactDOM.createRoot(document.getElementById('root'));
8
- root.render(
9
- <React.StrictMode>
10
- <App />
11
- </React.StrictMode>
12
- );
13
-
14
- // If you want to start measuring performance in your app, pass a function
15
- // to log results (for example: reportWebVitals(console.log))
16
- // or send to an analytics endpoint. Learn more: https://bit.ly/CRA-vitals
17
- reportWebVitals();
@@ -1,13 +0,0 @@
1
- const reportWebVitals = onPerfEntry => {
2
- if (onPerfEntry && onPerfEntry instanceof Function) {
3
- import('web-vitals').then(({ getCLS, getFID, getFCP, getLCP, getTTFB }) => {
4
- getCLS(onPerfEntry);
5
- getFID(onPerfEntry);
6
- getFCP(onPerfEntry);
7
- getLCP(onPerfEntry);
8
- getTTFB(onPerfEntry);
9
- });
10
- }
11
- };
12
-
13
- export default reportWebVitals;