fix(webui): streamline the connection screen

This commit is contained in:
chengyongru authored and chengyongru committed 2026-09-14 11:22:47 +08:00
1 parent 08b130cdd1
commit 15976ac559
14 files changed
+308 -127

No files matched your search

+17 -3
View File
@@ -1,17 +1,31 @@
import { useState } from "react";
import { useTranslation } from "react-i18next";
import { currentLocale, setAppLanguage } from "@/i18n";
import { supportedLocales, type SupportedLocale } from "@/i18n/config";
import { cn } from "@/lib/utils";
import { Select, SelectContent, SelectItem, SelectTrigger, SelectValue } from "@/components/ui/select";
export function LanguageSwitcher() {
export function LanguageSwitcher({ className }: { className?: string }) {
const { t } = useTranslation();
const [pointerFocus, setPointerFocus] = useState(false);
return (
<Select value={currentLocale()} onValueChange={(value) => { void setAppLanguage(value as SupportedLocale); }}>
<SelectTrigger className="min-w-40 rounded-full" aria-label={t("sidebar.language.ariaLabel")}>
<SelectTrigger
className={cn("min-w-40 rounded-full", pointerFocus && "focus-visible:ring-0", className)}
aria-label={t("sidebar.language.ariaLabel")}
onPointerDown={() => setPointerFocus(true)}
onKeyDown={() => setPointerFocus(false)}
onBlur={() => setPointerFocus(false)}
>
<SelectValue />
</SelectTrigger>
<SelectContent>
<SelectContent
onPointerUpCapture={() => setPointerFocus(true)}
onPointerDownOutside={() => setPointerFocus(true)}
onKeyDownCapture={() => setPointerFocus(false)}
onEscapeKeyDown={() => setPointerFocus(false)}
>
{supportedLocales.map((option) => (
<SelectItem key={option.code} value={option.code}>{option.nativeLabel}</SelectItem>
))}
+5 -2
View File
@@ -21,11 +21,14 @@ export const SelectTrigger = React.forwardRef<
));
SelectTrigger.displayName = "SelectTrigger";
export function SelectContent({ children }: { children: React.ReactNode }) {
export function SelectContent({ children, ...props }: Pick<
React.ComponentPropsWithoutRef<typeof SelectPrimitive.Content>,
"children" | "onPointerUpCapture" | "onPointerDownOutside" | "onKeyDownCapture" | "onEscapeKeyDown"
>) {
const container = useFloatingPortal();
return (
<SelectPrimitive.Portal container={container ?? undefined}>
<SelectPrimitive.Content position="item-aligned" className={cn("z-50 max-h-[min(24rem,calc(100dvh-2rem))] min-w-[10rem] overflow-hidden rounded-control border border-transparent", floatingSurfaceElevationClassName)}>
<SelectPrimitive.Content {...props} position="item-aligned" className={cn("z-50 max-h-[min(24rem,calc(100dvh-2rem))] min-w-[10rem] overflow-hidden rounded-control border border-transparent", floatingSurfaceElevationClassName)}>
<SelectPrimitive.ScrollUpButton className="flex h-6 items-center justify-center"><ChevronUp className="h-3.5 w-3.5" /></SelectPrimitive.ScrollUpButton>
<SelectPrimitive.Viewport className="p-1">
{children}