mirror of
https://github.com/mue/mue.git
synced 2026-07-15 13:03:55 +02:00
fix: cleanup code and fix weather etc
Co-authored-by: Alex Sparkes <turbomarshmello@gmail.com>
This commit is contained in:
@@ -41,21 +41,19 @@ export default class Checkbox extends PureComponent {
|
||||
|
||||
render() {
|
||||
return (
|
||||
<>
|
||||
<FormControlLabel
|
||||
control={
|
||||
<CheckboxUI
|
||||
name={this.props.name}
|
||||
color="primary"
|
||||
className="checkbox"
|
||||
checked={this.state.checked}
|
||||
onChange={this.handleChange}
|
||||
disabled={this.props.disabled || false}
|
||||
/>
|
||||
}
|
||||
label={this.props.text}
|
||||
/>
|
||||
</>
|
||||
<FormControlLabel
|
||||
control={
|
||||
<CheckboxUI
|
||||
name={this.props.name}
|
||||
color="primary"
|
||||
className="checkbox"
|
||||
checked={this.state.checked}
|
||||
onChange={this.handleChange}
|
||||
disabled={this.props.disabled || false}
|
||||
/>
|
||||
}
|
||||
label={this.props.text}
|
||||
/>
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,50 +0,0 @@
|
||||
import variables from 'modules/variables';
|
||||
import { MdCancel } from 'react-icons/md';
|
||||
import { TextField } from '@mui/material';
|
||||
|
||||
export default function KeybindInput(props) {
|
||||
const value = props.state[props.setting];
|
||||
|
||||
const getButton = () => {
|
||||
if (!value) {
|
||||
return (
|
||||
<button
|
||||
className="cleanButton"
|
||||
style={{ visibility: 'hidden' }}
|
||||
onClick={() => props.action('reset', props.setting)}
|
||||
>
|
||||
<MdCancel />
|
||||
</button>
|
||||
);
|
||||
} else if (value === variables.getMessage('modals.main.settings.sections.keybinds.recording')) {
|
||||
return (
|
||||
<button className="cleanButton" onClick={() => props.action('cancel', props.setting)}>
|
||||
<MdCancel />
|
||||
</button>
|
||||
);
|
||||
} else {
|
||||
return (
|
||||
<button className="cleanButton" onClick={() => props.action('reset', props.setting)}>
|
||||
<MdCancel />
|
||||
</button>
|
||||
);
|
||||
}
|
||||
};
|
||||
|
||||
return (
|
||||
<>
|
||||
<TextField
|
||||
label={props.name}
|
||||
onClick={() => props.action('listen', props.setting)}
|
||||
value={
|
||||
value || variables.getMessage('modals.main.settings.sections.keybinds.click_to_record')
|
||||
}
|
||||
readOnly
|
||||
spellCheck={false}
|
||||
varient="outlined"
|
||||
InputLabelProps={{ shrink: true }}
|
||||
/>
|
||||
{getButton()}
|
||||
</>
|
||||
);
|
||||
}
|
||||
@@ -37,20 +37,18 @@ export default class Switch extends PureComponent {
|
||||
|
||||
render() {
|
||||
return (
|
||||
<>
|
||||
<FormControlLabel
|
||||
control={
|
||||
<SwitchUI
|
||||
name={this.props.name}
|
||||
color="primary"
|
||||
checked={this.state.checked}
|
||||
onChange={this.handleChange}
|
||||
/>
|
||||
}
|
||||
label={this.props.header ? '' : this.props.text}
|
||||
labelPlacement="start"
|
||||
/>
|
||||
</>
|
||||
<FormControlLabel
|
||||
control={
|
||||
<SwitchUI
|
||||
name={this.props.name}
|
||||
color="primary"
|
||||
checked={this.state.checked}
|
||||
onChange={this.handleChange}
|
||||
/>
|
||||
}
|
||||
label={this.props.header ? '' : this.props.text}
|
||||
labelPlacement="start"
|
||||
/>
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,255 +0,0 @@
|
||||
import variables from 'modules/variables';
|
||||
import { PureComponent } from 'react';
|
||||
|
||||
import Header from '../Header';
|
||||
import KeybindInput from '../KeybindInput';
|
||||
|
||||
export default class KeybindSettings extends PureComponent {
|
||||
constructor() {
|
||||
super();
|
||||
this.state = {
|
||||
keybinds: JSON.parse(localStorage.getItem('keybinds')) || {},
|
||||
cancelled: false,
|
||||
};
|
||||
}
|
||||
|
||||
showReminder() {
|
||||
document.querySelector('.reminder-info').style.display = 'none';
|
||||
return localStorage.setItem('showReminder', false);
|
||||
}
|
||||
|
||||
listen(type) {
|
||||
const currentKeybinds = this.state.keybinds;
|
||||
currentKeybinds[type] = variables.getMessage(
|
||||
'modals.main.settings.sections.keybinds.recording',
|
||||
);
|
||||
this.setState({
|
||||
keybinds: currentKeybinds,
|
||||
cancelled: false,
|
||||
});
|
||||
this.forceUpdate();
|
||||
|
||||
let keys = '';
|
||||
let previouskey = '';
|
||||
this.keydown = document.addEventListener('keydown', (event) => {
|
||||
if (event.key === previouskey && this.state.cancelled === true) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (keys === '') {
|
||||
keys = event.key;
|
||||
} else {
|
||||
keys = `${keys}+${event.key}`;
|
||||
}
|
||||
|
||||
previouskey = event.key;
|
||||
});
|
||||
|
||||
this.keyup = document.addEventListener('keyup', () => {
|
||||
if (this.state.cancelled === true) {
|
||||
return;
|
||||
}
|
||||
|
||||
document.removeEventListener('keydown', this.keydown);
|
||||
const keybinds = this.state.keybinds;
|
||||
keybinds[type] = keys.split('+').slice(0, 4).join('+');
|
||||
localStorage.setItem('keybinds', JSON.stringify(keybinds));
|
||||
this.setState({
|
||||
keybinds: JSON.parse(localStorage.getItem('keybinds')) || {},
|
||||
});
|
||||
});
|
||||
|
||||
document.removeEventListener('keyup', this.keyup);
|
||||
|
||||
this.showReminder();
|
||||
}
|
||||
|
||||
cancel(type) {
|
||||
document.removeEventListener('keydown', this.keydown);
|
||||
document.removeEventListener('keyup', this.keyup);
|
||||
|
||||
const currentKeybinds = this.state.keybinds;
|
||||
delete currentKeybinds[type];
|
||||
|
||||
this.setState({
|
||||
keybinds: currentKeybinds,
|
||||
cancelled: true,
|
||||
});
|
||||
this.forceUpdate();
|
||||
}
|
||||
|
||||
reset(type) {
|
||||
const keybinds = this.state.keybinds;
|
||||
keybinds[type] = '';
|
||||
localStorage.setItem('keybinds', JSON.stringify(keybinds));
|
||||
|
||||
this.setState({
|
||||
keybinds: JSON.parse(localStorage.getItem('keybinds')) || {},
|
||||
cancelled: true,
|
||||
});
|
||||
|
||||
this.showReminder();
|
||||
}
|
||||
|
||||
action(action, e) {
|
||||
switch (action) {
|
||||
case 'listen':
|
||||
this.listen(e);
|
||||
break;
|
||||
case 'cancel':
|
||||
this.cancel(e);
|
||||
break;
|
||||
case 'reset':
|
||||
this.reset(e);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
render() {
|
||||
return (
|
||||
<>
|
||||
<Header
|
||||
title={variables.getMessage('modals.main.settings.sections.keybinds.title')}
|
||||
setting="keybindsEnabled"
|
||||
element=".other"
|
||||
/>
|
||||
<table className="keybind-table">
|
||||
<tbody>
|
||||
<tr>
|
||||
<th>
|
||||
<KeybindInput
|
||||
name={variables.getMessage(
|
||||
'modals.main.settings.sections.keybinds.background.favourite',
|
||||
)}
|
||||
state={this.state.keybinds}
|
||||
setting="favouriteBackground"
|
||||
action={(type, e) => this.action(type, e)}
|
||||
/>
|
||||
</th>
|
||||
<th>
|
||||
<KeybindInput
|
||||
name={variables.getMessage(
|
||||
'modals.main.settings.sections.keybinds.background.maximise',
|
||||
)}
|
||||
state={this.state.keybinds}
|
||||
setting="maximiseBackground"
|
||||
action={(type, e) => this.action(type, e)}
|
||||
/>
|
||||
</th>
|
||||
</tr>
|
||||
<tr>
|
||||
<th>
|
||||
<KeybindInput
|
||||
name={variables.getMessage(
|
||||
'modals.main.settings.sections.keybinds.background.download',
|
||||
)}
|
||||
state={this.state.keybinds}
|
||||
setting="downloadBackground"
|
||||
action={(type, e) => this.action(type, e)}
|
||||
/>
|
||||
</th>
|
||||
<th>
|
||||
<KeybindInput
|
||||
name={variables.getMessage(
|
||||
'modals.main.settings.sections.keybinds.background.show_info',
|
||||
)}
|
||||
state={this.state.keybinds}
|
||||
setting="showBackgroundInformation"
|
||||
action={(type, e) => this.action(type, e)}
|
||||
/>
|
||||
</th>
|
||||
</tr>
|
||||
<tr>
|
||||
<th>
|
||||
<KeybindInput
|
||||
name={variables.getMessage(
|
||||
'modals.main.settings.sections.keybinds.background.show_info',
|
||||
)}
|
||||
state={this.state.keybinds}
|
||||
setting="showBackgroundInformation"
|
||||
action={(type, e) => this.action(type, e)}
|
||||
/>
|
||||
</th>
|
||||
<th>
|
||||
<KeybindInput
|
||||
name={variables.getMessage(
|
||||
'modals.main.settings.sections.keybinds.quote.favourite',
|
||||
)}
|
||||
state={this.state.keybinds}
|
||||
setting="favouriteQuote"
|
||||
action={(type, e) => this.action(type, e)}
|
||||
/>
|
||||
</th>
|
||||
</tr>
|
||||
<tr>
|
||||
<th>
|
||||
<KeybindInput
|
||||
name={variables.getMessage('modals.main.settings.sections.keybinds.quote.copy')}
|
||||
state={this.state.keybinds}
|
||||
setting="copyQuote"
|
||||
action={(type, e) => this.action(type, e)}
|
||||
/>
|
||||
</th>
|
||||
<th>
|
||||
<KeybindInput
|
||||
name={variables.getMessage('modals.main.settings.sections.keybinds.quote.tweet')}
|
||||
state={this.state.keybinds}
|
||||
setting="tweetQuote"
|
||||
action={(type, e) => this.action(type, e)}
|
||||
/>
|
||||
</th>
|
||||
</tr>
|
||||
<tr>
|
||||
<th>
|
||||
<KeybindInput
|
||||
name={variables.getMessage('modals.main.settings.sections.keybinds.notes.pin')}
|
||||
state={this.state.keybinds}
|
||||
setting="pinNotes"
|
||||
action={(type, e) => this.action(type, e)}
|
||||
/>
|
||||
</th>
|
||||
<th>
|
||||
<KeybindInput
|
||||
name={variables.getMessage('modals.main.settings.sections.keybinds.notes.copy')}
|
||||
state={this.state.keybinds}
|
||||
setting="copyNotes"
|
||||
action={(type, e) => this.action(type, e)}
|
||||
/>
|
||||
</th>
|
||||
</tr>
|
||||
<tr>
|
||||
<th>
|
||||
<KeybindInput
|
||||
name={variables.getMessage('modals.main.settings.sections.keybinds.search')}
|
||||
state={this.state.keybinds}
|
||||
setting="focusSearch"
|
||||
action={(type, e) => this.action(type, e)}
|
||||
/>
|
||||
</th>
|
||||
<th>
|
||||
<KeybindInput
|
||||
name={variables.getMessage('modals.main.settings.sections.keybinds.quicklinks')}
|
||||
state={this.state.keybinds}
|
||||
setting="toggleQuicklinks"
|
||||
action={(type, e) => this.action(type, e)}
|
||||
/>
|
||||
</th>
|
||||
</tr>
|
||||
<tr>
|
||||
<th>
|
||||
<KeybindInput
|
||||
name={variables.getMessage('modals.main.settings.sections.keybinds.modal')}
|
||||
state={this.state.keybinds}
|
||||
setting="toggleModal"
|
||||
action={(type, e) => this.action(type, e)}
|
||||
/>
|
||||
</th>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
</>
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -114,7 +114,7 @@ export default class OrderSettings extends PureComponent {
|
||||
</span>*/}
|
||||
<div className="overviewGrid">
|
||||
<div>
|
||||
<span className="title">Preview</span>
|
||||
<span className="title">{variables.getMessage('modals.welcome.buttons.preview')}</span>
|
||||
<div className="tabPreview">
|
||||
<div className="previewItem" style={{ maxWidth: '50%' }}>
|
||||
{this.state.items.map((value, index) => {
|
||||
|
||||
@@ -60,6 +60,7 @@ export default class TimeSettings extends PureComponent {
|
||||
|
||||
render() {
|
||||
const weatherType = localStorage.getItem('weatherType');
|
||||
|
||||
return (
|
||||
<>
|
||||
<Header
|
||||
|
||||
Reference in New Issue
Block a user