diff --git a/package.json b/package.json index f0554a67..3daa1f9b 100644 --- a/package.json +++ b/package.json @@ -16,7 +16,6 @@ "@fontsource/roboto": "^4.2.2", "@material-ui/core": "4.11.3", "@material-ui/icons": "4.11.2", - "array-move": "^3.0.1", "react": "17.0.2", "react-clock": "3.0.0", "react-color-gradient-picker": "0.1.2", diff --git a/src/components/modals/main/settings/sections/Order.jsx b/src/components/modals/main/settings/sections/Order.jsx index 67db3107..0266a284 100644 --- a/src/components/modals/main/settings/sections/Order.jsx +++ b/src/components/modals/main/settings/sections/Order.jsx @@ -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) })); } diff --git a/src/components/modals/main/settings/sections/QuickLinks.jsx b/src/components/modals/main/settings/sections/QuickLinks.jsx index 573b42bd..bd5331f0 100644 --- a/src/components/modals/main/settings/sections/QuickLinks.jsx +++ b/src/components/modals/main/settings/sections/QuickLinks.jsx @@ -12,7 +12,6 @@ export default function QuickLinks() { - ); } diff --git a/src/components/modals/main/settings/sections/Time.jsx b/src/components/modals/main/settings/sections/Time.jsx index 4c3fadc8..34770994 100644 --- a/src/components/modals/main/settings/sections/Time.jsx +++ b/src/components/modals/main/settings/sections/Time.jsx @@ -109,6 +109,7 @@ export default class TimeSettings extends React.PureComponent {
+ {dateSettings} ); diff --git a/src/components/modals/main/settings/sections/Weather.jsx b/src/components/modals/main/settings/sections/Weather.jsx index 3764750d..d02569c6 100644 --- a/src/components/modals/main/settings/sections/Weather.jsx +++ b/src/components/modals/main/settings/sections/Weather.jsx @@ -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 {

{language.title}

    -

    {language.location} this.getLocation()}>{language.auto}

    +

    {language.location}

    this.setState({ location: e.target.value })}>

diff --git a/src/components/widgets/quicklinks/QuickLinks.jsx b/src/components/widgets/quicklinks/QuickLinks.jsx index 39039930..13d48093 100644 --- a/src/components/widgets/quicklinks/QuickLinks.jsx +++ b/src/components/widgets/quicklinks/QuickLinks.jsx @@ -14,6 +14,7 @@ export default class QuickLinks extends React.PureComponent { url: '', showAddLink: 'hidden' }; + this.language = window.language.widgets.quicklinks; } updateLink(type, value) { @@ -71,22 +72,36 @@ export default class QuickLinks extends React.PureComponent { rel ='noopener noreferrer'; } + const tooltipEnabled = localStorage.getItem('quicklinkstooltip'); + + const quickLink = (item) => { + const link = ( + this.deleteLink(item.name, e)} href={item.url} target={target} rel={rel}> + {item.name}/ + + ); + + if (tooltipEnabled === 'true') { + return {link}; + } else { + return link; + } + } + return (
{this.state.items.map((item) => ( - - this.deleteLink(item.name, e)} href={item.url} target={target} rel={rel}>{item.name}/ - + quickLink(item) ))}
-

New Link

- this.updateLink('name', e.target.value)} /> +

{this.language.new}

+ this.updateLink('name', e.target.value)} />
- this.updateLink('url', e.target.value)} /> + this.updateLink('url', e.target.value)} />
- +
diff --git a/src/components/widgets/time/Date.jsx b/src/components/widgets/time/Date.jsx index 899bf772..9ccbb71f 100644 --- a/src/components/widgets/time/Date.jsx +++ b/src/components/widgets/time/Date.jsx @@ -6,12 +6,35 @@ export default class DateWidget extends React.PureComponent { constructor() { super(); this.state = { - date: '' + date: '', + weekNumber: '' }; } + getWeekNumber(date) { + const dateToday = new Date(date.valueOf()); + const dayNumber = (dateToday.getDay() + 6) % 7; + + dateToday.setDate(dateToday.getDate() - dayNumber + 3); + const firstThursday = dateToday.valueOf(); + dateToday.setMonth(0, 1); + + if (dateToday.getDay() !== 4) { + dateToday.setMonth(0, 1 + ((4 - dateToday.getDay()) + 7) % 7); + } + + this.setState({ + weekNumber: `${window.language.widgets.date.week} ${1 + Math.ceil((firstThursday - dateToday) / 604800000)}` + }); + } + getDate() { const date = new Date(); + + if (localStorage.getItem('weeknumber') === 'true') { + this.getWeekNumber(date); + } + const type = localStorage.getItem('dateType'); if (type === 'short') { @@ -77,6 +100,6 @@ export default class DateWidget extends React.PureComponent { } render() { - return {this.state.date}; + return {this.state.date}
{this.state.weekNumber}
; } } diff --git a/src/components/widgets/weather/Weather.jsx b/src/components/widgets/weather/Weather.jsx index 69670f3e..5f21397f 100644 --- a/src/components/widgets/weather/Weather.jsx +++ b/src/components/widgets/weather/Weather.jsx @@ -1,6 +1,6 @@ import React from 'react'; -import WeatherIcon from './WeatherIcon'; +import WeatherIcon from './WeatherIcon'; import { WiHumidity, WiWindy } from 'weather-icons-react'; import './weather.scss'; @@ -71,13 +71,27 @@ export default class Weather extends React.PureComponent { const checkValue = (setting) => { return (localStorage.getItem(setting) === 'true'); }; + + const minmax = () => { + const mintemp = (localStorage.getItem('mintemp') === 'true'); + const maxtemp = (localStorage.getItem('maxtemp') === 'true'); + + if (!mintemp && !maxtemp) { + return null; + } else if (mintemp && !maxtemp) { + return <>
{this.state.weather.temp_min + this.state.temp_text}; + } else if (maxtemp && !mintemp) { + return <>
{this.state.weather.temp_max + this.state.temp_text}; + } else { + return <>
{this.state.weather.temp_min + this.state.temp_text} {this.state.weather.temp_max + this.state.temp_text}; + } + }; return (
{this.state.weather.temp + this.state.temp_text} -
- {checkValue('mintemp') ? this.state.weather.temp_min + this.state.temp_text : null} {checkValue('maxtemp') ? this.state.weather.temp_max + this.state.temp_text : null} + {minmax()} {checkValue('humidity') ?
{this.state.weather.humidity}%
: null} {checkValue('windspeed') ?
{this.state.weather.windspeed} m/s
: null} {checkValue('atmosphericpressure') ?
{this.state.weather.pressure} hPa
: null} diff --git a/src/modules/default_settings.json b/src/modules/default_settings.json index cd1b488f..a5f27c63 100644 --- a/src/modules/default_settings.json +++ b/src/modules/default_settings.json @@ -33,7 +33,7 @@ }, { "name": "customBackgroundColour", - "value": "" + "value": "{\"angle\":\"180\",\"gradient\":[{\"colour\":\"#ffb032\",\"stop\":0}],\"type\":\"linear\"}" }, { "name": "customBackground", diff --git a/src/translations/en_GB.json b/src/translations/en_GB.json index a2d55dd2..cf21756f 100644 --- a/src/translations/en_GB.json +++ b/src/translations/en_GB.json @@ -17,6 +17,15 @@ "download": "Download" }, "search": "Search", + "quicklinks": { + "new": "New Link", + "name": "Name", + "url": "URL", + "add": "Add" + }, + "date": { + "week": "Week" + }, "navbar": { "tooltips": { "update": "Update Patch Notes", @@ -69,6 +78,7 @@ "percentage_complete": "Percentage Complete", "date": { "title": "Date", + "week_number": "Week Number", "day_of_week": "Day of week", "datenth": "Date nth", "type": { @@ -164,8 +174,7 @@ "quicklinks": { "title": "Quick Links", "open_new": "Open in new tab", - "tooltip": "Tooltip", - "chrome_apps": "Chrome Apps" + "tooltip": "Tooltip" }, "appearance": { "title": "Appearance",