-
Notifications
You must be signed in to change notification settings - Fork 272
feat: add Wrapper support and bounding box for dynamic width/height #215
Conversation
Codecov Report
@@ Coverage Diff @@
## master #215 +/- ##
==========================================
+ Coverage 99.92% 99.93% +<.01%
==========================================
Files 130 157 +27
Lines 1406 1602 +196
Branches 354 419 +65
==========================================
+ Hits 1405 1601 +196
Partials 1 1
Continue to review full report at Codecov.
|
Deploy preview for superset-ui ready! Built with commit e98f670 |
onRenderSuccess={onRenderSuccess} | ||
onRenderFailure={onRenderFailure} | ||
/> | ||
<Wrapper width={width} height={height}> |
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.
width
and height
are invalid props for React.Fragment
right? Ideally we don't get propType
errors in that case 🤔
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.
const heightInfo = parseLength(height); | ||
|
||
const style = { | ||
height: heightInfo.isDynamic ? '100%' : heightInfo.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.
could this be simplified so parseLength
sets value
to 100%
if isDynamic
is true?
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.
if not, below we use multiplier
, why not use multiplier
here instead of 100%
or is this slightly different?
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.
Great idea.
) | ||
} | ||
</ParentSize> | ||
// bounding box will ensure that when |
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.
could probably consolidate to fewer lines here? I also wonder if this could be moved to the BoundingBox
selector to give more context to the Fragment
vs div
logic?
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.
Comments moved as suggested.
🏆 Enhancements
1. Add bounding box for dynamic
width
/height
calculationWhen either
width
orheight
is already known, such aswidth="100%" height={500}
.Default
<ParentSize>
behavior will set the container style to{width: '100%', height: '100%'}
, which may exceed the knownwidth
orheight
values, resulting in undesired blank space on the page. This PR add another<div>
to wrap it (only when necessary). If bothwidth
andheight
are dynamic then no bounding box will be added.e.g. when want 100% width and 500px height.
Alternative
Consider including these functionalities in the
@vx/responsive
rewrite.2. Add
Wrapper
prop forSuperChart
Problem
Inspired by use case in
dataportal
.There is a situation when a wrapper needs to be added to fix
z-index
issue such as tooltip.This won't work because the wrapper will mess with the dynamic width/height calculation.
If we want to insert something in between
SuperChart
andChartPlugin
to avoid messing with dynamicwidth
/height
, you either have toA. Do not use the built-in
SuperChart
way of determining autowidth
andheight
. Use your own way of computing dynamicwidth
&height
, which is pretty much re-implementing a lot of logic inSuperChart
.B. Modify the
ChartPlugin
to add the wrapper. Sounds like an overkill.Both options are undesirable extra work.
Solution
With the changes in this PR.
🏠 Internal
chart
package is 100% again.