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

Redesign gr.Button() #9167

Merged
merged 42 commits into from
Aug 30, 2024
Merged

Redesign gr.Button() #9167

merged 42 commits into from
Aug 30, 2024

Conversation

hannahblair
Copy link
Collaborator

@hannahblair hannahblair commented Aug 21, 2024

Description

Some notes/highlights:

  • Buttons translateY by 0.5px on hover. You could argue it could translateY by -0.5px but I noticed in a demo that the button can get slightly cut off when moving down.
  • Removed all drop shadows and gradients
  • Decreased overall radius size from lg to md in large buttons, and from sm to xs in small buttons

Also adds an Origin theme which retains all the old styling.

Demo

import gradio as gr

icon = "https://cdn.icon-icons.com/icons2/2620/PNG/512/among_us_player_red_icon_156942.png"
with gr.Blocks() as demo: # also try with gr.Blocks(theme=gr.themes.Origin()) as demo:

   gr.Button(variant="primary")
   gr.Button(variant="secondary")
   gr.Button(variant="stop")

   gr.Button(variant="primary", size="sm")
   gr.Button(variant="secondary", size="sm")
   gr.Button(variant="stop", size="sm")

   gr.Button(variant="primary", icon=icon)
   gr.Button(variant="secondary", icon=icon)
   gr.Button(variant="stop", icon=icon)


   gr.Button(variant="primary", size="sm", icon=icon)
   gr.Button(variant="secondary", size="sm", icon=icon)
   gr.Button(variant="stop", size="sm", icon=icon)

demo.launch()

Closes: #8789

🎯 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

*add origin theme class with old button styling
@hannahblair hannahblair changed the title Redesign gr.Button Redesign gr.Buttons Aug 21, 2024
@hannahblair hannahblair changed the base branch from main to 5.0-dev August 21, 2024 23:51
@gradio-pr-bot
Copy link
Collaborator

gradio-pr-bot commented Aug 21, 2024

🪼 branch checks and previews

Name Status URL
Spaces ready! Spaces preview
Website ready! Website preview
Storybook ready! Storybook preview
🦄 Changes detected! Details

Install Gradio from this PR

pip install https://gradio-pypi-previews.s3.amazonaws.com/4c04dc1310df8d29a243d299e52b776594d56e10/gradio-4.42.0-py3-none-any.whl

Install Gradio Python Client from this PR

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

Install Gradio JS Client from this PR

npm install https://gradio-npm-previews.s3.amazonaws.com/4c04dc1310df8d29a243d299e52b776594d56e10/gradio-client-1.5.1.tgz

@gradio-pr-bot
Copy link
Collaborator

gradio-pr-bot commented Aug 21, 2024

🦄 change detected

This Pull Request includes changes to the following packages.

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

With the following changelog entry.

Redesign gr.Button()

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 Redesign gr.Buttons Redesign gr.Button() Aug 22, 2024
@hannahblair
Copy link
Collaborator Author

According to Claude, the brightest possible orange we can have with white text while meeting minimum colour contrast standards is #D35400 which looks like this:

Screenshot 2024-08-22 at 22 30 06

@pngwn
Copy link
Member

pngwn commented Aug 22, 2024

i like it, burnished orange

@hannahblair hannahblair marked this pull request as ready for review August 29, 2024 14:07
@abidlabs
Copy link
Member

Huge fan of the changes @hannahblair! Everything looks good except that the stop button with light mode looks very faded out. I'd suggest darken the red & using a white font:

image

similar to the primary button:

image

@hannahblair
Copy link
Collaborator Author

@abidlabs you're right. I didn't want to stray too far from our current cancel buttons shade originally but it just looks much better dark. wdyt of this red?

Screenshot 2024-08-30 at 01 27 25

@abidlabs
Copy link
Member

Looks perfect!

@hannahblair hannahblair merged commit e9e737e into 5.0-dev Aug 30, 2024
20 of 21 checks passed
@hannahblair hannahblair deleted the v5-buttons branch August 30, 2024 20:17
Copy link
Member

@abidlabs abidlabs left a comment

Choose a reason for hiding this comment

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

Nice, tested the buttons again and they look great in both dark mode and light mode!

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