feat(useMeasure): support custom measurers in order to support border-box and others
What is the current behavior, and the steps to reproduce the issue?
Current implementation of the useMeasure hook calculates the element bounds based on content-box model only.
It is a little unexpected behavior when the project and all the layout is based on border-box model and trying to calculate measures of the element has paddings.
Thus, current hook ignores paddings calculating element's width and height.
What is the expected behavior?
Giving the possibility to define custom measure matcher model to take the values needed.
How does this PR fix the problem?
By adding the additional optional function argument receives the ResizeObserverEntry value and returns the new measures should be applied or null. If function returns null, the default behavior is applied and content-box measures will be returned.
Checklist
- [x] Have you read contribution guideline?
- [x] Have you added an explanation of what your changes do and why you'd like us to include them?
- [x] Is there an existing issue for this PR?
- https://github.com/react-hookz/web/issues/1548
- [x] Have the files been linted and formatted?
- [x] Have the docs been updated to match the changes in the PR?
- [x] Have the tests been updated to match the changes in the PR?
- [x] Have you run the tests locally to confirm they pass?
Thanks for contribution!
Codecov Report
All modified and coverable lines are covered by tests :white_check_mark:
Project coverage is 97.80%. Comparing base (
95de481) to head (34b5df0). Report is 51 commits behind head on master.
Additional details and impacted files
@@ Coverage Diff @@
## master #1603 +/- ##
==========================================
+ Coverage 97.60% 97.80% +0.19%
==========================================
Files 63 63
Lines 1714 1868 +154
Branches 481 483 +2
==========================================
+ Hits 1673 1827 +154
Misses 39 39
Partials 2 2
:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.
:rocket: New features to boost your workflow:
- :package: JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.