mirror of
https://github.com/binaricat/Netcatty.git
synced 2026-11-26 02:31:40 +00:00
feat(ui): improve selected protocol contrast in new connection form (#4319)
This commit is contained in:
7 files changed
+330
-217
No files matched your search
@@ -5,7 +5,11 @@ import { renderToStaticMarkup } from "react-dom/server";
|
||||
import { I18nProvider } from "../application/i18n/I18nProvider";
|
||||
import type { Host } from "../types";
|
||||
import ProtocolSelectDialog from "./ProtocolSelectDialog";
|
||||
import { PROTOCOL_VISUAL_STYLES } from "./protocolVisuals";
|
||||
import {
|
||||
PROTOCOL_OPTION_CARD_IDLE_CLASS,
|
||||
PROTOCOL_OPTION_CARD_SELECTED_CLASS,
|
||||
PROTOCOL_VISUAL_STYLES,
|
||||
} from "./protocolVisuals";
|
||||
|
||||
const host = (overrides: Partial<Host> = {}): Host => ({
|
||||
id: "host-1",
|
||||
@@ -65,10 +69,25 @@ test("plugin protocol hosts default to the plugin provider when optional built-i
|
||||
);
|
||||
|
||||
assert.ok(markup.indexOf(providerId) < markup.indexOf(">Telnet<"));
|
||||
assert.match(markup, new RegExp(`border-primary bg-primary/5[^>]*>[\\s\\S]*${providerId}`));
|
||||
const providerStart = markup.lastIndexOf("<button", markup.indexOf(providerId));
|
||||
const providerEnd = markup.indexOf("</button>", markup.indexOf(providerId));
|
||||
assert.doesNotMatch(markup.slice(providerStart, providerEnd), /type="number"/);
|
||||
const providerButton = markup.slice(providerStart, providerEnd);
|
||||
assert.match(providerButton, /aria-pressed="true"/);
|
||||
assert.match(providerButton, /data-state="active"/);
|
||||
for (const token of PROTOCOL_OPTION_CARD_SELECTED_CLASS.split(/\s+/)) {
|
||||
assert.ok(providerButton.includes(token), `expected active plugin protocol card to include ${token}`);
|
||||
}
|
||||
assert.doesNotMatch(providerButton, /type="number"/);
|
||||
assert.equal((markup.match(/type="number"/g) ?? []).length, 3);
|
||||
assert.doesNotMatch(markup, /10\.2\.0\.31:22/);
|
||||
|
||||
const telnetStart = markup.lastIndexOf("<button", markup.indexOf(">Telnet<"));
|
||||
const telnetEnd = markup.indexOf("</button>", markup.indexOf(">Telnet<"));
|
||||
const telnetButton = markup.slice(telnetStart, telnetEnd);
|
||||
assert.match(telnetButton, /aria-pressed="false"/);
|
||||
assert.match(telnetButton, /data-state="inactive"/);
|
||||
for (const token of PROTOCOL_OPTION_CARD_IDLE_CLASS.split(/\s+/)) {
|
||||
assert.ok(telnetButton.includes(token), `expected idle Telnet card to include ${token}`);
|
||||
}
|
||||
assert.ok(!telnetButton.includes("border-primary"));
|
||||
});
|
||||
@@ -5,7 +5,15 @@ import { formatHostPort } from "../domain/host";
|
||||
import { isPluginHostProtocol } from "../domain/pluginConnection";
|
||||
import { cn } from "../lib/utils";
|
||||
import { Host, HostProtocol } from "../types";
|
||||
import { getProtocolVisualStyle, type ProtocolVisualKey } from "./protocolVisuals";
|
||||
import {
|
||||
getProtocolOptionCardClass,
|
||||
getProtocolVisualStyle,
|
||||
PROTOCOL_OPTION_SUBTITLE_IDLE_CLASS,
|
||||
PROTOCOL_OPTION_SUBTITLE_SELECTED_CLASS,
|
||||
PROTOCOL_OPTION_TITLE_IDLE_CLASS,
|
||||
PROTOCOL_OPTION_TITLE_SELECTED_CLASS,
|
||||
type ProtocolVisualKey,
|
||||
} from "./protocolVisuals";
|
||||
import { Button } from "./ui/button";
|
||||
import { Input } from "./ui/input";
|
||||
|
||||
@@ -157,36 +165,50 @@ const ProtocolSelectDialog: React.FC<ProtocolSelectDialogProps> = ({
|
||||
<h3 className="text-sm font-medium">{t("protocolSelect.chooseProtocol")}</h3>
|
||||
<div className="space-y-3">
|
||||
{protocolOptions.map((option) => {
|
||||
const isSelected = selectedProtocol === option.protocol;
|
||||
const visual = isPluginHostProtocol(option.protocol)
|
||||
? {
|
||||
icon: <Plug size={18} />,
|
||||
selected: "bg-primary text-primary-foreground",
|
||||
selected: "bg-primary text-primary-foreground shadow-sm",
|
||||
idle: "bg-secondary text-muted-foreground",
|
||||
}
|
||||
: getProtocolVisualStyle(option.protocol as ProtocolVisualKey);
|
||||
return (
|
||||
<button
|
||||
key={option.protocol}
|
||||
className={cn(
|
||||
"w-full flex items-center justify-between px-4 py-3 rounded-xl border-2 transition-all text-left",
|
||||
selectedProtocol === option.protocol
|
||||
? "border-primary bg-primary/5"
|
||||
: "border-border/60 hover:border-border hover:bg-secondary/50",
|
||||
)}
|
||||
type="button"
|
||||
aria-pressed={isSelected}
|
||||
data-state={isSelected ? "active" : "inactive"}
|
||||
data-protocol={option.protocol}
|
||||
className={getProtocolOptionCardClass(isSelected)}
|
||||
onClick={() => setSelectedProtocol(option.protocol)}
|
||||
>
|
||||
<div className="flex items-center gap-3">
|
||||
<div
|
||||
className={cn(
|
||||
"h-10 w-10 rounded-lg flex items-center justify-center",
|
||||
selectedProtocol === option.protocol ? visual.selected : visual.idle,
|
||||
"h-10 w-10 rounded-lg flex items-center justify-center transition-colors",
|
||||
isSelected ? visual.selected : visual.idle,
|
||||
)}
|
||||
>
|
||||
{visual.icon}
|
||||
</div>
|
||||
<div>
|
||||
<div className="font-medium">{option.label}</div>
|
||||
<div className="text-xs text-muted-foreground font-mono">
|
||||
<div
|
||||
className={
|
||||
isSelected
|
||||
? PROTOCOL_OPTION_TITLE_SELECTED_CLASS
|
||||
: PROTOCOL_OPTION_TITLE_IDLE_CLASS
|
||||
}
|
||||
>
|
||||
{option.label}
|
||||
</div>
|
||||
<div
|
||||
className={
|
||||
isSelected
|
||||
? PROTOCOL_OPTION_SUBTITLE_SELECTED_CLASS
|
||||
: PROTOCOL_OPTION_SUBTITLE_IDLE_CLASS
|
||||
}
|
||||
>
|
||||
{option.description}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -209,6 +209,31 @@ test("explicit Close dismisses the protocol step", async () => {
|
||||
});
|
||||
});
|
||||
|
||||
test("switching protocol options updates aria-pressed, data-state, and active contrast classes", async () => {
|
||||
await withWizard(async (f) => {
|
||||
const ssh = document.querySelector<HTMLButtonElement>('button[data-protocol="ssh"]')!;
|
||||
const telnet = document.querySelector<HTMLButtonElement>('button[data-protocol="telnet"]')!;
|
||||
assert.ok(ssh && telnet);
|
||||
|
||||
assert.equal(ssh.getAttribute("aria-pressed"), "true");
|
||||
assert.equal(ssh.getAttribute("data-state"), "active");
|
||||
assert.ok(ssh.className.includes("border-primary"));
|
||||
assert.equal(telnet.getAttribute("aria-pressed"), "false");
|
||||
assert.equal(telnet.getAttribute("data-state"), "inactive");
|
||||
assert.ok(!telnet.className.includes("border-primary"));
|
||||
|
||||
await f.click(telnet);
|
||||
|
||||
assert.equal(telnet.getAttribute("aria-pressed"), "true");
|
||||
assert.equal(telnet.getAttribute("data-state"), "active");
|
||||
assert.ok(telnet.className.includes("border-primary"));
|
||||
assert.ok(telnet.className.includes("ring-primary/30"));
|
||||
assert.equal(ssh.getAttribute("aria-pressed"), "false");
|
||||
assert.equal(ssh.getAttribute("data-state"), "inactive");
|
||||
assert.ok(!ssh.className.includes("border-primary"));
|
||||
});
|
||||
});
|
||||
|
||||
for (const step of ["username", "auth"]) {
|
||||
test(`the header X explicitly closes the ${step} step`, async () => {
|
||||
await withWizard(async (f) => {
|
||||
|
||||
@@ -1,10 +1,20 @@
|
||||
import assert from "node:assert/strict";
|
||||
import { readFile } from "node:fs/promises";
|
||||
import path from "node:path";
|
||||
import test from "node:test";
|
||||
import { compile } from "@tailwindcss/node";
|
||||
import postcss from "postcss";
|
||||
import React from "react";
|
||||
import { renderToStaticMarkup } from "react-dom/server";
|
||||
import { I18nProvider } from "../application/i18n/I18nProvider";
|
||||
import QuickConnectWizard from "./QuickConnectWizard";
|
||||
import { PROTOCOL_VISUAL_STYLES } from "./protocolVisuals";
|
||||
import {
|
||||
PROTOCOL_OPTION_CARD_IDLE_CLASS,
|
||||
PROTOCOL_OPTION_CARD_SELECTED_CLASS,
|
||||
PROTOCOL_OPTION_TITLE_IDLE_CLASS,
|
||||
PROTOCOL_OPTION_TITLE_SELECTED_CLASS,
|
||||
PROTOCOL_VISUAL_STYLES,
|
||||
} from "./protocolVisuals";
|
||||
|
||||
test("QuickConnectWizard offers ET without obsolete Mosh path or log controls", () => {
|
||||
const markup = renderToStaticMarkup(
|
||||
@@ -103,3 +113,85 @@ test("quick connect credential section title matches protocol section title styl
|
||||
assert.match(markup, /text-sm font-medium[^>]*>Credential preset</);
|
||||
});
|
||||
|
||||
test("quick connect gives the selected protocol option high-contrast active styling distinct from idle options", () => {
|
||||
const markup = renderToStaticMarkup(
|
||||
<I18nProvider locale="en">
|
||||
<QuickConnectWizard
|
||||
open
|
||||
target={{ hostname: "192.168.1.1" }}
|
||||
keys={[]}
|
||||
identities={[]}
|
||||
onConnect={() => undefined}
|
||||
onClose={() => undefined}
|
||||
/>
|
||||
</I18nProvider>,
|
||||
);
|
||||
|
||||
const buttonMatches = [...markup.matchAll(/<button[^>]*data-protocol="(ssh|mosh|et|telnet)"[^>]*>[\s\S]*?<\/button>/g)];
|
||||
assert.equal(buttonMatches.length, 4);
|
||||
|
||||
const byProtocol = new Map(buttonMatches.map((match) => [match[1], match[0]]));
|
||||
const sshButton = byProtocol.get("ssh")!;
|
||||
assert.match(sshButton, /aria-pressed="true"/);
|
||||
assert.match(sshButton, /data-state="active"/);
|
||||
for (const token of PROTOCOL_OPTION_CARD_SELECTED_CLASS.split(/\s+/)) {
|
||||
assert.ok(sshButton.includes(token), `expected selected SSH card to include ${token}`);
|
||||
}
|
||||
assert.ok(sshButton.includes(PROTOCOL_OPTION_TITLE_SELECTED_CLASS));
|
||||
assert.ok(!sshButton.includes(PROTOCOL_OPTION_CARD_IDLE_CLASS));
|
||||
|
||||
for (const idleProtocol of ["mosh", "et", "telnet"] as const) {
|
||||
const idleButton = byProtocol.get(idleProtocol)!;
|
||||
assert.match(idleButton, /aria-pressed="false"/);
|
||||
assert.match(idleButton, /data-state="inactive"/);
|
||||
for (const token of PROTOCOL_OPTION_CARD_IDLE_CLASS.split(/\s+/)) {
|
||||
assert.ok(idleButton.includes(token), `expected idle ${idleProtocol} card to include ${token}`);
|
||||
}
|
||||
assert.ok(idleButton.includes(PROTOCOL_OPTION_TITLE_IDLE_CLASS));
|
||||
assert.ok(!idleButton.includes("border-primary"));
|
||||
assert.ok(!idleButton.includes("ring-primary/30"));
|
||||
}
|
||||
});
|
||||
|
||||
test("global index.css keeps default border-color in @layer base so border-primary utilities take precedence", async () => {
|
||||
const source = await readFile(new URL("../index.css", import.meta.url), "utf8");
|
||||
const compiler = await compile(source, { base: path.resolve("."), onDependency() {} });
|
||||
const css = compiler.build([
|
||||
...PROTOCOL_OPTION_CARD_SELECTED_CLASS.split(/\s+/),
|
||||
...PROTOCOL_OPTION_CARD_IDLE_CLASS.split(/\s+/),
|
||||
"border-2",
|
||||
]);
|
||||
const root = postcss.parse(css);
|
||||
|
||||
let foundLayeredDefaultBorder = false;
|
||||
let foundUnlayeredUniversalBorder = false;
|
||||
let foundBorderPrimaryUtility = false;
|
||||
|
||||
root.walkRules((rule) => {
|
||||
const isUniversal = rule.selectors.some((sel) => sel.trim() === "*");
|
||||
let layerName: string | null = null;
|
||||
let parent: postcss.Node | undefined = rule.parent;
|
||||
while (parent) {
|
||||
if (parent.type === "atrule" && (parent as postcss.AtRule).name === "layer") {
|
||||
layerName = (parent as postcss.AtRule).params.trim();
|
||||
break;
|
||||
}
|
||||
parent = parent.parent;
|
||||
}
|
||||
|
||||
rule.walkDecls("border-color", (decl) => {
|
||||
if (isUniversal && decl.value.includes("var(--border)")) {
|
||||
if (layerName === "base") foundLayeredDefaultBorder = true;
|
||||
else foundUnlayeredUniversalBorder = true;
|
||||
}
|
||||
if (rule.selector.includes(".border-primary") && layerName === "utilities") {
|
||||
foundBorderPrimaryUtility = true;
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
assert.equal(foundUnlayeredUniversalBorder, false, "unlayered universal border-color would override Tailwind @layer utilities");
|
||||
assert.equal(foundLayeredDefaultBorder, true, "default border-color should remain in @layer base");
|
||||
assert.equal(foundBorderPrimaryUtility, true, ".border-primary should be generated inside @layer utilities");
|
||||
});
|
||||
|
||||
+120
-192
@@ -31,7 +31,28 @@ import { Input } from "./ui/input";
|
||||
import { Label } from "./ui/label";
|
||||
import { Dropdown, DropdownContent, DropdownTrigger } from "./ui/dropdown";
|
||||
import { ScrollArea } from "./ui/scroll-area";
|
||||
import { PROTOCOL_VISUAL_STYLES } from "./protocolVisuals";
|
||||
import {
|
||||
getProtocolOptionCardClass,
|
||||
PROTOCOL_OPTION_CARD_IDLE_CLASS,
|
||||
PROTOCOL_OPTION_CARD_SELECTED_CLASS,
|
||||
PROTOCOL_OPTION_SUBTITLE_IDLE_CLASS,
|
||||
PROTOCOL_OPTION_SUBTITLE_SELECTED_CLASS,
|
||||
PROTOCOL_OPTION_TITLE_IDLE_CLASS,
|
||||
PROTOCOL_OPTION_TITLE_SELECTED_CLASS,
|
||||
PROTOCOL_VISUAL_STYLES,
|
||||
} from "./protocolVisuals";
|
||||
|
||||
const QUICK_CONNECT_PROTOCOLS: ReadonlyArray<{
|
||||
protocol: QuickConnectProtocol;
|
||||
label: string;
|
||||
commandPrefix: string;
|
||||
defaultPort: number;
|
||||
}> = [
|
||||
{ protocol: "ssh", label: "SSH", commandPrefix: "ssh", defaultPort: 22 },
|
||||
{ protocol: "mosh", label: "Mosh", commandPrefix: "mosh", defaultPort: 22 },
|
||||
{ protocol: "et", label: "Eternal Terminal", commandPrefix: "et", defaultPort: 22 },
|
||||
{ protocol: "telnet", label: "Telnet", commandPrefix: "telnet", defaultPort: 23 },
|
||||
];
|
||||
|
||||
|
||||
|
||||
@@ -264,173 +285,66 @@ const QuickConnectWizard: React.FC<QuickConnectWizardProps> = ({
|
||||
<div className="space-y-4">
|
||||
<h3 className="text-sm font-medium">{t("protocolSelect.chooseProtocol")}</h3>
|
||||
<div className="space-y-3">
|
||||
{/* SSH */}
|
||||
<button
|
||||
className={cn(
|
||||
"w-full flex items-center justify-between px-4 py-3 rounded-xl border-2 transition-all text-left",
|
||||
protocol === "ssh"
|
||||
? "border-primary bg-primary/5"
|
||||
: "border-border/60 hover:border-border hover:bg-secondary/50",
|
||||
)}
|
||||
onClick={() => handleProtocolSelect("ssh")}
|
||||
>
|
||||
<div className="flex items-center gap-3">
|
||||
<div
|
||||
className={cn(
|
||||
"h-10 w-10 rounded-lg flex items-center justify-center",
|
||||
protocol === "ssh"
|
||||
? PROTOCOL_VISUAL_STYLES.ssh.selected
|
||||
: PROTOCOL_VISUAL_STYLES.ssh.idle,
|
||||
)}
|
||||
{QUICK_CONNECT_PROTOCOLS.map((item) => {
|
||||
const isSelected = protocol === item.protocol;
|
||||
const visual = PROTOCOL_VISUAL_STYLES[item.protocol];
|
||||
return (
|
||||
<button
|
||||
key={item.protocol}
|
||||
type="button"
|
||||
aria-pressed={isSelected}
|
||||
data-state={isSelected ? "active" : "inactive"}
|
||||
data-protocol={item.protocol}
|
||||
className={getProtocolOptionCardClass(isSelected)}
|
||||
onClick={() => handleProtocolSelect(item.protocol)}
|
||||
>
|
||||
{PROTOCOL_VISUAL_STYLES.ssh.icon}
|
||||
</div>
|
||||
<div>
|
||||
<div className="font-medium">SSH</div>
|
||||
<div className="text-xs text-muted-foreground font-mono">
|
||||
ssh {target.hostname}
|
||||
<div className="flex items-center gap-3">
|
||||
<div
|
||||
className={cn(
|
||||
"h-10 w-10 rounded-lg flex items-center justify-center transition-colors",
|
||||
isSelected ? visual.selected : visual.idle,
|
||||
)}
|
||||
>
|
||||
{visual.icon}
|
||||
</div>
|
||||
<div>
|
||||
<div
|
||||
className={
|
||||
isSelected
|
||||
? PROTOCOL_OPTION_TITLE_SELECTED_CLASS
|
||||
: PROTOCOL_OPTION_TITLE_IDLE_CLASS
|
||||
}
|
||||
>
|
||||
{item.label}
|
||||
</div>
|
||||
<div
|
||||
className={
|
||||
isSelected
|
||||
? PROTOCOL_OPTION_SUBTITLE_SELECTED_CLASS
|
||||
: PROTOCOL_OPTION_SUBTITLE_IDLE_CLASS
|
||||
}
|
||||
>
|
||||
{item.commandPrefix} {target.hostname}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div className="flex items-center gap-2">
|
||||
<span className="text-xs text-muted-foreground">{t("protocolSelect.port")}</span>
|
||||
<Input
|
||||
type="number"
|
||||
value={protocol === "ssh" ? port : 22}
|
||||
onChange={(e) => handleProtocolPortChange("ssh", e.target.value, 22)}
|
||||
onClick={(e) => e.stopPropagation()}
|
||||
className="w-16 h-7 text-xs text-center"
|
||||
min={1}
|
||||
max={65535}
|
||||
/>
|
||||
</div>
|
||||
</button>
|
||||
|
||||
{/* Mosh */}
|
||||
<button
|
||||
className={cn(
|
||||
"w-full flex items-center justify-between px-4 py-3 rounded-xl border-2 transition-all text-left",
|
||||
protocol === "mosh"
|
||||
? "border-primary bg-primary/5"
|
||||
: "border-border/60 hover:border-border hover:bg-secondary/50",
|
||||
)}
|
||||
onClick={() => handleProtocolSelect("mosh")}
|
||||
>
|
||||
<div className="flex items-center gap-3">
|
||||
<div
|
||||
className={cn(
|
||||
"h-10 w-10 rounded-lg flex items-center justify-center",
|
||||
protocol === "mosh"
|
||||
? PROTOCOL_VISUAL_STYLES.mosh.selected
|
||||
: PROTOCOL_VISUAL_STYLES.mosh.idle,
|
||||
)}
|
||||
>
|
||||
{PROTOCOL_VISUAL_STYLES.mosh.icon}
|
||||
</div>
|
||||
<div>
|
||||
<div className="font-medium">Mosh</div>
|
||||
<div className="text-xs text-muted-foreground font-mono">
|
||||
mosh {target.hostname}
|
||||
<div className="flex items-center gap-2">
|
||||
<span className="text-xs text-muted-foreground">{t("protocolSelect.port")}</span>
|
||||
<Input
|
||||
type="number"
|
||||
value={isSelected ? port : item.defaultPort}
|
||||
onChange={(e) =>
|
||||
handleProtocolPortChange(item.protocol, e.target.value, item.defaultPort)
|
||||
}
|
||||
onClick={(e) => e.stopPropagation()}
|
||||
className="w-16 h-7 text-xs text-center"
|
||||
min={1}
|
||||
max={65535}
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div className="flex items-center gap-2">
|
||||
<span className="text-xs text-muted-foreground">{t("protocolSelect.port")}</span>
|
||||
<Input
|
||||
type="number"
|
||||
value={protocol === "mosh" ? port : 22}
|
||||
onChange={(e) => handleProtocolPortChange("mosh", e.target.value, 22)}
|
||||
onClick={(e) => e.stopPropagation()}
|
||||
className="w-16 h-7 text-xs text-center"
|
||||
min={1}
|
||||
max={65535}
|
||||
/>
|
||||
</div>
|
||||
</button>
|
||||
|
||||
{/* Eternal Terminal */}
|
||||
<button
|
||||
className={cn(
|
||||
"w-full flex items-center justify-between px-4 py-3 rounded-xl border-2 transition-all text-left",
|
||||
protocol === "et"
|
||||
? "border-primary bg-primary/5"
|
||||
: "border-border/60 hover:border-border hover:bg-secondary/50",
|
||||
)}
|
||||
onClick={() => handleProtocolSelect("et")}
|
||||
>
|
||||
<div className="flex items-center gap-3">
|
||||
<div
|
||||
className={cn(
|
||||
"h-10 w-10 rounded-lg flex items-center justify-center",
|
||||
protocol === "et"
|
||||
? PROTOCOL_VISUAL_STYLES.et.selected
|
||||
: PROTOCOL_VISUAL_STYLES.et.idle,
|
||||
)}
|
||||
>
|
||||
{PROTOCOL_VISUAL_STYLES.et.icon}
|
||||
</div>
|
||||
<div>
|
||||
<div className="font-medium">Eternal Terminal</div>
|
||||
<div className="text-xs text-muted-foreground font-mono">
|
||||
et {target.hostname}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div className="flex items-center gap-2">
|
||||
<span className="text-xs text-muted-foreground">{t("protocolSelect.port")}</span>
|
||||
<Input
|
||||
type="number"
|
||||
value={protocol === "et" ? port : 22}
|
||||
onChange={(e) => handleProtocolPortChange("et", e.target.value, 22)}
|
||||
onClick={(e) => e.stopPropagation()}
|
||||
className="w-16 h-7 text-xs text-center"
|
||||
min={1}
|
||||
max={65535}
|
||||
/>
|
||||
</div>
|
||||
</button>
|
||||
|
||||
{/* Telnet */}
|
||||
<button
|
||||
className={cn(
|
||||
"w-full flex items-center justify-between px-4 py-3 rounded-xl border-2 transition-all text-left",
|
||||
protocol === "telnet"
|
||||
? "border-primary bg-primary/5"
|
||||
: "border-border/60 hover:border-border hover:bg-secondary/50",
|
||||
)}
|
||||
onClick={() => handleProtocolSelect("telnet")}
|
||||
>
|
||||
<div className="flex items-center gap-3">
|
||||
<div
|
||||
className={cn(
|
||||
"h-10 w-10 rounded-lg flex items-center justify-center",
|
||||
protocol === "telnet"
|
||||
? PROTOCOL_VISUAL_STYLES.telnet.selected
|
||||
: PROTOCOL_VISUAL_STYLES.telnet.idle,
|
||||
)}
|
||||
>
|
||||
{PROTOCOL_VISUAL_STYLES.telnet.icon}
|
||||
</div>
|
||||
<div>
|
||||
<div className="font-medium">Telnet</div>
|
||||
<div className="text-xs text-muted-foreground font-mono">
|
||||
telnet {target.hostname}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div className="flex items-center gap-2">
|
||||
<span className="text-xs text-muted-foreground">{t("protocolSelect.port")}</span>
|
||||
<Input
|
||||
type="number"
|
||||
value={protocol === "telnet" ? port : 23}
|
||||
onChange={(e) => handleProtocolPortChange("telnet", e.target.value, 23)}
|
||||
onClick={(e) => e.stopPropagation()}
|
||||
className="w-16 h-7 text-xs text-center"
|
||||
min={1}
|
||||
max={65535}
|
||||
/>
|
||||
</div>
|
||||
</button>
|
||||
</button>
|
||||
);
|
||||
})}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -534,6 +448,9 @@ const QuickConnectWizard: React.FC<QuickConnectWizardProps> = ({
|
||||
{/* Auth method tabs */}
|
||||
<div className="flex gap-1 p-1 bg-secondary/80 rounded-lg border border-border/60">
|
||||
<button
|
||||
type="button"
|
||||
aria-pressed={authMethod === "password"}
|
||||
data-state={authMethod === "password" ? "active" : "inactive"}
|
||||
className={cn(
|
||||
"flex-1 flex items-center justify-center gap-2 py-2 text-sm font-medium rounded-md transition-all",
|
||||
authMethod === "password"
|
||||
@@ -549,6 +466,9 @@ const QuickConnectWizard: React.FC<QuickConnectWizardProps> = ({
|
||||
{t("terminal.auth.password")}
|
||||
</button>
|
||||
<button
|
||||
type="button"
|
||||
aria-pressed={authMethod !== "password"}
|
||||
data-state={authMethod !== "password" ? "active" : "inactive"}
|
||||
className={cn(
|
||||
"flex-1 flex items-center justify-center gap-2 py-2 text-sm font-medium rounded-md transition-all",
|
||||
authMethod !== "password"
|
||||
@@ -607,38 +527,46 @@ const QuickConnectWizard: React.FC<QuickConnectWizardProps> = ({
|
||||
<div className="space-y-2">
|
||||
{keys
|
||||
.filter((k) => k.category === "key")
|
||||
.map((key) => (
|
||||
<button
|
||||
key={key.id}
|
||||
className={cn(
|
||||
"w-full flex items-center gap-3 px-3 py-2.5 rounded-lg border transition-colors text-left",
|
||||
selectedKeyId === key.id
|
||||
? "border-primary bg-primary/5"
|
||||
: "border-border/50 hover:bg-secondary/50",
|
||||
)}
|
||||
onClick={() => {
|
||||
setSelectedIdentityId(null);
|
||||
setSelectedKeyId(key.id);
|
||||
}}
|
||||
>
|
||||
<div
|
||||
.map((key) => {
|
||||
const isKeySelected = selectedKeyId === key.id;
|
||||
return (
|
||||
<button
|
||||
key={key.id}
|
||||
type="button"
|
||||
aria-pressed={isKeySelected}
|
||||
data-state={isKeySelected ? "active" : "inactive"}
|
||||
className={cn(
|
||||
"h-8 w-8 rounded-lg flex items-center justify-center",
|
||||
"bg-primary/20 text-primary",
|
||||
"w-full flex items-center gap-3 px-3 py-2.5 rounded-lg border-2 transition-all text-left",
|
||||
isKeySelected
|
||||
? PROTOCOL_OPTION_CARD_SELECTED_CLASS
|
||||
: PROTOCOL_OPTION_CARD_IDLE_CLASS,
|
||||
)}
|
||||
onClick={() => {
|
||||
setSelectedIdentityId(null);
|
||||
setSelectedKeyId(key.id);
|
||||
}}
|
||||
>
|
||||
<Key size={14} />
|
||||
</div>
|
||||
<div className="flex-1 min-w-0">
|
||||
<div className="text-sm font-medium truncate">
|
||||
{key.label}
|
||||
<div
|
||||
className={cn(
|
||||
"h-8 w-8 rounded-lg flex items-center justify-center transition-colors",
|
||||
isKeySelected
|
||||
? "bg-primary text-primary-foreground shadow-sm"
|
||||
: "bg-primary/10 text-primary",
|
||||
)}
|
||||
>
|
||||
<Key size={14} />
|
||||
</div>
|
||||
<div className="text-xs text-muted-foreground">
|
||||
Type {key.type}
|
||||
<div className="flex-1 min-w-0">
|
||||
<div className="text-sm font-medium truncate">
|
||||
{key.label}
|
||||
</div>
|
||||
<div className="text-xs text-muted-foreground">
|
||||
Type {key.type}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</button>
|
||||
))}
|
||||
</button>
|
||||
);
|
||||
})}
|
||||
</div>
|
||||
</ScrollArea>
|
||||
)}
|
||||
|
||||
@@ -15,26 +15,50 @@ export interface ProtocolVisualStyle {
|
||||
selected: string;
|
||||
}
|
||||
|
||||
export const PROTOCOL_OPTION_CARD_BASE_CLASS =
|
||||
"group w-full flex items-center justify-between px-4 py-3 rounded-xl border-2 transition-all text-left";
|
||||
|
||||
export const PROTOCOL_OPTION_CARD_SELECTED_CLASS =
|
||||
"border-primary bg-primary/12 shadow-sm ring-1 ring-primary/30";
|
||||
|
||||
export const PROTOCOL_OPTION_CARD_IDLE_CLASS =
|
||||
"border-border/60 bg-background/60 hover:border-border hover:bg-secondary/50";
|
||||
|
||||
export const PROTOCOL_OPTION_TITLE_SELECTED_CLASS = "font-semibold text-foreground";
|
||||
|
||||
export const PROTOCOL_OPTION_TITLE_IDLE_CLASS =
|
||||
"font-medium text-muted-foreground group-hover:text-foreground transition-colors";
|
||||
|
||||
export const PROTOCOL_OPTION_SUBTITLE_SELECTED_CLASS = "text-xs text-foreground/75 font-mono";
|
||||
|
||||
export const PROTOCOL_OPTION_SUBTITLE_IDLE_CLASS = "text-xs text-muted-foreground font-mono";
|
||||
|
||||
export function getProtocolOptionCardClass(selected: boolean): string {
|
||||
return `${PROTOCOL_OPTION_CARD_BASE_CLASS} ${
|
||||
selected ? PROTOCOL_OPTION_CARD_SELECTED_CLASS : PROTOCOL_OPTION_CARD_IDLE_CLASS
|
||||
}`;
|
||||
}
|
||||
|
||||
export const PROTOCOL_VISUAL_STYLES: Record<ProtocolVisualKey, ProtocolVisualStyle> = {
|
||||
ssh: {
|
||||
icon: <Shield size={18} />,
|
||||
idle: "bg-sky-500/10 text-sky-500",
|
||||
selected: "bg-sky-500/20 text-sky-500",
|
||||
selected: "bg-sky-500 text-white shadow-sm",
|
||||
},
|
||||
mosh: {
|
||||
icon: <Radio size={18} />,
|
||||
idle: "bg-violet-500/10 text-violet-500",
|
||||
selected: "bg-violet-500/20 text-violet-500",
|
||||
selected: "bg-violet-500 text-white shadow-sm",
|
||||
},
|
||||
et: {
|
||||
icon: <Link2 size={18} />,
|
||||
idle: "bg-emerald-500/10 text-emerald-500",
|
||||
selected: "bg-emerald-500/20 text-emerald-500",
|
||||
selected: "bg-emerald-500 text-white shadow-sm",
|
||||
},
|
||||
telnet: {
|
||||
icon: <TerminalIcon size={18} />,
|
||||
idle: "bg-amber-500/10 text-amber-500",
|
||||
selected: "bg-amber-500/20 text-amber-500",
|
||||
selected: "bg-amber-500 text-white shadow-sm",
|
||||
},
|
||||
};
|
||||
|
||||
|
||||
@@ -478,11 +478,14 @@ html.platform-win32 {
|
||||
color-scheme: light;
|
||||
}
|
||||
|
||||
/* Global default border color - ensures 'border' class always uses theme color */
|
||||
*,
|
||||
*::before,
|
||||
*::after {
|
||||
border-color: hsl(var(--border));
|
||||
@layer base {
|
||||
/* Global default border color - ensures 'border' class always uses theme color
|
||||
without overriding Tailwind @layer utilities border-* color classes. */
|
||||
*,
|
||||
*::before,
|
||||
*::after {
|
||||
border-color: hsl(var(--border));
|
||||
}
|
||||
}
|
||||
|
||||
body {
|
||||
|
||||
Reference in new issue
Block a user