Add first-run name modal
This commit is contained in:
+20
-1
@@ -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);
|
||||
}
|
||||
|
||||
|
||||
+15
-1
@@ -15,7 +15,7 @@
|
||||
</div>
|
||||
<form id="name-form" class="name-form">
|
||||
<input id="name-input" autocomplete="name" maxlength="48" placeholder="Your name" required />
|
||||
<button type="submit">Join</button>
|
||||
<button type="submit">Rename</button>
|
||||
</form>
|
||||
</header>
|
||||
|
||||
@@ -121,6 +121,20 @@
|
||||
</article>
|
||||
</template>
|
||||
|
||||
<dialog id="name-dialog" class="name-dialog">
|
||||
<form id="initial-name-form" class="initial-name-form">
|
||||
<h2>Choose your name</h2>
|
||||
<input
|
||||
id="initial-name-input"
|
||||
autocomplete="name"
|
||||
maxlength="48"
|
||||
placeholder="Your name"
|
||||
required
|
||||
/>
|
||||
<button type="submit">Join call</button>
|
||||
</form>
|
||||
</dialog>
|
||||
|
||||
<script type="module" src="/app.js"></script>
|
||||
</body>
|
||||
</html>
|
||||
|
||||
+45
-9
@@ -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%;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user