pablen / toasty

A notification package for Elm apps.
http://package.elm-lang.org/packages/pablen/toasty/latest
BSD 3-Clause "New" or "Revised" License
40 stars 12 forks source link

Accessibility #10

Open toastal opened 5 years ago

toastal commented 5 years ago

I know it's possible to pass a11y attributes in via the config, but I think they should be the default. I think Twitter Bootstrap's toasts are a good starting point. This would possibly also include giving it a tabindex and keyboard shortcuts for Enter and Escape to dismiss.

I wouldn't mind doing a PR for this.

pablen commented 5 years ago

I agree it would be great to be accessible by default. A PR would be greatly appreciated!

toastal commented 5 years ago

I'm looking at this and it's a little more involved than I thought.

I think it's easy to have what-you-probably-want defaults like aria-atomic="true" and role="alert" and aria-live="polite". But maybe this should be something in a Toasty.Accessibility module rather than the actual defaults? You can overwrite these defaults if the attribute 'setters' were 'appenders', but that's not how they work now.

For me, the bigger deal is that each alert should be allowed to have its own politeness -- meaning like inf are 'polite' whereas error are 'assertive'. I had started with a politeness ADT type Politeness = Polite | Assertive | Off. One way to do this would be to pass in yet another functions from a -> Politeness where that a is the a in Stack a (like the view in the example). This would make the render have yet another argument which would be more to think about as well as make this a breaking change. An Accessibility module could wrap these pieces together, but my question is: do you want to enforce consumers to do a11y or make it opt-in? I can see the arguments for both.

toastal commented 5 years ago

What I mean by that is that is, if there were an Accessibility module added to this, it would likely be the preferred/best practice way to use this library. The basic form may be easier to work with, but should it be?