Skip to content

FEATURE: Nested components#32

Open
dkaoster wants to merge 2 commits into
accurat:masterfrom
freedomofpress:nested-components
Open

FEATURE: Nested components#32
dkaoster wants to merge 2 commits into
accurat:masterfrom
freedomofpress:nested-components

Conversation

@dkaoster
Copy link
Copy Markdown

@dkaoster dkaoster commented Jul 6, 2023

Closes #31

TYPE OF CHANGE

After some discussion and testing on our end, we've decided to go with this approach to solve the issues outlined in #31. Specifically, we modified this repo to allow for a nested hierarchy when creating elements based on data.

PROBLEM

Sometimes, we would like for our datasets to generate svg elements more than a single node. For instance, we may want to wrap a rect with an anchor, or include text with a shape.

SOLUTION

The solution is to allow components to be nested. That way, we can use something like

<AnimatedDataset
  dataset={['Hello World', 'Goodbye World']}
  tag="a"
  attrs={{ href: "#test" }}
  keyFn={t => t}
  disableAnimation
>
  <AnimatedDataset
    tag="text"
    attrs={{ text: t => t }}
    keyFn={t => t}
    disableAnimation
  />
</AnimatedDataset>

NOTES

This should be fully backward compatible with the current API and introduce this feature with no breaking changes.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Allow link elements in lieu of click handlers

1 participant