diff --git a/www/html/wordle/board.js b/www/html/wordle/board.js index 50109ed..7c46fdb 100644 --- a/www/html/wordle/board.js +++ b/www/html/wordle/board.js @@ -1,8 +1,8 @@ import { - h, icon, tile, bigBoard, emptyState, skeleton, toast, copyText, confetti, mountShell, + h, fill, icon, tile, bigBoard, emptyState, skeleton, toast, copyText, confetti, mountShell, profileHeader, parseBoardName, boardPage, historyPage, getBoard, getLastBoard, findGame, today, formatDay, resultText, shareText, -} from "./wordle.js?v=2"; +} from "./wordle.js?v=3"; mountShell(); const main = document.getElementById("main"); @@ -30,14 +30,14 @@ async function show(user, day) { ? await findGame(user, today(), -1) ?? await getLastBoard(user) : await getBoard(user, day); } catch { - stage.replaceChildren(h("h2", {}, "Couldn't load the board"), h("p", {}, "Check your connection and try again."), + fill(stage, h("h2", {}, "Couldn't load the board"), h("p", {}, "Check your connection and try again."), h("button", { class: "btn btn-primary", type: "button", onclick: () => location.reload() }, "Retry")); return; } if (!board) { const when = day == null ? "any games" : `a game on ${formatDay(day)}`; - stage.replaceChildren( + fill(stage, h("h2", {}, `No board for ${user}`), h("p", { style: { color: "var(--muted)", margin: "0" } }, `Couldn't find ${when}.`), day == null ? null : navRow(user, day), @@ -59,7 +59,7 @@ async function show(user, day) { h("span", {}, "The word was"), [...board.answer].map(letter => tile(letter, "correct"))); - stage.replaceChildren( + fill(stage, h("div", { class: "headline" }, h("span", { class: board.won ? "badge win" : "badge loss", style: { "font-size": "0.95rem", padding: "6px 14px" } }, board.won ? `Solved in ${resultText(board)}` : `Missed it - ${resultText(board)}`)), diff --git a/www/html/wordle/game.html b/www/html/wordle/game.html index c359f78..881b6f0 100644 --- a/www/html/wordle/game.html +++ b/www/html/wordle/game.html @@ -8,7 +8,7 @@ - + - +
diff --git a/www/html/wordle/games.html b/www/html/wordle/games.html index 7859299..2f399f9 100644 --- a/www/html/wordle/games.html +++ b/www/html/wordle/games.html @@ -8,7 +8,7 @@ - + - +
diff --git a/www/html/wordle/history.js b/www/html/wordle/history.js index fea9722..8bd62d4 100644 --- a/www/html/wordle/history.js +++ b/www/html/wordle/history.js @@ -1,7 +1,7 @@ import { h, icon, miniBoard, emptyState, skeleton, mountShell, profileHeader, normalizeUser, boardPage, getHistory, today, formatDay, relativeDay, weekdayIndex, resultText, -} from "./wordle.js?v=2"; +} from "./wordle.js?v=3"; mountShell(); const main = document.getElementById("main"); diff --git a/www/html/wordle/home.js b/www/html/wordle/home.js index 5694251..1fa6b99 100644 --- a/www/html/wordle/home.js +++ b/www/html/wordle/home.js @@ -2,7 +2,7 @@ import { SSH_COMMAND, h, icon, tile, avatar, miniBoard, emptyState, skeleton, toast, copyText, countdown, mountShell, normalizeUser, statsPage, boardPage, following, setFollowing, recentSearches, addRecentSearch, getStats, getBoard, today, resultText, score, sleep, reducedMotion, -} from "./wordle.js?v=2"; +} from "./wordle.js?v=3"; mountShell({ active: "home" }); const main = document.getElementById("main"); diff --git a/www/html/wordle/index.html b/www/html/wordle/index.html index 88b157e..3857550 100644 --- a/www/html/wordle/index.html +++ b/www/html/wordle/index.html @@ -8,7 +8,7 @@ - + - +
diff --git a/www/html/wordle/stats.html b/www/html/wordle/stats.html index 45607a9..4499b70 100644 --- a/www/html/wordle/stats.html +++ b/www/html/wordle/stats.html @@ -8,7 +8,7 @@ - + - +
diff --git a/www/html/wordle/stats.js b/www/html/wordle/stats.js index d5ac2d5..80aa310 100644 --- a/www/html/wordle/stats.js +++ b/www/html/wordle/stats.js @@ -2,7 +2,7 @@ import { h, icon, miniBoard, emptyState, skeleton, toast, copyText, countUp, countdown, mountShell, profileHeader, normalizeUser, statsPage, boardPage, getStats, getHistory, today, formatDay, relativeDay, resultText, describeBoard, -} from "./wordle.js?v=2"; +} from "./wordle.js?v=3"; mountShell(); const main = document.getElementById("main"); diff --git a/www/html/wordle/wordle.js b/www/html/wordle/wordle.js index 23d4524..abf3adc 100644 --- a/www/html/wordle/wordle.js +++ b/www/html/wordle/wordle.js @@ -27,6 +27,13 @@ export function h(tag, props = {}, ...children) { return el; } +// Replace an element's children, skipping null/false like h() does +// (replaceChildren on its own would show them as the text "null") +export function fill(el, ...children) { + el.replaceChildren(...children.flat(Infinity).filter(child => child != null && child !== false)); + return el; +} + const ICONS = { search: '', gear: '',