[Glitch] Removes React Toggle library

Port bc09d3c5f2e48895d686f550a21af6c8155f2485 to glitch-soc

Co-authored-by: diondiondion <mail@diondiondion.com>
Signed-off-by: Claire <claire.github-309c@sitedethib.com>
This commit is contained in:
Echo 2026-04-22 13:31:14 +02:00 committed by Claire
parent b6abf7a69f
commit c5f07296af
8 changed files with 23 additions and 29 deletions

View File

@ -1,3 +1,13 @@
.wrapper {
--diameter: 20px;
--padding: 2px;
--transition: 0.2s ease-in-out;
display: inline-block;
position: relative;
height: calc(var(--diameter) + var(--padding) * 2);
}
.input { .input {
position: absolute; position: absolute;
opacity: 0; opacity: 0;
@ -9,10 +19,6 @@
} }
.toggle { .toggle {
--diameter: 20px;
--padding: 2px;
--transition: 0.2s ease-in-out;
display: inline-flex; display: inline-flex;
align-items: center; align-items: center;
border-radius: 9999px; border-radius: 9999px;
@ -68,8 +74,3 @@
:global([dir='rtl']) .input:checked + .toggle::before { :global([dir='rtl']) .input:checked + .toggle::before {
transform: translateX(calc(-1 * (var(--diameter) - (var(--padding) * 2)))); transform: translateX(calc(-1 * (var(--diameter) - (var(--padding) * 2))));
} }
.wrapper {
display: inline-block;
position: relative;
}

View File

@ -31,20 +31,17 @@ ToggleField.displayName = 'ToggleField';
export const Toggle = forwardRef<HTMLInputElement, Props>( export const Toggle = forwardRef<HTMLInputElement, Props>(
({ className, size, ...otherProps }, ref) => ( ({ className, size, ...otherProps }, ref) => (
<span className={classes.wrapper}> <span
className={classes.wrapper}
style={{ '--diameter': size ? `${size}px` : undefined } as CSSProperties}
>
<input <input
{...otherProps} {...otherProps}
type='checkbox' type='checkbox'
className={classes.input} className={classes.input}
ref={ref} ref={ref}
/> />
<span <span className={classNames(classes.toggle, className)} hidden />
className={classNames(classes.toggle, className)}
style={
{ '--diameter': size ? `${size}px` : undefined } as CSSProperties
}
hidden
/>
</span> </span>
), ),
); );

View File

@ -7,10 +7,9 @@ import ImmutablePropTypes from 'react-immutable-proptypes';
import { NonceProvider } from 'react-select'; import { NonceProvider } from 'react-select';
import AsyncSelect from 'react-select/async'; import AsyncSelect from 'react-select/async';
import Toggle from 'react-toggle';
import { maxFeedHashtags } from 'flavours/glitch/initial_state';
import { maxFeedHashtags } from '@/flavours/glitch/initial_state';
import { Toggle } from '@/flavours/glitch/components/form_fields/toggle_field';
import { injectIntl } from '@/flavours/glitch/components/intl'; import { injectIntl } from '@/flavours/glitch/components/intl';
import SettingToggle from '../../notifications/components/setting_toggle'; import SettingToggle from '../../notifications/components/setting_toggle';

View File

@ -7,8 +7,6 @@ import { useParams, useHistory, Link } from 'react-router-dom';
import { isFulfilled } from '@reduxjs/toolkit'; import { isFulfilled } from '@reduxjs/toolkit';
import Toggle from 'react-toggle';
import ChevronRightIcon from '@/material-icons/400-24px/chevron_right.svg?react'; import ChevronRightIcon from '@/material-icons/400-24px/chevron_right.svg?react';
import ListAltIcon from '@/material-icons/400-24px/list_alt.svg?react'; import ListAltIcon from '@/material-icons/400-24px/list_alt.svg?react';
import { fetchList } from 'flavours/glitch/actions/lists'; import { fetchList } from 'flavours/glitch/actions/lists';
@ -23,6 +21,7 @@ import { ColumnHeader } from 'flavours/glitch/components/column_header';
import { import {
SelectField, SelectField,
TextInputField, TextInputField,
Toggle,
} from 'flavours/glitch/components/form_fields'; } from 'flavours/glitch/components/form_fields';
import { Icon } from 'flavours/glitch/components/icon'; import { Icon } from 'flavours/glitch/components/icon';
import { LoadingIndicator } from 'flavours/glitch/components/loading_indicator'; import { LoadingIndicator } from 'flavours/glitch/components/loading_indicator';

View File

@ -1,7 +1,7 @@
import type { PropsWithChildren } from 'react'; import type { PropsWithChildren } from 'react';
import { useCallback } from 'react'; import { useCallback } from 'react';
import Toggle from 'react-toggle'; import { Toggle } from '@/flavours/glitch/components/form_fields/toggle_field';
interface Props { interface Props {
checked: boolean; checked: boolean;

View File

@ -3,7 +3,7 @@ import { PureComponent } from 'react';
import ImmutablePropTypes from 'react-immutable-proptypes'; import ImmutablePropTypes from 'react-immutable-proptypes';
import Toggle from 'react-toggle'; import { Toggle } from '@/flavours/glitch/components/form_fields/toggle_field';
export default class SettingToggle extends PureComponent { export default class SettingToggle extends PureComponent {
@ -27,7 +27,7 @@ export default class SettingToggle extends PureComponent {
return ( return (
<div className='setting-toggle'> <div className='setting-toggle'>
<Toggle disabled={disabled} id={id} checked={settings.getIn(settingPath, defaultValue)} onChange={this.onChange} onKeyDown={this.onKeyDown} /> <Toggle disabled={disabled} id={id} checked={settings.getIn(settingPath, defaultValue)} onChange={this.onChange} onKeyDown={this.onKeyDown} size={16} />
<label htmlFor={id} className='setting-toggle__label'>{label}</label> <label htmlFor={id} className='setting-toggle__label'>{label}</label>
</div> </div>
); );

View File

@ -6,8 +6,6 @@ import classNames from 'classnames';
import { Helmet } from 'react-helmet'; import { Helmet } from 'react-helmet';
import { useHistory } from 'react-router-dom'; import { useHistory } from 'react-router-dom';
import Toggle from 'react-toggle';
import AddPhotoAlternateIcon from '@/material-icons/400-24px/add_photo_alternate.svg?react'; import AddPhotoAlternateIcon from '@/material-icons/400-24px/add_photo_alternate.svg?react';
import EditIcon from '@/material-icons/400-24px/edit.svg?react'; import EditIcon from '@/material-icons/400-24px/edit.svg?react';
import PersonIcon from '@/material-icons/400-24px/person.svg?react'; import PersonIcon from '@/material-icons/400-24px/person.svg?react';
@ -19,6 +17,7 @@ import { ColumnHeader } from 'flavours/glitch/components/column_header';
import { import {
TextAreaField, TextAreaField,
TextInputField, TextInputField,
Toggle,
} from 'flavours/glitch/components/form_fields'; } from 'flavours/glitch/components/form_fields';
import { Icon } from 'flavours/glitch/components/icon'; import { Icon } from 'flavours/glitch/components/icon';
import { LoadingIndicator } from 'flavours/glitch/components/loading_indicator'; import { LoadingIndicator } from 'flavours/glitch/components/loading_indicator';

View File

@ -6,8 +6,7 @@ import type { Map } from 'immutable';
import { OrderedSet } from 'immutable'; import { OrderedSet } from 'immutable';
import { shallowEqual } from 'react-redux'; import { shallowEqual } from 'react-redux';
import Toggle from 'react-toggle'; import { Toggle } from '@/flavours/glitch/components/form_fields/toggle_field';
import { fetchAccount } from 'flavours/glitch/actions/accounts'; import { fetchAccount } from 'flavours/glitch/actions/accounts';
import { Button } from 'flavours/glitch/components/button'; import { Button } from 'flavours/glitch/components/button';
import type { Status } from 'flavours/glitch/models/status'; import type { Status } from 'flavours/glitch/models/status';