jackbsteinberg / std-toast

120 stars 4 forks source link

First-class title and icon #17

Open jackbsteinberg opened 5 years ago

jackbsteinberg commented 5 years ago

During the research phase there was a split where about half of the libraries surveyed treated had first-class support for titles and icons. Among those around half had that support baked into the custom view, s.t. tagging title/icon elements in a certain way allowed the library to display them specially.

Do we think this feature a critical and popular enough part of toasts to support in a first-class way, or is it covered by allowing developers to create their own custom views?

scottaohara commented 5 years ago

As we discussed today, if potentially using the output element to serve as the basis for the live region, then it could be labelled by the label element. Authors could then, possibly through a slot inject an image / text that they wanted associated with the message (output), which would then be supplied as the accessible name for the live region.

A quick-n-dirty HTML example:

<my-message>
  <label for="message">
    <img src="..." alt=""> <!-- or svg, or icon font...whatever -->
     My title
  </label>
  <output id="message" role="status/alert" aria-live="polite/assertive">
    <!-- message gets injected here -->
  </output>
  <button>
    Dismiss
  </button>
</my-message>

Labeling in this manner would then separate out the accessible name from the string that the live region would announce, which could be announced by a screen reader like "Live announcement of accessible name and possibly role, followed by injected content (message)."