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 UX of non-interactive slider #7814

Merged
merged 4 commits into from Mar 25, 2024
Merged

Improve UX of non-interactive slider #7814

merged 4 commits into from Mar 25, 2024

Conversation

Pythongor
Copy link
Contributor

Description

This pull request makes the slider look more logical and compliant with UX standards. Now in the inactive state the slider looks more subdued and the cursor on the hover is displayed correctly.

Closes: #7813

@gradio-pr-bot
Copy link
Contributor

gradio-pr-bot commented Mar 24, 2024

🪼 branch checks and previews

Name Status URL
Spaces ready! Spaces preview
Website building...
Storybook ready! Storybook preview
🦄 Changes detecting...

Install Gradio from this PR

pip install https://gradio-builds.s3.amazonaws.com/219f2f4a5af408ed3733c3841670242944a79d64/gradio-4.22.0-py3-none-any.whl

Install Gradio Python Client from this PR

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

@Pythongor Pythongor marked this pull request as ready for review March 24, 2024 18:03
@shubhamofbce
Copy link
Contributor

@Pythongor Can you please add a comparison screenshot after the fix here, so we can take a look without running the code.

@gradio-pr-bot
Copy link
Contributor

gradio-pr-bot commented Mar 25, 2024

🦄 change detected

This Pull Request includes changes to the following packages.

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

With the following changelog entry.

Improve UX of non-interactive slider

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.

@pngwn
Copy link
Member

pngwn commented Mar 25, 2024

Looks great!

Screenshot 2024-03-25 at 14 34 26

@pngwn pngwn changed the title Fix disabled slider appearance Improve UX of non-interactive slider Mar 25, 2024
@pngwn
Copy link
Member

pngwn commented Mar 25, 2024

Fixed the stories and also fixed a small bug that mean the background size wasn't being coloured in when the max was not set.

Comment on lines +64 to +67
const dividend = Number(rangeInput.value) - Number(rangeInput.min);
const divisor = Number(rangeInput.max) - Number(rangeInput.min);
const h = divisor === 0 ? 0 : dividend / divisor;
rangeInput.style.backgroundSize = h * 100 + "% 100%";
Copy link
Member

Choose a reason for hiding this comment

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

Just added some checks so we don't get infinity.

@@ -24,7 +24,7 @@
export let scale: number | null = null;
export let min_width: number | undefined = undefined;
export let minimum: number;
export let maximum: number;
export let maximum = 100;
Copy link
Member

Choose a reason for hiding this comment

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

Default for browser is 100 anyway, so just set this explicitly, to avoid undefined values.

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 great. Thanks for tackling this @Pythongor!

@pngwn pngwn enabled auto-merge (squash) March 25, 2024 15:07
@pngwn pngwn merged commit f7df92f into gradio-app:main Mar 25, 2024
8 checks passed
@pngwn pngwn mentioned this pull request Mar 23, 2024
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.

Disabled slider is visually no different from enabled one
4 participants