refactor: cleanup

This commit is contained in:
David Ralph
2021-08-15 22:28:37 +01:00
parent 5e4a14ba2c
commit 4f5233fab9
44 changed files with 133 additions and 234 deletions

View File

@@ -1,10 +1,8 @@
import { PureComponent } from 'react';
import { Checkbox as CheckboxUI, FormControlLabel } from '@material-ui/core';
import EventBus from '../../../../modules/helpers/eventbus';
import CheckboxUI from '@material-ui/core/Checkbox';
import FormControlLabel from '@material-ui/core/FormControlLabel';
export default class Checkbox extends PureComponent {
constructor(props) {
super(props);
@@ -34,19 +32,11 @@ export default class Checkbox extends PureComponent {
}
render() {
let text = this.props.text;
if (this.props.newFeature) {
text = <>{this.props.text} <span className='newFeature'> NEW</span></>;
} else if (this.props.betaFeature) {
text = <>{this.props.text} <span className='newFeature'> BETA</span></>;
}
return (
<>
<FormControlLabel
control={<CheckboxUI name={this.props.name} color='primary' className='checkbox' checked={this.state.checked} onChange={this.handleChange} />}
label={text}
label={this.props.text}
/>
<br/>
</>

View File

@@ -1,5 +1,4 @@
import { PureComponent } from 'react';
import { toast } from 'react-toastify';
export default class FileUpload extends PureComponent {

View File

@@ -1,13 +1,8 @@
import { PureComponent } from 'react';
import { Radio as RadioUI, RadioGroup, FormControlLabel, FormControl, FormLabel } from '@material-ui/core';
import EventBus from '../../../../modules/helpers/eventbus';
import RadioUI from '@material-ui/core/Radio';
import RadioGroup from '@material-ui/core/RadioGroup';
import FormControlLabel from '@material-ui/core/FormControlLabel';
import FormControl from '@material-ui/core/FormControl';
import FormLabel from '@material-ui/core/FormLabel';
export default class Radio extends PureComponent {
constructor(props) {
super(props);

View File

@@ -1,6 +1,4 @@
import CloseIcon from '@material-ui/icons/Close';
import DeleteIcon from '@material-ui/icons/Delete';
import { Close, Delete } from '@material-ui/icons';
import { setDefaultSettings } from '../../../../modules/helpers/settings';
export default function ResetModal(props) {
@@ -20,10 +18,10 @@ export default function ResetModal(props) {
<span>{language.information}</span>
<div className='resetfooter'>
<button className='round reset' style={{ marginLeft: 0 }} onClick={() => reset()}>
<DeleteIcon/>
<Delete/>
</button>
<button className='round import' style={{ marginLeft: '5px' }} onClick={props.modalClose}>
<CloseIcon/>
<Close/>
</button>
</div>
</>

View File

@@ -1,10 +1,9 @@
// todo: find a better method to do width of number input
import { PureComponent } from 'react';
import { toast } from 'react-toastify';
import EventBus from '../../../../modules/helpers/eventbus';
import { toast } from 'react-toastify';
export default class Slider extends PureComponent {
constructor(props) {
super(props);

View File

@@ -1,10 +1,8 @@
import { PureComponent } from 'react';
import { Switch as SwitchUI, FormControlLabel } from '@material-ui/core';
import EventBus from '../../../../modules/helpers/eventbus';
import SwitchUI from '@material-ui/core/Switch';
import FormControlLabel from '@material-ui/core/FormControlLabel';
export default class Switch extends PureComponent {
constructor(props) {
super(props);
@@ -34,19 +32,11 @@ export default class Switch extends PureComponent {
}
render() {
let text = this.props.text;
if (this.props.newFeature) {
text = <>{this.props.text} <span className='newFeature'> NEW</span></>;
} else if (this.props.betaFeature) {
text = <>{this.props.text} <span className='newFeature'> BETA</span></>;
}
return (
<>
<FormControlLabel
control={<SwitchUI name={this.props.name} color='primary' checked={this.state.checked} onChange={this.handleChange} />}
label={text}
label={this.props.text}
labelPlacement='start'
/>
<br/>

View File

@@ -1,9 +1,8 @@
import { PureComponent } from 'react';
import { toast } from 'react-toastify';
import EventBus from '../../../../modules/helpers/eventbus';
import { toast } from 'react-toastify';
export default class Text extends PureComponent {
constructor(props) {
super(props);

View File

@@ -1,11 +1,7 @@
import { PureComponent } from 'react';
import { Email, Twitter, Chat, Instagram, Facebook } from '@material-ui/icons';
import Tooltip from '../../../../helpers/tooltip/Tooltip';
import EmailIcon from '@material-ui/icons/Email';
import TwitterIcon from '@material-ui/icons/Twitter';
import ChatIcon from '@material-ui/icons/Chat';
import InstagramIcon from '@material-ui/icons/Instagram';
import FacebookIcon from '@material-ui/icons/Facebook';
const other_contributors = require('../../../../../modules/other_contributors.json');
@@ -94,11 +90,11 @@ export default class About extends PureComponent {
<a href={window.constants.PRIVACY_URL} className='aboutLink' target='_blank' rel='noopener noreferrer' style={{ fontSize: '1rem' }}>{window.language.modals.welcome.sections.privacy.links.privacy_policy}</a>
<h3>{this.language.contact_us}</h3>
<a href={'mailto:' + window.constants.EMAIL} className='aboutIcon' target='_blank' rel='noopener noreferrer'><EmailIcon/></a>
<a href={'https://twitter.com/' + window.constants.TWITTER_HANDLE} className='aboutIcon' target='_blank' rel='noopener noreferrer'><TwitterIcon/></a>
<a href={'https://instagram.com/' + window.constants.INSTAGRAM_HANDLE} className='aboutIcon' target='_blank' rel='noopener noreferrer'><InstagramIcon/></a>
<a href={'https://facebook.com/' + window.constants.FACEBOOK_HANDLE} className='aboutIcon' target='_blank' rel='noopener noreferrer'><FacebookIcon/></a>
<a href={'https://discord.gg/' + window.constants.DISCORD_SERVER} className='aboutIcon' target='_blank' rel='noopener noreferrer'><ChatIcon/></a>
<a href={'mailto:' + window.constants.EMAIL} className='aboutIcon' target='_blank' rel='noopener noreferrer'><Email/></a>
<a href={'https://twitter.com/' + window.constants.TWITTER_HANDLE} className='aboutIcon' target='_blank' rel='noopener noreferrer'><Twitter/></a>
<a href={'https://instagram.com/' + window.constants.INSTAGRAM_HANDLE} className='aboutIcon' target='_blank' rel='noopener noreferrer'><Instagram/></a>
<a href={'https://facebook.com/' + window.constants.FACEBOOK_HANDLE} className='aboutIcon' target='_blank' rel='noopener noreferrer'><Facebook/></a>
<a href={'https://discord.gg/' + window.constants.DISCORD_SERVER} className='aboutIcon' target='_blank' rel='noopener noreferrer'><Chat/></a>
<h3>{this.language.support_mue}</h3>
<p>

View File

@@ -1,4 +1,7 @@
import { PureComponent } from 'react';
import Modal from 'react-modal';
import { exportSettings, importSettings } from '../../../../../modules/helpers/settings/modals';
import Checkbox from '../Checkbox';
import FileUpload from '../FileUpload';
@@ -7,10 +10,6 @@ import Switch from '../Switch';
import ResetModal from '../ResetModal';
import Dropdown from '../Dropdown';
import { exportSettings, importSettings } from '../../../../../modules/helpers/settings/modals';
import Modal from 'react-modal';
const time_zones = require('../../../../widgets/time/timezones.json');
export default class AdvancedSettings extends PureComponent {

View File

@@ -1,11 +1,9 @@
import { PureComponent } from 'react';
import { WifiOff } from '@material-ui/icons';
import Modal from 'react-modal';
import Lightbox from '../../marketplace/Lightbox';
import WifiOffIcon from '@material-ui/icons/WifiOff';
export default class Changelog extends PureComponent {
constructor() {
super();
@@ -89,7 +87,7 @@ export default class Changelog extends PureComponent {
const language = window.language.modals.main.marketplace;
return errorMessage(<>
<WifiOffIcon/>
<WifiOff/>
<h1>{language.offline.title}</h1>
<p className='description'>{language.offline.description}</p>
</>);

View File

@@ -1,5 +1,6 @@
import Checkbox from '../Checkbox';
import Slider from '../Slider';
import EventBus from '../../../../../modules/helpers/eventbus';
export default function ExperimentalSettings() {

View File

@@ -1,12 +1,10 @@
import { PureComponent } from 'react';
import EventBus from '../../../../../modules/helpers/eventbus';
import DragHandleIcon from '@material-ui/icons/DragIndicator';
import { DragIndicator } from '@material-ui/icons';
import { sortableContainer, sortableElement } from 'react-sortable-hoc';
import { toast } from 'react-toastify';
import EventBus from '../../../../../modules/helpers/eventbus';
const enabled = (setting) => {
switch (setting) {
case 'quicklinks':
@@ -27,7 +25,7 @@ const widget_name = {
const SortableItem = sortableElement(({ value }) => (
<li className='sortableitem' style={{ display: enabled(value) ? 'block' : 'none' }}>
<DragHandleIcon style={{ verticalAlign: 'middle' }} />
<DragIndicator style={{ verticalAlign: 'middle' }} />
{widget_name[value]}
</li>
));

View File

@@ -1,4 +1,5 @@
import { PureComponent } from 'react';
import { toast } from 'react-toastify';
import Dropdown from '../Dropdown';
import Checkbox from '../Checkbox';
@@ -7,8 +8,6 @@ import Radio from '../Radio';
import EventBus from '../../../../../modules/helpers/eventbus';
import { toast } from 'react-toastify';
const searchEngines = require('../../../../widgets/search/search_engines.json');
const autocompleteProviders = require('../../../../widgets/search/autocomplete_providers.json');

View File

@@ -1,6 +1,5 @@
import { PureComponent } from 'react';
import EventBus from '../../../../../../modules/helpers/eventbus';
import { toast } from 'react-toastify';
import Checkbox from '../../Checkbox';
import Dropdown from '../../Dropdown';
@@ -11,7 +10,7 @@ import Radio from '../../Radio';
import ColourSettings from './Colour';
import { toast } from 'react-toastify';
import EventBus from '../../../../../../modules/helpers/eventbus';
export default class BackgroundSettings extends PureComponent {
constructor() {

View File

@@ -1,12 +1,10 @@
import { PureComponent, Fragment } from 'react';
import { ColorPicker } from 'react-color-gradient-picker';
import { toast } from 'react-toastify';
import hexToRgb from '../../../../../../modules/helpers/background/hexToRgb';
import rgbToHex from '../../../../../../modules/helpers/background/rgbToHex';
import { toast } from 'react-toastify';
import 'react-color-gradient-picker/dist/index.css';
import '../../../scss/settings/react-color-picker-gradient-picker-custom-styles.scss';