Skip to content

Commit c9ded83

Browse files
author
jacquesbach
committed
Change Forecast Card Styles
1 parent 39e3387 commit c9ded83

3 files changed

Lines changed: 43 additions & 10 deletions

File tree

static/css/style.css

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -195,15 +195,17 @@
195195
box-shadow: 0 10px 30px rgba(0, 0, 0, 0.03);
196196
display: flex;
197197
flex-direction: column;
198-
justify-content: center;
198+
justify-content: flex-start;
199+
height: 100%;
200+
box-sizing: border-box;
199201
}
200202

201203
.card-gradient {
202204
background: var(--gradient);
203205
color: white;
204206
box-shadow: 0 15px 35px rgba(255, 75, 114, 0.25);
205207
}
206-
208+
207209
.card-gradient .label {
208210
color: rgba(255, 255, 255, 0.85);
209211
font-size: 0.9em;

static/js/layout.js

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,32 @@ async function resetDatabaseLayout() {
8585
}
8686
}
8787

88+
function resizeForecastCardToFit() {
89+
if (!window.dashboardGrid) return;
90+
91+
const gridItem = document.getElementById('card-forecast');
92+
const innerCard = gridItem.querySelector('.card');
93+
94+
if (!gridItem || !innerCard) return;
95+
96+
// 1. Wir erlauben der Karte kurz, ihre natürliche, volle Höhe anzunehmen
97+
innerCard.style.height = 'auto';
98+
const requiredHeightPx = innerCard.scrollHeight;
99+
100+
// 2. Zurücksetzen für das Flex-Layout
101+
innerCard.style.height = '100%';
102+
103+
// 3. Höhe einer einzelnen Gridstack-Zelle plus Margin abrufen
104+
const cellHeight = dashboardGrid.getCellHeight();
105+
const margin = dashboardGrid.getOpts().margin || 20;
106+
107+
// 4. Ausrechnen, wie viele "Blöcke" (h) wir brauchen, aufgerundet
108+
const newH = Math.ceil((requiredHeightPx + margin) / (cellHeight + margin));
109+
110+
// 5. Gridstack anweisen, die neue Höhe anzuwenden
111+
dashboardGrid.update(gridItem, { h: newH });
112+
}
113+
88114
document.addEventListener("DOMContentLoaded", async () => {
89115
// --- PHASE 1: Das Gerüst aufbauen ---
90116
initGridstack();

static/js/script.js

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1153,23 +1153,27 @@ function showShapDetails(point) {
11531153
const container = document.getElementById("shapForcePlot");
11541154

11551155
// ===== ResizeObserver nur einmal registrieren =====
1156-
if (!container._resizeObserverAttached) {
1157-
1156+
const cardItem = document.getElementById("card-forecast");
1157+
if (!cardItem._resizeObserverAttached) {
11581158
const observer = new ResizeObserver(() => {
1159-
if (window._lastShapPoint) {
1160-
showShapDetails(window._lastShapPoint);
1161-
}
1159+
// Wir nutzen einen winzigen Delay, damit Gridstack erst fertig zeichnet
1160+
clearTimeout(window._shapResizeTimer);
1161+
window._shapResizeTimer = setTimeout(() => {
1162+
if (window._lastShapPoint) {
1163+
showShapDetails(window._lastShapPoint);
1164+
}
1165+
}, 50);
11621166
});
1163-
1164-
observer.observe(container);
1165-
container._resizeObserverAttached = true;
1167+
observer.observe(cardItem);
1168+
cardItem._resizeObserverAttached = true;
11661169
}
11671170

11681171
container.innerHTML = "";
11691172
container.style.position = "relative";
11701173
container.style.display = "flex";
11711174
container.style.alignItems = "center";
11721175
container.style.justifyContent = "center";
1176+
container.style.width = "100%";
11731177
container.style.height = "100px";
11741178
container.style.overflow = "visible";
11751179

@@ -1403,4 +1407,5 @@ function showShapDetails(point) {
14031407
}
14041408

14051409
document.getElementById("seasonInterpretation").innerText = text;
1410+
resizeForecastCardToFit();
14061411
}

0 commit comments

Comments
 (0)