Improve responsive media controls

This commit is contained in:
codex
2026-06-09 21:17:10 +02:00
parent 2657f40039
commit 0db77b7e7d
3 changed files with 63 additions and 26 deletions
+4 -3
View File
@@ -322,7 +322,8 @@ function setTrackEnabled(kind, enabled) {
function updateToggleButton(button, enabled, enabledLabel, disabledLabel) {
button.setAttribute("aria-pressed", String(enabled));
button.textContent = enabled ? enabledLabel : disabledLabel;
button.setAttribute("aria-label", enabled ? enabledLabel : disabledLabel);
button.title = enabled ? enabledLabel : disabledLabel;
}
nameForm.addEventListener("submit", (event) => {
@@ -346,13 +347,13 @@ nameInput.addEventListener("change", () => {
cameraButton.addEventListener("click", () => {
const enabled = cameraButton.getAttribute("aria-pressed") !== "true";
updateToggleButton(cameraButton, enabled, "📷 Camera on", "🚫 Camera off");
updateToggleButton(cameraButton, enabled, "Turn camera off", "Turn camera on");
setTrackEnabled("video", enabled);
});
micButton.addEventListener("click", () => {
const enabled = micButton.getAttribute("aria-pressed") !== "true";
updateToggleButton(micButton, enabled, "🎙️ Mic on", "🔇 Mic muted");
updateToggleButton(micButton, enabled, "Mute microphone", "Unmute microphone");
setTrackEnabled("audio", enabled);
});
+20 -2
View File
@@ -29,14 +29,32 @@
<div class="control-panel">
<div class="device-controls" aria-label="Media devices">
<div class="device-row">
<button id="camera-button" type="button" aria-pressed="true">📷 Camera on</button>
<button
id="camera-button"
type="button"
class="symbol-button"
aria-label="Turn camera off"
aria-pressed="true"
title="Turn camera off"
>
📷
</button>
<label>
<span>Camera</span>
<select id="camera-select"></select>
</label>
</div>
<div class="device-row">
<button id="mic-button" type="button" aria-pressed="true">🎙️ Mic on</button>
<button
id="mic-button"
type="button"
class="symbol-button"
aria-label="Mute microphone"
aria-pressed="true"
title="Mute microphone"
>
🎙️
</button>
<label>
<span>Microphone</span>
<select id="mic-select"></select>
+39 -21
View File
@@ -166,41 +166,55 @@ button[aria-pressed="false"] {
.controls {
display: grid;
grid-template-columns: minmax(0, 1fr) auto;
grid-template-columns: minmax(0, 1fr) clamp(160px, 18vw, 240px);
align-items: center;
column-gap: 20px;
row-gap: 14px;
justify-content: initial;
border-top: 1px solid rgba(255, 255, 255, 0.12);
background: rgba(16, 18, 20, 0.92);
}
.control-panel {
display: grid;
display: flex;
align-items: end;
justify-content: center;
flex-wrap: wrap;
gap: 12px;
min-width: 0;
}
.device-controls {
display: grid;
grid-template-columns: repeat(2, minmax(220px, 360px));
display: flex;
align-items: end;
justify-content: center;
flex-wrap: wrap;
gap: 12px;
min-width: 0;
}
.device-row {
display: grid;
grid-template-columns: 132px minmax(0, 1fr);
grid-template-columns: 48px minmax(170px, 260px);
align-items: end;
gap: 10px;
min-width: 0;
}
.device-row button {
.symbol-button {
display: inline-grid;
place-items: center;
width: 48px;
height: 48px;
min-width: 0;
padding: 0;
font-size: 22px;
line-height: 1;
}
.device-row button[aria-pressed="false"] {
.symbol-button[aria-pressed="false"] {
background: #5a6470;
opacity: 0.72;
}
.device-row label {
@@ -220,6 +234,7 @@ button[aria-pressed="false"] {
justify-content: center;
flex-wrap: wrap;
gap: 12px;
align-items: end;
}
.control-actions button {
@@ -230,7 +245,7 @@ button[aria-pressed="false"] {
.self-preview {
position: relative;
overflow: hidden;
width: clamp(150px, 18vw, 240px);
width: 100%;
aspect-ratio: 16 / 10;
border-radius: 8px;
background: #1b2026;
@@ -260,6 +275,17 @@ button[aria-pressed="false"] {
white-space: nowrap;
}
@media (max-width: 980px) {
.controls {
grid-template-columns: 1fr;
}
.self-preview {
justify-self: center;
width: min(260px, 100%);
}
}
@media (max-width: 680px) {
.topbar {
align-items: stretch;
@@ -293,31 +319,23 @@ button[aria-pressed="false"] {
}
.controls {
grid-template-columns: 1fr;
gap: 12px;
padding: 12px;
}
.control-actions {
order: 2;
}
.device-controls {
order: 1;
display: grid;
grid-template-columns: 1fr;
width: 100%;
}
.device-row {
grid-template-columns: 120px minmax(0, 1fr);
grid-template-columns: 48px minmax(0, 1fr);
width: 100%;
}
.control-actions button {
min-width: min(100%, 180px);
min-width: min(100%, 220px);
}
.self-preview {
justify-self: end;
width: min(42vw, 180px);
width: min(62vw, 220px);
}
}