-
Notifications
You must be signed in to change notification settings - Fork 71
/
IFVariationSwitch.js
90 lines (75 loc) · 2.12 KB
/
IFVariationSwitch.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
import React from 'react';
import Radium from 'radium';
import Light from '../light/light';
import Switch from '../switch/switch';
import { grey, darkBlack, silver } from '../../theme/variables';
import { labelDarkGrey } from '../../theme/mixins';
@Radium
class IFVariationSwitch extends React.Component {
static propTypes = {
onChange: React.PropTypes.func.isRequired,
position: React.PropTypes.number.isRequired
}
render() {
const { onChange, position } = this.props;
const thickness = 35;
const length = 65;
const styles = {
wrapper: {
width: length * 1.8, height: 87.5,
display: 'flex',
flexDirection: 'column',
alignItems: 'center',
justifyContent: 'space-between'
},
switchTitle: labelDarkGrey,
label: labelDarkGrey,
switchWrapper: {
width: length,
display: 'flex',
flexDirection: 'column',
alignItems: 'center'
},
labelWrapper: {
width: length - 15,
display: 'flex',
flexDirection: 'row',
alignItems: 'center',
justifyContent: 'space-between',
paddingTop: 5
},
switchOuter: {
backgroundColor: darkBlack,
borderRadius: thickness * .475
},
switchInner: {
backgroundColor: silver,
borderRadius: '50%',
border: `solid ${grey} 2px`
}
};
return (
<div style={styles.wrapper}>
<div style={styles.switchTitle}>I / F - VARIATION</div>
<div style={styles.switchWrapper}>
<Switch
position={position}
onChange={onChange}
direction='horizontal'
numPositions={2}
thickness={thickness}
length={length}
padding={5}
innerThickness={thickness - 10}
outerStyle={styles.switchOuter}
innerStyle={styles.switchInner} />
<div style={styles.labelWrapper}>
<div style={styles.label}>A</div>
<div style={styles.label}>B</div>
</div>
</div>
</div>
);
}
}
export default IFVariationSwitch;