Skip to content

Commit

Permalink
Improve responsiveness of gr.Audio() controls (#6991)
Browse files Browse the repository at this point in the history
* improve audio container in mobile

* check for denied device access

* add changeset

* add changeset

* tweak controls placements

* add changeset

* add viewport modes to test

* add changeset

* add changeset

* add changeset

---------

Co-authored-by: gradio-pr-bot <gradio-pr-bot@users.noreply.github.com>
Co-authored-by: pngwn <hello@pngwn.io>
  • Loading branch information
3 people authored Feb 16, 2024
1 parent 3e4e680 commit f191786
Show file tree
Hide file tree
Showing 8 changed files with 44 additions and 26 deletions.
7 changes: 7 additions & 0 deletions .changeset/nine-states-sip.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
---
"@gradio/audio": patch
"@gradio/icons": patch
"gradio": patch
---

fix:Improve responsiveness of `gr.Audio()` controls
2 changes: 2 additions & 0 deletions js/audio/Index.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,7 @@
variant={"solid"}
border_mode={dragging ? "focus" : "base"}
padding={false}
allow_overflow={false}
{elem_id}
{elem_classes}
{visible}
Expand Down Expand Up @@ -165,6 +166,7 @@
variant={value === null && active_source === "upload" ? "dashed" : "solid"}
border_mode={dragging ? "focus" : "base"}
padding={false}
allow_overflow={false}
{elem_id}
{elem_classes}
{visible}
Expand Down
1 change: 0 additions & 1 deletion js/audio/interactive/InteractiveAudio.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -286,7 +286,6 @@
on:edit
/>
{/if}

<SelectSource {sources} bind:active_source handle_clear={clear} />
</div>

Expand Down
44 changes: 27 additions & 17 deletions js/audio/shared/WaveformControls.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -276,6 +276,7 @@
display: flex;
justify-self: self-end;
align-items: center;
grid-area: editing;
}
.text-button {
border: 1px solid var(--neutral-400);
Expand All @@ -299,9 +300,26 @@
.controls {
display: grid;
grid-template-columns: 1fr 1fr 1fr;
grid-template-areas: "controls playback editing";
margin-top: 5px;
align-items: center;
position: relative;
flex-wrap: wrap;
justify-content: space-between;
}
.controls div {
margin: var(--size-1) 0;
}
@media (max-width: 600px) {
.controls {
grid-template-columns: 1fr 1fr;
grid-template-rows: auto auto;
grid-template-areas:
"playback playback"
"controls editing";
overflow: scroll;
}
}
.hidden {
Expand All @@ -313,25 +331,10 @@
justify-self: self-start;
align-items: center;
justify-content: space-between;
}
@media (max-width: 375px) {
.controls {
display: flex;
flex-wrap: wrap;
}
.controls * {
margin: var(--spacing-sm);
}
.controls .text-button {
margin-left: 0;
}
grid-area: controls;
}
.action {
width: var(--size-5);
width: var(--size-5);
color: var(--neutral-400);
margin-left: var(--spacing-md);
Expand All @@ -343,6 +346,13 @@
.play-pause-wrapper {
display: flex;
justify-self: center;
grid-area: playback;
}
@media (max-width: 600px) {
.play-pause-wrapper {
margin: var(--spacing-md);
}
}
.playback {
border: 1px solid var(--neutral-400);
Expand All @@ -369,7 +379,6 @@
}
.play-pause-button {
width: var(--size-8);
width: var(--size-8);
display: flex;
align-items: center;
Expand All @@ -383,5 +392,6 @@
display: flex;
justify-content: center;
margin-right: var(--spacing-xl);
width: var(--size-5);
}
</style>
4 changes: 2 additions & 2 deletions js/icons/src/Trim.svelte
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<svg
xmlns="http://www.w3.org/2000/svg"
width="20"
height="20"
width="100%"
height="100%"
viewBox="0 0 24 24"
fill="none"
stroke="currentColor"
Expand Down
4 changes: 2 additions & 2 deletions js/icons/src/VolumeHigh.svelte
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<svg
width="24"
height="24"
width="100%"
height="100%"
viewBox="0 0 24 24"
stroke-width="1.5"
fill="none"
Expand Down
4 changes: 2 additions & 2 deletions js/icons/src/VolumeLow.svelte
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<svg
width="24"
height="24"
width="100%"
height="100%"
viewBox="0 0 24 24"
stroke-width="1.5"
fill="none"
Expand Down
4 changes: 2 additions & 2 deletions js/icons/src/VolumeMuted.svelte
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<svg
width="24"
height="24"
width="100%"
height="100%"
viewBox="0 0 24 24"
stroke-width="1.5"
fill="none"
Expand Down

0 comments on commit f191786

Please sign in to comment.