-
-
Notifications
You must be signed in to change notification settings - Fork 33
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 calc function #506
Fix calc function #506
Conversation
The latest updates on your projects. Learn more about Vercel for Git ↗︎ 1 Skipped Deployment
|
@@ -190,7 +189,7 @@ module Length = struct | |||
| `add of calc_value * calc_value | |||
| `sub of calc_value * calc_value | |||
| `mult of calc_value * calc_value | |||
| `div of calc_value * float | |||
| `div of calc_value * calc_value |
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.
heads up, this doesn't seem right. You can't divide by something that isn't a number.
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.
Ok, it's a bit more complex than this:
Current implementations require that for the * and / operators, one of the operands has to be unitless. For /, the right operand must be unitless. For example font-size: calc(1.25rem / 1.25) is valid but font-size: calc(1.25rem / 125%) is invalid.
https://developer.mozilla.org/en-US/docs/Web/CSS/calc#rules_and_best_practices_while_using_calc
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 the formal grammar is a bit misleading.
<calc-product> = <calc-value> [ [ '*' | '/' ] <calc-value>]*
maybe we can have <unitless-calc-value>
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.
maybe later, i think float should be sufficient for now
@@ -146,5 +146,5 @@ If this test fail means that the module is not in sync with the ppx | |||
CSS.unsafe({js|columnRuleColor|js}, {js|#000000FF|js}); | |||
CSS.unsafe({js|columnRuleColor|js}, {js|rebeccapurple|js}); | |||
|
|||
CSS.color(`rgba((0, 0, 0, `num(1.)))); | |||
CSS.color(`rgba((0, 0, 0, `calc(`num(1.))))); |
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 don't think this is correct, calc shouldn't leak here
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.
So calc(1) should evaluate to 1?
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.
Nevermind, I read the diff wrong. I thought calc wasn't on the value.
No description provided.