jackbsteinberg / std-toast

120 stars 4 forks source link

Natively supported pattern discussion #21

Closed jackbsteinberg closed 5 years ago

jackbsteinberg commented 5 years ago

The <std-toast> HTML element will let developers add more controlled custom views to their toasts. However, there are certain commonly used patterns for toasts (e.g. the "Snackbar" pattern of message and action) that it could be advantageous to natively support.

For instance, if a developer writes this:

<std-toast>
    <p>Hello World!</p>
    <button>Learn More</button>
</std-toast>

The toast could know to use the <p> element as the message and the <button> element as the action. Are patterns like this prevalent enough that this should work out of the box? If so, what are those patterns (#17)?

Additionally, if we use Shadow DOM for displaying toast content, how should we manage capturing the patterns and putting them in the right place? Like this:

<std-toast>
    <p slot='message>Hello World!</p>
    <button slot='action>Learn More</button>
</std-toast>

Like this:

<std-toast>
    <toastmessage><p>Hello World!</p></toastmessage>
    <toastaction><button>Learn More</button></toastaction>
</std-toast>

Or is there a better way?