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
Baseline border fix #5074
base: main
Are you sure you want to change the base?
Baseline border fix #5074
Conversation
Adjusted the p-nudge for default text to align better to the baseline grid. Also other small fixes to align components that depend on p-nudge better to the baseline grid.
@bartaz I created a PR for the border calculations based on CSS variables as discussed in the other PR, just so we don't forget about this. |
@@ -2,10 +2,20 @@ | |||
@import 'settings_colors'; | |||
|
|||
// Global placeholder settings | |||
$input-border-thickness: 1.5px; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for going extra mile and implementing it as a CSS variable.
But for simplicity and consistency with color variables, I think we can keep the $input-border-thickness
SCSS variable, just make it use the value of CSS variable.
So in places where we use it it won't need to change.
To do that I think you just need to define its value as CSS variable:
$input-border-thickness: var(--input-border-thickness);
And this should be it. All places that currently use $input-border-thickness
variable will use it as CSS var automatically without need to change their code to explicitly do that.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That makes sense! I'll look into changing that this week. :)
scss/_settings_placeholders.scss
Outdated
// If we use $input-border-thickness = 1.5px in the calculation and the user is on a low pixel density screen | ||
// then the border is rendered as 1px, but we still eg. subtract 1.5px from the padding which will throw off the baseline grid alignment. | ||
// So we have to check if the users screen is capable of displaying 0.5px steps at runtime. This is only possible with CSS variables. | ||
--input-border-thickness: 1.5px; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Small suggestion, to avoid any future name clashes we namespace our CSS variables with --vf
, so in this case --vf-input-border-thickness
(I guess maybe we can have a better name later when we properly define this as a token).
There is another issue I've noticed (it's why the tests are failing). By adding media query to settings we are breaking this rule, as there is CSS (media query definition of the border width value) in settings. I'll have to think how best to avoid it. I guess we would need to define a default value of |
I reverted the variables back to the scss variable and renamed the css variable. |
Done
On low pixel density devices a 1.5px border would computed as 1px.
If we use $input-border-thickness = 1.5px in the calculation and the user is on a low pixel density screen then the border is rendered as 1px, but we still eg. subtract 1.5px from the padding which will throw off the baseline grid alignment.
So we have to check if the users screen is capable of displaying 0.5px steps at runtime. This is only possible with CSS variables.
This PR uses a CSS variable for input-border-thickness and checks the devices pixelRatio to either give it a 1.5px border or a 1px border.
Additionally the calculation for taking the border width into account was moved from $input-vertical-padding to the components themselves because sometime the border has to be removed twice (button) or only once (input).
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:
Feature 🎁
,Breaking Change 💣
,Bug 🐛
,Documentation 📝
,Maintenance 🔨
.package.json
should be updated relative to the most recent release, following semver convention:Screenshots
Before
After