mirror of
https://github.com/wassname/talk.git
synced 2026-06-30 03:47:59 +08:00
23 lines
766 B
JavaScript
23 lines
766 B
JavaScript
import React from 'react';
|
|
import Toggle from '../components/Toggle';
|
|
import withSettingsToggle from '../hocs/withSettingsToggle';
|
|
|
|
/**
|
|
* createSettingsToggle will add a boolean setting with the
|
|
* name `settingsName` to notification settings and return
|
|
* a full Toggle Component.
|
|
*
|
|
* You must provide a `label` either as a string or as a callback.
|
|
* E.g. to provide translations you could do:
|
|
*
|
|
* `const SettingsToggle = createSettingsToggle('onReply', () => t('translate'));`
|
|
*/
|
|
const createSettingsToggle = (settingsName, label) => {
|
|
const SettingsToggle = props => (
|
|
<Toggle {...props}>{typeof label === 'function' ? label() : label}</Toggle>
|
|
);
|
|
return withSettingsToggle(settingsName)(SettingsToggle);
|
|
};
|
|
|
|
export default createSettingsToggle;
|