mirror of
https://github.com/tiennm99/bsk.git
synced 2026-09-20 05:11:50 +00:00
- responsive app shell: persistent sidebar at md+, accessible off-canvas drawer (focus trap, Esc, dialog semantics) + hamburger below md - active-route highlight, localized role labels, greet by name - visible focus rings, AA-contrast muted text, 44px primary actions - sign-in: autofocus, show/hide password, always-enabled submit - Be Vietnam Pro via next/font; prefers-reduced-motion guard; skip-link
41 lines
1004 B
TypeScript
41 lines
1004 B
TypeScript
"use client";
|
|
|
|
/**
|
|
* Sign-out button — Client Component.
|
|
*
|
|
* Wraps signOutAction in a <form> so it works as a native form submission
|
|
* (no JS required for the redirect). useFormStatus() disables the button
|
|
* while the server action is in-flight to prevent double-submit.
|
|
*/
|
|
|
|
import { useFormStatus } from "react-dom";
|
|
import { useTranslations } from "next-intl";
|
|
import { signOutAction } from "@/app/[locale]/(auth)/sign-in/actions";
|
|
import { Button } from "@/components/ui/button";
|
|
import { LogOut } from "lucide-react";
|
|
|
|
function SignOutButtonInner() {
|
|
const { pending } = useFormStatus();
|
|
const t = useTranslations("app");
|
|
|
|
return (
|
|
<Button
|
|
type="submit"
|
|
variant="ghost"
|
|
disabled={pending}
|
|
className="w-full justify-start gap-2"
|
|
>
|
|
<LogOut className="size-4" />
|
|
{pending ? "…" : t("signOut")}
|
|
</Button>
|
|
);
|
|
}
|
|
|
|
export function SignOutButton() {
|
|
return (
|
|
<form action={signOutAction}>
|
|
<SignOutButtonInner />
|
|
</form>
|
|
);
|
|
}
|