@a11ypros/a11y-ui-components 1.0.0 → 1.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 +252 -0
- package/package.json +1 -2
package/README.md
ADDED
|
@@ -0,0 +1,252 @@
|
|
|
1
|
+
# @a11ypros/a11y-ui-components
|
|
2
|
+
|
|
3
|
+
An accessibility-first React UI component library built with WCAG 2.1/2.2 Level AA compliance. Every component has been carefully crafted by a certified WAS (Web Accessibility Specialist) to ensure your applications are usable by everyone, regardless of their abilities or the assistive technologies they use.
|
|
4
|
+
|
|
5
|
+
## Features
|
|
6
|
+
|
|
7
|
+
- ✅ **WCAG 2.1/2.2 Level AA Compliant** - Built with accessibility as a core requirement
|
|
8
|
+
- ✅ **TypeScript** - Full TypeScript support with type definitions included
|
|
9
|
+
- ✅ **Tree-shakeable** - ES modules with side-effect-free exports for optimal bundle sizes
|
|
10
|
+
- ✅ **Keyboard Navigation** - Full keyboard support for all interactive components
|
|
11
|
+
- ✅ **Screen Reader Friendly** - Proper ARIA labels and semantic HTML
|
|
12
|
+
- ✅ **Focus Management** - Built-in focus trap and focus return utilities
|
|
13
|
+
- ✅ **Modern React** - Built for React 18+ with hooks and modern patterns
|
|
14
|
+
|
|
15
|
+
## Installation
|
|
16
|
+
|
|
17
|
+
```bash
|
|
18
|
+
npm install @a11ypros/a11y-ui-components
|
|
19
|
+
```
|
|
20
|
+
|
|
21
|
+
or
|
|
22
|
+
|
|
23
|
+
```bash
|
|
24
|
+
yarn add @a11ypros/a11y-ui-components
|
|
25
|
+
```
|
|
26
|
+
|
|
27
|
+
## Peer Dependencies
|
|
28
|
+
|
|
29
|
+
This package requires React 18+ and React DOM 18+:
|
|
30
|
+
|
|
31
|
+
```bash
|
|
32
|
+
npm install react react-dom
|
|
33
|
+
```
|
|
34
|
+
|
|
35
|
+
## Quick Start
|
|
36
|
+
|
|
37
|
+
### 1. Import CSS
|
|
38
|
+
|
|
39
|
+
Import the global styles in your application entry point:
|
|
40
|
+
|
|
41
|
+
```tsx
|
|
42
|
+
// In your main CSS file or entry point
|
|
43
|
+
import '@a11ypros/a11y-ui-components/styles';
|
|
44
|
+
```
|
|
45
|
+
|
|
46
|
+
Or import component-specific styles:
|
|
47
|
+
|
|
48
|
+
```tsx
|
|
49
|
+
import '@a11ypros/a11y-ui-components/styles/components';
|
|
50
|
+
```
|
|
51
|
+
|
|
52
|
+
### 2. Import and Use Components
|
|
53
|
+
|
|
54
|
+
```tsx
|
|
55
|
+
import { Button, Input, Modal } from '@a11ypros/a11y-ui-components';
|
|
56
|
+
|
|
57
|
+
function App() {
|
|
58
|
+
return (
|
|
59
|
+
<div>
|
|
60
|
+
<Button>Click me</Button>
|
|
61
|
+
<Input label="Email" type="email" />
|
|
62
|
+
<Modal isOpen={true} onClose={() => {}}>
|
|
63
|
+
<p>Modal content</p>
|
|
64
|
+
</Modal>
|
|
65
|
+
</div>
|
|
66
|
+
);
|
|
67
|
+
}
|
|
68
|
+
```
|
|
69
|
+
|
|
70
|
+
## Available Components
|
|
71
|
+
|
|
72
|
+
### Form Components
|
|
73
|
+
- **Input** - Accessible text input with label and error handling
|
|
74
|
+
- **Textarea** - Multi-line text input
|
|
75
|
+
- **Select** - Dropdown select with keyboard navigation
|
|
76
|
+
- **Checkbox** - Accessible checkbox with proper labeling
|
|
77
|
+
- **Radio** - Radio button group with fieldset support
|
|
78
|
+
- **Label** - Accessible form label component
|
|
79
|
+
- **Fieldset** - Form fieldset for grouping related inputs
|
|
80
|
+
|
|
81
|
+
### UI Components
|
|
82
|
+
- **Button** - Accessible button with multiple variants
|
|
83
|
+
- **Link** - Accessible link component
|
|
84
|
+
- **Modal** - Accessible modal dialog with focus trap
|
|
85
|
+
- **Tabs** - Keyboard-navigable tab component
|
|
86
|
+
- **DataTable** - Accessible data table with sorting
|
|
87
|
+
- **Toast** - Accessible toast notification system
|
|
88
|
+
- **ToastProvider** - Context provider for toast notifications
|
|
89
|
+
|
|
90
|
+
### Hooks
|
|
91
|
+
- **useFocusTrap** - Trap focus within a container
|
|
92
|
+
- **useFocusReturn** - Return focus to previous element
|
|
93
|
+
- **useAriaLive** - Manage ARIA live regions for announcements
|
|
94
|
+
|
|
95
|
+
### Utilities
|
|
96
|
+
- **aria** - ARIA attribute utilities
|
|
97
|
+
- **keyboard** - Keyboard event utilities
|
|
98
|
+
- **focus** - Focus management utilities
|
|
99
|
+
|
|
100
|
+
### Design Tokens
|
|
101
|
+
- **colors** - Color palette and theme tokens
|
|
102
|
+
- **typography** - Typography scale and font tokens
|
|
103
|
+
- **spacing** - Spacing scale tokens
|
|
104
|
+
- **breakpoints** - Responsive breakpoint tokens
|
|
105
|
+
- **motion** - Animation and transition tokens
|
|
106
|
+
|
|
107
|
+
## Documentation
|
|
108
|
+
|
|
109
|
+
📚 **[View Full Documentation & Storybook](https://ui.a11ypros.com/storybook)**
|
|
110
|
+
|
|
111
|
+
Browse all components, see live examples, and explore accessibility features in our interactive Storybook documentation.
|
|
112
|
+
|
|
113
|
+
## Usage Examples
|
|
114
|
+
|
|
115
|
+
### Form with Validation
|
|
116
|
+
|
|
117
|
+
```tsx
|
|
118
|
+
import { Input, Button, Label } from '@a11ypros/a11y-ui-components';
|
|
119
|
+
|
|
120
|
+
function LoginForm() {
|
|
121
|
+
const [email, setEmail] = useState('');
|
|
122
|
+
const [error, setError] = useState('');
|
|
123
|
+
|
|
124
|
+
return (
|
|
125
|
+
<form>
|
|
126
|
+
<Input
|
|
127
|
+
label="Email"
|
|
128
|
+
type="email"
|
|
129
|
+
value={email}
|
|
130
|
+
onChange={(e) => setEmail(e.target.value)}
|
|
131
|
+
error={error}
|
|
132
|
+
required
|
|
133
|
+
/>
|
|
134
|
+
<Button type="submit">Sign In</Button>
|
|
135
|
+
</form>
|
|
136
|
+
);
|
|
137
|
+
}
|
|
138
|
+
```
|
|
139
|
+
|
|
140
|
+
### Modal Dialog
|
|
141
|
+
|
|
142
|
+
```tsx
|
|
143
|
+
import { Modal, Button } from '@a11ypros/a11y-ui-components';
|
|
144
|
+
import { useState } from 'react';
|
|
145
|
+
|
|
146
|
+
function App() {
|
|
147
|
+
const [isOpen, setIsOpen] = useState(false);
|
|
148
|
+
|
|
149
|
+
return (
|
|
150
|
+
<>
|
|
151
|
+
<Button onClick={() => setIsOpen(true)}>Open Modal</Button>
|
|
152
|
+
<Modal
|
|
153
|
+
isOpen={isOpen}
|
|
154
|
+
onClose={() => setIsOpen(false)}
|
|
155
|
+
title="Confirm Action"
|
|
156
|
+
>
|
|
157
|
+
<p>Are you sure you want to proceed?</p>
|
|
158
|
+
<Button onClick={() => setIsOpen(false)}>Confirm</Button>
|
|
159
|
+
</Modal>
|
|
160
|
+
</>
|
|
161
|
+
);
|
|
162
|
+
}
|
|
163
|
+
```
|
|
164
|
+
|
|
165
|
+
### Toast Notifications
|
|
166
|
+
|
|
167
|
+
```tsx
|
|
168
|
+
import { ToastProvider, useToast, Button } from '@a11ypros/a11y-ui-components';
|
|
169
|
+
|
|
170
|
+
function App() {
|
|
171
|
+
return (
|
|
172
|
+
<ToastProvider>
|
|
173
|
+
<MyComponent />
|
|
174
|
+
</ToastProvider>
|
|
175
|
+
);
|
|
176
|
+
}
|
|
177
|
+
|
|
178
|
+
function MyComponent() {
|
|
179
|
+
const { addToast } = useToast();
|
|
180
|
+
|
|
181
|
+
return (
|
|
182
|
+
<Button
|
|
183
|
+
onClick={() =>
|
|
184
|
+
addToast({
|
|
185
|
+
message: 'Action completed successfully!',
|
|
186
|
+
type: 'success',
|
|
187
|
+
})
|
|
188
|
+
}
|
|
189
|
+
>
|
|
190
|
+
Show Toast
|
|
191
|
+
</Button>
|
|
192
|
+
);
|
|
193
|
+
}
|
|
194
|
+
```
|
|
195
|
+
|
|
196
|
+
## Important Note on Accessibility
|
|
197
|
+
|
|
198
|
+
> **Note**: While these components are built with accessibility in mind and meet WCAG 2.1/2.2 Level AA standards, **simply using these components does not guarantee an accessible application**. These components are foundational building blocks that must be used properly within the larger consuming application with accessibility in mind.
|
|
199
|
+
|
|
200
|
+
To ensure your application is truly accessible, consider:
|
|
201
|
+
|
|
202
|
+
- **Proper Implementation**: Use components according to their documented patterns and accessibility guidelines
|
|
203
|
+
- **Application-Level Considerations**: Ensure proper page structure, heading hierarchy, and landmark regions
|
|
204
|
+
- **Content Accessibility**: Write clear, descriptive text and provide alternative text for images
|
|
205
|
+
- **Testing**: Regularly test your application with keyboard navigation and screen readers
|
|
206
|
+
- **User Experience**: Consider the full user journey and how components work together
|
|
207
|
+
|
|
208
|
+
## Internationalization (i18n)
|
|
209
|
+
|
|
210
|
+
Currently, all screen reader text and ARIA labels are provided in English. Full i18n support is a high-priority feature coming soon to ensure global accessibility.
|
|
211
|
+
|
|
212
|
+
## Tree Shaking
|
|
213
|
+
|
|
214
|
+
This package is fully tree-shakeable. Import only what you need:
|
|
215
|
+
|
|
216
|
+
```tsx
|
|
217
|
+
// ✅ Good - tree-shakeable
|
|
218
|
+
import { Button } from '@a11ypros/a11y-ui-components';
|
|
219
|
+
|
|
220
|
+
// ✅ Also good - import specific utilities
|
|
221
|
+
import { useFocusTrap } from '@a11ypros/a11y-ui-components';
|
|
222
|
+
```
|
|
223
|
+
|
|
224
|
+
## TypeScript Support
|
|
225
|
+
|
|
226
|
+
Full TypeScript definitions are included. No need to install `@types` packages.
|
|
227
|
+
|
|
228
|
+
```tsx
|
|
229
|
+
import { Button, ButtonProps } from '@a11ypros/a11y-ui-components';
|
|
230
|
+
|
|
231
|
+
const props: ButtonProps = {
|
|
232
|
+
variant: 'primary',
|
|
233
|
+
size: 'medium',
|
|
234
|
+
children: 'Click me',
|
|
235
|
+
};
|
|
236
|
+
```
|
|
237
|
+
|
|
238
|
+
## Contributing
|
|
239
|
+
|
|
240
|
+
Contributions are welcome! Please see our [GitHub repository](https://github.com/ryan0122/a11ypros-components) for contribution guidelines.
|
|
241
|
+
|
|
242
|
+
## License
|
|
243
|
+
|
|
244
|
+
MIT © [A11y Pros](https://a11ypros.com)
|
|
245
|
+
|
|
246
|
+
## Links
|
|
247
|
+
|
|
248
|
+
- 📦 [npm package](https://www.npmjs.com/package/@a11ypros/a11y-ui-components)
|
|
249
|
+
- 📚 [Documentation & Storybook](https://ui.a11ypros.com/storybook)
|
|
250
|
+
- 🐛 [Issue Tracker](https://github.com/ryan0122/a11ypros-components/issues)
|
|
251
|
+
- 💻 [Source Code](https://github.com/ryan0122/a11ypros-components)
|
|
252
|
+
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@a11ypros/a11y-ui-components",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.2",
|
|
4
4
|
"description": "An accessibility-first React UI component library built with WCAG 2.1/2.2 compliance",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"react",
|
|
@@ -65,4 +65,3 @@
|
|
|
65
65
|
"typescript": "^5.3.3"
|
|
66
66
|
}
|
|
67
67
|
}
|
|
68
|
-
|