@a11y-hud/react 0.2.0 → 0.2.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.
Files changed (3) hide show
  1. package/LICENSE +0 -5
  2. package/README.md +93 -0
  3. package/package.json +2 -2
package/LICENSE CHANGED
@@ -19,8 +19,3 @@ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
19
  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
20
  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
21
  SOFTWARE.
22
-
23
- ---
24
-
25
- This software includes icons from Lucide (https://lucide.dev/).
26
- See LICENSE-ICONS.md for details.
package/README.md ADDED
@@ -0,0 +1,93 @@
1
+ # @a11y-hud/react
2
+
3
+ React adapter for [a11y-hud](https://www.npmjs.com/package/a11y-hud) — run axe-core accessibility audits in your React app with no browser extension required.
4
+
5
+ ## Install
6
+
7
+ ```sh
8
+ npm install a11y-hud @a11y-hud/react
9
+ ```
10
+
11
+ Peer dependencies: `react@>=18`, `react-dom@>=18`.
12
+
13
+ ## Usage
14
+
15
+ ### Component
16
+
17
+ Drop `<A11yHud />` anywhere in your React tree. It renders nothing into the React DOM — the HUD panel is appended to `document.body` as a Custom Element.
18
+
19
+ ```tsx
20
+ import { A11yHud } from "@a11y-hud/react";
21
+
22
+ export function App() {
23
+ return (
24
+ <>
25
+ <A11yHud theme="auto" />
26
+ {/* rest of your app */}
27
+ </>
28
+ );
29
+ }
30
+ ```
31
+
32
+ ### Hook
33
+
34
+ Use `useA11yHud` when you need programmatic access to `runScan` or `setTheme`.
35
+
36
+ ```tsx
37
+ import { useA11yHud } from "@a11y-hud/react";
38
+
39
+ function DevTools() {
40
+ const { runScan, setTheme } = useA11yHud({ theme: "auto" });
41
+
42
+ return <button onClick={() => runScan()}>Scan now</button>;
43
+ }
44
+ ```
45
+
46
+ ### Subtree scoping
47
+
48
+ Restrict the scan to a specific subtree by passing a ref.
49
+
50
+ ```tsx
51
+ import { useRef } from "react";
52
+ import { A11yHud } from "@a11y-hud/react";
53
+
54
+ function App() {
55
+ const scopeRef = useRef<HTMLDivElement>(null);
56
+
57
+ return (
58
+ <>
59
+ <A11yHud scope={scopeRef} />
60
+ <div ref={scopeRef}>
61
+ {/* only this subtree is scanned */}
62
+ </div>
63
+ </>
64
+ );
65
+ }
66
+ ```
67
+
68
+ ### Route change rescans
69
+
70
+ For React Router (or any router), ensure the component containing `<A11yHud>` re-renders on navigation so the render-settled rescan fires. The standard approach is `useLocation()`:
71
+
72
+ ```tsx
73
+ import { useLocation } from "react-router-dom";
74
+ import { A11yHud } from "@a11y-hud/react";
75
+
76
+ function AppContent() {
77
+ useLocation(); // subscribes to route changes
78
+ return <A11yHud />;
79
+ }
80
+ ```
81
+
82
+ ### Props
83
+
84
+ | Prop | Type | Default | Description |
85
+ |------|------|---------|-------------|
86
+ | `theme` | `"auto" \| "default" \| "light" \| "high-contrast"` | `"auto"` | Panel theme |
87
+ | `scope` | `RefObject<Element \| null>` | — | Restrict scan to a subtree |
88
+ | `autoScan` | `boolean` | `true` | Auto-rescan on DOM mutations |
89
+ | `debounce` | `number` | `500` | Debounce delay in ms |
90
+
91
+ ## License
92
+
93
+ MIT © Arthur Vasconcelos
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@a11y-hud/react",
3
- "version": "0.2.0",
3
+ "version": "0.2.2",
4
4
  "description": "React adapter for a11y-hud — run axe-core accessibility audits in your React app with no DevTools required.",
5
5
  "type": "module",
6
6
  "exports": {
@@ -19,7 +19,7 @@
19
19
  "README.md"
20
20
  ],
21
21
  "dependencies": {
22
- "a11y-hud": "0.1.0"
22
+ "a11y-hud": "0.1.2"
23
23
  },
24
24
  "peerDependencies": {
25
25
  "react": ">=18",