fix: search button and refactor wind direction icon slightly

This commit is contained in:
David Ralph
2021-05-08 10:58:17 +01:00
parent 7327382497
commit b1fbaa7601
3 changed files with 6 additions and 8 deletions

View File

@@ -36,7 +36,7 @@ export default class Autocomplete extends React.Component {
input: e.target.innerText
});
this.props.onClick(e.target.innerText);
this.props.onClick(e);
};
render() {

View File

@@ -48,8 +48,8 @@ export default class Search extends React.PureComponent {
searchButton = (e) => {
let value;
if (e) {
value = e;
if (e.target.innerText !== undefined) {
value = e.target.innerText;
} else {
value = document.getElementById('searchtext').value || 'mue fast';
}

View File

@@ -5,12 +5,10 @@ export default function WindDirectionIcon(props) {
let icon;
// convert the number openweathermap gives us to closest direction or something
const getDirection = (angle) => {
const directions = ['North', 'North-West', 'West', 'South-West', 'South', 'South-East', 'East', 'North-East'];
return directions[Math.round(((angle %= 360) < 0 ? angle + 360 : angle) / 45) % 8];
}
const directions = ['North', 'North-West', 'West', 'South-West', 'South', 'South-East', 'East', 'North-East'];
const direction = directions[Math.round(((props.degrees %= 360) < 0 ? props.degrees + 360 : props.degrees) / 45) % 8];
switch (getDirection(props.degrees)) {
switch (direction) {
case 'North': icon = <WiDirectionUp/>; break;
case 'North-West': icon = <WiDirectionUpLeft/>; break;
case 'West': icon = <WiDirectionLeft/>; break;