Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve source selection UX #6766

Merged
merged 35 commits into from Dec 19, 2023
Merged

Improve source selection UX #6766

merged 35 commits into from Dec 19, 2023

Conversation

hannahblair
Copy link
Collaborator

@hannahblair hannahblair commented Dec 12, 2023

Description

This PR

  • Fixes the source selection being cut off in Webcam (and changes it to use the select and option elements so a little a11y win)
  • Changes gr.Image to use the source selection component used in Audio and Video for alignment (extra benefit is seeing the selected source icon styling)
    • I've changed active_source logic slightly: 1) it can be any of the sources, not just webcam or null. 2) active_tool renamed to active_source for a tiny bit of consistency cc @pngwn
  • Adds a paste from clipboard view when active_source is clipboard
  • Improve Video source selection styling (use webcam icon) and UX (couldn't switch to upload from webcam)

Test Demo

import gradio as gr

with gr.Blocks() as demo:
    with gr.Row():
        gr.Image(label="Input", sources=["upload", "webcam", "clipboard"])
        gr.Image(label="Input", sources=["webcam", "webcam"])
        gr.Video(sources=["webcam", "upload"])

demo.launch()

Before After
gr.Image Kapture 2023-12-13 at 12 29 17 Kapture 2023-12-13 at 12 27 26
gr.Image Kapture 2023-12-13 at 12 12 13 Kapture 2023-12-13 at 12 15 10
gr.Video Kapture 2023-12-13 at 13 25 57 Kapture 2023-12-13 at 13 28 58
gr.Video (can now be small in mobile) Screenshot 2023-12-13 at 14 35 56 Screenshot 2023-12-13 at 14 33 58

Closes: #6710
Closes: #6751

🎯 PRs Should Target Issues

Before your create a PR, please check to see if there is an existing issue for this change. If not, please create an issue before you create this PR, unless the fix is very small.

Not adhering to this guideline will result in the PR being closed.

Tests

  1. PRs will only be merged if tests pass on CI. To run the tests locally, please set up your Gradio environment locally and run the tests: bash scripts/run_all_tests.sh

  2. You may need to run the linters: bash scripts/format_backend.sh and bash scripts/format_frontend.sh

@hannahblair hannahblair changed the title Improve source selection styling Improve Image source selection UX Dec 12, 2023
@hannahblair hannahblair changed the title Improve Image source selection UX Improve source selection UX Dec 13, 2023
Set sources[0] to active_source in Image
@hannahblair hannahblair marked this pull request as ready for review December 13, 2023 16:36
@abidlabs
Copy link
Member

Does this solve #6751 by any chance?

@gradio-pr-bot
Copy link
Contributor

gradio-pr-bot commented Dec 13, 2023

🪼 branch checks and previews

Name Status URL
Spaces ready! Spaces preview
Website ready! Website preview
Storybook ready! Storybook preview
Visual tests all good! Build review
🦄 Changes detected! Details

Install Gradio from this PR

pip install https://gradio-builds.s3.amazonaws.com/46dc324d0ebccf8fce8328e09a3f0591f9a5e70f/gradio-4.10.0-py3-none-any.whl

Install Gradio Python Client from this PR

pip install "gradio-client @ git+https://github.com/gradio-app/gradio@46dc324d0ebccf8fce8328e09a3f0591f9a5e70f#subdirectory=client/python"

@hannahblair
Copy link
Collaborator Author

hannahblair commented Dec 13, 2023

Does this solve #6751 by any chance?

Ah, no (just managed to repro after updating main). But it makes sense to fix it in this PR!

@abidlabs
Copy link
Member

Thanks @hannahblair! I'll mark it as a regression then

@gradio-pr-bot
Copy link
Contributor

gradio-pr-bot commented Dec 13, 2023

🦄 change detected

This Pull Request includes changes to the following packages.

Package Version
@gradio/app patch
@gradio/atoms patch
@gradio/audio patch
@gradio/image patch
@gradio/upload patch
@gradio/video patch
gradio patch
  • Maintainers can select this checkbox to manually select packages to update.

With the following changelog entry.

Improve source selection UX

Maintainers or the PR author can modify the PR title to modify this entry.

Something isn't right?

  • Maintainers can change the version label to modify the version bump.
  • If the bot has failed to detect any changes, or if this pull request needs to update multiple packages to different versions or requires a more comprehensive changelog entry, maintainers can update the changelog file directly.

@hannahblair
Copy link
Collaborator Author

@abidlabs scrap my comment above, it does fix it

@abidlabs
Copy link
Member

Great! Perhaps @dawoodkhan82 or @aliabid94 could review the PR

@pngwn
Copy link
Member

pngwn commented Dec 15, 2023

Thanks for those changes, will take a look!

Copy link
Member

@pngwn pngwn left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me. Thanks @hannahblair!

@hannahblair hannahblair merged commit 73268ee into main Dec 19, 2023
21 of 22 checks passed
@hannahblair hannahblair deleted the improve-source-selection branch December 19, 2023 19:24
@pngwn pngwn mentioned this pull request Dec 19, 2023
whitphx pushed a commit that referenced this pull request Dec 20, 2023
* Add new source option styling for pasting from clipboard
Use SourceSelect in Image component

* prevent device selection cut off
tweak source selection ux

* Check for dupe sources in source selection
Set sources[0] to active_source in Image

* tweaks

* tweak

* add image interaction test

* more tests

* improve light/dark mode color contrast

* add changeset

* remove unused prop

* add no device found placeholder
change T<sources> -> T<source_types>

* style tweak

* allow pasting on click + add e2e test

* fix e2e tests

* formatting

* add timeout to e2e test

* tweak

* tweak test

* change `getByLabel` to `getByText`

* value tweak

* logic tweak

* test

* formatting

---------

Co-authored-by: gradio-pr-bot <gradio-pr-bot@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

How to use video trim function in Blocks Webcam selection UI gets cut off
6 participants