Skip to content
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

Alternative node template syntax #25

Open
KjetilHaaheim opened this issue May 13, 2021 · 3 comments
Open

Alternative node template syntax #25

KjetilHaaheim opened this issue May 13, 2021 · 3 comments

Comments

@KjetilHaaheim
Copy link

Component node templates are currently based on nodeComponent property in the dataset. This proposition is to incorporate one or both of the following suggestions:

  1. Node template by slot (#default or #named). This can prevent some prop drilling.
<flowy :nodes="items">
  <template v-slot:default="{ node }">
    <flow-item v-bind="node" />
  </template>
</flowy>
  1. Component as data property:
<flowy :nodes="items" :node-component='$options.FlowItem' />

Both suggestions are compatible with multiple block types in same collection if neccessary.

@remcoplasmeyer
Copy link
Owner

Either solution will work for me, node-component makes a bit more sense to myself

I was thinking of combining this with https://v3.vuejs.org/guide/composition-api-provide-inject.html on the switch to vue3 eventually. Should be straightforward to put this into a composable :)

@KjetilHaaheim
Copy link
Author

Either solution will work for me, node-component makes a bit more sense to myself

Absolutely, I agree. The reasoning for using slot is to avoid prop-drilling. By having the node component "in the controller", one can manipulate and/or listen to it directly:

<flowy :nodes="items">
  <template v-slot:default="{ node }">
    <flow-item v-bind="node" @click='sayHello' />
  </template>
</flowy>

export default {
  methods: {
    sayHello() {
      alert("Hello world!")
    }
  }
}

@KjetilHaaheim
Copy link
Author

KjetilHaaheim commented Aug 4, 2021

#39

node-component currently implemented, no slots yet.

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

No branches or pull requests

2 participants