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

Expand JS events from components #239

Open
sezaru opened this issue Aug 1, 2023 · 1 comment
Open

Expand JS events from components #239

sezaru opened this issue Aug 1, 2023 · 1 comment
Labels
help wanted Extra attention is needed

Comments

@sezaru
Copy link
Contributor

sezaru commented Aug 1, 2023

This is an idea to make Petal Components more "customizable" by allows users to "expand" JS events inside a component.

For example, the Dropdown component has 2 JS events, phx-click for the trigger button and phx-click-away for the full dropdown.

I was wondering if we could add new attr fields so we can expand these JS events.

For the dropdown, we could have something like this:

attr :click_away_event, JS, default: %JS{}
attr :click_event, JS, default: %JS{}

...

 defp js_attributes("container", "live_view_js", options_container_id, click_away_event) do
    %{
      "phx-click-away":
        click_away_event
        |> JS.hide(
          to: "##{options_container_id}",
          transition: {@transition_out_base, @transition_out_start, @transition_out_end}
        )
    }
  end

This would allow the user to do some other actions when the Petal component events are triggered.

@mplatts
Copy link
Contributor

mplatts commented Aug 3, 2023

Yeah looks good. Bit busy atm but open to PRs

@nhobes nhobes added the help wanted Extra attention is needed label Aug 9, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
help wanted Extra attention is needed
Projects
None yet
Development

No branches or pull requests

3 participants