Skip to content

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

Merged
merged 2 commits into from
Aug 17, 2019

Conversation

cameronnorman
Copy link
Collaborator

@cameronnorman cameronnorman commented Jul 26, 2019

Issue #56: onclick Docs and tests

Changes

  • Adds tests for onclick component
  • Adds docs for onclick component

Notes

  • Just explained a simple async function with emitting an event onclick

@@ -1,3 +1,28 @@
# matestack core component: Action
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Onclick, not Action ;)

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
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  1. The onclick only requires emit. data is optional
  2. 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
  1. If you want to show the more advanced usage of onclick including data param usages and a separate method defining the config of the onclick component, please use a second example and increase the complexity of your examples step by step. Otherwise you may "overwhelm" new matestack users
  2. 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 :)

}
end

def run_this_function
Copy link
Member

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.

@jonasjabari jonasjabari merged commit 082b669 into develop Aug 17, 2019
@pascalwengerter pascalwengerter deleted the add-onlick-docs-and-tests branch August 20, 2019 06:50
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