Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion defaultmodules/weather/forecast.njk
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
{% if forecast %}
{% set numSteps = forecast | calcNumSteps %}
{% set currentStep = 0 %}
<div class="{{ config.tableClass }} weather-forecast" role="table">
{% set columnCount = 4 + (1 if config.showUVIndex else 0) + (1 if config.showPrecipitationAmount else 0) + (1 if config.showPrecipitationProbability else 0) %}
<div class="{{ config.tableClass }} weather-forecast" role="table" style="--weather-columns: {{ columnCount }};">
{% if config.ignoreToday %}
{% set forecast = forecast.splice(1) %}
{% endif %}
Expand Down
3 changes: 2 additions & 1 deletion defaultmodules/weather/hourly.njk
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
{% if hourly %}
{% set numSteps = hourly | calcNumEntries %}
{% set currentStep = 0 %}
<div class="{{ config.tableClass }} weather-hourly" role="table">
{% set columnCount = 3 + (1 if config.showUVIndex else 0) + (1 if config.showHumidity != "none" else 0) + (1 if config.showPrecipitationAmount else 0) + (1 if config.showPrecipitationProbability else 0) %}
<div class="{{ config.tableClass }} weather-hourly" role="table" style="--weather-columns: {{ columnCount }};">
{% set hours = hourly.slice(0, numSteps) %}
{% for hour in hours %}
<div class="weather-hourly-row{% if config.colored %}{{ " colored" }}{% endif %}" role="row" {% if config.fade %}style="opacity: {{ currentStep | opacity(numSteps) }};"{% endif %}>
Expand Down
7 changes: 5 additions & 2 deletions defaultmodules/weather/weather.css
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,12 @@

.weather .weather-forecast,
.weather .weather-hourly {
display: grid;
display: inline-grid;
vertical-align: top;
width: max-content;
grid-template-columns: repeat(7, max-content);

/* Templates set --weather-columns to the number of enabled columns, so no empty tracks and gaps are reserved */
grid-template-columns: repeat(var(--weather-columns, 7), max-content);
}

.weather .weather-forecast-row,
Expand Down
6 changes: 6 additions & 0 deletions tests/e2e/modules/weather_forecast_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,12 @@ describe("Weather module: Weather Forecast", () => {
expect(firstCell.x).toBe(secondCell.x);
}
});

it("should not reserve space for disabled columns", async () => {
const grid = await page.locator(".weather .weather-forecast").boundingBox();
const lastCell = await page.locator(".weather .weather-forecast-row:nth-child(1) .max-temp").boundingBox();
expect(grid.x + grid.width - (lastCell.x + lastCell.width)).toBeLessThan(1);
});
});

describe("Absolute configuration", () => {
Expand Down
6 changes: 6 additions & 0 deletions tests/e2e/modules/weather_hourly_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,12 @@ describe("Weather module: Weather Hourly Forecast", () => {
expect(firstCell.x).toBe(secondCell.x);
}
});

it("should not reserve space for disabled columns", async () => {
const grid = await page.locator(".weather .weather-hourly").boundingBox();
const lastCell = await page.locator(".weather .weather-hourly-row:nth-child(1) .temperature").boundingBox();
expect(grid.x + grid.width - (lastCell.x + lastCell.width)).toBeLessThan(1);
});
});

describe("Hourly weather options", () => {
Expand Down
Loading