Skip to content

Commit

Permalink
feat: add SettingMenuItem.props.useSwitch
Browse files Browse the repository at this point in the history
  • Loading branch information
ma-efremoff committed Dec 20, 2023
1 parent 162f666 commit c3f5154
Showing 1 changed file with 16 additions and 6 deletions.
22 changes: 16 additions & 6 deletions packages/ui/src/ui/containers/SettingsMenu/SettingsMenuItem.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import {connect} from 'react-redux';
import PropTypes from 'prop-types';
import block from 'bem-cn-lite';

import {Checkbox} from '@gravity-ui/uikit';
import {Checkbox, Switch} from '@gravity-ui/uikit';

import {setSetting} from '../../store/actions/settings';
import {makeGetSetting} from '../../store/selectors/settings';
Expand All @@ -25,6 +25,8 @@ class SettingsMenuItem extends Component {
annotationHighlight: PropTypes.string,

oneLine: PropTypes.bool,

useSwitch: PropTypes.bool,
};

render() {
Expand All @@ -37,6 +39,7 @@ class SettingsMenuItem extends Component {
settingNS,
label,
oneLine,
useSwitch,
} = this.props;
const checked = getSetting(settingName, settingNS);

Expand All @@ -49,11 +52,18 @@ class SettingsMenuItem extends Component {
})}
title={label}
>
<Checkbox
content={label}
checked={checked}
onChange={() => setSetting(settingName, settingNS, !checked)}
/>
{useSwitch ? (
<Switch
checked={checked}
onUpdate={(value) => setSetting(settingName, settingNS, value)}
/>
) : (
<Checkbox
content={label}
checked={checked}
onUpdate={(value) => setSetting(settingName, settingNS, value)}
/>
)}
<div className={b('settings-annotation', 'elements-secondary-text')}>
<span dangerouslySetInnerHTML={{__html: annotation}} />
{annotationHighlight && (
Expand Down

0 comments on commit c3f5154

Please sign in to comment.