-
Notifications
You must be signed in to change notification settings - Fork 16
/
Copy pathexpansionPanelFrame.tsx
66 lines (64 loc) · 2.04 KB
/
expansionPanelFrame.tsx
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
import React, { Component } from 'react';
import {
ExpansionPanel,
ExpansionPanelSummary,
Typography,
ExpansionPanelDetails,
Grid,
} from '@material-ui/core';
import ExpandMoreIcon from '@material-ui/icons/ExpandMore';
import { inject, observer } from 'mobx-react';
import { EMITTER_STORE, EmitterStoreProp } from 'src/stores';
import Switch from '../Switch';
import TextField from '../TextField';
import MultipleInput from '../MultipleInput';
import { selectComponent } from '../Select';
import { frames } from 'src/constants';
import _get from 'lodash/get';
@inject(EMITTER_STORE)
@observer
class ExpansionPanelFrame extends Component<EmitterStoreProp> {
render() {
const { emitterStore } = this.props;
const { currentEmitterConfig } = emitterStore!;
return (
<ExpansionPanel>
<ExpansionPanelSummary expandIcon={<ExpandMoreIcon />}>
<Typography>Frame</Typography>
</ExpansionPanelSummary>
<ExpansionPanelDetails>
<Grid container spacing={16}>
<Grid item xs={6}>
<Switch
configName="frame>cycle"
label="Cycle"
disabled={currentEmitterConfig.frame.frames.length < 2}
/>
</Grid>
<Grid item xs={6}>
<TextField
configName="frame>quantity"
type="number"
label="Quantity"
disabled={!currentEmitterConfig.frame.cycle}
/>
</Grid>
<Grid item xs={12}>
<MultipleInput configName="frame>frames">
{(params: any) => {
const { configName } = params;
return selectComponent({
...params,
options: frames,
value: _get(currentEmitterConfig, configName.split('>')),
});
}}
</MultipleInput>
</Grid>
</Grid>
</ExpansionPanelDetails>
</ExpansionPanel>
);
}
}
export default ExpansionPanelFrame;