-
Notifications
You must be signed in to change notification settings - Fork 88
Conversation
@chrisbolin this is so awesome! I love the simplicity of this approach. I couple thoughts:
Even though it would be a breaking change, the architecture is making me think that something more like |
@boygirl I love the idea of simplifying the API. Instead of <VictoryContainer behaviors={["zoom", "voronoi"]} zoomDomain={{x: [0, 100]}}.../> we could do... <VictoryContainer
voronoi
zoom={{
zoomDomain: {x: [0, 100]},
}}
/>
{
zoomDomain,
minimumZoom,
onDomainChange,
clipContainerComponent,
allowZoom,
dimension,
} All the same defaults would still apply, so What do you think? |
Alright, I decided to take a slightly different path from what I mentioned up there. This uses a simple For example, we can eliminate VictoryVoronoiZoomContainer, as uses can create it with just const VictoryVoronoiZoomContainer = createContainer("zoom", "voronoi”); The Container behaviors can still be mixed in with the custom user containers with I wanted to abstract this further into a component with a Currently I still have to add exports to |
@chrisbolin I like the simplicity of this approach a lot. A few things to clarify. This might just come down to documentation
|
I think we can make all that more clear in the code. I'll whip something up
|
Alright, I added some helpful warnings for the two cases you mentioned. |
As for order-of-behaviors... I found an annoying quirk. Surprisingly, it has nothing to do with events, though! It has to do with clipping in
This is caused by how I implemented getChildren(props) {
const children = instanceA.getChildren.call(this, props);
return instanceB.getChildren.call(this, {...props, children});
} A is called before B, and hence why |
…yVoronoiZoomContainer; demo createContainer
3d1b472
to
185b60c
Compare
@boygirl I pushed some changes...
I'll merge in master now and go from there. |
63bb743
to
185b60c
Compare
Introduces a
combineContainerMixins
function that (wait for it) combines containers. This required a 2-line change to each of the containers, so that they export both the container (as before) and a mixin function that lets the container inherit from any class.As an example, the
VictoryVoronoiZoomContainer
is included in this PR. It's entire code isAgain, the
*ContainerMixin
are very similar to theVictory*Container
classes; all of the magic happens incombineContainerMixins(A, B)
. This function combines the classes; the interesting bits are forgetChildren
anddefaultEvents
.getChildren
will call A'sgetChildren()
and insert the resulting children intoprops
calling B'sgetChildren()
.defaultEvents
is more complex. It attempts to resolve any conflicts between A and B'sdefaultEvents
by concatenating the produce mutations.The results are pretty fun...
Voronoi + Zoom Containers
Voronoi + Brush Containers
Voronoi + Selection Containers
Zoom + Selection Containers
(see WIP before for a note on this)
Work in progress. Still need to figure out...
VictoryVoronoiZoomContainer
rather than make people build their own? Building is easy (2 lines of code) but it's nice to have an example.mixin
ok?(also includes individual page titles for the demos, because I needed that :) )