diff --git a/crates/ghostlight-dungeon/page/page.css b/crates/ghostlight-dungeon/page/page.css index ff06e22..7e2d916 100644 --- a/crates/ghostlight-dungeon/page/page.css +++ b/crates/ghostlight-dungeon/page/page.css @@ -63,3 +63,5 @@ textarea { resize: vertical; line-height: 1.5; } .compose .row { margin-top: .4rem; } .compose .btn { flex: 1 1 8rem; } @media (min-width: 700px) { :root { --fs: 1.2rem; } main { padding-top: 1.25rem; } } +.blk { display: block; } .bad { color: var(--bad); } .gap { margin-top: .6rem; margin-bottom: .2rem; } +label.choice { text-transform: none; letter-spacing: 0; font: inherit; color: var(--text); margin: .4rem 0; } diff --git a/crates/ghostlight-dungeon/page/page.js b/crates/ghostlight-dungeon/page/page.js index 3123088..7d847f7 100644 --- a/crates/ghostlight-dungeon/page/page.js +++ b/crates/ghostlight-dungeon/page/page.js @@ -63,7 +63,7 @@ function stopLive() { if (S.stream) { S.stream.close(); S.stream = null; } if (S.poll) { clearTimeout(S.poll); S.poll = null; } } -function show(...nodes) { $view.replaceChildren(...nodes.flat()); window.scrollTo(0, 0); } +function show(...nodes) { document.querySelector(".compose")?.remove(); $view.replaceChildren(...nodes.flat()); window.scrollTo(0, 0); } function inviteFromHash() { const m = /(?:^#|&)invite=([A-Za-z0-9_\-]{8,200})/.exec(location.hash); return m ? m[1] : ""; @@ -89,7 +89,7 @@ function signInView(message) { const invite = el("input", { type: "text", id: "invite", autocomplete: "off", autocapitalize: "off", spellcheck: "false", value: inviteFromHash() }); const out = el("div", {}); if (message) out.append(errorLine(message)); - const buttons = providers.map((name) => el("button", { class: "btn wide", type: "button", style: "margin:.4rem 0", onclick: () => beginSignIn(name, invite.value.trim(), out) }, + const buttons = providers.map((name) => el("button", { class: "btn wide gap", type: "button", onclick: () => beginSignIn(name, invite.value.trim(), out) }, "Sign in with " + name[0].toUpperCase() + name.slice(1))); show(el("h1", {}, "Sign in"), el("p", { class: "note" }, "Only people on the allowlist can play. A first sign-in needs the invite you were given; after that, signing in is enough."), @@ -163,9 +163,9 @@ function timelineRow(row) { return el("button", { class: "tl" + (row.current ? " current" : ""), type: "button", onclick: () => openTimeline(row.timeline) }, el("span", { class: "t" }, row.title || "Untitled"), el("span", { class: "chip " + row.status }, row.status), " ", - row.parent ? el("span", { class: "small" }, "fork") : "", - el("span", { class: "small", style: "display:block" }, (row.current ? "Current. " : "") + when), - row.status === "failed" ? el("span", { class: "small", style: "display:block;color:var(--bad)" }, row.reason || "Seeding failed.") : ""); + row.parent ? el("span", { class: "small" }, " fork") : "", + el("span", { class: "small blk" }, (row.current ? "Current. " : "") + when), + row.status === "failed" ? el("span", { class: "small blk bad" }, row.reason || "Seeding failed.") : ""); } // ---- begin --------------------------------------------------------------- @@ -179,12 +179,12 @@ async function beginView() { const msg = el("div", {}); if (status !== 200) msg.append(errorLine(body.error || "The lore list could not be read.")); let vault = vaults.length ? vaults[0] : ""; - const choices = vaults.map((name, i) => el("label", { class: "choice", style: "text-transform:none;letter-spacing:0;font:inherit;color:var(--text);margin:.4rem 0" }, + const choices = vaults.map((name, i) => el("label", { class: "choice" }, el("input", { type: "radio", name: "vault", value: name, checked: i === 0, onchange: () => { vault = name; } }), name)); const title = el("input", { type: "text", id: "title", autocomplete: "off", value: LS.get("begin-title") || "" }); const name = el("input", { type: "text", id: "name", autocomplete: "off", value: LS.get("begin-name") || "" }); const brief = el("textarea", { id: "brief", rows: "3" }); - const go = el("button", { class: "btn wide", type: "button", style: "margin-top:1.2rem" }, "Begin"); + const go = el("button", { class: "btn wide gap", type: "button" }, "Begin"); go.onclick = async () => { if (!title.value.trim() || !name.value.trim()) return msg.replaceChildren(errorLine("A world needs a title and your name in it.")); go.disabled = true; msg.replaceChildren(el("p", { class: "note pulse" }, "Starting the world")); @@ -233,7 +233,6 @@ function playView(row) { $status = el("p", { class: "status", role: "status" }); $retryRow = el("div", { class: "row" }); show(el("h1", {}, row.title), el("p", { class: "small" }, "Earlier turns stay on screen while this page is open; after a reload the open turn is shown again."), $log, $status, $retryRow); - document.querySelector(".compose")?.remove(); $text = el("textarea", { id: "say", rows: "2", "aria-label": "What do you do?", placeholder: "What do you do? (Empty Send carries on an unfinished turn.)" }); $text.value = LS.get("draft:" + S.timeline) || ""; $text.addEventListener("input", () => LS.set("draft:" + S.timeline, $text.value)); @@ -243,8 +242,6 @@ function playView(row) { ))); connect(); } -const leavePlay = () => document.querySelector(".compose")?.remove(); -for (const id of ["home", "signout"]) document.getElementById(id).addEventListener("click", leavePlay); function connect() { const id = S.timeline; diff --git a/crates/ghostlight-dungeon/src/api.rs b/crates/ghostlight-dungeon/src/api.rs index 9094f5f..f67ddda 100644 --- a/crates/ghostlight-dungeon/src/api.rs +++ b/crates/ghostlight-dungeon/src/api.rs @@ -1625,6 +1625,7 @@ mod tests { if uri == "/" { assert!(!body.contains("