UBCCM / UBC-DEF

University of British Columbia Digital Experience Framework (previously known as UBC-CLF)
MIT License
3 stars 4 forks source link

New Component: Spinner / Loading #55

Open kelvin-xu opened 4 years ago

kelvin-xu commented 4 years ago

Problem description
Spinner is a UI component to indicate the loading state of certain actions inside application such as Initialization, Async request and etc.

Proposed solution
https://codepen.io/xucongzhe/pen/WNvdZWX

The spinner component is simply a container with screen reader text in it. The animation is done by CSS which is overridable by developers.

Accessibility consideration:

  1. Add role="alert" & aria-live=”assertive" on the spinner container element.
  2. Screen reader text should be changed with Javascript once action is complete and states become loaded.
  3. The element with the role & aria-live attributes needs to exist in the DOM before the spinner is required. The change or addition of content inside that element is what triggers the screen reader notification.

Alternatives considered
https://getbootstrap.com/docs/4.4/components/spinners/ and https://codepen.io/stuartjnelson/pen/xWyLGR share simillar markups, the later one provides better accessibility.

Additional context

Feature Review Checklist: