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

@@ -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}