refactor: Use shadcn Tabs component and fix modal styling

- Replace custom tab navigation with shadcn Tabs component
- Restore border-2 border-dark-border for modal consistency
- Remove circular icon from login success message
- Simplify authentication success display
This commit is contained in:
ZacharyZcR
2025-11-09 09:04:19 +08:00
parent fe9e392b2c
commit a6fbd00a58

View File

@@ -5,6 +5,7 @@ import { Input } from "@/components/ui/input.tsx";
import { PasswordInput } from "@/components/ui/password-input.tsx"; import { PasswordInput } from "@/components/ui/password-input.tsx";
import { Label } from "@/components/ui/label.tsx"; import { Label } from "@/components/ui/label.tsx";
import { Alert, AlertDescription, AlertTitle } from "@/components/ui/alert.tsx"; import { Alert, AlertDescription, AlertTitle } from "@/components/ui/alert.tsx";
import { Tabs, TabsList, TabsTrigger, TabsContent } from "@/components/ui/tabs.tsx";
import { useTranslation } from "react-i18next"; import { useTranslation } from "react-i18next";
import { LanguageSwitcher } from "@/ui/desktop/user/LanguageSwitcher.tsx"; import { LanguageSwitcher } from "@/ui/desktop/user/LanguageSwitcher.tsx";
import { toast } from "sonner"; import { toast } from "sonner";
@@ -890,7 +891,7 @@ export function Auth({
{/* Right Side - Auth Form */} {/* Right Side - Auth Form */}
<div className="flex-1 flex items-center justify-center p-6 md:p-12 bg-background overflow-y-auto"> <div className="flex-1 flex items-center justify-center p-6 md:p-12 bg-background overflow-y-auto">
<div className="w-full max-w-md backdrop-blur-sm bg-card/50 rounded-2xl p-8 shadow-xl border border-border/50 animate-in fade-in slide-in-from-bottom-4 duration-500" <div className="w-full max-w-md backdrop-blur-sm bg-card/50 rounded-2xl p-8 shadow-xl border-2 border-dark-border animate-in fade-in slide-in-from-bottom-4 duration-500"
style={{ maxHeight: "calc(100vh - 3rem)" }} style={{ maxHeight: "calc(100vh - 3rem)" }}
> >
{isInElectronWebView() && !webviewAuthSuccess && ( {isInElectronWebView() && !webviewAuthSuccess && (
@@ -902,21 +903,6 @@ export function Auth({
)} )}
{isInElectronWebView() && webviewAuthSuccess && ( {isInElectronWebView() && webviewAuthSuccess && (
<div className="flex flex-col items-center justify-center h-64 gap-4"> <div className="flex flex-col items-center justify-center h-64 gap-4">
<div className="w-16 h-16 rounded-full bg-green-500/20 flex items-center justify-center">
<svg
className="w-10 h-10 text-green-500"
fill="none"
stroke="currentColor"
viewBox="0 0 24 24"
>
<path
strokeLinecap="round"
strokeLinejoin="round"
strokeWidth={2}
d="M5 13l4 4L19 7"
/>
</svg>
</div>
<div className="text-center"> <div className="text-center">
<h2 className="text-xl font-bold mb-2"> <h2 className="text-xl font-bold mb-2">
{t("messages.loginSuccess")} {t("messages.loginSuccess")}
@@ -1004,70 +990,44 @@ export function Auth({
return ( return (
<> <>
{/* Tab Navigation */} {/* Tab Navigation */}
<div className="flex gap-1 p-1 mb-8 bg-muted/50 rounded-lg"> <Tabs value={tab} onValueChange={(value) => {
{passwordLoginAllowed && ( const newTab = value as "login" | "signup" | "external" | "reset";
<button setTab(newTab);
type="button" if (tab === "reset") resetPasswordState();
className={cn( if ((tab === "login" && newTab === "signup") || (tab === "signup" && newTab === "login")) {
"flex-1 py-2.5 px-4 text-sm font-medium rounded-md transition-all duration-200", clearFormFields();
tab === "login" }
? "bg-background text-foreground shadow-sm" }} className="w-full mb-8">
: "text-muted-foreground hover:text-foreground", <TabsList className="w-full">
)} {passwordLoginAllowed && (
onClick={() => { <TabsTrigger
setTab("login"); value="login"
if (tab === "reset") resetPasswordState(); disabled={loading || firstUser}
if (tab === "signup") clearFormFields(); className="flex-1"
}} >
aria-selected={tab === "login"} {t("common.login")}
disabled={loading || firstUser} </TabsTrigger>
> )}
{t("common.login")} {(passwordLoginAllowed || firstUser) && registrationAllowed && (
</button> <TabsTrigger
)} value="signup"
{(passwordLoginAllowed || firstUser) &&
registrationAllowed && (
<button
type="button"
className={cn(
"flex-1 py-2.5 px-4 text-sm font-medium rounded-md transition-all duration-200",
tab === "signup"
? "bg-background text-foreground shadow-sm"
: "text-muted-foreground hover:text-foreground",
)}
onClick={() => {
setTab("signup");
if (tab === "reset") resetPasswordState();
if (tab === "login") clearFormFields();
}}
aria-selected={tab === "signup"}
disabled={loading} disabled={loading}
className="flex-1"
> >
{t("common.register")} {t("common.register")}
</button> </TabsTrigger>
)} )}
{oidcConfigured && ( {oidcConfigured && (
<button <TabsTrigger
type="button" value="external"
className={cn( disabled={oidcLoading}
"flex-1 py-2.5 px-4 text-sm font-medium rounded-md transition-all duration-200", className="flex-1"
tab === "external" >
? "bg-background text-foreground shadow-sm" {t("auth.external")}
: "text-muted-foreground hover:text-foreground", </TabsTrigger>
)} )}
onClick={() => { </TabsList>
setTab("external"); </Tabs>
if (tab === "reset") resetPasswordState();
if (tab === "login" || tab === "signup")
clearFormFields();
}}
aria-selected={tab === "external"}
disabled={oidcLoading}
>
{t("auth.external")}
</button>
)}
</div>
{/* Page Title */} {/* Page Title */}
<div className="mb-8 text-center"> <div className="mb-8 text-center">