mc-react-structure-visualizer 0.4.2 → 0.5.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,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;