jackbsteinberg/std-toast

Handling Toast actions (buttons and links)

Closed this issue · 1 comments

When the developer is creating a toast in HTML using , they can include in the children button(s) that will take some action upon user feedback. At this point, the intention is to have an actionclick event that would fire when a with a single button or link has had that button or link clicked.

I see two issues with including this as our action support:

  • It doesn't address a case where the developer wants to put two action buttons in the toast.
  • It doesn't address how to add actions using the showToast() function.

A proposal that came up in #9 to solve this second issue was to allow the developer to pass in an action like so:

const toast = showToast("message", {
  action: ['Click me', doSomething]
});

This same pattern could also be used to pass in a list of actions, but would have the same issue with actionclick. This pattern would also need to be amended to support both buttons and links.

Some ideas from #9:

  • Provide an element
  • Provide a HTML string
  • Provide a URL (to create a link) or a function (to create a button)