accessibility-widgets 1.0.5 → 1.0.6

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.
Files changed (3) hide show
  1. package/README.md +159 -22
  2. package/package.json +1 -1
  3. package/widget.js +121 -30
package/README.md CHANGED
@@ -40,22 +40,111 @@ A comprehensive, lightweight accessibility tool that enhances web accessibility
40
40
  ## Features
41
41
 
42
42
  ### Core Accessibility Features
43
- - **High Contrast Mode** - Improves visibility for users with low vision
44
- - **Text Size Adjustment** - Increases font size for better readability
45
- - **Text Spacing** - Adds letter and word spacing for easier reading
46
- - **Animation Control** - Pauses animations that may cause distraction or discomfort
47
- - **Image Hiding** - Removes images for users who prefer text-only content
48
- - **Dyslexia-Friendly Font** - Uses OpenDyslexic font for users with dyslexia
49
- - **Cursor Enhancement** - Increases cursor size for better visibility
50
- - **Line Height Adjustment** - Improves text readability with increased line spacing
51
- - **Text Alignment** - Forces left alignment for consistent text layout
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
82
+
83
+ How it works: Overrides the font-family CSS property for all elements on the page.
84
+
85
+ #### **Cursor Enhancement**
86
+ Provides a larger, high-contrast cursor for better visibility.
87
+
88
+ How it works: Uses a custom SVG cursor (48x72px) with black fill and white stroke, applied via CSS cursor property.
89
+
90
+ #### **Line Height Adjustment**
91
+ Increases line spacing to 2.5x normal for improved readability.
92
+
93
+ How it works: Applies CSS `line-height: 2.5` to all text elements except the widget interface.
94
+
95
+ #### **Text Alignment**
96
+ Provides three alignment options:
97
+ - **Left**: Forces left alignment for consistent reading flow
98
+ - **Center**: Centers all text for specific user preferences
99
+ - **Right**: Right-aligns all text
100
+
101
+ How it works: Uses CSS `text-align` property override for all text elements.
52
102
 
53
103
  ### Advanced Features
54
- - **Screen Reader Support** - Built-in text-to-speech functionality
55
- - **Voice Control** - Voice commands to control accessibility features
56
- - **Reduced Motion** - Respects user preferences for reduced motion
57
- - **Font Selection** - Choose between Arial, Times New Roman, and Verdana
58
- - **Color Blindness Filters** - Filters for Protanopia, Deuteranopia, Tritanopia, and Grayscale
104
+
105
+ #### **Screen Reader Support**
106
+ Built-in text-to-speech functionality that reads focused elements aloud.
107
+
108
+ How it works: Uses the Web Speech API's SpeechSynthesis interface. When enabled, it listens for `focusin` events and speaks the text content, alt text, or title of focused elements. Includes error handling for unsupported browsers.
109
+
110
+ #### **Voice Control**
111
+ Voice commands to control accessibility features hands-free.
112
+
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
+
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
+
127
+ #### **Reduced Motion**
128
+ Disables all animations and transitions for users with motion sensitivity.
129
+
130
+ How it works: Similar to Animation Control but specifically targets motion-related CSS properties including pseudo-elements (::before, ::after).
131
+
132
+ #### **Font Selection**
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
137
+
138
+ How it works: Applies font-family overrides via CSS classes, cycling through options when activated.
139
+
140
+ #### **Color Blindness Filters**
141
+ Provides specialized filters for different types of color blindness:
142
+ - **Protanopia**: Red-blind color correction
143
+ - **Deuteranopia**: Green-blind color correction
144
+ - **Tritanopia**: Blue-blind color correction
145
+ - **Grayscale**: Complete color removal
146
+
147
+ How it works: Uses SVG filters with color matrix transformations applied via CSS filter property to the entire document.
59
148
 
60
149
  ## Installation
61
150
 
@@ -123,6 +212,9 @@ window.ACCESSIBILITY_WIDGET_CONFIG = {
123
212
  enableFontSelection: true,
124
213
  enableColorFilter: true,
125
214
 
215
+ // Widget button layout
216
+ widgetColumns: 2, // Number of columns in the options grid (1-4, default: 2)
217
+
126
218
  // Widget dimensions and position
127
219
  widgetWidth: '440px',
128
220
  widgetPosition: {
@@ -209,6 +301,29 @@ window.ACCESSIBILITY_WIDGET_CONFIG = {
209
301
  screenReaderOff: 'Screen reader off',
210
302
  voiceControlActivated: 'Voice control activated',
211
303
  notSupportedBrowser: 'is not supported in this browser'
304
+ },
305
+
306
+ // Voice Command Configuration - Customize voice commands for different languages
307
+ voiceCommands: {
308
+ showMenu: ['show menu', 'open menu', 'accessibility menu'],
309
+ highContrast: ['high contrast'],
310
+ biggerText: ['bigger text', 'large text'],
311
+ textSpacing: ['text spacing'],
312
+ pauseAnimations: ['pause animations', 'stop animations'],
313
+ hideImages: ['hide images'],
314
+ dyslexiaFont: ['dyslexia friendly', 'dyslexia font'],
315
+ biggerCursor: ['bigger cursor', 'large cursor'],
316
+ lineHeight: ['line height'],
317
+ textAlign: ['align text', 'text align'],
318
+ screenReader: ['screen reader'],
319
+ voiceControl: ['voice command', 'voice control'],
320
+ 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
212
327
  }
213
328
  };
214
329
  </script>
@@ -248,7 +363,7 @@ window.ACCESSIBILITY_WIDGET_CONFIG = {
248
363
  ```
249
364
 
250
365
  ### Internationalization (i18n)
251
- The widget supports full internationalization. You can customize all text strings:
366
+ The widget supports full internationalization. You can customize all text strings and voice commands:
252
367
 
253
368
  ```html
254
369
  <script>
@@ -263,6 +378,23 @@ window.ACCESSIBILITY_WIDGET_CONFIG = {
263
378
  resetAllSettings: 'Restablecer Todas las Configuraciones',
264
379
  close: 'Cerrar'
265
380
  // ... add more translations as needed
381
+ },
382
+
383
+ // Customize voice commands for Spanish
384
+ voiceCommands: {
385
+ showMenu: ['mostrar menú', 'abrir menú', 'menú de accesibilidad'],
386
+ highContrast: ['alto contraste'],
387
+ biggerText: ['texto más grande', 'texto grande'],
388
+ textSpacing: ['espaciado de texto'],
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']
266
398
  }
267
399
  };
268
400
  </script>
@@ -270,18 +402,23 @@ window.ACCESSIBILITY_WIDGET_CONFIG = {
270
402
 
271
403
  ## Voice Commands
272
404
 
273
- When voice control is enabled, users can activate features using these commands:
405
+ When voice control is enabled, users can activate features using these commands (default English commands shown - fully customizable via `voiceCommands` configuration):
274
406
 
275
- - "show menu" / "open menu" - Opens the accessibility menu
407
+ - "show menu" / "open menu" / "accessibility menu" - Opens the accessibility menu
276
408
  - "high contrast" - Toggles high contrast mode
277
- - "bigger text" - Toggles larger text size
409
+ - "bigger text" / "large text" - Toggles larger text size
278
410
  - "text spacing" - Toggles text spacing
279
- - "pause animations" - Toggles animation pausing
411
+ - "pause animations" / "stop animations" - Toggles animation pausing
280
412
  - "hide images" - Toggles image hiding
281
- - "dyslexia font" - Toggles dyslexia-friendly font
282
- - "bigger cursor" - Toggles larger cursor
413
+ - "dyslexia friendly" / "dyslexia font" - Toggles dyslexia-friendly font
414
+ - "bigger cursor" / "large cursor" - Toggles larger cursor
415
+ - "line height" - Toggles line height adjustment
416
+ - "align text" / "text align" - Cycles through text alignment options
283
417
  - "screen reader" - Toggles screen reader
284
- - "reset all" - Resets all accessibility settings
418
+ - "voice command" / "voice control" - Toggles voice control
419
+ - "reset all" / "reset everything" - Resets all accessibility settings
420
+
421
+ **Note:** All voice commands can be customized for different languages using the `voiceCommands` configuration option.
285
422
 
286
423
  ## Browser Compatibility
287
424
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "accessibility-widgets",
3
- "version": "1.0.5",
3
+ "version": "1.0.6",
4
4
  "description": "A comprehensive, lightweight accessibility widget that enhances web accessibility for all users. Provides multiple accessibility features including screen reader support, voice control, high contrast mode, and more.",
5
5
  "main": "widget.js",
6
6
  "scripts": {
package/widget.js CHANGED
@@ -115,6 +115,29 @@ const DEFAULT_WIDGET_CONFIG = {
115
115
  voiceControlActivated: 'Voice control activated',
116
116
  notSupportedBrowser: 'is not supported in this browser',
117
117
  close: 'Close'
118
+ },
119
+
120
+ // Voice Command Configuration - Developers can customize commands for different languages
121
+ voiceCommands: {
122
+ showMenu: ['show menu', 'open menu', 'accessibility menu'],
123
+ highContrast: ['high contrast'],
124
+ biggerText: ['bigger text', 'large text'],
125
+ textSpacing: ['text spacing'],
126
+ pauseAnimations: ['pause animations', 'stop animations'],
127
+ hideImages: ['hide images'],
128
+ dyslexiaFont: ['dyslexia friendly', 'dyslexia font'],
129
+ biggerCursor: ['bigger cursor', 'large cursor'],
130
+ lineHeight: ['line height'],
131
+ textAlign: ['align text', 'text align'],
132
+ screenReader: ['screen reader'],
133
+ voiceControl: ['voice command', 'voice control'],
134
+ resetAll: ['reset all', 'reset everything']
135
+ },
136
+
137
+ // Grid Layout Configuration
138
+ gridLayout: {
139
+ columns: '1fr 1fr', // Default 2-column layout (can be changed to '1fr 1fr 1fr' for 3 columns, etc.)
140
+ gap: '10px' // Gap between grid items
118
141
  }
119
142
  };
120
143
 
@@ -294,8 +317,8 @@ const styles = `
294
317
 
295
318
  .snn-options-grid {
296
319
  display: grid;
297
- grid-template-columns: 1fr 1fr;
298
- gap: ${WIDGET_CONFIG.menu.optionMargin};
320
+ grid-template-columns: ${WIDGET_CONFIG.gridLayout.columns};
321
+ gap: ${WIDGET_CONFIG.gridLayout.gap};
299
322
  margin-bottom: 20px;
300
323
  }
301
324
 
@@ -1118,32 +1141,8 @@ const voiceControl = {
1118
1141
  console.log(`Received command: ${command}`);
1119
1142
 
1120
1143
  try {
1121
- const commandMap = {
1122
- 'show menu': 'snn-accessibility-button',
1123
- 'open menu': 'snn-accessibility-button',
1124
- 'accessibility menu': 'snn-accessibility-button',
1125
- 'high contrast': 'highContrast',
1126
- 'bigger text': 'biggerText',
1127
- 'large text': 'biggerText',
1128
- 'text spacing': 'textSpacing',
1129
- 'pause animations': 'pauseAnimations',
1130
- 'stop animations': 'pauseAnimations',
1131
- 'hide images': 'hideImages',
1132
- 'dyslexia friendly': 'dyslexiaFont',
1133
- 'dyslexia font': 'dyslexiaFont',
1134
- 'bigger cursor': 'biggerCursor',
1135
- 'large cursor': 'biggerCursor',
1136
- 'line height': 'lineHeight',
1137
- 'align text': 'textAlign',
1138
- 'text align': 'textAlign',
1139
- 'screen reader': 'screenReader',
1140
- 'voice command': 'voiceControl',
1141
- 'voice control': 'voiceControl',
1142
- 'reset all': 'resetAll',
1143
- 'reset everything': 'resetAll',
1144
- };
1145
-
1146
- if (command === 'show menu' || command === 'open menu' || command === 'accessibility menu') {
1144
+ // Check for show menu commands
1145
+ if (WIDGET_CONFIG.voiceCommands.showMenu.includes(command)) {
1147
1146
  if (!menuCache.button) menuCache.init();
1148
1147
  if (menuCache.button) {
1149
1148
  menuCache.button.click();
@@ -1151,12 +1150,40 @@ const voiceControl = {
1151
1150
  return;
1152
1151
  }
1153
1152
 
1154
- if (command === 'reset all' || command === 'reset everything') {
1153
+ // Check for reset all commands
1154
+ if (WIDGET_CONFIG.voiceCommands.resetAll.includes(command)) {
1155
1155
  resetAccessibilitySettings();
1156
1156
  return;
1157
1157
  }
1158
1158
 
1159
- const localStorageKey = commandMap[command];
1159
+ // Build dynamic command map based on configuration
1160
+ let localStorageKey = null;
1161
+
1162
+ // Check each command group
1163
+ if (WIDGET_CONFIG.voiceCommands.highContrast.includes(command)) {
1164
+ localStorageKey = 'highContrast';
1165
+ } else if (WIDGET_CONFIG.voiceCommands.biggerText.includes(command)) {
1166
+ localStorageKey = 'biggerText';
1167
+ } else if (WIDGET_CONFIG.voiceCommands.textSpacing.includes(command)) {
1168
+ localStorageKey = 'textSpacing';
1169
+ } else if (WIDGET_CONFIG.voiceCommands.pauseAnimations.includes(command)) {
1170
+ localStorageKey = 'pauseAnimations';
1171
+ } else if (WIDGET_CONFIG.voiceCommands.hideImages.includes(command)) {
1172
+ localStorageKey = 'hideImages';
1173
+ } else if (WIDGET_CONFIG.voiceCommands.dyslexiaFont.includes(command)) {
1174
+ localStorageKey = 'dyslexiaFont';
1175
+ } else if (WIDGET_CONFIG.voiceCommands.biggerCursor.includes(command)) {
1176
+ localStorageKey = 'biggerCursor';
1177
+ } else if (WIDGET_CONFIG.voiceCommands.lineHeight.includes(command)) {
1178
+ localStorageKey = 'lineHeight';
1179
+ } else if (WIDGET_CONFIG.voiceCommands.textAlign.includes(command)) {
1180
+ localStorageKey = 'textAlign';
1181
+ } else if (WIDGET_CONFIG.voiceCommands.screenReader.includes(command)) {
1182
+ localStorageKey = 'screenReader';
1183
+ } else if (WIDGET_CONFIG.voiceCommands.voiceControl.includes(command)) {
1184
+ localStorageKey = 'voiceControl';
1185
+ }
1186
+
1160
1187
  if (localStorageKey) {
1161
1188
  // Use cached menu reference if available
1162
1189
  if (!menuCache.menu) menuCache.init();
@@ -1522,5 +1549,69 @@ if (document.readyState === 'loading') {
1522
1549
  - Performance optimization with DOM caching
1523
1550
  - Single file deployment
1524
1551
 
1552
+ Configuration Options:
1553
+ - Customizable language/text strings
1554
+ - Customizable voice command strings
1555
+ - Configurable grid layout (columns and gap)
1556
+ - All widget styling and positioning options
1557
+ - Feature enable/disable toggles
1558
+
1559
+ ===========================================
1560
+
1561
+ CONFIGURATION EXAMPLE:
1562
+
1563
+ To customize the widget, define window.ACCESSIBILITY_WIDGET_CONFIG
1564
+ before loading the widget script:
1565
+
1566
+ <script>
1567
+ window.ACCESSIBILITY_WIDGET_CONFIG = {
1568
+ // Customize language/text strings
1569
+ lang: {
1570
+ accessibilityMenu: 'Menu de Accesibilidad',
1571
+ screenReader: 'Lector de Pantalla',
1572
+ biggerText: 'Texto Más Grande',
1573
+ highContrast: 'Alto Contraste',
1574
+ // ... customize any text string
1575
+ },
1576
+
1577
+ // Customize voice commands for different languages
1578
+ voiceCommands: {
1579
+ showMenu: ['mostrar menú', 'abrir menú', 'menú de accesibilidad'],
1580
+ highContrast: ['alto contraste'],
1581
+ biggerText: ['texto más grande', 'texto grande'],
1582
+ textSpacing: ['espaciado de texto'],
1583
+ pauseAnimations: ['pausar animaciones', 'detener animaciones'],
1584
+ hideImages: ['ocultar imágenes'],
1585
+ dyslexiaFont: ['fuente para dislexia', 'fuente dislexia'],
1586
+ biggerCursor: ['cursor más grande', 'cursor grande'],
1587
+ lineHeight: ['altura de línea'],
1588
+ textAlign: ['alinear texto', 'alineación de texto'],
1589
+ screenReader: ['lector de pantalla'],
1590
+ voiceControl: ['comando de voz', 'control de voz'],
1591
+ resetAll: ['reiniciar todo', 'resetear todo']
1592
+ },
1593
+
1594
+ // Customize grid layout
1595
+ gridLayout: {
1596
+ columns: '1fr 1fr 1fr', // 3-column layout
1597
+ gap: '15px' // Custom gap between buttons
1598
+ },
1599
+
1600
+ // Other customizable options
1601
+ widgetWidth: '500px',
1602
+ widgetPosition: {
1603
+ side: 'left',
1604
+ left: '30px',
1605
+ bottom: '30px'
1606
+ },
1607
+ colors: {
1608
+ primary: '#2196F3',
1609
+ primaryHover: '#1976D2',
1610
+ // ... customize any color
1611
+ }
1612
+ };
1613
+ </script>
1614
+ <script src="widget.js"></script>
1615
+
1525
1616
  ===========================================
1526
1617
  */