Add custom Toggle component (wrapper around react-toggle)

api-accept
Alex Gleason 2022-05-06 12:46:42 -05:00
rodzic 04463b8aaf
commit 8ad66ec45a
Nie znaleziono w bazie danych klucza dla tego podpisu
ID klucza GPG: 7211D1F99744FBB7
4 zmienionych plików z 18 dodań i 4 usunięć

Wyświetl plik

@ -0,0 +1,14 @@
import React from 'react';
import ReactToggle, { ToggleProps } from 'react-toggle';
/** Wrapper around react-toggle. */
const Toggle: React.FC<ToggleProps> = ({ icons = false, ...rest }) => {
return (
<ReactToggle
icons={icons}
{...rest}
/>
);
};
export default Toggle;

Wyświetl plik

@ -1,11 +1,11 @@
import React, { useState, useEffect, useMemo } from 'react';
import { defineMessages, useIntl, FormattedMessage } from 'react-intl';
import Toggle from 'react-toggle';
import { updateNotificationSettings } from 'soapbox/actions/accounts';
import { patchMe } from 'soapbox/actions/me';
import snackbar from 'soapbox/actions/snackbar';
import List, { ListItem } from 'soapbox/components/list';
import Toggle from 'soapbox/components/toggle';
import { useAppSelector, useAppDispatch, useOwnAccount, useFeatures } from 'soapbox/hooks';
import { normalizeAccount } from 'soapbox/normalizers';
import resizeImage from 'soapbox/utils/resize_image';

Wyświetl plik

@ -2,7 +2,8 @@ import PropTypes from 'prop-types';
import React from 'react';
import ImmutablePropTypes from 'react-immutable-proptypes';
import ImmutablePureComponent from 'react-immutable-pure-component';
import Toggle from 'react-toggle';
import Toggle from 'soapbox/components/toggle';
export default class SettingToggle extends ImmutablePureComponent {
@ -26,7 +27,6 @@ export default class SettingToggle extends ImmutablePureComponent {
id={id}
checked={settings.getIn(settingPath)}
onChange={this.onChange}
icons={false}
onKeyDown={this.onKeyDown}
/>
);

Wyświetl plik

@ -1,12 +1,12 @@
import { Map as ImmutableMap, List as ImmutableList, fromJS } from 'immutable';
import React, { useState, useEffect, useMemo } from 'react';
import { defineMessages, useIntl, FormattedMessage } from 'react-intl';
import Toggle from 'react-toggle';
import { updateConfig } from 'soapbox/actions/admin';
import { uploadMedia } from 'soapbox/actions/media';
import snackbar from 'soapbox/actions/snackbar';
import List, { ListItem } from 'soapbox/components/list';
import Toggle from 'soapbox/components/toggle';
import {
Column,
CardHeader,