-
Notifications
You must be signed in to change notification settings - Fork 811
/
left.js
138 lines (125 loc) · 3.47 KB
/
left.js
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
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
import React from 'react';
import PropTypes from 'prop-types';
import css from 'styled-jsx/css';
import {connect, EditorContainer} from '../../../containers';
import KeyboardNumberInput from '../../keyboard-number-input';
import Slider from './slider';
const {className: keyboardInputClass, styles: keyboardInputStyles} = css.resolve`
height: 24px;
background: hsla(0, 0%, 100%, 0.1);
text-align: center;
font-size: 12px;
box-sizing: border-box;
border: none;
padding: 4px;
border-bottom-left-radius: 4px;
border-top-left-radius: 4px;
width: 48px;
color: white;
input + input {
border-bottom-left-radius: 0;
border-top-left-radius: 0;
border-bottom-right-radius: 4px;
border-top-right-radius: 4px;
margin-left: 1px;
margin-right: 16px;
}
:focus, :hover {
outline: none;
background: hsla(0, 0%, 100%, 0.2);
}
`;
class LeftOptions extends React.Component {
handleBlur = event => {
const {changeDimension} = this.props;
changeDimension(event, {ignoreEmpty: false});
}
render() {
const {width, height, changeDimension, fps, originalFps, setFps, original} = this.props;
return (
<div className="container">
<div className="label">Size</div>
<KeyboardNumberInput
className={keyboardInputClass}
value={width || ''}
size="5"
maxLength="5"
min={1}
max={original && original.width}
name="width"
onChange={changeDimension}
onKeyDown={changeDimension}
onBlur={this.handleBlur}
/>
<KeyboardNumberInput
className={keyboardInputClass}
value={height || ''}
size="5"
maxLength="5"
min={1}
max={original && original.height}
name="height"
onChange={changeDimension}
onKeyDown={changeDimension}
onBlur={this.handleBlur}
/>
<div className="label">FPS</div>
<div className="fps">
<Slider value={fps} min={1} max={originalFps} onChange={setFps}/>
</div>
{keyboardInputStyles}
<style jsx>{`
.container {
height: 100%;
display: flex;
align-items: center;
}
.label {
font-size: 12px;
margin-right: 8px;
color: white;
}
.fps {
height: 24px;
width: 32px;
}
.option {
width: 48px;
height: 22px;
background: transparent;
display: flex;
align-items: center;
justify-content: center;
font-size: 12px;
color: white;
box-sizing: border-box;
}
.option:hover {
background: hsla(0, 0%, 100%, 0.2);
}
.option:active,
.option.selected {
background: transparent;
}
`}</style>
</div>
);
}
}
LeftOptions.propTypes = {
width: PropTypes.number,
height: PropTypes.number,
changeDimension: PropTypes.elementType,
fps: PropTypes.number,
setFps: PropTypes.elementType,
originalFps: PropTypes.number,
original: PropTypes.shape({
width: PropTypes.number,
height: PropTypes.number
})
};
export default connect(
[EditorContainer],
({width, height, fps, originalFps, original}) => ({width, height, fps, originalFps, original}),
({changeDimension, setFps}) => ({changeDimension, setFps})
)(LeftOptions);