-
Notifications
You must be signed in to change notification settings - Fork 38
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
Return numeric values in precomputeValues #82
Comments
Hey Travis, very much interested in supporting relative units but have not found the right approach just yet. Curious to see what direction you've taken things and see what is working. |
Awesome! Yeah, for sure! I think it should be a simple tweak. Here is a working Codesandbox to see an example. |
My relative units workaround is based on 62.5% font-size on html trick, with that, just dividing numeric values of font-size and line-height by 10 do the job. |
@michaeltaranto , @souporserious I have found a solution, which also allows CSS-heavy implementation, yet I would have to dive into details, because I have faced two serious browser limitations:
There are two aspects of workaround:
Example: --pro-rata-cap-height-trim:
calc(
(
var(--pro-rata-precomputed-cap-height-trim-factors)
-
(
(
(
var(--pro-rata-precomputed-line-height-scale) /* 1.362 */
*
var(--pro-rata-font-size)
)
-
var(--pro-rata-line-height) /* Dynamic numeric, latter converted to rem */
)
/
2
/
var(--pro-rata-font-size) /* Dynamic numeric, latter converted to rem */
)
)
*
(-1) /* you may use (-1em) here and only here, if you want, actually */
);
}
(ascentScale - capHeightScale + lineGapScale) inlined to offset some portion of calculations into compile-time.
/* utility class for font-size */
.pro-rata-cap-size-2 {
--pro-rata-cap-size: 0.5; /* numeric, not rem */
--pro-rata-font-size:
calc(
var(--pro-rata-cap-size)
/ var(--pro-rata-cap-height-scale)
);
font-size: calc(var(--pro-rata-font-size) * 1rem);
} Illustrative draft implementation is visible here: https://github.com/andriytyurnikov/andriytyurnikov.github.io/blob/main/src/pro-rata.css, |
Hello again 😊 I've been using Capsize recently with REM units and ThreeJS which relies on World units and was wondering if you'd be interested in simplifying
precomputeValues
to numeric values to better serve these use cases? This would be a breaking change so totally understand if you'd rather not change the API this much, but I think something along the lines of this would help:So you'd get numeric values back that are more flexible to work with and instead of using
em
units for the trim values, I propose multiplying the value by the font size so it can be used with libraries like ThreeJS where relative values don't exist.Right now I simply parse and round the incoming values myself which is working well:
Happy to work on a PR for this if it sounds like something you'd want to add 🙂
The text was updated successfully, but these errors were encountered: