diff options
| author | Petri Hienonen <petri.hienonen@gmail.com> | 2025-11-07 10:35:28 +0200 |
|---|---|---|
| committer | Petri Hienonen <petri.hienonen@gmail.com> | 2025-11-07 10:35:28 +0200 |
| commit | 08528a9e05a12e564f2c3776be4c8ae672f5054c (patch) | |
| tree | b5fe872701d0e30b5df18f7d4ea994b5b4a1761a /app/main.js | |
| parent | f3d3700dcca8555da9882f923a9fc4a30fcab3b8 (diff) | |
| download | housing-08528a9e05a12e564f2c3776be4c8ae672f5054c.tar.zst | |
Minor dom cleanup
Diffstat (limited to 'app/main.js')
| -rw-r--r-- | app/main.js | 91 |
1 files changed, 41 insertions, 50 deletions
diff --git a/app/main.js b/app/main.js index 5bd3534..6f5f7b7 100644 --- a/app/main.js +++ b/app/main.js @@ -34,8 +34,8 @@ export class App { #controls; /** @type {HTMLDialogElement|null} */ #modal = null; - /** @type {number | null} */ - #modalTimer = null; + /** @type {number | undefined} */ + #modalTimer = undefined; /** @type {boolean} */ #persistent = false; /** @type {string} */ @@ -51,38 +51,7 @@ export class App { margin: "0", }); - const loading = App.createLoading(); - - // Create main content container - const mainContainer = Dom.div({ - styles: { - display: "flex", - flex: "1", - overflow: "hidden", - }, - }); - - // Create map container - const mapContainer = Dom.div({ - styles: { - display: "flex", - flex: "1", - flexDirection: "column", - minWidth: "0", // Prevents flex overflow - }, - }); - - const stats = Dom.div({ - styles: { - background: "#fff", - borderTop: "1px solid #ddd", - flexShrink: "0", - fontSize: "0.95rem", - padding: "0.75rem 1rem", - }, - }); - - const controls = App.buildControls( + this.#controls = App.buildControls( this.#filters, this.#weights, () => this.#applyFilters(), @@ -100,13 +69,6 @@ export class App { }, ); - // Build layout hierarchy - mainContainer.append(controls, mapContainer); - document.body.append(loading, mainContainer); - - this.#stats = stats; - this.#controls = controls; - this.#map = new MapEl({ onHouseClick: (houseId, persistent) => this.#showHouseModal(houseId, persistent), onHouseHover: (houseId, hide) => { @@ -118,16 +80,19 @@ export class App { }, }); - mapContainer.append(this.#map.svg, stats); - this.#initialize(loading); - } + this.#stats = Dom.div({ + id: "stats", + styles: { + background: "#fff", + borderTop: "1px solid #ddd", + flexShrink: "0", + fontSize: "0.95rem", + padding: "0.75rem 1rem", + }, + }); - /** - * Create loading indicator - * @returns {HTMLElement} - */ - static createLoading() { - return Dom.div({ + const loading = Dom.div({ + id: "loading", styles: { background: "white", borderRadius: "8px", @@ -144,6 +109,32 @@ export class App { }, textContent: "Loading data…", }); + + document.body.append( + loading, + Dom.div({ + children: [ + this.#controls, + Dom.div({ + children: [this.#map.svg, this.#stats], + id: "map-container", + styles: { + display: "flex", + flex: "1", + flexDirection: "column", + minWidth: "0", // Prevents flex overflow + }, + }), + ], + id: "main", + styles: { + display: "flex", + flex: "1", + overflow: "hidden", + }, + }), + ); + this.#initialize(loading); } /** |
