-
-
Notifications
You must be signed in to change notification settings - Fork 551
/
AxesSettings.jsx
95 lines (88 loc) · 3.04 KB
/
AxesSettings.jsx
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
import _ from 'lodash';
import PropTypes from 'prop-types';
import React, { Component } from 'react';
import i18n from '../../lib/i18n';
import {
DEFAULT_AXES
} from './constants';
class AxesSettings extends Component {
static propTypes = {
axes: PropTypes.array
};
static defaultProps = {
axes: DEFAULT_AXES
};
state = this.getInitialState();
getInitialState() {
const { axes } = this.props;
return { axes };
}
componentWillReceiveProps(nextProps) {
const { axes } = nextProps;
this.setState({ axes });
}
render() {
const axes = _(this.state.axes)
.union(DEFAULT_AXES)
.uniq()
.value();
return (
<div className="form-group">
<label>{i18n._('Axes')}</label>
<div className="row no-gutters">
<div className="col-xs-3">
<label>
<input
type="checkbox"
checked
disabled
/>
<span className="space" />
{i18n._('X-axis')}
</label>
</div>
<div className="col-xs-3">
<label>
<input
type="checkbox"
checked
disabled
/>
<span className="space" />
{i18n._('Y-axis')}
</label>
</div>
<div className="col-xs-3">
<label>
<input
type="checkbox"
checked
disabled
/>
<span className="space" />
{i18n._('Z-axis')}
</label>
</div>
<div className="col-xs-3">
<label>
<input
type="checkbox"
checked={_.includes(axes, 'a')}
onChange={(event) => {
if (_.includes(axes, 'a')) {
this.setState({ axes: ['x', 'y', 'z'] });
} else {
this.setState({ axes: ['x', 'y', 'z', 'a'] });
}
}}
/>
<span className="space" />
{i18n._('A-axis')}
</label>
</div>
</div>
</div>
);
}
}
export default AxesSettings;