mirror of
https://github.com/Moepchi/webspeak3.git
synced 2026-12-03 18:02:49 +08:00
Accessibility stage 2. - The channel tree is an ARIA tree with one Tab stop. Up/Down/Home/End walk the visible rows, Left/Right collapse, expand, or jump to parent and first child, and selection follows focus. The server row is focusable too. - Menu bar entries are buttons with aria-expanded. Dropdown and context menus focus their first item on open, move with the arrow keys (except inside the volume slider), and Escape returns focus to the opener. - Bookmark and contact list items, chat tabs and server tabs work from the keyboard (Delete closes a tab, since its × can't be a nested button). - <main> landmark and a level-1 heading for screen-reader navigation. An axe-core scan of the connected UI in every built-in design turned up contrast failures, three of them real bugs: the active server tab, the update toast and the feedback bubble sit on a fixed dark background but used the theme's text colour, so the light theme showed dark-on-dark text. Also darkens the light theme's muted text, the donate button, and lifts GreenTeaSpeak's muted grey to 4.5:1 (its selection colour stays native). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Hu2cuPLqpuKVfd9wWFFakU
99 lines
3.1 KiB
TypeScript
99 lines
3.1 KiB
TypeScript
import type { ReactNode } from "react";
|
||
import { useT } from "../../i18n";
|
||
|
||
export type ConnectionTabItem = {
|
||
id: string;
|
||
label: string;
|
||
connected?: boolean;
|
||
connecting?: boolean;
|
||
};
|
||
|
||
export type GreenteaSpeakChromeProps = {
|
||
/** @deprecated Prefer `tabs` + `activeTabId` for multi-join. */
|
||
connected?: boolean;
|
||
/** @deprecated Prefer `tabs`. */
|
||
serverName?: string;
|
||
tabs?: ConnectionTabItem[];
|
||
activeTabId?: string | null;
|
||
onSelectTab?: (id: string) => void;
|
||
onCloseTab?: (id: string) => void;
|
||
children?: ReactNode;
|
||
};
|
||
|
||
/**
|
||
* GTS branding chrome: connection-tab strip (multi-join) + brand label when empty.
|
||
* Renders children unchanged — WebSpeak keeps its own React state/handlers.
|
||
*/
|
||
export function GreenteaSpeakChrome({
|
||
connected,
|
||
serverName,
|
||
tabs,
|
||
activeTabId,
|
||
onSelectTab,
|
||
onCloseTab,
|
||
children,
|
||
}: GreenteaSpeakChromeProps) {
|
||
const resolvedTabs: ConnectionTabItem[] =
|
||
tabs ??
|
||
(connected
|
||
? [{ id: "legacy", label: (serverName ?? "").trim() || "GreenTeaSpeak", connected: true }]
|
||
: []);
|
||
|
||
const hasTabs = resolvedTabs.length > 0;
|
||
const t = useT();
|
||
|
||
return (
|
||
<>
|
||
{hasTabs ? (
|
||
<div className="gts-connection-tabs" role="tablist" aria-label={t("tabs.connections")}>
|
||
{resolvedTabs.map((tab) => {
|
||
const isActive = tab.id === (activeTabId ?? resolvedTabs[0]?.id);
|
||
return (
|
||
<div
|
||
key={tab.id}
|
||
role="tab"
|
||
aria-selected={isActive}
|
||
className={`gts-connection-tab${isActive ? " gts-connection-tab-active" : ""}${
|
||
tab.connecting ? " gts-connection-tab-connecting" : ""
|
||
}`}
|
||
onClick={() => onSelectTab?.(tab.id)}
|
||
tabIndex={0}
|
||
aria-keyshortcuts={onCloseTab ? "Delete" : undefined}
|
||
onKeyDown={(e) => {
|
||
if (e.target !== e.currentTarget) return;
|
||
// The × below is mouse-only (a button can't sit inside a tab); Delete closes.
|
||
if (e.key === "Delete" && onCloseTab) onCloseTab(tab.id);
|
||
else if (e.key === "Enter" || e.key === " ") onSelectTab?.(tab.id);
|
||
else return;
|
||
e.preventDefault();
|
||
}}
|
||
title={tab.label}
|
||
>
|
||
<span className="gts-connection-tab-label">{tab.label}</span>
|
||
{onCloseTab ? (
|
||
<span
|
||
className="gts-connection-tab-close"
|
||
aria-hidden="true"
|
||
title={t("tabs.disconnect")}
|
||
onClick={(e) => {
|
||
e.stopPropagation();
|
||
onCloseTab(tab.id);
|
||
}}
|
||
>
|
||
×
|
||
</span>
|
||
) : null}
|
||
</div>
|
||
);
|
||
})}
|
||
</div>
|
||
) : (
|
||
<div className="gts-connection-tabs gts-brand-strip">
|
||
<span className="gts-brand-label">GreenTeaSpeak</span>
|
||
</div>
|
||
)}
|
||
{children}
|
||
</>
|
||
);
|
||
}
|