├── LICENSE
├── README.md
├── index.d.ts
├── index.js
└── package.json
/LICENSE:
--------------------------------------------------------------------------------
1 | Copyright (c) 2023 Mayank
2 |
3 | The following license is modified from the MIT license.
4 |
5 | ANTI-FASCIST LICENSE:
6 |
7 | The following conditions must be met by any person obtaining a copy of this
8 | software:
9 |
10 | - You MAY NOT be a fascist.
11 | - You MUST not financially support fascists.
12 | - You MUST not publicly voice support for fascists.
13 |
14 | "Fascist" can be understood as any entity which supports radical authoritarian
15 | nationalism. For example: Donald Trump is a fascist; if you donated to his
16 | campaign then all rights provided by this license are not granted to you.
17 |
18 | MIT LICENSE:
19 |
20 | Permission is hereby granted, free of charge, to any person obtaining a copy
21 | of this software and associated documentation files (the "Software"), to deal
22 | in the Software without restriction, including without limitation the rights
23 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
24 | copies of the Software, and to permit persons to whom the Software is
25 | furnished to do so, subject to the following conditions:
26 |
27 | The above copyright notice and this permission notice shall be included in all
28 | copies or substantial portions of the Software.
29 |
30 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
31 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
32 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
33 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
34 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
35 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
36 | SOFTWARE.
37 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # live-announcer
2 |
3 | A web component that makes it easier to work with [live regions](https://developer.mozilla.org/en-US/docs/Web/Accessibility/ARIA/ARIA_Live_Regions).
4 |
5 | ```
6 | npm add @acab/live-announcer
7 | ```
8 |
9 | ## Usage
10 |
11 | 1. Set it up on page load. This should be done as early as possible.
12 |
13 | ```js
14 | import * as announcer from '@acab/live-announcer';
15 | announcer.setup();
16 | ```
17 |
18 | 2. Announce notifications from anywhere on the page, in an [assertive](https://developer.mozilla.org/en-US/docs/Web/Accessibility/ARIA/Attributes/aria-live#assertive) or [polite](https://developer.mozilla.org/en-US/docs/Web/Accessibility/ARIA/Attributes/aria-live#polite) way.
19 |
20 | ```js
21 | announcer.notify('Something happened!', { priority: 'important' });
22 | ```
23 |
24 | ```js
25 | announcer.notify('Something happened, but it can wait.');
26 | ```
27 |
28 | ### Best practices
29 |
30 | 1. Keep the notification text short and concise. Don't use special characters or non-text content.
31 | 2. Set up the announcer as early as possible, before even sending any notifications.
32 | 3. Don't send too many notifications at the same time. Prefer static text.
33 |
34 | ### Dialogs and popout windows
35 |
36 | Calling `setup()` will automatically create an instance of the announcer and inject it into the page. Specifically, it will be appended into the `
` element's shadow tree.
37 |
38 | In some cases, you might want to inject it somewhere else, for example, into a modal `