fix: close mobile menu before wallet login

This commit is contained in:
TerryM
2026-06-02 00:45:58 +08:00
parent 4900256423
commit 05c2252b49
2 changed files with 12 additions and 3 deletions

View File

@@ -723,7 +723,7 @@ export function PublicLayout() {
{t("popular")}
</Link>
<div className="mt-2 w-full max-w-xs">
<WalletButton compact />
<WalletButton compact onOpenLogin={() => setOpen(false)} />
</div>
</div>
) : null}

View File

@@ -2,7 +2,13 @@ import { useEffect, useRef, useState } from "react";
import { useI18n } from "../i18n";
import { shortenAddress, useWallet } from "./WalletProvider";
export function WalletButton({ compact = false }: { compact?: boolean }) {
export function WalletButton({
compact = false,
onOpenLogin,
}: {
compact?: boolean;
onOpenLogin?: () => void;
}) {
const { t } = useI18n();
const wallet = useWallet();
const [open, setOpen] = useState(false);
@@ -66,7 +72,10 @@ export function WalletButton({ compact = false }: { compact?: boolean }) {
return (
<button
type="button"
onClick={wallet.openLoginModal}
onClick={() => {
onOpenLogin?.();
wallet.openLoginModal();
}}
className={[
"inline-flex h-10 items-center justify-center rounded-full border border-ark-gold/50 bg-ark-gold px-4 text-sm font-bold text-black outline-none transition hover:bg-ark-gold2 focus-visible:ring-2 focus-visible:ring-ark-gold/80 focus-visible:ring-offset-2 focus-visible:ring-offset-ark-bg",
compact ? "w-full" : "",