diff --git a/.changeset/plenty-steaks-lay.md b/.changeset/plenty-steaks-lay.md new file mode 100644 index 0000000..9965cfa --- /dev/null +++ b/.changeset/plenty-steaks-lay.md @@ -0,0 +1,5 @@ +--- +"@farcaster/auth-kit": patch +--- + +add optional disableSignOut prop diff --git a/packages/auth-kit/src/components/ProfileButton/ProfileButton.tsx b/packages/auth-kit/src/components/ProfileButton/ProfileButton.tsx index 967a078..1fe30b4 100644 --- a/packages/auth-kit/src/components/ProfileButton/ProfileButton.tsx +++ b/packages/auth-kit/src/components/ProfileButton/ProfileButton.tsx @@ -17,19 +17,26 @@ interface UserDataProps { export function ProfileButton({ userData, signOut, + disableSignOut, }: { userData?: UserDataProps; signOut?: () => void; + disableSignOut: boolean; }) { - const [showSignOut, setShowSignOut] = useState(false); + const [showSignOutButton, setShowSignOutButton] = useState(false); const ref = useRef(null); - useDetectClickOutside(ref, () => setShowSignOut(false)); + useDetectClickOutside(ref, () => setShowSignOutButton(false)); const name = userData?.username ?? `!${userData?.fid}`; const pfpUrl = userData?.pfpUrl ?? "https://warpcast.com/avatar.png"; + const showSignOut = showSignOutButton && !disableSignOut; + return ( -
+
setShowSignOut(!showSignOut)} + onClick={() => setShowSignOutButton(!showSignOutButton)} > - avatar + avatar {name} - - Dropdown - - - - + {!disableSignOut && ( + + Dropdown + + + + + )} {showSignOut && }
diff --git a/packages/auth-kit/src/components/SignInButton/SignInButton.tsx b/packages/auth-kit/src/components/SignInButton/SignInButton.tsx index 47603d8..f1ac768 100644 --- a/packages/auth-kit/src/components/SignInButton/SignInButton.tsx +++ b/packages/auth-kit/src/components/SignInButton/SignInButton.tsx @@ -7,9 +7,9 @@ import { isMobile } from "../../utils.ts"; import { AuthClientError, StatusAPIResponse } from "@farcaster/auth-client"; import { debugPanel } from "./SignInButton.css.ts"; -type SignInButtonProps = UseSignInArgs & { debug?: boolean }; +type SignInButtonProps = UseSignInArgs & { debug?: boolean, disableSignOut?: boolean }; -export function SignInButton({ debug, ...signInArgs }: SignInButtonProps) { +export function SignInButton({ debug, disableSignOut, ...signInArgs }: SignInButtonProps) { const { onSuccess, onStatusResponse, onError } = signInArgs; const onSuccessCallback = useCallback( @@ -83,7 +83,7 @@ export function SignInButton({ debug, ...signInArgs }: SignInButtonProps) { return (
{authenticated ? ( - + ) : ( <>