Open History to see the last commit
1import { ChangeDetectionStrategy, Component, signal } from '@angular/core'
2import type { TanStackDevtoolsAngularPlugin } from '@tanstack/angular-devtools'
3import { TanStackDevtools } from '@tanstack/angular-devtools'
4import { a11yDevtoolsPlugin } from '@tanstack/devtools-a11y/angular'
5β
6@Component({
7 selector: 'app-root',
8 imports: [TanStackDevtools],
9 template: `
10 <div style="padding: 20px; font-family: system-ui, sans-serif">
11 <h1>A11y Devtools Demo</h1>
12 <p>
13 This page contains intentional accessibility issues to demonstrate the A11y devtools plugin.
14 Open the devtools panel and click "Run Audit" to see the issues.
15 </p>
16β
17 <section style="margin-top: 24px">
18 <h2>Accessibility Issues Demo</h2>
19β
20 <!-- Issue: Image without alt text -->
21 <div style="margin-bottom: 16px">
22 <h3>1. Image without alt text</h3>
23 <img
24 src="https://via.placeholder.com/150"
25 width="150"
26 height="150"
27 style="border: 1px solid #ccc"
28 />
29 </div>
30β
31 <!-- Issue: Button without accessible name -->
32 <div style="margin-bottom: 16px">
33 <h3>2. Button without accessible name</h3>
34 <button style="width: 40px; height: 40px; font-size: 20px">
35 <span aria-hidden="true">Γ</span>
36 </button>
37 </div>
38β
39 <!-- Issue: Form input without label -->
40 <div style="margin-bottom: 16px">
41 <h3>3. Form input without label</h3>
42 <input type="text" placeholder="Enter your name" style="padding: 8px" />
43 </div>
44β
45 <!-- Issue: Low color contrast -->
46 <div style="margin-bottom: 16px">
47 <h3>4. Low color contrast</h3>
48 <p style="color: #aaa; background-color: #fff">
49 This text has poor color contrast and may be hard to read.
50 </p>
51 </div>
52β
53 <!-- Issue: Link without discernible text -->
54 <div style="margin-bottom: 16px">
55 <h3>5. Link without discernible text</h3>
56 <a href="https://example.com" style="display: inline-block">
57 <img src="https://via.placeholder.com/24" width="24" height="24" />
58 </a>
59 </div>
60β
61 <!-- Issue: Click handler on non-interactive element -->
62 <div style="margin-bottom: 16px">
63 <h3>6. Click handler on non-interactive element</h3>
64 <div
65 (click)="showModal.set(true)"
66 style="padding: 12px 24px; background-color: #0ea5e9; color: white; border-radius: 4px; display: inline-block; cursor: pointer"
67 >
68 Click me (not a button!)
69 </div>
70 </div>
71β
72 <!-- Issue: Empty heading -->
73 <div style="margin-bottom: 16px">
74 <h3>7. Empty heading</h3>
75 <h4></h4>
76 </div>
77β
78 <!-- Issue: Select without label -->
79 <div style="margin-bottom: 16px">
80 <h3>8. Select without label</h3>
81 <select style="padding: 8px">
82 <option>Option 1</option>
83 <option>Option 2</option>
84 <option>Option 3</option>
85 </select>
86 </div>
87 </section>
88β
89 <section
90 style="margin-top: 32px; padding: 16px; background-color: #f5f5f5; border-radius: 8px"
91 >
92 <h2>Accessible Content (for comparison)</h2>
93β
94 <div style="margin-bottom: 16px">
95 <h3>Proper image with alt text</h3>
96 <img
97 src="https://via.placeholder.com/150"
98 alt="Placeholder image for demonstration"
99 width="150"
100 height="150"
101 style="border: 1px solid #ccc"
102 />
103 </div>
104β
105 <div style="margin-bottom: 16px">
106 <h3>Proper button with label</h3>
107 <button aria-label="Close dialog" style="width: 40px; height: 40px; font-size: 20px">
108 <span aria-hidden="true">Γ</span>
109 </button>
110 </div>
111β
112 <div style="margin-bottom: 16px">
113 <h3>Proper input with label</h3>
114 <label for="name-input" style="display: block; margin-bottom: 4px"> Your Name </label>
115 <input id="name-input" type="text" style="padding: 8px" />
116 </div>
117 </section>
118β
119 @if (showModal()) {
120 <div
121 role="dialog"
122 aria-labelledby="modal-title"
123 style="position: fixed; top: 50%; left: 50%; transform: translate(-50%, -50%); background-color: white; padding: 24px; border-radius: 8px; box-shadow: 0 4px 20px rgba(0,0,0,0.2); z-index: 1000"
124 >
125 <h2 id="modal-title">Modal Dialog</h2>
126 <p>This is a modal that was triggered by a non-button element.</p>
127 <button (click)="showModal.set(false)">Close</button>
128 </div>
129 }
130 </div>
131β
132 @defer (when true) {
133 <tanstack-devtools [plugins]="plugins()" />
134 }
135 `,
136 changeDetection: ChangeDetectionStrategy.OnPush,
137})
138export class App {
139 readonly showModal = signal(false)
140β
141 readonly plugins = signal<TanStackDevtoolsAngularPlugin[]>([a11yDevtoolsPlugin()])
142}