mirror of
https://github.com/mue/mue.git
synced 2026-07-27 10:41:08 +02:00
feat: finish weather, add week number back, improve widget order and quick links
This commit is contained in:
@@ -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 <><br/>{this.state.weather.temp_min + this.state.temp_text}</>;
|
||||
} else if (maxtemp && !mintemp) {
|
||||
return <><br/>{this.state.weather.temp_max + this.state.temp_text}</>;
|
||||
} else {
|
||||
return <><br/>{this.state.weather.temp_min + this.state.temp_text} {this.state.weather.temp_max + this.state.temp_text}</>;
|
||||
}
|
||||
};
|
||||
|
||||
return (
|
||||
<div className='weather'>
|
||||
<WeatherIcon name={this.state.icon}/>
|
||||
<span>{this.state.weather.temp + this.state.temp_text}</span>
|
||||
<br/>
|
||||
<span className='minmax'>{checkValue('mintemp') ? this.state.weather.temp_min + this.state.temp_text : null} {checkValue('maxtemp') ? this.state.weather.temp_max + this.state.temp_text : null}</span>
|
||||
<span className='minmax'>{minmax()}</span>
|
||||
{checkValue('humidity') ? <span className='loc'><br/><WiHumidity/>{this.state.weather.humidity}%</span> : null}
|
||||
{checkValue('windspeed') ? <span className='loc'><br/><WiWindy/>{this.state.weather.windspeed}<span className='minmax'> m/s</span></span> : null}
|
||||
{checkValue('atmosphericpressure') ? <span className='loc'><br/>{this.state.weather.pressure}<span className='minmax'> hPa</span></span> : null}
|
||||
|
||||
Reference in New Issue
Block a user