mirror of
https://github.com/Moepchi/webspeak3.git
synced 2026-12-01 08:52:51 +08:00
GreenTeaSpeak was renamed to VoySpeak with new colours, so the theme no longer matches anything. The server tab strip that lived in the theme module moves to ConnectionTabs. A saved GreenTeaSpeak pick or custom-theme base falls back to Standard. Server-compat wording says VoySpeak. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Hu2cuPLqpuKVfd9wWFFakU
73 lines
2.1 KiB
TypeScript
73 lines
2.1 KiB
TypeScript
import { useT } from "./i18n";
|
||
|
||
export type ConnectionTabItem = {
|
||
id: string;
|
||
label: string;
|
||
connected?: boolean;
|
||
connecting?: boolean;
|
||
};
|
||
|
||
/** Server tab strip for multi-join: one tab per open connection. */
|
||
export function ConnectionTabs({
|
||
tabs,
|
||
activeTabId,
|
||
onSelectTab,
|
||
onCloseTab,
|
||
}: {
|
||
tabs: ConnectionTabItem[];
|
||
activeTabId?: string | null;
|
||
onSelectTab?: (id: string) => void;
|
||
onCloseTab?: (id: string) => void;
|
||
}) {
|
||
const t = useT();
|
||
return (
|
||
<div
|
||
className="gts-connection-tabs"
|
||
role="tablist"
|
||
aria-label={t("tabs.connections")}
|
||
>
|
||
{tabs.map((tab) => {
|
||
const isActive = tab.id === (activeTabId ?? tabs[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>
|
||
);
|
||
}
|