2022-01-15 21:54:37 +01:00
|
|
|
<template>
|
|
|
|
<div class="wind">
|
2022-11-07 15:18:19 -07:00
|
|
|
{{ useImperialUnits ?
|
|
|
|
convert_mps_to_mph(Number(weather.wind)).toFixed(1) + ' mph' :
|
|
|
|
Number(weather.wind).toFixed(1) + " m/s" }}
|
2022-01-15 21:54:37 +01:00
|
|
|
<div class="wind-bearing">
|
|
|
|
<i
|
|
|
|
v-if="weather.windBearing"
|
2022-01-16 21:14:28 +01:00
|
|
|
class="fa fa-long-arrow-down"
|
2022-01-15 21:54:37 +01:00
|
|
|
:style="{
|
|
|
|
transform: `rotate(${weather.windBearing}deg)`,
|
|
|
|
}"
|
|
|
|
aria-hidden="true"
|
|
|
|
:title="getWindDirectionTitle(weather.windBearing)"
|
|
|
|
/>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</template>
|
|
|
|
|
|
|
|
<script setup lang="ts">
|
|
|
|
import { toRefs } from 'vue'
|
|
|
|
import { useI18n } from 'vue-i18n'
|
|
|
|
|
|
|
|
import { IWeather } from '@/types/workouts'
|
|
|
|
import { convertDegreeToDirection } from '@/utils/weather'
|
|
|
|
|
|
|
|
interface Props {
|
|
|
|
weather: IWeather
|
|
|
|
useImperialUnits: boolean
|
|
|
|
}
|
|
|
|
const props = defineProps<Props>()
|
|
|
|
|
|
|
|
const { useImperialUnits, weather } = toRefs(props)
|
|
|
|
const { t } = useI18n()
|
|
|
|
|
|
|
|
function getWindDirectionTitle(windBearing: number): string {
|
|
|
|
return t(
|
|
|
|
`workouts.WEATHER.WIND_DIRECTIONS.${convertDegreeToDirection(
|
|
|
|
windBearing
|
|
|
|
)}`
|
|
|
|
)
|
|
|
|
}
|
2022-11-07 15:18:19 -07:00
|
|
|
|
|
|
|
function convert_mps_to_mph(windSpeed: number): number {
|
|
|
|
return windSpeed * 2.2369363
|
|
|
|
}
|
2022-01-15 21:54:37 +01:00
|
|
|
</script>
|
|
|
|
|
|
|
|
<style lang="scss" scoped>
|
|
|
|
.wind {
|
|
|
|
display: flex;
|
|
|
|
justify-content: center;
|
|
|
|
.wind-bearing {
|
|
|
|
padding-left: 5px;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
</style>
|