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
calc()
it up — use Sass calculations more
#39606
base: main
Are you sure you want to change the base?
Conversation
Replace Sass number operators with calculations for math when possible.
Without reviewing in depth yet, I'll just add that this is the way and I'm glad you proposed it. Unsure what version we'll do this in just yet. Thoughts on v5.4 @julien-deramond? |
@@ -126,7 +126,7 @@ | |||
|
|||
> .btn:not(:first-child), | |||
> .btn-group:not(:first-child) { | |||
margin-top: calc(#{$btn-border-width} * -1); // stylelint-disable-line function-disallowed-list |
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.
You'll have to interpolate the Sass variables across all of these calc()
functions.
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.
oof... it looks like that is a requirement for node-sass in the failed CI, which uses LibSass (both deprecated in favor of Dart Sass).
See https://sass-lang.com/documentation/syntax/special-functions/#element-progid-and-expression
LibSass, Ruby Sass, and versions of Dart Sass prior to 1.40.0 parse calc() as special syntactic function like element().
Dart Sass versions 1.40.0 and later parse calc() as a calculation.
Does Bootstrap support LibSass builds in v5? I know that it was internally dropped but I mean for when people import and build the Sass themselves.
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.
Yeah, v5 still supports it. We'll drop it in v6 I imagine.
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.
This would probably have to hold off until then, because the calc simplification only happens when the variables are not interpolated. Switching everything to calc would probably make the output too large in most cases.
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.
We could actually consider dropping LibSass in v5.4 or like a special v5.5. We'll be moving onto v6 dev at some point but TBD on actual timeline.
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.
I agree in terms of realistic timeline that we could consider dropping LibSass in v5.4/v5.5. I hope, however, that it wouldn't trigger a semver comments war.
Description
+
,-
, and*
math operators with Sasscalc()
ulationscalc()
from the disallowed functions in stylelintwith-value()
functioncalc()
with addition or subtraction with potentiallynull
or unitless values like zeroadd()
andsubtract()
but it is more explicit and the output css is slightly more optimizedMotivation & Context
I described the full motivation in #39507.
Also, a nice side-effect here is that the code is slightly less tedious to convert to use css variables.
Type of changes
Checklist
npm run lint
)Live previews
Related issues
#39507