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

21 lines
709 B
React
Raw Normal View History

import PropTypes from 'prop-types';
2017-01-10 16:25:10 +00:00
import ImmutablePropTypes from 'react-immutable-proptypes';
import Toggle from 'react-toggle';
const SettingToggle = ({ settings, settingKey, label, onChange, htmlFor = '' }) => (
<label htmlFor={htmlFor} className='setting-toggle__label'>
2017-01-10 16:25:10 +00:00
<Toggle checked={settings.getIn(settingKey)} onChange={(e) => onChange(settingKey, e.target.checked)} />
<span className='setting-toggle'>{label}</span>
2017-01-10 16:25:10 +00:00
</label>
);
SettingToggle.propTypes = {
settings: ImmutablePropTypes.map.isRequired,
settingKey: PropTypes.array.isRequired,
label: PropTypes.node.isRequired,
onChange: PropTypes.func.isRequired,
htmlFor: PropTypes.string
2017-01-10 16:25:10 +00:00
};
export default SettingToggle;