mastodon/app/assets/javascripts/components/features/notifications/components/setting_toggle.jsx

32 lines
858 B
React
Raw Normal View History

2017-01-10 16:25:10 +00: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 16:30:06 +00:00
marginLeft: '8px'
2017-01-10 16:25:10 +00:00
};
const SettingToggle = ({ settings, settingKey, label, onChange }) => (
<label style={labelStyle}>
<Toggle checked={settings.getIn(settingKey)} onChange={(e) => onChange(settingKey, e.target.checked)} />
2017-02-10 16:30:06 +00:00
<span className='setting-toggle' style={labelSpanStyle}>{label}</span>
2017-01-10 16:25:10 +00:00
</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;