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

Add an "Action" component #161

Closed
antoine4livre opened this issue Feb 12, 2024 · 4 comments · Fixed by #165
Closed

Add an "Action" component #161

antoine4livre opened this issue Feb 12, 2024 · 4 comments · Fixed by #165
Assignees
Labels
enhancement New feature or request

Comments

@antoine4livre
Copy link
Contributor

JS component with no twig template to trigger action on another component.

API example :

<button type="button" data-component="Action" data-option-target="Panel" data-option-method="close">Close every panel</button>
@antoine4livre antoine4livre added the enhancement New feature or request label Feb 12, 2024
@antoine4livre antoine4livre self-assigned this Feb 12, 2024
@titouanmathis
Copy link
Contributor

Great idea, 2 points:

  • What would the API for passing parameters to the method look like?
  • How do I target a specific instance of a Panel?

@antoine4livre
Copy link
Contributor Author

I didn't think that passing parameters to the method would be necessary for the uses I have in mind.

Any ideas on how to add this?
Maybe like this: data-option-method="close(true, 'hello')"
My advice is not to implement it and to handle special cases in the method.

To specify a target, you can add data-option-selector="#my-component" to filter instances specified by data-option-target.

We could also pass several instance types in the "target" option, separating them with a comma or a space.

<button
  type="button"
  data-component="Action"
  data-option-target="Panel Modal"
  data-option-selector=".can-be-closed"
  data-option-method="close">
  Close every panel & modal with .can-be-closed class
</button>

@antoine4livre
Copy link
Contributor Author

antoine4livre commented Feb 13, 2024

@titouanmathis Here is a first draft, I prepare the PR...

@titouanmathis
Copy link
Contributor

I think your implementation is missing an option to configure the type of event triggering the action. Maybe a data-option-on could be added? It could be either a single event (click) or a list of events (mouseenter mouseleave).

This could then be used on <form> elements for example.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants