mirror of
https://github.com/farion1231/cc-switch.git
synced 2026-07-25 13:45:03 +08:00
bb2756d0fb
Replace hardcoded Tailwind color classes with design system CSS variables to improve text visibility in dark mode: - text-gray-900 dark:text-gray-100 → text-foreground - text-gray-500/600 dark:text-gray-400 → text-muted-foreground - bg-white dark:bg-gray-800 → bg-background
66 lines
1.7 KiB
TypeScript
66 lines
1.7 KiB
TypeScript
import { useTranslation } from "react-i18next";
|
|
import { FormLabel } from "@/components/ui/form";
|
|
import { Input } from "@/components/ui/input";
|
|
import { Zap } from "lucide-react";
|
|
|
|
interface EndpointFieldProps {
|
|
id: string;
|
|
label: string;
|
|
value: string;
|
|
onChange: (value: string) => void;
|
|
placeholder: string;
|
|
hint?: string;
|
|
showManageButton?: boolean;
|
|
onManageClick?: () => void;
|
|
manageButtonLabel?: string;
|
|
}
|
|
|
|
export function EndpointField({
|
|
id,
|
|
label,
|
|
value,
|
|
onChange,
|
|
placeholder,
|
|
hint,
|
|
showManageButton = true,
|
|
onManageClick,
|
|
manageButtonLabel,
|
|
}: EndpointFieldProps) {
|
|
const { t } = useTranslation();
|
|
|
|
const defaultManageLabel = t("providerForm.manageAndTest", {
|
|
defaultValue: "管理和测速",
|
|
});
|
|
|
|
return (
|
|
<div className="space-y-2">
|
|
<div className="flex items-center justify-between">
|
|
<FormLabel htmlFor={id}>{label}</FormLabel>
|
|
{showManageButton && onManageClick && (
|
|
<button
|
|
type="button"
|
|
onClick={onManageClick}
|
|
className="flex items-center gap-1 text-xs text-muted-foreground hover:text-foreground transition-colors"
|
|
>
|
|
<Zap className="h-3.5 w-3.5" />
|
|
{manageButtonLabel || defaultManageLabel}
|
|
</button>
|
|
)}
|
|
</div>
|
|
<Input
|
|
id={id}
|
|
type="url"
|
|
value={value}
|
|
onChange={(e) => onChange(e.target.value)}
|
|
placeholder={placeholder}
|
|
autoComplete="off"
|
|
/>
|
|
{hint ? (
|
|
<div className="p-3 bg-amber-50 dark:bg-amber-900/20 border border-amber-200 dark:border-amber-700 rounded-lg">
|
|
<p className="text-xs text-amber-600 dark:text-amber-400">{hint}</p>
|
|
</div>
|
|
) : null}
|
|
</div>
|
|
);
|
|
}
|