-
-
Notifications
You must be signed in to change notification settings - Fork 112
Test nested connections and add nested connection #91
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
Test nested connections and add nested connection #91
Conversation
PR review comment suggested that until override via props is necessary we implement only the necessary context
Instead of modifyPlotProps we have a more general supplyPlotProps. If a supplyPlotProps is present it is run. Most implementations of supplyPlotProps will run `unpackPlotProps` first and then alter plotProps as necessary. However, this enables us to now alter `props` and `context` _before_ running unpackPlotProps. This will allows us to "fix" the problem of nested layout fields within a trace context. See #58 (comment) for background.
a5f8d5e
to
04c83ef
Compare
src/lib/connectToContainer.js
Outdated
WrappedComponent.modifyPlotProps(props, context, plotProps); | ||
static supplyPlotProps(props, context) { | ||
if (supplyPlotProps) { | ||
return supplyPlotProps(props, context); |
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.
not blocking by any means, this will work fine, but for symmetry and to avoid multiple things with the bare name supplyPlotProps
I might have written this as
if (config.supplyPlotProps) {
return config.supplyPlotProps(props, context);
}
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.
True, that might be an easier read. I'll make the change
src/DefaultEditor.js
Outdated
<BoxGap | ||
label={_('Box Padding')} | ||
attr="boxgroupgap" | ||
showArrows={false} |
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.
Do you need this? It's already a NumericNoArrows
component...
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.
Nope! Forgot to take it out
src/DefaultEditor.js
Outdated
@@ -145,6 +147,21 @@ class DefaultEditor extends Component { | |||
<ColorPicker label={_('Border Color')} attr="marker.line.color" /> | |||
</TraceMarkerSection> | |||
|
|||
<Section name={_('Size and Spacing')}> | |||
<BoxGap label={_('Bar Width')} attr="bargap" /> |
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.
Hmm, what do we call this component? I feel like its name should indicate that it's numeric and that the attr
you specify is in layout
, not in a trace. But it's not specific to boxes or gaps.
Also, the label 'Bar Width' isn't quite right, is it? ie an increased bargap
decreases the width, right?
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.
TraceLayoutNumericSansArrows.
I copied the workspace descriptions but looks like it is doing a transformation on the input. Maybe (1-x)*100. I'll implement this transform (and the reverse onUpdate) in this PR and tag you on the commit.
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.
With the transformation it will again be a hyper specific component so perhaps BoxGap
is more applicable.
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.
Though BoxWidth
is probably clearer
@alexcjohnson okay implemented your suggestions. Also cb1a95a reintroduces modifyPlotProps. More info in the commit message. |
We now have modifyPlotProps and supplyPlotProps. We have need of both and trying to overload any one of them for both behaviours results in complicated code.
fad2cb5
to
1c137f3
Compare
src/components/containers/Section.js
Outdated
@@ -52,6 +52,9 @@ export default class Section extends Component { | |||
} else if (isAttr) { | |||
if (child.type.supplyPlotProps) { | |||
plotProps = child.type.supplyPlotProps(child.props, context); | |||
if (child.type.modifyPlotProps) { | |||
child.type.modifyPlotProps(child.props, context, plotProps); | |||
} | |||
} else { | |||
plotProps = unpackPlotProps(child.props, context); |
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 you see a use for this unpack
, then wouldn't the if (child.type.modifyPlotProps)
block possibly be relevant in that case too? ie should it be moved outside that if/else
block, so the existences of supply
and modify
are independent?
src/shame.js
Outdated
}); | ||
}; | ||
|
||
export const BoxWidth = connectLayoutToPlot( |
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.
Perhaps FractionalWidth
? Or LayoutWidthFraction
? Violin is going to use this too.
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.
Yep works for me 👍
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.
something like 1bebf70 ?
src/shame.js
Outdated
} | ||
}; | ||
|
||
plotProps.max = 100; |
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.
right now all of these have min: 0, max: 1
, so setting just max = 100
works. But I'd feel more comfortable about future-proofing if we at least explicitly supply min = 0
, and maybe even better do the same (1-v) * 100
transform (which would actually switch min / max
)
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.
good point will do.
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.
1bebf70
to
94a27c1
Compare
nice, lets go! 💃 |
@alexcjohnson This PR removes the
modifyPlotProps
system in favour ofsupplyPlotProps
. It also introducesBoxGap
- a component that talks to Layout though nested within a trace context.supplyPlotProps
is more general in that a component has the responsibility of returning plotProps rather than just modifying them. This adds a line of boilerplate to all components requiring additional behaviourconst plotProps = unpackPlotProps(props, context);
but the advantage is that there is more control.For example
<BoxGap>
uses this functionality to forcibly assign fullLayout to fullContainer which gets around the problem of having a layoutConnected component inside a<Section>
inside a traceConnected component.The problem is that
<Section>
can only see the trace context so it handsunpackPlotProps
a fullContainer that is fullData not fullLayout. The Layout connected component nested within does not recompute plotProps as we do not want to compute plotProps twice for every component in a<Section>
. The Layout connected component is therefore broken. Now<BoxGap>
supplies a layout fullContainer and we have a workaround.