about summary refs log tree commit diff
path: root/app/assets/javascripts/components/features/notifications/components/setting_toggle.jsx
blob: c2438f716ea2ac4a463d94f2dfaa9154d7c8c946 (plain) (blame)
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
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',
  marginLeft: '8px',
  color: '#9baec8'
};

const SettingToggle = ({ settings, settingKey, label, onChange }) => (
  <label style={labelStyle}>
    <Toggle checked={settings.getIn(settingKey)} onChange={(e) => onChange(settingKey, e.target.checked)} />
    <span style={labelSpanStyle}>{label}</span>
  </label>
);

SettingToggle.propTypes = {
  settings: ImmutablePropTypes.map.isRequired,
  settingKey: React.PropTypes.array.isRequired,
  label: React.PropTypes.node.isRequired,
  onChange: React.PropTypes.func.isRequired
};

export default SettingToggle;