accessibility-widgets 1.0.7 → 2.0.2
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 +370 -365
- package/package.json +1 -1
- package/widget.js +1239 -333
package/README.md
CHANGED
|
@@ -1,202 +1,157 @@
|
|
|
1
1
|
# Accessibility Widgets
|
|
2
2
|
|
|
3
|
+
[](https://www.npmjs.com/package/accessibility-widgets)
|
|
4
|
+
[](https://opensource.org/licenses/GPL-3.0)
|
|
5
|
+
[](https://unpkg.com/accessibility-widgets)
|
|
3
6
|
|
|
4
|
-
A comprehensive,
|
|
7
|
+
A comprehensive, zero-dependency accessibility widget that enhances web accessibility for all users. This lightweight, single-file JavaScript solution provides 14+ accessibility features to make your website instantly more inclusive and compliant with WCAG 2.1 AA, Section 508, and EN 301 549 standards.
|
|
5
8
|
|
|
6
|
-

|
|
7
10
|
|
|
8
11
|
|
|
12
|
+
## ⚡ Quick Start
|
|
9
13
|
|
|
14
|
+
```html
|
|
15
|
+
<!-- Include the widget - That's it! -->
|
|
16
|
+
<script src="https://unpkg.com/accessibility-widgets@latest/widget.js"></script>
|
|
17
|
+
```
|
|
10
18
|
|
|
11
|
-
|
|
12
|
-
> These checks show how each feature aligns with WCAG 2.1 AA success criteria.
|
|
13
|
-
> They do **not** by themselves make a site fully compliant with WCAG, EN 301 549 or Section 508.
|
|
14
|
-
> To become fully compliant you still need to run a manual checks, fix any underlying HTML/CSS/ARIA issues, test with real users, and re-test every time the site changes.
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
| Feature | WCAG AA criterion(s) | EU (EN 301 549 / EAA / WAD) | US (ADA / Section 508) |
|
|
20
|
-
|---------|---------------------|-----------------------------|------------------------|
|
|
21
|
-
| High Contrast Mode | ✔️ | ✔️ | ✔️ |
|
|
22
|
-
| Text Size Adjustment | ✔️ | ✔️ | ✔️ |
|
|
23
|
-
| Text Spacing | ✔️ | ✔️ | ✔️ |
|
|
24
|
-
| Line Height Adjustment | ✔️ | ✔️ | ✔️ |
|
|
25
|
-
| Text Alignment (Left Align) | ✔️ (1.4.8) | ✔️ | ✔️ |
|
|
26
|
-
| Cursor Enhancement | ✔️ | ✔️ | ✔️ |
|
|
27
|
-
| Pause Animations | ✔️ | ✔️ | ✔️ |
|
|
28
|
-
| Reduced Motion | ✔️ | ✔️ | ✔️ |
|
|
29
|
-
| Hide Images | ✔️ (1.1.1) | ✔️ | ✔️ |
|
|
30
|
-
| Dyslexia-Friendly / Font Select | ✔️ | ✔️ | ✔️ |
|
|
31
|
-
| Screen Reader Assist | ✔️ | ✔️ | ✔️ |
|
|
32
|
-
| Voice Control | ✔️ (Chrome-only API) | ◑ | ◑ |
|
|
33
|
-
| Color-Blindness Filters | ✔️ | ✔️ | ✔️ |
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
## Features
|
|
41
|
-
|
|
42
|
-
### Core Accessibility Features
|
|
43
|
-
|
|
44
|
-
#### **High Contrast Mode**
|
|
45
|
-
Provides three levels of contrast enhancement:
|
|
46
|
-
- **Medium**: 1.3x contrast boost for subtle improvement
|
|
47
|
-
- **High**: Black background with white text and 1.5x contrast
|
|
48
|
-
- **Ultra**: Black background with yellow text and 2.0x contrast for maximum visibility
|
|
49
|
-
|
|
50
|
-
How it works: Applies CSS filters and background/text color overrides while preserving the widget's own styling.
|
|
51
|
-
|
|
52
|
-
#### **Text Size Adjustment**
|
|
53
|
-
Offers four text size options:
|
|
54
|
-
- **Default**: Original website text size
|
|
55
|
-
- **Medium**: 20px font size for all text elements
|
|
56
|
-
- **Large**: 24px font size for improved readability
|
|
57
|
-
- **X-Large**: 28px font size for maximum accessibility
|
|
58
|
-
|
|
59
|
-
How it works: Uses CSS to override font-size properties across all page elements while excluding the widget interface.
|
|
60
|
-
|
|
61
|
-
#### **Text Spacing**
|
|
62
|
-
Enhances text readability by adding:
|
|
63
|
-
- **Letter spacing**: 0.2em between characters
|
|
64
|
-
- **Word spacing**: 0.3em between words
|
|
65
|
-
|
|
66
|
-
How it works: Applies CSS letter-spacing and word-spacing properties to all text elements except the widget interface.
|
|
67
|
-
|
|
68
|
-
#### **Animation Control**
|
|
69
|
-
Completely stops all animations and transitions on the page.
|
|
70
|
-
|
|
71
|
-
How it works: Uses CSS to disable all `animation` and `transition` properties, helping users with vestibular disorders or attention difficulties.
|
|
72
|
-
|
|
73
|
-
#### **Image Hiding**
|
|
74
|
-
Removes all images from the page for users who prefer text-only content or have slow connections.
|
|
75
|
-
|
|
76
|
-
How it works: Sets `display: none` on all `<img>` elements. The system caches image queries for performance and updates every 5 seconds to catch dynamically loaded images.
|
|
77
|
-
|
|
78
|
-
#### **Dyslexia-Friendly Font**
|
|
79
|
-
Replaces all fonts with dyslexia-friendly alternatives:
|
|
80
|
-
- Primary: Comic Sans MS (widely available dyslexia-friendly font)
|
|
81
|
-
- Fallbacks: Chalkboard SE, Bradley Hand, Brush Script MT, fantasy
|
|
19
|
+
Or install via NPM:
|
|
82
20
|
|
|
83
|
-
|
|
21
|
+
```bash
|
|
22
|
+
npm install accessibility-widgets
|
|
23
|
+
```
|
|
84
24
|
|
|
85
|
-
|
|
86
|
-
|
|
25
|
+
```javascript
|
|
26
|
+
// Import in your project
|
|
27
|
+
import 'accessibility-widgets';
|
|
28
|
+
// or
|
|
29
|
+
require('accessibility-widgets');
|
|
30
|
+
```
|
|
87
31
|
|
|
88
|
-
|
|
32
|
+
## ✨ Key Features
|
|
89
33
|
|
|
90
|
-
|
|
91
|
-
|
|
34
|
+
### 🎨 Visual Enhancements
|
|
35
|
+
- **High Contrast Mode** - 3 levels (Medium 1.3x, High 1.5x, Ultra 2.0x) for improved visibility
|
|
36
|
+
- **Text Size Control** - 4 size options (Default, Medium 20px, Large 24px, X-Large 28px)
|
|
37
|
+
- **Line Height Adjustment** - 3 spacing levels (2em, 3em, 4em) for better readability
|
|
38
|
+
- **Text Spacing** - Enhanced letter (0.2em) and word spacing (0.3em)
|
|
39
|
+
- **Text Alignment** - Left, Center, or Right alignment options
|
|
40
|
+
- **Bigger Cursor** - High-contrast 48x72px cursor with SVG rendering
|
|
41
|
+
- **Hide Images** - Text-only mode for focused reading or bandwidth saving
|
|
92
42
|
|
|
93
|
-
|
|
43
|
+
### 🧠 Cognitive Support
|
|
44
|
+
- **Dyslexia-Friendly Font** - Comic Sans MS and other dyslexia-optimized fonts
|
|
45
|
+
- **Font Selection** - Choose between Arial, Times New Roman, or Verdana
|
|
46
|
+
- **Animation Control** - Pause all animations and transitions
|
|
47
|
+
- **Reduced Motion** - Motion sensitivity support for vestibular disorders
|
|
94
48
|
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
- **
|
|
98
|
-
- **
|
|
99
|
-
- **
|
|
49
|
+
### ♿ Assistive Technology
|
|
50
|
+
- **Screen Reader** - Built-in text-to-speech using Web Speech API
|
|
51
|
+
- **Voice Control** - Hands-free navigation with 15+ voice commands
|
|
52
|
+
- **Color Blindness Filters** - Protanopia, Deuteranopia, Tritanopia, and Grayscale modes
|
|
53
|
+
- **Keyboard Navigation** - Full Tab/Arrow key support with proper focus indicators
|
|
100
54
|
|
|
101
|
-
|
|
55
|
+
## 📊 Compliance & Standards
|
|
102
56
|
|
|
103
|
-
###
|
|
57
|
+
### WCAG 2.1 AA Coverage
|
|
104
58
|
|
|
105
|
-
|
|
106
|
-
|
|
59
|
+
| Feature | WCAG Criteria | EU EN 301 549 | US Section 508 |
|
|
60
|
+
|---------|---------------|---------------|----------------|
|
|
61
|
+
| High Contrast Mode | ✅ 1.4.3, 1.4.6 | ✅ | ✅ |
|
|
62
|
+
| Text Size Adjustment | ✅ 1.4.4 | ✅ | ✅ |
|
|
63
|
+
| Text Spacing | ✅ 1.4.12 | ✅ | ✅ |
|
|
64
|
+
| Line Height Adjustment | ✅ 1.4.12 | ✅ | ✅ |
|
|
65
|
+
| Text Alignment | ✅ 1.4.8 | ✅ | ✅ |
|
|
66
|
+
| Cursor Enhancement | ✅ 2.5.5 | ✅ | ✅ |
|
|
67
|
+
| Pause Animations | ✅ 2.2.2, 2.3.3 | ✅ | ✅ |
|
|
68
|
+
| Reduced Motion | ✅ 2.3.3 | ✅ | ✅ |
|
|
69
|
+
| Hide Images | ✅ 1.1.1 | ✅ | ✅ |
|
|
70
|
+
| Dyslexia-Friendly Font | ✅ 1.4.8 | ✅ | ✅ |
|
|
71
|
+
| Screen Reader | ✅ 4.1.3 | ✅ | ✅ |
|
|
72
|
+
| Voice Control | ⚠️ Browser API | ⚠️ | ⚠️ |
|
|
73
|
+
| Color Filters | ✅ 1.4.1 | ✅ | ✅ |
|
|
107
74
|
|
|
108
|
-
|
|
75
|
+
> **Note**: This widget helps meet accessibility criteria but does not guarantee full compliance. Complete WCAG/Section 508 compliance requires proper HTML semantics, ARIA attributes, manual testing, and user validation.
|
|
109
76
|
|
|
110
|
-
#### **Voice Control**
|
|
111
|
-
Voice commands to control accessibility features hands-free.
|
|
112
77
|
|
|
113
|
-
How it works: Uses the Web Speech API's SpeechRecognition interface. Continuously listens for voice commands and maps them to widget functions. Includes retry logic for reliability and graceful degradation for unsupported browsers.
|
|
114
78
|
|
|
115
|
-
Supported commands:
|
|
116
|
-
- "show menu" / "open menu" - Opens accessibility menu
|
|
117
|
-
- "high contrast" - Cycles through contrast levels
|
|
118
|
-
- "bigger text" - Cycles through text sizes
|
|
119
|
-
- "text spacing" - Toggles text spacing
|
|
120
|
-
- "pause animations" - Toggles animation control
|
|
121
|
-
- "hide images" - Toggles image visibility
|
|
122
|
-
- "dyslexia font" - Toggles dyslexia-friendly font
|
|
123
|
-
- "bigger cursor" - Toggles cursor enhancement
|
|
124
|
-
- "screen reader" - Toggles screen reader
|
|
125
|
-
- "reset all" - Resets all settings
|
|
126
79
|
|
|
127
|
-
#### **Reduced Motion**
|
|
128
|
-
Disables all animations and transitions for users with motion sensitivity.
|
|
129
80
|
|
|
130
|
-
How it works: Similar to Animation Control but specifically targets motion-related CSS properties including pseudo-elements (::before, ::after).
|
|
131
81
|
|
|
132
|
-
|
|
133
|
-
Cycle through three professional font options:
|
|
134
|
-
- **Arial**: Sans-serif, high readability
|
|
135
|
-
- **Times New Roman**: Serif, traditional
|
|
136
|
-
- **Verdana**: Sans-serif, designed for screen reading
|
|
82
|
+
## 🎯 Installation Methods
|
|
137
83
|
|
|
138
|
-
|
|
84
|
+
### CDN (Fastest)
|
|
85
|
+
```html
|
|
86
|
+
<!-- unpkg CDN -->
|
|
87
|
+
<script src="https://unpkg.com/accessibility-widgets@latest/widget.js"></script>
|
|
139
88
|
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
- **Deuteranopia**: Green-blind color correction
|
|
144
|
-
- **Tritanopia**: Blue-blind color correction
|
|
145
|
-
- **Grayscale**: Complete color removal
|
|
89
|
+
<!-- jsdelivr CDN -->
|
|
90
|
+
<script src="https://cdn.jsdelivr.net/npm/accessibility-widgets@latest/widget.js"></script>
|
|
91
|
+
```
|
|
146
92
|
|
|
147
|
-
|
|
93
|
+
### NPM
|
|
94
|
+
```bash
|
|
95
|
+
npm install accessibility-widgets
|
|
96
|
+
```
|
|
148
97
|
|
|
149
|
-
|
|
98
|
+
```javascript
|
|
99
|
+
// ES6 Import
|
|
100
|
+
import 'accessibility-widgets/widget.js';
|
|
150
101
|
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
102
|
+
// CommonJS
|
|
103
|
+
require('accessibility-widgets/widget.js');
|
|
104
|
+
```
|
|
154
105
|
|
|
106
|
+
### Direct Download
|
|
107
|
+
1. Download [widget.js](https://github.com/sinanisler/accessibility-widgets/raw/main/widget.js)
|
|
108
|
+
2. Include in your HTML:
|
|
155
109
|
```html
|
|
156
|
-
<script src="widget.js"></script>
|
|
110
|
+
<script src="path/to/widget.js"></script>
|
|
157
111
|
```
|
|
158
112
|
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
113
|
+
## ⚙️ Configuration
|
|
114
|
+
|
|
115
|
+
### Basic Setup (No Configuration Needed)
|
|
116
|
+
The widget works out of the box with zero configuration:
|
|
163
117
|
|
|
164
|
-
### Method 3: CDN
|
|
165
118
|
```html
|
|
166
119
|
<script src="https://unpkg.com/accessibility-widgets@latest/widget.js"></script>
|
|
167
120
|
```
|
|
168
121
|
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
## Configuration
|
|
172
|
-
|
|
173
|
-
The widget is highly customizable. You can override the default settings by defining `window.ACCESSIBILITY_WIDGET_CONFIG` before loading the widget script.
|
|
122
|
+
### Custom Configuration
|
|
123
|
+
Customize the widget by defining `window.ACCESSIBILITY_WIDGET_CONFIG` before loading the script:
|
|
174
124
|
|
|
175
|
-
### Basic Configuration
|
|
176
125
|
```html
|
|
177
126
|
<script>
|
|
178
|
-
// Define your custom configuration
|
|
179
127
|
window.ACCESSIBILITY_WIDGET_CONFIG = {
|
|
180
|
-
//
|
|
128
|
+
// Disable specific features
|
|
181
129
|
enableVoiceControl: false,
|
|
182
130
|
enableScreenReader: true,
|
|
183
131
|
|
|
184
|
-
//
|
|
185
|
-
widgetWidth: '
|
|
132
|
+
// Custom styling
|
|
133
|
+
widgetWidth: '400px',
|
|
186
134
|
colors: {
|
|
187
135
|
primary: '#0066cc',
|
|
188
136
|
secondary: '#ffffff'
|
|
137
|
+
},
|
|
138
|
+
|
|
139
|
+
// Position on left side
|
|
140
|
+
widgetPosition: {
|
|
141
|
+
side: 'left',
|
|
142
|
+
left: '20px',
|
|
143
|
+
bottom: '20px'
|
|
189
144
|
}
|
|
190
145
|
};
|
|
191
146
|
</script>
|
|
192
147
|
<script src="https://unpkg.com/accessibility-widgets@latest/widget.js"></script>
|
|
193
148
|
```
|
|
194
149
|
|
|
195
|
-
###
|
|
196
|
-
|
|
197
|
-
|
|
150
|
+
### Full Configuration Options
|
|
151
|
+
|
|
152
|
+
```javascript
|
|
198
153
|
window.ACCESSIBILITY_WIDGET_CONFIG = {
|
|
199
|
-
// Feature
|
|
154
|
+
// ===== Feature Toggles =====
|
|
200
155
|
enableHighContrast: true,
|
|
201
156
|
enableBiggerText: true,
|
|
202
157
|
enableTextSpacing: true,
|
|
@@ -208,75 +163,49 @@ window.ACCESSIBILITY_WIDGET_CONFIG = {
|
|
|
208
163
|
enableTextAlign: true,
|
|
209
164
|
enableScreenReader: true,
|
|
210
165
|
enableVoiceControl: true,
|
|
211
|
-
enableReducedMotion: true,
|
|
212
166
|
enableFontSelection: true,
|
|
213
167
|
enableColorFilter: true,
|
|
214
|
-
|
|
215
|
-
// Widget
|
|
216
|
-
widgetColumns: 2, // Number of columns in the options grid (1-4, default: 2)
|
|
217
|
-
|
|
218
|
-
// Widget dimensions and position
|
|
168
|
+
|
|
169
|
+
// ===== Widget Layout =====
|
|
219
170
|
widgetWidth: '440px',
|
|
171
|
+
widgetColumns: 2, // Grid columns (1-4)
|
|
172
|
+
|
|
173
|
+
// ===== Position =====
|
|
220
174
|
widgetPosition: {
|
|
221
|
-
side: 'right',
|
|
222
|
-
right: '20px',
|
|
223
|
-
left: '20px',
|
|
224
|
-
bottom: '20px'
|
|
175
|
+
side: 'right', // 'left' or 'right'
|
|
176
|
+
right: '20px',
|
|
177
|
+
left: '20px',
|
|
178
|
+
bottom: '20px'
|
|
225
179
|
},
|
|
226
|
-
|
|
227
|
-
//
|
|
180
|
+
|
|
181
|
+
// ===== Colors =====
|
|
228
182
|
colors: {
|
|
229
|
-
primary: '#
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
border: '#e6e6e6',
|
|
235
|
-
borderHover: '#d4d4d4',
|
|
236
|
-
shadow: 'rgba(0, 0, 0, 0.2)',
|
|
237
|
-
focus: '#ff6b35',
|
|
238
|
-
focusGlow: 'rgba(255, 107, 53, 0.3)'
|
|
183
|
+
primary: '#1663d7',
|
|
184
|
+
secondary: '#ffffff',
|
|
185
|
+
optionBg: '#ffffff',
|
|
186
|
+
optionText: '#333333',
|
|
187
|
+
optionIcon: '#000000'
|
|
239
188
|
},
|
|
240
|
-
|
|
241
|
-
// Button
|
|
189
|
+
|
|
190
|
+
// ===== Button Styling =====
|
|
242
191
|
button: {
|
|
243
192
|
size: '55px',
|
|
244
|
-
borderRadius: '
|
|
245
|
-
iconSize: '
|
|
193
|
+
borderRadius: '100px',
|
|
194
|
+
iconSize: '40px',
|
|
246
195
|
shadow: '0 4px 8px rgba(0, 0, 0, 0.2)'
|
|
247
196
|
},
|
|
248
|
-
|
|
249
|
-
//
|
|
250
|
-
menu: {
|
|
251
|
-
headerHeight: '55px',
|
|
252
|
-
padding: '0 10px 10px 10px',
|
|
253
|
-
optionPadding: '14px 10px',
|
|
254
|
-
optionMargin: '10px',
|
|
255
|
-
borderRadius: '8px',
|
|
256
|
-
fontSize: '16px',
|
|
257
|
-
titleFontSize: '22px',
|
|
258
|
-
closeButtonSize: '44px'
|
|
259
|
-
},
|
|
260
|
-
|
|
261
|
-
// Typography
|
|
197
|
+
|
|
198
|
+
// ===== Typography =====
|
|
262
199
|
typography: {
|
|
263
200
|
fontFamily: 'Arial, sans-serif',
|
|
264
|
-
fontSize: '
|
|
201
|
+
fontSize: '17px',
|
|
265
202
|
titleFontSize: '22px',
|
|
266
|
-
titleFontWeight: '
|
|
267
|
-
lineHeight: '1'
|
|
203
|
+
titleFontWeight: '700'
|
|
268
204
|
},
|
|
269
|
-
|
|
270
|
-
//
|
|
271
|
-
animation: {
|
|
272
|
-
transition: '0.2s',
|
|
273
|
-
hoverScale: '1.05'
|
|
274
|
-
},
|
|
275
|
-
|
|
276
|
-
// Language/Text Configuration - Customize all text strings
|
|
205
|
+
|
|
206
|
+
// ===== Internationalization (i18n) =====
|
|
277
207
|
lang: {
|
|
278
208
|
accessibilityMenu: 'Accessibility Menu',
|
|
279
|
-
closeAccessibilityMenu: 'Close Accessibility Menu',
|
|
280
209
|
accessibilityTools: 'Accessibility Tools',
|
|
281
210
|
resetAllSettings: 'Reset All Settings',
|
|
282
211
|
screenReader: 'Screen Reader',
|
|
@@ -287,236 +216,312 @@ window.ACCESSIBILITY_WIDGET_CONFIG = {
|
|
|
287
216
|
dyslexiaFriendly: 'Dyslexia Friendly',
|
|
288
217
|
biggerCursor: 'Bigger Cursor',
|
|
289
218
|
lineHeight: 'Line Height',
|
|
290
|
-
reducedMotion: 'Reduced Motion',
|
|
291
219
|
fontSelection: 'Font Selection',
|
|
292
220
|
colorFilter: 'Color Filter',
|
|
293
221
|
textAlign: 'Text Align',
|
|
294
222
|
textSize: 'Text Size',
|
|
295
|
-
highContrast: 'High Contrast'
|
|
296
|
-
defaultFont: 'Default Font',
|
|
297
|
-
noFilter: 'No Filter',
|
|
298
|
-
default: 'Default',
|
|
299
|
-
close: 'Close',
|
|
300
|
-
screenReaderOn: 'Screen reader on',
|
|
301
|
-
screenReaderOff: 'Screen reader off',
|
|
302
|
-
voiceControlActivated: 'Voice control activated',
|
|
303
|
-
notSupportedBrowser: 'is not supported in this browser'
|
|
223
|
+
highContrast: 'High Contrast'
|
|
304
224
|
},
|
|
305
225
|
|
|
306
|
-
// Voice
|
|
226
|
+
// ===== Voice Commands =====
|
|
307
227
|
voiceCommands: {
|
|
308
|
-
showMenu: ['show menu', 'open menu'
|
|
228
|
+
showMenu: ['show menu', 'open menu'],
|
|
309
229
|
highContrast: ['high contrast'],
|
|
310
230
|
biggerText: ['bigger text', 'large text'],
|
|
311
231
|
textSpacing: ['text spacing'],
|
|
312
|
-
pauseAnimations: ['pause animations'
|
|
232
|
+
pauseAnimations: ['pause animations'],
|
|
313
233
|
hideImages: ['hide images'],
|
|
314
|
-
dyslexiaFont: ['dyslexia
|
|
315
|
-
biggerCursor: ['bigger cursor'
|
|
316
|
-
lineHeight: ['line height'],
|
|
317
|
-
textAlign: ['align text', 'text align'],
|
|
234
|
+
dyslexiaFont: ['dyslexia font'],
|
|
235
|
+
biggerCursor: ['bigger cursor'],
|
|
318
236
|
screenReader: ['screen reader'],
|
|
319
|
-
voiceControl: ['voice command', 'voice control'],
|
|
320
237
|
resetAll: ['reset all', 'reset everything']
|
|
321
|
-
},
|
|
322
|
-
|
|
323
|
-
// Grid Layout Configuration - Customize button grid layout
|
|
324
|
-
gridLayout: {
|
|
325
|
-
columns: '1fr 1fr', // Default 2-column layout (change to '1fr 1fr 1fr' for 3 columns, etc.)
|
|
326
|
-
gap: '10px' // Gap between grid items
|
|
327
|
-
}
|
|
328
|
-
};
|
|
329
|
-
</script>
|
|
330
|
-
<script src="https://unpkg.com/accessibility-widgets@latest/widget.js"></script>
|
|
331
|
-
```
|
|
332
|
-
|
|
333
|
-
### Partial Configuration
|
|
334
|
-
You only need to specify the settings you want to change. The widget will merge your settings with the defaults:
|
|
335
|
-
|
|
336
|
-
```html
|
|
337
|
-
<script>
|
|
338
|
-
// Only override what you need
|
|
339
|
-
window.ACCESSIBILITY_WIDGET_CONFIG = {
|
|
340
|
-
enableVoiceControl: false, // Disable voice control
|
|
341
|
-
widgetWidth: '300px', // Smaller width
|
|
342
|
-
colors: {
|
|
343
|
-
primary: '#purple' // Custom color (other colors remain default)
|
|
344
238
|
}
|
|
345
239
|
};
|
|
346
|
-
</script>
|
|
347
|
-
<script src="widget.js"></script>
|
|
348
240
|
```
|
|
349
241
|
|
|
350
|
-
|
|
351
|
-
The widget can be positioned on either side of the screen:
|
|
242
|
+
## 🌍 Internationalization (i18n)
|
|
352
243
|
|
|
353
|
-
|
|
354
|
-
<script>
|
|
355
|
-
window.ACCESSIBILITY_WIDGET_CONFIG = {
|
|
356
|
-
widgetPosition: {
|
|
357
|
-
side: 'left', // Position on left side of screen
|
|
358
|
-
left: '20px', // 20px from left edge
|
|
359
|
-
bottom: '20px' // 20px from bottom
|
|
360
|
-
}
|
|
361
|
-
};
|
|
362
|
-
</script>
|
|
363
|
-
```
|
|
364
|
-
|
|
365
|
-
### Internationalization (i18n)
|
|
366
|
-
The widget supports full internationalization. You can customize all text strings and voice commands:
|
|
244
|
+
Full multilingual support - customize all text and voice commands:
|
|
367
245
|
|
|
246
|
+
### Spanish Example
|
|
368
247
|
```html
|
|
369
248
|
<script>
|
|
370
|
-
// Spanish language example
|
|
371
249
|
window.ACCESSIBILITY_WIDGET_CONFIG = {
|
|
372
250
|
lang: {
|
|
373
251
|
accessibilityMenu: 'Menú de Accesibilidad',
|
|
374
252
|
accessibilityTools: 'Herramientas de Accesibilidad',
|
|
375
253
|
screenReader: 'Lector de Pantalla',
|
|
376
|
-
biggerText: 'Texto Más Grande',
|
|
377
254
|
highContrast: 'Alto Contraste',
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
// ... add more translations as needed
|
|
255
|
+
biggerText: 'Texto Más Grande',
|
|
256
|
+
resetAllSettings: 'Restablecer Todo'
|
|
381
257
|
},
|
|
382
|
-
|
|
383
|
-
// Customize voice commands for Spanish
|
|
384
258
|
voiceCommands: {
|
|
385
|
-
showMenu: ['mostrar menú', 'abrir menú'
|
|
259
|
+
showMenu: ['mostrar menú', 'abrir menú'],
|
|
386
260
|
highContrast: ['alto contraste'],
|
|
387
|
-
biggerText: ['texto
|
|
388
|
-
|
|
389
|
-
pauseAnimations: ['pausar animaciones', 'detener animaciones'],
|
|
390
|
-
hideImages: ['ocultar imágenes'],
|
|
391
|
-
dyslexiaFont: ['fuente para dislexia', 'fuente dislexia'],
|
|
392
|
-
biggerCursor: ['cursor más grande', 'cursor grande'],
|
|
393
|
-
lineHeight: ['altura de línea'],
|
|
394
|
-
textAlign: ['alinear texto', 'alineación de texto'],
|
|
395
|
-
screenReader: ['lector de pantalla'],
|
|
396
|
-
voiceControl: ['comando de voz', 'control de voz'],
|
|
397
|
-
resetAll: ['reiniciar todo', 'resetear todo']
|
|
261
|
+
biggerText: ['texto grande', 'texto más grande'],
|
|
262
|
+
resetAll: ['reiniciar todo']
|
|
398
263
|
}
|
|
399
264
|
};
|
|
400
265
|
</script>
|
|
266
|
+
<script src="https://unpkg.com/accessibility-widgets@latest/widget.js"></script>
|
|
401
267
|
```
|
|
402
268
|
|
|
403
|
-
## Voice Commands
|
|
404
|
-
|
|
405
|
-
When voice control is enabled
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
- **
|
|
426
|
-
- **
|
|
427
|
-
- **
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
269
|
+
## 🎤 Voice Commands
|
|
270
|
+
|
|
271
|
+
When voice control is enabled (Chrome/Edge only), use these commands:
|
|
272
|
+
|
|
273
|
+
| Command | Action |
|
|
274
|
+
|---------|--------|
|
|
275
|
+
| "show menu" / "open menu" | Opens accessibility menu |
|
|
276
|
+
| "high contrast" | Toggles contrast mode |
|
|
277
|
+
| "bigger text" / "large text" | Increases text size |
|
|
278
|
+
| "text spacing" | Toggles text spacing |
|
|
279
|
+
| "pause animations" | Stops all animations |
|
|
280
|
+
| "hide images" | Removes images |
|
|
281
|
+
| "dyslexia font" | Activates dyslexia-friendly font |
|
|
282
|
+
| "bigger cursor" | Enlarges cursor |
|
|
283
|
+
| "line height" | Adjusts line spacing |
|
|
284
|
+
| "screen reader" | Activates text-to-speech |
|
|
285
|
+
| "reset all" | Resets all settings |
|
|
286
|
+
|
|
287
|
+
*All commands are fully customizable via `voiceCommands` configuration*## 📚 Feature Details
|
|
288
|
+
|
|
289
|
+
### High Contrast Mode
|
|
290
|
+
Three contrast enhancement levels:
|
|
291
|
+
- **Medium**: 1.3x boost for subtle improvement
|
|
292
|
+
- **High**: Black background + white text + 1.5x contrast
|
|
293
|
+
- **Ultra**: Black background + yellow text + 2.0x contrast
|
|
294
|
+
|
|
295
|
+
### Text Size Control
|
|
296
|
+
Four size options (Default, Medium 20px, Large 24px, X-Large 28px) with smart widget exclusion to maintain UI consistency.
|
|
297
|
+
|
|
298
|
+
### Text Spacing
|
|
299
|
+
Enhanced letter spacing (0.2em) and word spacing (0.3em) for improved readability, especially helpful for dyslexia.
|
|
300
|
+
|
|
301
|
+
### Line Height Adjustment
|
|
302
|
+
Three spacing levels (2em, 3em, 4em) to reduce visual crowding and improve reading flow.
|
|
303
|
+
|
|
304
|
+
### Animation Control
|
|
305
|
+
Completely disables CSS animations and transitions - critical for users with vestibular disorders or ADHD.
|
|
306
|
+
|
|
307
|
+
### Image Hiding
|
|
308
|
+
Text-only mode with smart caching (5-second intervals) to catch dynamically loaded images.
|
|
309
|
+
|
|
310
|
+
### Dyslexia-Friendly Font
|
|
311
|
+
Uses Comic Sans MS and fallback fonts optimized for dyslexia (Chalkboard SE, Bradley Hand, Brush Script MT).
|
|
312
|
+
|
|
313
|
+
### Cursor Enhancement
|
|
314
|
+
Custom 48x72px SVG cursor with high-contrast black fill and white stroke for better visibility.
|
|
315
|
+
|
|
316
|
+
### Screen Reader (Text-to-Speech)
|
|
317
|
+
Built-in TTS using Web Speech API - reads focused element text, alt attributes, and titles.
|
|
318
|
+
|
|
319
|
+
### Voice Control
|
|
320
|
+
Hands-free operation with Web Speech Recognition API. Supports 15+ customizable commands.
|
|
321
|
+
|
|
322
|
+
### Color Blindness Filters
|
|
323
|
+
SVG-based filters for Protanopia (red-blind), Deuteranopia (green-blind), Tritanopia (blue-blind), and Grayscale modes.
|
|
324
|
+
|
|
325
|
+
### Font Selection
|
|
326
|
+
Cycle through Arial (modern sans-serif), Times New Roman (traditional serif), and Verdana (screen-optimized).
|
|
327
|
+
|
|
328
|
+
## 🚀 Technical Features
|
|
329
|
+
|
|
330
|
+
- ✅ **Zero Dependencies** - Pure vanilla JavaScript, no frameworks required
|
|
331
|
+
- ✅ **Lightweight** - Single file, ~1900 lines minified
|
|
332
|
+
- ✅ **Persistent Settings** - localStorage saves user preferences across sessions
|
|
333
|
+
- ✅ **Keyboard Accessible** - Full Tab/Arrow key navigation with proper focus management
|
|
334
|
+
- ✅ **ARIA Compliant** - Complete ARIA labels and roles for assistive technologies
|
|
335
|
+
- ✅ **Performance Optimized** - DOM caching, efficient event delegation, debounced updates
|
|
336
|
+
- ✅ **Error Handling** - Graceful degradation for unsupported browser APIs
|
|
337
|
+
- ✅ **Responsive Design** - Works seamlessly on desktop, tablet, and mobile
|
|
338
|
+
- ✅ **Flexible Positioning** - Left or right side placement with custom offsets
|
|
339
|
+
- ✅ **Full i18n Support** - Complete text customization for any language
|
|
340
|
+
- ✅ **Dynamic Theming** - Customizable colors with SVG icon color synchronization
|
|
341
|
+
- ✅ **Auto-initialization** - Automatically loads when DOM is ready
|
|
342
|
+
|
|
343
|
+
## 🌐 Browser Compatibility
|
|
344
|
+
|
|
345
|
+
| Browser | Core Features | Screen Reader | Voice Control |
|
|
346
|
+
|---------|---------------|---------------|---------------|
|
|
347
|
+
| Chrome 90+ | ✅ | ✅ | ✅ |
|
|
348
|
+
| Edge 90+ | ✅ | ✅ | ✅ |
|
|
349
|
+
| Firefox 88+ | ✅ | ✅ | ❌ |
|
|
350
|
+
| Safari 14+ | ✅ | ✅ | ❌ |
|
|
351
|
+
| Opera 76+ | ✅ | ✅ | ✅ |
|
|
352
|
+
|
|
353
|
+
**Note**: Voice Control requires Web Speech Recognition API (Chromium-based browsers only). Screen Reader requires Web Speech Synthesis API.
|
|
354
|
+
## 💡 Usage Examples
|
|
355
|
+
|
|
356
|
+
### Minimal Implementation
|
|
447
357
|
```html
|
|
448
358
|
<!DOCTYPE html>
|
|
449
|
-
<html>
|
|
359
|
+
<html lang="en">
|
|
450
360
|
<head>
|
|
361
|
+
<meta charset="UTF-8">
|
|
451
362
|
<title>My Accessible Website</title>
|
|
452
363
|
</head>
|
|
453
364
|
<body>
|
|
454
|
-
<h1>Welcome
|
|
455
|
-
<p>This site
|
|
365
|
+
<h1>Welcome</h1>
|
|
366
|
+
<p>This site is fully accessible.</p>
|
|
456
367
|
|
|
457
|
-
<!--
|
|
458
|
-
<script src="widget.js"></script>
|
|
368
|
+
<!-- Add widget - automatically initializes -->
|
|
369
|
+
<script src="https://unpkg.com/accessibility-widgets@latest/widget.js"></script>
|
|
459
370
|
</body>
|
|
460
371
|
</html>
|
|
461
372
|
```
|
|
462
373
|
|
|
463
|
-
### Custom Configuration
|
|
374
|
+
### With Custom Configuration
|
|
464
375
|
```html
|
|
465
|
-
|
|
466
|
-
|
|
376
|
+
<!DOCTYPE html>
|
|
377
|
+
<html lang="en">
|
|
378
|
+
<head>
|
|
379
|
+
<meta charset="UTF-8">
|
|
380
|
+
<title>Custom Accessible Site</title>
|
|
381
|
+
</head>
|
|
382
|
+
<body>
|
|
383
|
+
<h1>Custom Configuration</h1>
|
|
384
|
+
|
|
385
|
+
<script>
|
|
386
|
+
// Configure before loading widget
|
|
387
|
+
window.ACCESSIBILITY_WIDGET_CONFIG = {
|
|
388
|
+
widgetWidth: '380px',
|
|
389
|
+
colors: {
|
|
390
|
+
primary: '#9c27b0', // Purple theme
|
|
391
|
+
secondary: '#ffffff'
|
|
392
|
+
},
|
|
393
|
+
enableVoiceControl: false, // Disable voice control
|
|
394
|
+
widgetPosition: {
|
|
395
|
+
side: 'left',
|
|
396
|
+
left: '15px',
|
|
397
|
+
bottom: '15px'
|
|
398
|
+
}
|
|
399
|
+
};
|
|
400
|
+
</script>
|
|
401
|
+
<script src="https://unpkg.com/accessibility-widgets@latest/widget.js"></script>
|
|
402
|
+
</body>
|
|
403
|
+
</html>
|
|
404
|
+
```
|
|
405
|
+
|
|
406
|
+
### NPM/Module Usage
|
|
407
|
+
```javascript
|
|
408
|
+
// main.js
|
|
409
|
+
import 'accessibility-widgets/widget.js';
|
|
410
|
+
|
|
411
|
+
// Optional: Configure before import
|
|
467
412
|
window.ACCESSIBILITY_WIDGET_CONFIG = {
|
|
468
|
-
enableVoiceControl: false,
|
|
469
|
-
widgetWidth: '
|
|
470
|
-
colors: {
|
|
471
|
-
primary: '#0066cc', // Custom blue color
|
|
472
|
-
secondary: '#ffffff' // White background
|
|
473
|
-
}
|
|
413
|
+
enableVoiceControl: false,
|
|
414
|
+
widgetWidth: '400px'
|
|
474
415
|
};
|
|
475
|
-
|
|
476
|
-
|
|
416
|
+
|
|
417
|
+
// Widget auto-initializes
|
|
477
418
|
```
|
|
478
419
|
|
|
479
|
-
|
|
420
|
+
### React/Vue/Angular Integration
|
|
421
|
+
```javascript
|
|
422
|
+
// App.jsx (React)
|
|
423
|
+
import { useEffect } from 'react';
|
|
424
|
+
|
|
425
|
+
function App() {
|
|
426
|
+
useEffect(() => {
|
|
427
|
+
// Configure widget
|
|
428
|
+
window.ACCESSIBILITY_WIDGET_CONFIG = {
|
|
429
|
+
colors: { primary: '#4caf50' }
|
|
430
|
+
};
|
|
431
|
+
|
|
432
|
+
// Load widget script
|
|
433
|
+
const script = document.createElement('script');
|
|
434
|
+
script.src = 'https://unpkg.com/accessibility-widgets@latest/widget.js';
|
|
435
|
+
script.async = true;
|
|
436
|
+
document.body.appendChild(script);
|
|
437
|
+
|
|
438
|
+
return () => {
|
|
439
|
+
// Cleanup if needed
|
|
440
|
+
document.body.removeChild(script);
|
|
441
|
+
};
|
|
442
|
+
}, []);
|
|
443
|
+
|
|
444
|
+
return <div>Your App Content</div>;
|
|
445
|
+
}
|
|
446
|
+
```
|
|
480
447
|
|
|
481
|
-
|
|
482
|
-
- **WCAG 2.1** (Web Content Accessibility Guidelines)
|
|
483
|
-
- **Section 508** (US Federal accessibility requirements)
|
|
484
|
-
- **ADA** (Americans with Disabilities Act) digital accessibility standards
|
|
448
|
+
## 🛠️ Development
|
|
485
449
|
|
|
486
|
-
|
|
450
|
+
```bash
|
|
451
|
+
# Clone repository
|
|
452
|
+
git clone https://github.com/sinanisler/accessibility-widgets.git
|
|
453
|
+
cd accessibility-widgets
|
|
487
454
|
|
|
455
|
+
# Install dependencies (optional)
|
|
456
|
+
npm install
|
|
457
|
+
|
|
458
|
+
# Start local server
|
|
459
|
+
npm run dev
|
|
460
|
+
# Opens http://localhost:8000
|
|
488
461
|
```
|
|
489
|
-
widget/
|
|
490
|
-
├── widget.js # Main accessibility widget file
|
|
491
|
-
├── index.html # Demo/test page
|
|
492
|
-
└── README.md # This documentation
|
|
493
|
-
```
|
|
494
462
|
|
|
495
|
-
##
|
|
463
|
+
## 📦 NPM Publishing Setup
|
|
464
|
+
|
|
465
|
+
After setting up your NPM account:
|
|
466
|
+
|
|
467
|
+
1. **Create NPM Token**:
|
|
468
|
+
```bash
|
|
469
|
+
npm login
|
|
470
|
+
npm token create
|
|
471
|
+
```
|
|
472
|
+
|
|
473
|
+
2. **Add to GitHub Secrets**:
|
|
474
|
+
- Go to your repository Settings → Secrets and variables → Actions
|
|
475
|
+
- Create new secret: `NPM_TOKEN`
|
|
476
|
+
- Paste your NPM token
|
|
477
|
+
|
|
478
|
+
3. **Publish**:
|
|
479
|
+
```bash
|
|
480
|
+
# Manual publish
|
|
481
|
+
npm publish
|
|
482
|
+
|
|
483
|
+
# Or create GitHub release to trigger workflow
|
|
484
|
+
git tag v2.0.0
|
|
485
|
+
git push origin v2.0.0
|
|
486
|
+
```
|
|
487
|
+
|
|
488
|
+
The GitHub Actions workflow will automatically publish to NPM on new releases.
|
|
489
|
+
|
|
490
|
+
## 🤝 Contributing
|
|
491
|
+
|
|
492
|
+
Contributions are welcome! Please:
|
|
493
|
+
|
|
494
|
+
1. Fork the repository
|
|
495
|
+
2. Create a feature branch (`git checkout -b feature/amazing-feature`)
|
|
496
|
+
3. Commit changes (`git commit -m 'Add amazing feature'`)
|
|
497
|
+
4. Push to branch (`git push origin feature/amazing-feature`)
|
|
498
|
+
5. Open a Pull Request
|
|
499
|
+
|
|
500
|
+
## 📄 License
|
|
501
|
+
|
|
502
|
+
GPL-3.0 License - See [LICENSE](LICENSE) file for details.
|
|
496
503
|
|
|
497
|
-
|
|
504
|
+
## 👨💻 Author
|
|
498
505
|
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
5. Check that settings persist across page reloads
|
|
506
|
+
**Sinan Isler**
|
|
507
|
+
- Website: [sinan.im](https://sinan.im)
|
|
508
|
+
- Email: sinan@sinan.im
|
|
509
|
+
- GitHub: [@sinanisler](https://github.com/sinanisler)
|
|
504
510
|
|
|
505
|
-
##
|
|
511
|
+
## 🌟 Support
|
|
506
512
|
|
|
507
|
-
|
|
513
|
+
- ⭐ Star this repository
|
|
514
|
+
- 🐛 [Report bugs](https://github.com/sinanisler/accessibility-widgets/issues)
|
|
515
|
+
- 💡 [Request features](https://github.com/sinanisler/accessibility-widgets/issues)
|
|
516
|
+
- ❤️ [Sponsor on GitHub](https://github.com/sponsors/sinanisler)
|
|
508
517
|
|
|
509
|
-
##
|
|
518
|
+
## 📊 Stats
|
|
510
519
|
|
|
511
|
-
|
|
520
|
+

|
|
521
|
+

|
|
522
|
+

|
|
523
|
+

|
|
512
524
|
|
|
513
|
-
|
|
525
|
+
---
|
|
514
526
|
|
|
515
|
-
|
|
516
|
-
- **Widget Positioning**: Added support for left/right side positioning with configurable distances
|
|
517
|
-
- **Internationalization**: Full i18n support with customizable text strings for all languages
|
|
518
|
-
- **Color Theming**: SVG icons now use configurable primary color instead of hardcoded values
|
|
519
|
-
- **Screen Reader Improvements**: Fixed close button text to read properly ("Close" instead of "times")
|
|
520
|
-
- **Removed Features**: Removed Reading Mode and Enhanced Focus features for better performance
|
|
521
|
-
- **UI Improvements**: Updated header background to black, removed gradient from accessibility button
|
|
522
|
-
- **Configuration**: Enhanced configuration system with deep merging for partial overrides
|
|
527
|
+
**Made with ❤️ for a more accessible web**
|