Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/jadu/pulsar-live-region

Simple methods for updating a live region to communicate state changes to assistive technologies
https://github.com/jadu/pulsar-live-region

Last synced: 5 days ago
JSON representation

Simple methods for updating a live region to communicate state changes to assistive technologies

Awesome Lists containing this project

README

        

Live Region

Simple methods for updating a live region to communicate state changes to assistive technologies.

Example implementation

The Live Region component needs two containers to be placed in the DOM on page load, these are then populated by the methods detailed below.

```html



```

Styles

This example uses Pulsar's `.hide` class, which is a screenreader-friendly hiding method which allows the region changes to still be announced.

JavaScript

The component should be initialised with references to the required containers.

```js
const $ = require('jquery');
const LiveRegion = require('./src/LiveRegion');

$(function () {
const liveRegion = new LiveRegion($('html'));

liveRegion.init({
assertiveContainer: '.js-live-region-assertive',
politeContainer: '.js-live-region-polite'
});
});
```

Usage

There are two methods `polite()` and `assertive()`.

```js
$('.example-polite-trigger').on('click', function () {
liveRegion.polite('this is a polite annoucement');
});

$('.example-assertive-trigger').on('click', function () {
liveRegion.assertive('this is an assertive annoucement');
});
```

Tests

Run the test suite to check expected functionality.

```shell
npm test
```

Generate a code coverage report, which can be viewed by opening `/coverage/lcov-report/index.html`

```shell
npm run coverage
```