feat: finish weather, add week number back, improve widget order and quick links

This commit is contained in:
David Ralph
2021-04-10 13:05:56 +01:00
parent 7c8c61472e
commit e3a482614c
10 changed files with 99 additions and 26 deletions

View File

@@ -3,7 +3,6 @@ import React from 'react';
import DragHandleIcon from '@material-ui/icons/DragIndicator';
import { sortableContainer, sortableElement } from 'react-sortable-hoc';
import arrayMove from 'array-move';
import { toast } from 'react-toastify';
const SortableItem = sortableElement(({value}) => (
@@ -26,9 +25,29 @@ export default class OrderSettings extends React.PureComponent {
this.language = window.language.modals.main.settings;
}
// based on https://stackoverflow.com/a/48301905
arrayMove(array, oldIndex, newIndex) {
if (oldIndex === newIndex) {
return array;
}
const newArray = [...array];
const target = newArray[oldIndex];
const inc = newIndex < oldIndex ? -1 : 1;
for (let i = oldIndex; i !== newIndex; i += inc) {
newArray[i] = newArray[i + inc];
}
newArray[newIndex] = target;
return newArray;
}
onSortEnd = ({oldIndex, newIndex}) => {
this.setState(({items}) => ({
items: arrayMove(items, oldIndex, newIndex)
items: this.arrayMove(items, oldIndex, newIndex)
}));
}

View File

@@ -12,7 +12,6 @@ export default function QuickLinks() {
<Switch name='quicklinksenabled' text={window.language.modals.main.settings.enabled} />
<Checkbox name='quicklinksnewtab' text={language.open_new} />
<Checkbox name='quicklinkstooltip' text={language.tooltip} />
<Checkbox name='quicklinksnewtab' text={language.chrome_apps} />
</>
);
}

View File

@@ -109,6 +109,7 @@ export default class TimeSettings extends React.PureComponent {
<option value='short'>{time.date.type.short}</option>
</Dropdown>
<br/>
<Checkbox name='weeknumber' text={time.date.week_number}/>
{dateSettings}
</>
);

View File

@@ -13,12 +13,6 @@ export default class TimeSettings extends React.PureComponent {
this.language = window.language.modals.main.settings;
}
getLocation() {
if (window.navigator.geolocation) {
window.navigator.geolocation.getCurrentPosition(console.log, console.log);
}
}
componentDidUpdate() {
localStorage.setItem('location', this.state.location);
}
@@ -46,7 +40,7 @@ export default class TimeSettings extends React.PureComponent {
<h2>{language.title}</h2>
<Switch name='weatherEnabled' text={this.language.enabled} />
<ul>
<p>{language.location} <span className='modalLink' onClick={() => this.getLocation()}>{language.auto}</span></p>
<p>{language.location}</p>
<input type='text' value={this.state.location} onChange={(e) => this.setState({ location: e.target.value })}></input>
</ul>
<br/>