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

Provide toggle context to children #3

Merged
merged 1 commit into from
Oct 5, 2022

Conversation

melohagan
Copy link
Contributor

@melohagan melohagan commented Oct 5, 2022

I realised there was no way for the toggle to pass its state to the Budibase app. I'm creating this PR for you because I had to figure out how to use the context myself 😅 - I'll follow up with some docs tomorrow hopefully.

Screenshot 2022-10-05 at 21 00 27

Screenshot 2022-10-05 at 21 00 41

Screenshot 2022-10-05 at 21 01 25

Screenshot 2022-10-05 at 21 01 50

So the context provides bindings to the children. You then need to add the Provider component to expose those bindings to the children, which are indicated by the generic <slot />.


There's a couple of other things you could have done instead. One is as a form component, another would be to add the onClick event:

{
    "type": "event",
    "label": "On Click",
    "key": "onClick"
  }

I think the context provider works well for something like a toggle.

@YuanZhang98
Copy link
Owner

Thanks for contributing this, that looks awesome. 🥰

@YuanZhang98 YuanZhang98 merged commit ab7b252 into YuanZhang98:main Oct 5, 2022
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.

2 participants