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

Implement left and right click in Gallery component and show implicit images in Gallery grid #4995

Merged
merged 15 commits into from
Jul 25, 2023

Conversation

hannahblair
Copy link
Collaborator

@hannahblair hannahblair commented Jul 21, 2023

Description

This PR adds improvements to Gallery as part of the component cleanup.

  • A user can now click on the left or right hand side of a preview image to scroll between images
  • When the number of images imported into the Gallery component is greater than the specified cells, (ie. the explicit cells) the implicit cells (the extra cells created by CSS grid) are now visible as well as the explicit cells.

Closes:
#4585
#4497

Demo code (create a dir /images containing over 4 images to test the hidden images fix):

import pathlib
import gradio as gr

paths = [path.as_posix() for path in sorted(pathlib.Path('images').glob('*'))]
with gr.Blocks() as demo:
    gr.Gallery(value=paths).style(columns=2,
                                  rows=2,
                                  height="400px",
                                  object_fit='contain')
demo.queue().launch()

🎯 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 & Changelog

  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

  3. Unless the pull request is labeled with the "no-changelog-update" label by a maintainer of the repo, all pull requests must update the changelog located in CHANGELOG.md:

Please add a brief summary of the change to the Upcoming Release section of the CHANGELOG.md file and include
a link to the PR (formatted in markdown) and a link to your github profile (if you like). For example, "* Added a cool new feature by [@myusername](link-to-your-github-profile) in [PR 11111](https://github.com/gradio-app/gradio/pull/11111)".

@vercel
Copy link

vercel bot commented Jul 21, 2023

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Updated (UTC)
gradio ✅ Ready (Inspect) Visit Preview Jul 25, 2023 0:37am

@hannahblair hannahblair changed the title Improve gr.Gallery Improvements to gr.Gallery component Jul 21, 2023
@gradio-pr-bot
Copy link
Collaborator

gradio-pr-bot commented Jul 21, 2023

🎉 Chromatic build completed!

There are 0 visual changes to review.
There are 0 failed tests to fix.

@gradio-pr-bot
Copy link
Collaborator

gradio-pr-bot commented Jul 21, 2023

All the demos for this PR have been deployed at https://huggingface.co/spaces/gradio-pr-deploys/pr-4995-all-demos


You can install the changes in this PR by running:

pip install https://gradio-builds.s3.amazonaws.com/41c83070b01632084e7d29123048a96c1e261407/gradio-3.38.0-py3-none-any.whl

@gradio-pr-bot
Copy link
Collaborator

gradio-pr-bot commented Jul 21, 2023

🦄 change detected

This Pull Request includes changes to the following packages.

Package Version
@gradio/app minor
@gradio/gallery minor
gradio minor
  • Maintainers can select this checkbox to manually select packages to update.

With the following changelog entry.

Implement left and right click in Gallery component and show implicit images in Gallery grid

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 hannahblair changed the title Improvements to gr.Gallery component Implement left and right click in Gallery component and show implicit images in Gallery grid Jul 24, 2023
@hannahblair hannahblair self-assigned this Jul 24, 2023
Copy link
Collaborator

@freddyaboulton freddyaboulton left a comment

Choose a reason for hiding this comment

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

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.

4 participants