Outsource weather icons

This commit is contained in:
Daniel Kluge 2022-01-06 18:50:54 +01:00
parent 11f1807ae9
commit 90372e12e0
6 changed files with 27 additions and 2 deletions

3
.gitmodules vendored Normal file
View File

@ -0,0 +1,3 @@
[submodule "src/images/weather-icons"]
path = src/images/weather-icons
url = git@github.com:erikflowers/weather-icons.git

View File

@ -9,7 +9,7 @@ module.exports = {
resolve: "gatsby-plugin-react-svg", resolve: "gatsby-plugin-react-svg",
options: { options: {
rule: { rule: {
include: /weather/ include: /svg/
} }
} }
} }

View File

@ -6,7 +6,27 @@ import * as styles from "../styles/containers/WeatherAndTime.module.css";
const WEATHER_REFRESH_INTERVAL = 15 * 60 * 1000; const WEATHER_REFRESH_INTERVAL = 15 * 60 * 1000;
function getWeatherIcon(icon: string) { function getWeatherIcon(icon: string) {
const ImportedIcon = require(`../images/weather/${icon}.svg`); //const isNight = document.querySelector(':root[data-theme="night"]') !== null
let weatherIcon: string;
switch (icon) {
case "clear-day":
weatherIcon = "day-sunny"
break
case "clear-night":
weatherIcon = "night-clear"
break
case "wind":
weatherIcon = "windy"
break
case "partly-cloudy-day":
weatherIcon = "day-cloudy"
break
case "partly-cloudy-night":
weatherIcon = "night-cloudy"
break;
default: weatherIcon = icon
}
const ImportedIcon = require(`../images/weather-icons/svg/wi-${weatherIcon}.svg`);
return <ImportedIcon /> return <ImportedIcon />
} }

View File

@ -0,0 +1 @@
Subproject commit bb80982bf1f43f2d57f9dd753e7413bf88beb9ed

View File

@ -55,6 +55,7 @@
} }
#futureWeatherInfos th { #futureWeatherInfos th {
width: 25%;
text-align: center; text-align: center;
font-size: 3vh; font-size: 3vh;
font-weight: bold; font-weight: bold;