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

Access node state in node option?? #49

Closed
RingoKam opened this issue Feb 9, 2020 · 4 comments
Closed

Access node state in node option?? #49

RingoKam opened this issue Feb 9, 2020 · 4 comments

Comments

@RingoKam
Copy link
Contributor

RingoKam commented Feb 9, 2020

Is there a way to access Node state within option?

Great library! But documentation is kinda sparse. I would love to contribute to the doc after I gain a better understanding of the library πŸ™‡β€β™‚οΈ

@newcat
Copy link
Owner

newcat commented Feb 9, 2020

Yes there is. Every option component receives some props, one of them being the node instance. Example:

module.exports = {
    props: ["node"],
    methods: {
        onClick() {
            this.node.state.counter++;
        }
    }
}

Admittedly, the documentation is not very good at the moment. I actually reworked the documentation about node options a few days ago, but apparently it is still not clear. Maybe I should add some code examples like the one above. Would that help?

@RingoKam
Copy link
Contributor Author

RingoKam commented Feb 9, 2020

Awesome! Thanks for the quick reply.

As far as the doc goes, having the project written in typescript definitely help me navigate the library and understand what each part does. More code example would definitely helped.

How about adding code sandbox to the doc?

Setting up based on https://newcat.github.io/baklavajs/#/plugins/view
https://codesandbox.io/s/baklavajs-setup-zvevk

Creating a customNode:
https://codesandbox.io/s/baklavajs-customnode-i0lzl

Some unrelated questions:
If I want to have more granular control over the node component, let say I want to change the template of the node itself, is extending the Node.vue component is the way to go?

@newcat
Copy link
Owner

newcat commented Feb 9, 2020

I really like the code sandbox idea and will definetely implement that.

Yes you can "extend" the node component. Unfortunately, extending in Vue is not really possible, so you have to copy the source code and modify the copy. Have a look here (hope it helps πŸ˜‰): https://newcat.github.io/baklavajs/#/styling?id=hardcore-customization

@RingoKam
Copy link
Contributor Author

RingoKam commented Feb 9, 2020

yup thats what i needed! thank you πŸ™‡β€β™‚οΈ

closing this issue.

@RingoKam RingoKam closed this as completed Feb 9, 2020
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