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

Fix slider margin #5392

Merged
merged 4 commits into from
Oct 23, 2024
Merged

Fix slider margin #5392

merged 4 commits into from
Oct 23, 2024

Conversation

mcslayer
Copy link
Contributor

@mcslayer mcslayer commented Oct 21, 2024

Done

Based on the comment of @lyubomir-popov, it seems we need to reduce the top and bottom margins by half the height of the track.
I'm not sure if the calculations needed to be enclosed in parentheses, but I did so for better code readability.

Fixes #5391

QA

Check if PR is ready for release

If this PR contains Vanilla SCSS code changes, it should contain the following changes to make sure it's ready for the release:

  • PR should have one of the following labels to automatically categorise it in release notes:
    • Feature 🎁, Breaking Change 💣, Bug 🐛, Documentation 📝, Maintenance 🔨.
  • Vanilla version in package.json should be updated relative to the most recent release, following semver convention:
    • if CSS class names are not changed it can be bugfix release (x.x.X)
    • if CSS class names are changed/added/removed it should be minor version (x.X.0)
    • see the wiki for more details
  • Any changes to component class names (new patterns, variants, removed or added features) should be listed on the what's new page.

@webteam-app
Copy link

mcslayer is not a collaborator of the repo

@jmuzina
Copy link
Member

jmuzina commented Oct 21, 2024

I think it looks good, @lyubomir-popov can you give a design review here?

@bartaz
Copy link
Member

bartaz commented Oct 22, 2024

There still seems to be a bit of baseline drift if text in paragraphs is added between sliders. You can see that the middle paragraph moves onto the baseline a bit, and the one on the bottom even more.

image

The baseline alignment is quite tricky, especially in such old components like slider, so no worries if you can't figure that one out @mcslayer. We can have a look ourselves as well.

scss/_base_forms-range.scss Outdated Show resolved Hide resolved
@bartaz
Copy link
Member

bartaz commented Oct 22, 2024

The math seems to be correct. 3px height + 2* 6.5px margins add up to 16px which should be exactly right.

image

Not sure where the drift comes from. Maybe rounding and/or subpixes issues. Because all of those px values are calculated from fractions of rem values, so maybe rounding kicks in and moves things by a pixel somewhere.

@mcslayer
Copy link
Contributor Author

mcslayer commented Oct 22, 2024

Yes, I’ve double-checked the calculation, and it is correct. Interestingly, if I adjust the margin to 6.6px 0 6.4px, it looks perfect!

@mcslayer
Copy link
Contributor Author

We can apply vertical-align: bottom to input[type=range], though I am unsure if this solution fully meets your requirements. If this approach is acceptable, I can proceed with pushing my changes to this PR.

Screenshot 2024-10-22 at 15 52 01

@jmuzina
Copy link
Member

jmuzina commented Oct 22, 2024

I think there is something Chromium-specific (or possibly Chrome on Mac-specific) happening here. I can't replicate the issue on Firefox, but I can on chrome-based browers.

Firefox:
Screenshot 2024-10-22 at 11 11 10 AM

Brave (chrome-based):
Screenshot 2024-10-22 at 11 12 06 AM

@bartaz
Copy link
Member

bartaz commented Oct 22, 2024

That looks promising. I think you can push the code so that we can see it in the demo server. Thanks for exploring!

@mcslayer mcslayer force-pushed the slider-fix branch 2 times, most recently from c1c889d to 6d509ad Compare October 22, 2024 16:18
@mcslayer
Copy link
Contributor Author

Unfortunately, I found a problem with Firefox where the slider height was calculated incorrectly because Firefox includes the thumb in the input height by default. I figured out how to fix it, and I've applied the fix. I've attached screenshots showing Safari, Chrome, and Firefox (before and after the fix) for comparison.

Before:
Screenshot 2024-10-22 at 19 09 40

After:
Screenshot 2024-10-22 at 19 10 21

Copy link
Member

@jmuzina jmuzina left a comment

Choose a reason for hiding this comment

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

Demo updated to include latest changes

Looks good to me - tested on firefox, chrome, and safari and there are no longer spacing differences between them and the margin is fixed on all of them.

@bartaz Have a look and let me know if I've missed something 👀

@jmuzina jmuzina added Review: QA +1 Review: Percy +1 and removed Review: QA -1 Review: Percy needed This PR needs a review of Percy for visual regressions labels Oct 22, 2024
Copy link
Member

@bartaz bartaz left a comment

Choose a reason for hiding this comment

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

Thanks for chasing that one down @mcslayer

@bartaz bartaz merged commit df1ec03 into canonical:main Oct 23, 2024
10 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Sliders off baseline grid
4 participants