2017-01-10 17:25:10 +01:00
|
|
|
import ImmutablePropTypes from 'react-immutable-proptypes';
|
|
|
|
import Toggle from 'react-toggle';
|
|
|
|
|
|
|
|
const labelStyle = {
|
|
|
|
display: 'block',
|
|
|
|
lineHeight: '24px',
|
|
|
|
verticalAlign: 'middle'
|
|
|
|
};
|
|
|
|
|
|
|
|
const labelSpanStyle = {
|
|
|
|
display: 'inline-block',
|
|
|
|
verticalAlign: 'middle',
|
|
|
|
marginBottom: '14px',
|
2017-02-10 17:30:06 +01:00
|
|
|
marginLeft: '8px'
|
2017-01-10 17:25:10 +01:00
|
|
|
};
|
|
|
|
|
2017-04-15 13:27:27 +02:00
|
|
|
const SettingToggle = ({ settings, settingKey, label, onChange, htmlFor = '' }) => (
|
|
|
|
<label htmlFor={htmlFor} style={labelStyle}>
|
2017-01-10 17:25:10 +01:00
|
|
|
<Toggle checked={settings.getIn(settingKey)} onChange={(e) => onChange(settingKey, e.target.checked)} />
|
2017-02-10 17:30:06 +01:00
|
|
|
<span className='setting-toggle' style={labelSpanStyle}>{label}</span>
|
2017-01-10 17:25:10 +01:00
|
|
|
</label>
|
|
|
|
);
|
|
|
|
|
|
|
|
SettingToggle.propTypes = {
|
|
|
|
settings: ImmutablePropTypes.map.isRequired,
|
|
|
|
settingKey: React.PropTypes.array.isRequired,
|
|
|
|
label: React.PropTypes.node.isRequired,
|
2017-04-15 13:27:27 +02:00
|
|
|
onChange: React.PropTypes.func.isRequired,
|
|
|
|
htmlFor: React.PropTypes.string
|
2017-01-10 17:25:10 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
export default SettingToggle;
|