aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/components/services/OpenWeather.vue
diff options
context:
space:
mode:
Diffstat (limited to 'src/components/services/OpenWeather.vue')
-rw-r--r--src/components/services/OpenWeather.vue28
1 files changed, 14 insertions, 14 deletions
diff --git a/src/components/services/OpenWeather.vue b/src/components/services/OpenWeather.vue
index 79d5e37..756abf7 100644
--- a/src/components/services/OpenWeather.vue
+++ b/src/components/services/OpenWeather.vue
@@ -22,7 +22,7 @@
22 <div v-else> 22 <div v-else>
23 <p class="title is-4">{{ name }}</p> 23 <p class="title is-4">{{ name }}</p>
24 <p class="subtitle is-6"> 24 <p class="subtitle is-6">
25 {{ temp | tempSuffix(this.item.units) }} 25 {{ temperature }}
26 </p> 26 </p>
27 </div> 27 </div>
28 </div> 28 </div>
@@ -50,6 +50,19 @@ export default {
50 conditions: null, 50 conditions: null,
51 error: false, 51 error: false,
52 }), 52 }),
53 computed: {
54 temperature: function () {
55 if (!this.temp) return "";
56
57 let unit = "K";
58 if (this.item.type === "metric") {
59 unit = "°C";
60 } else if (this.item.type === "imperial") {
61 unit = "°F";
62 }
63 return `${this.temp} ${unit}`;
64 },
65 },
53 created() { 66 created() {
54 this.fetchWeather(); 67 this.fetchWeather();
55 }, 68 },
@@ -86,19 +99,6 @@ export default {
86 }); 99 });
87 }, 100 },
88 }, 101 },
89 filters: {
90 tempSuffix: function (value, type) {
91 if (!value) return "";
92
93 let unit = "K";
94 if (type === "metric") {
95 unit = "°C";
96 } else if (type === "imperial") {
97 unit = "°F";
98 }
99 return `${value} ${unit}`;
100 },
101 },
102}; 102};
103</script> 103</script>
104 104