Skip to content

Commit 782b395

Browse files
Ajit Pratap Singhclaude
authored andcommitted
fix(website): fix playground accessibility for Lighthouse ≥0.95 (WCAG tabpanel, labels, ARIA)
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
1 parent 49d5cb7 commit 782b395

2 files changed

Lines changed: 17 additions & 6 deletions

File tree

website/src/components/playground/Playground.tsx

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -112,14 +112,21 @@ export default function Playground() {
112112
return (
113113
<div className="flex items-center justify-center h-full bg-[#09090b]">
114114
<div className="text-center space-y-4 max-w-xs">
115-
<div className="inline-block w-8 h-8 border-2 border-blue-500 border-t-transparent rounded-full animate-spin" />
115+
<div className="inline-block w-8 h-8 border-2 border-blue-500 border-t-transparent rounded-full animate-spin" role="status" aria-label="Loading SQL parser" />
116116
<p className="text-slate-400 text-sm">
117117
{progress < 1
118118
? `Downloading SQL parser... ${Math.round(progress * 100)}%`
119119
: "Initializing..."}
120120
</p>
121121
{progress > 0 && progress < 1 && (
122-
<div className="w-full bg-slate-700 rounded-full h-1.5">
122+
<div
123+
className="w-full bg-slate-700 rounded-full h-1.5"
124+
role="progressbar"
125+
aria-valuenow={Math.round(progress * 100)}
126+
aria-valuemin={0}
127+
aria-valuemax={100}
128+
aria-label="Download progress"
129+
>
123130
<div
124131
className="bg-blue-500 h-1.5 rounded-full transition-all duration-300"
125132
style={{ width: `${progress * 100}%` }}
@@ -171,7 +178,7 @@ export default function Playground() {
171178
</label>
172179
</div>
173180
<div className="flex items-center gap-1.5">
174-
<span className="w-2 h-2 rounded-full bg-green-500" />
181+
<span className="w-2 h-2 rounded-full bg-green-500" aria-hidden="true" />
175182
<span className="text-xs text-slate-500">WASM Ready</span>
176183
</div>
177184
</div>
@@ -196,12 +203,14 @@ export default function Playground() {
196203
{/* Right panel - Tabs + Content */}
197204
<div className="w-full md:w-1/2 flex flex-col min-h-0">
198205
{/* Tab bar with animated underline */}
199-
<div className="flex border-b border-slate-800 bg-slate-900/30" role="tablist">
206+
<div className="flex border-b border-slate-800 bg-slate-900/30" role="tablist" aria-label="Output format">
200207
{TABS.map((tab) => (
201208
<button
202209
key={tab.id}
210+
id={`tab-${tab.id}`}
203211
role="tab"
204212
aria-selected={activeTab === tab.id}
213+
aria-controls={`tabpanel-${tab.id}`}
205214
onClick={() => setActiveTab(tab.id)}
206215
className={`px-4 py-3 text-sm font-medium transition-colors relative ${
207216
activeTab === tab.id
@@ -222,7 +231,7 @@ export default function Playground() {
222231
</div>
223232

224233
{/* Tab content */}
225-
<div className="flex-1 overflow-auto min-h-0" role="tabpanel">
234+
<div className="flex-1 overflow-auto min-h-0" role="tabpanel" id={`tabpanel-${activeTab}`} aria-labelledby={`tab-${activeTab}`}>
226235
{activeTab === "ast" && <AstTab data={results.ast} />}
227236
{activeTab === "format" && <FormatTab data={results.format} />}
228237
{activeTab === "lint" && <LintTab data={results.lint} />}

website/src/components/playground/SqlEditor.tsx

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ interface SqlEditorProps {
1717
placeholder?: string;
1818
readOnly?: boolean;
1919
minHeight?: string;
20+
ariaLabel?: string;
2021
}
2122

2223
const baseTheme = EditorView.theme({
@@ -49,6 +50,7 @@ export default function SqlEditor({
4950
placeholder = "",
5051
readOnly = false,
5152
minHeight = "200px",
53+
ariaLabel = "SQL editor",
5254
}: SqlEditorProps) {
5355
const containerRef = useRef<HTMLDivElement>(null);
5456
const viewRef = useRef<EditorView | null>(null);
@@ -144,5 +146,5 @@ export default function SqlEditor({
144146
}
145147
}, [value]);
146148

147-
return <div ref={containerRef} style={{ maxWidth: "100%", overflow: "hidden" }} />;
149+
return <div ref={containerRef} style={{ maxWidth: "100%", overflow: "hidden" }} aria-label={ariaLabel || placeholder || "SQL editor"} />;
148150
}

0 commit comments

Comments
 (0)