From b48aa88e32d8289ba8bb4e2eefb0b89753f535bd Mon Sep 17 00:00:00 2001 From: codex Date: Tue, 9 Jun 2026 22:37:51 +0200 Subject: [PATCH] Add first-run name modal --- public/app.js | 21 +++++++++++++++++- public/index.html | 16 +++++++++++++- public/styles.css | 54 +++++++++++++++++++++++++++++++++++++++-------- 3 files changed, 80 insertions(+), 11 deletions(-) diff --git a/public/app.js b/public/app.js index c58e8b7..ff1cdbc 100644 --- a/public/app.js +++ b/public/app.js @@ -5,6 +5,9 @@ const remoteGrid = document.querySelector("#remote-grid"); const remoteTemplate = document.querySelector("#remote-template"); const nameForm = document.querySelector("#name-form"); const nameInput = document.querySelector("#name-input"); +const nameDialog = document.querySelector("#name-dialog"); +const initialNameForm = document.querySelector("#initial-name-form"); +const initialNameInput = document.querySelector("#initial-name-input"); const statusText = document.querySelector("#status"); const youtubeForm = document.querySelector("#youtube-form"); const youtubeInput = document.querySelector("#youtube-input"); @@ -663,6 +666,20 @@ nameForm.addEventListener("submit", (event) => { }); }); +initialNameForm.addEventListener("submit", (event) => { + event.preventDefault(); + setDisplayName(initialNameInput.value); + nameDialog.close(); + joinCall().catch((error) => { + console.error(error); + setStatus("Could not start camera or join the call."); + }); +}); + +nameDialog.addEventListener("cancel", (event) => { + event.preventDefault(); +}); + nameInput.addEventListener("change", () => { setDisplayName(nameInput.value); if (events) { @@ -765,7 +782,9 @@ if (savedName) { setStatus("Could not start camera or join the call."); }); } else { - nameInput.focus(); + setStatus("Choose your name to join the call."); + nameDialog.showModal(); + initialNameInput.focus(); refreshDeviceLists().catch(console.error); } diff --git a/public/index.html b/public/index.html index c5efbb4..e540bf6 100644 --- a/public/index.html +++ b/public/index.html @@ -15,7 +15,7 @@
- +
@@ -121,6 +121,20 @@ + +
+

Choose your name

+ + +
+
+ diff --git a/public/styles.css b/public/styles.css index eeb4b74..c1290cd 100644 --- a/public/styles.css +++ b/public/styles.css @@ -67,6 +67,36 @@ h1 { gap: 10px; } +.name-dialog { + width: min(420px, calc(100vw - 32px)); + border: 1px solid rgba(255, 255, 255, 0.14); + border-radius: 8px; + background: #171b20; + color: #f2f4f7; + padding: 0; +} + +.name-dialog::backdrop { + background: rgba(0, 0, 0, 0.72); +} + +.initial-name-form { + display: grid; + gap: 14px; + padding: 20px; +} + +.initial-name-form h2 { + margin: 0; + font-size: 20px; + letter-spacing: 0; +} + +.initial-name-form input, +.initial-name-form button { + width: 100%; +} + input, select { width: min(42vw, 260px); @@ -392,23 +422,28 @@ button[aria-pressed="false"] { .device-row { display: grid; - grid-template-columns: 48px minmax(170px, 260px); + grid-template-columns: 40px minmax(150px, 240px); align-items: end; - gap: 10px; + gap: 8px; min-width: 0; } .symbol-button { display: inline-grid; place-items: center; - width: 48px; - height: 48px; + width: 40px; + height: 40px; min-width: 0; padding: 0; - font-size: 24px; + font-size: 20px; line-height: 1; } +.device-row select { + height: 36px; + font-size: 13px; +} + .symbol-button[aria-pressed="false"] { background: #5a6470; opacity: 0.72; @@ -435,8 +470,9 @@ button[aria-pressed="false"] { } .control-actions button { - height: 48px; - min-width: 112px; + height: 40px; + min-width: 104px; + font-size: 13px; } .self-preview { @@ -488,7 +524,7 @@ button[aria-pressed="false"] { } .device-row { - grid-template-columns: 48px minmax(0, 1fr); + grid-template-columns: 40px minmax(0, 1fr); } .device-row select { @@ -553,7 +589,7 @@ button[aria-pressed="false"] { } .device-row { - grid-template-columns: 48px minmax(0, 1fr); + grid-template-columns: 40px minmax(0, 1fr); width: 100%; }