Fix precipitation styles (#3041)

They weren't applied to wrong classnames, this PR fixes that and also
expands the weather util tests

---------

Co-authored-by: veeck <michael@veeck.de>
This commit is contained in:
Veeck
2023-02-18 18:24:11 +01:00
committed by GitHub
parent 81244d961e
commit fb22a76796
8 changed files with 40 additions and 19 deletions

View File

@@ -23,13 +23,13 @@
{{ f.minTemperature | roundValue | unit("temperature") | decimalSymbol }}
</td>
{% if config.showPrecipitationAmount %}
<td class="align-right bright precipitationAmount">
<td class="align-right bright precipitation-amount">
{{ f.precipitationAmount | unit("precip", f.precipitationUnits) }}
</td>
{% endif %}
{% if config.showPrecipitationProbability %}
<td class="align-right bright precipitationProbability">
{{ f.precipitationProbability }}%
<td class="align-right bright precipitation-prob">
{{ f.precipitationProbability | unit("precip", "%") }}
</td>
{% endif %}
</tr>

View File

@@ -11,13 +11,13 @@
{{ hour.temperature | roundValue | unit("temperature") }}
</td>
{% if config.showPrecipitationAmount %}
<td class="align-right bright precipitationAmount">
<td class="align-right bright precipitation-amount">
{{ hour.precipitationAmount | unit("precip", hour.precipitationUnits) }}
</td>
{% endif %}
{% if config.showPrecipitationProbability %}
<td class="align-right bright precipitationProbability">
{{ hour.precipitationProbability }}%
<td class="align-right bright precipitation-prob">
{{ hour.precipitationProbability | unit("precip", "%") }}
</td>
{% endif %}
</tr>

View File

@@ -29,7 +29,8 @@
padding-right: 0;
}
.weather .precipitation {
.weather .precipitation-amount,
.weather .precipitation-prob {
padding-left: 20px;
padding-right: 0;
}

View File

@@ -12,7 +12,7 @@ const WeatherUtils = {
* @returns {number} the speed in beaufort
*/
beaufortWindSpeed(speedInMS) {
const windInKmh = (speedInMS * 3600) / 1000;
const windInKmh = this.convertWind(speedInMS, "kmh");
const speeds = [1, 5, 11, 19, 28, 38, 49, 61, 74, 88, 102, 117, 1000];
for (const [index, speed] of speeds.entries()) {
if (speed > windInKmh) {
@@ -40,6 +40,8 @@ const WeatherUtils = {
valueUnit = valueUnit ? valueUnit : "mm";
}
if (valueUnit === "%") return `${value}${valueUnit}`;
return `${value.toFixed(2)} ${valueUnit}`;
},