aria-ease 1.0.8 → 1.0.9
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md
CHANGED
|
@@ -6,10 +6,18 @@ Out of the box accessibility utility package to develop production ready applica
|
|
|
6
6
|
|
|
7
7
|
`npm i aria-ease`
|
|
8
8
|
|
|
9
|
-
##
|
|
9
|
+
## Features
|
|
10
|
+
|
|
11
|
+
Add accessibility to menu: menu can be dropdown, side menu, slide navigation. Basically any component that toggles display and has a list of children items. The function creates a focus trap within the menu and the focus can be navigated using the arrow keys. The escape key also closes the menu and returns the focus back to the trigger.
|
|
12
|
+
|
|
13
|
+
The makeMenuAccessible function takes two string arguments; the id of the menu, and the class name of the children item of the menu. And should only be invoked after the menu has become visible or added to the DOM.
|
|
14
|
+
|
|
15
|
+
The updateMenuTriggerAriaAttributes function take two string arguments; the id of the menu trigger, and the aria-label that will replace the current one in the DOM. Behind the scene the aria-expanded and aria-attributes are also updated based on the visibility of the menu.
|
|
16
|
+
|
|
17
|
+
#### Usage
|
|
10
18
|
|
|
11
19
|
```
|
|
12
|
-
import { makeMenuAccessible,
|
|
20
|
+
import { makeMenuAccessible, updateMenuTriggerAriaAttributes } from "aria-ease"
|
|
13
21
|
|
|
14
22
|
const App = () => {
|
|
15
23
|
const toggleMenuDisplay = (): void => {
|
|
@@ -24,10 +32,6 @@ const App = () => {
|
|
|
24
32
|
}
|
|
25
33
|
}
|
|
26
34
|
|
|
27
|
-
const handleTabButtonClick = (): void => {
|
|
28
|
-
makeTabAccessible('custom-tab', 'custom-tab-item')
|
|
29
|
-
}
|
|
30
|
-
|
|
31
35
|
return (
|
|
32
36
|
<div>
|
|
33
37
|
<button
|
|
@@ -46,7 +50,29 @@ const App = () => {
|
|
|
46
50
|
<button role="menuitem" className="profile-menu-item">Two</button>
|
|
47
51
|
<button role="menuitem" className="profile-menu-item">Three</button>
|
|
48
52
|
</div>
|
|
49
|
-
|
|
53
|
+
</div>
|
|
54
|
+
)
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
export default App
|
|
58
|
+
```
|
|
59
|
+
|
|
60
|
+
Add accessibility to tab: tab can be tabs, interactive sliders and carousels. Basically any component that is permanently displayed and has a list of interractive children items. The function creates a focus trap within the tab and the focus can be navigated using the arrow keys.
|
|
61
|
+
|
|
62
|
+
The makeTabAccessible function takes two string arguments; the id of the tab main div, and the class name of the children item of the div. The function should be called when any of the interractive children item (e.g button) of the tab is clicked. The clicked button gets focused and the focus can be navigated using the arrow keys.
|
|
63
|
+
|
|
64
|
+
#### Usage
|
|
65
|
+
|
|
66
|
+
```
|
|
67
|
+
import { makeTabAccessible } from "aria-ease"
|
|
68
|
+
|
|
69
|
+
const App = () => {
|
|
70
|
+
const handleTabButtonClick = (): void => {
|
|
71
|
+
makeTabAccessible('custom-tab', 'custom-tab-item')
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
return (
|
|
75
|
+
<div>
|
|
50
76
|
<div id="custom-tab">
|
|
51
77
|
<button className="custom-tab-item" onClick={handleTabButtonClick}>One</button>
|
|
52
78
|
<button className="custom-tab-item" onClick={handleTabButtonClick}>Two</button>
|
package/aria-ease.d.ts
CHANGED
|
@@ -21,7 +21,8 @@ declare module 'aria-ease' {
|
|
|
21
21
|
* @param {string} triggerId The id of the trigger button that toggles the menu.
|
|
22
22
|
* @param {string} ariaLabel The aria-label to be updated.
|
|
23
23
|
*/
|
|
24
|
-
declare function updateMenuTriggerAriaAttributes(triggerId: string, ariaLabel: string): void;
|
|
24
|
+
export declare function updateMenuTriggerAriaAttributes(triggerId: string, ariaLabel: string): void;
|
|
25
|
+
|
|
25
26
|
|
|
26
27
|
|
|
27
28
|
|
package/package.json
CHANGED
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Adds keyboard navigation to toggle menu. The menu traps focus and can be interacted with using the keyboard. The first item of the menu has focus when menu appears.
|
|
3
|
+
* @param {string} menuId The id of the menu
|
|
4
|
+
* @param {string} menuItemClass The class of the items that are children of the menu
|
|
5
|
+
*/
|
|
6
|
+
export declare function makeMenuAccessible(menuId: string, menuItemClass: string): void;
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Updates the aria attributes of the menu trigger button. Trigger button element must possess the following aria attributes; aria-expanded, aria-pressed, aria-label.
|
|
3
|
+
* @param {string} triggerId The id of the trigger button that toggles the menu.
|
|
4
|
+
* @param {string} ariaLabel The aria-label to be updated.
|
|
5
|
+
*/
|
|
6
|
+
export declare function updateMenuTriggerAriaAttributes(triggerId: string, ariaLabel: string): void;
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Adds keyboard navigation to tab. The tab traps focus and can be interacted with using the keyboard.
|
|
3
|
+
* @param {string} tabId The id of the tab
|
|
4
|
+
* @param {string} tabItemClass The class of the items that are children of the tab
|
|
5
|
+
*/
|
|
6
|
+
export declare function makeTabAccessible(tabId: string, tabItemClass: string): void;
|
package/tsconfig.json
CHANGED
package/CONTRIBUTION-GUIDE.md
DELETED
|
File without changes
|