-
Notifications
You must be signed in to change notification settings - Fork 3
/
Switch.js
36 lines (32 loc) · 880 Bytes
/
Switch.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
import React from 'react';
import { render } from 'react-dom';
import ReactSwitch from 'react-bootstrap-switch';
/**
* A binary switch UI component for controlling audio parameters
*/
export default class Switch extends React.Component
{
componentWillMount()
{
const { props } = this;
if (props.state) {
props.onToggleOn();
}
this.classes = ['audio-control'];
this.classes.push(props.className);
}
render()
{
const { props } = this;
return (
<div className={this.classes.join(' ')}>
<label className='audio-control-label'>{props.label}</label>
<ReactSwitch state={props.state} animate={false} size='mini'
onChange={(state) => {
if (state && props.onToggleOn) props.onToggleOn();
if (!state && props.onToggleOff) props.onToggleOff();
}} />
</div>
)
}
}