mirror of
https://github.com/mue/mue.git
synced 2026-07-09 21:45:26 +02:00
fix: search button and refactor wind direction icon slightly
This commit is contained in:
@@ -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() {
|
||||
|
||||
@@ -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';
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user