canonical / vanilla-framework

From community websites to web applications, this CSS framework will help you achieve a consistent look and feel.
https://vanillaframework.io
GNU Lesser General Public License v3.0
845 stars 167 forks source link

Fix slider margin #5392

Closed mcslayer closed 1 month ago

mcslayer commented 1 month ago

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:

webteam-app commented 1 month ago

mcslayer is not a collaborator of the repo

jmuzina commented 1 month ago

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

bartaz commented 1 month ago

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.

bartaz commented 1 month ago

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 commented 1 month ago

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 commented 1 month ago

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 commented 1 month ago

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 commented 1 month ago

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

mcslayer commented 1 month ago

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