-
-
Notifications
You must be signed in to change notification settings - Fork 43
Adds docs and tests for onclick component #96
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
Conversation
docs/components/onclick.md
Outdated
@@ -1,3 +1,28 @@ | |||
# matestack core component: Action |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Onclick, not Action ;)
docs/components/onclick.md
Outdated
Show [specs](../../spec/usage/components/action_spec.rb) | ||
Show [specs](../../spec/usage/components/onclick_spec.rb) | ||
|
||
The `onclick` component renders a div that runs a function on click. This is a nice component for use cases where you would like to wrap multiple components into one click function. The function called by the onclick component requires two fields. These two fields are `emit` and `data`. These two fields are then emitted as a event in javascript when the component is clicked |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
- The
onclick
only requiresemit
.data
is optional - The usecase you describe sounds pretty complicated. The main purpose of this component is to provide an easy to use client side event emitting API. Normally it would only wrap one component, which shows an interaction element such as one button or one specially styled div or something
onclick emit: "my_event" do
button text: "click"
end
async rerender_on: "my_event" do
#some content which gets rerendered onclick
end
- If you want to show the more advanced usage of
onclick
includingdata
param usages and a separate method defining the config of theonclick
component, please use a second example and increase the complexity of your examples step by step. Otherwise you may "overwhelm" new matestack users - please add a separate section where you explain which params could be used for the
onclick
component. We use this approach in other component documentations as well :)
docs/components/onclick.md
Outdated
} | ||
end | ||
|
||
def run_this_function |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this is a bit misleading: the ruby method run_this_function
just returns a config hash, which determines the client side behavior of the onclick
component. I would rather call the ruby method onclick_config
although it sounds not as nice as yours. I just don't want to confuse the reader.
Issue #56:
onclick
Docs and testsChanges
Notes