Skip to content

Commit 892bbaf

Browse files
committed
fix all wallets button to show based on remaining undisplayed wallets
1 parent f6b0cf8 commit 892bbaf

File tree

3 files changed

+17
-2
lines changed

3 files changed

+17
-2
lines changed

packages/modal/src/ui/components/Login/Login.tsx

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@ function Login(props: LoginProps) {
5050
isDark,
5151
handleSocialLoginClick,
5252
totalExternalWallets,
53+
remainingUndisplayedWallets,
5354
isEmailPasswordLessLoginVisible,
5455
isSmsPasswordLessLoginVisible,
5556
handleExternalWalletBtnClick,
@@ -509,7 +510,7 @@ function Login(props: LoginProps) {
509510
))}
510511

511512
{/* EXTERNAL WALLETS DISCOVERY */}
512-
{totalExternalWallets > 1 && (
513+
{remainingUndisplayedWallets > 0 && (
513514
<button
514515
type="button"
515516
className={cn("w3a--btn !w3a--justify-between w3a--group w3a--relative w3a--overflow-hidden", {
@@ -525,7 +526,7 @@ function Login(props: LoginProps) {
525526
id="external-wallet-count"
526527
className="w3a--absolute w3a--right-4 w3a--top-1/2 w3a--w-auto -w3a--translate-y-1/2 w3a--rounded-full w3a--bg-app-primary-100 w3a--px-2.5 w3a--py-0.5 w3a--text-xs w3a--font-medium w3a--text-app-primary-800 w3a--transition-all w3a--delay-300 w3a--duration-300 group-hover:w3a--translate-x-6 group-hover:w3a--opacity-0 group-hover:w3a--delay-0 dark:w3a--border dark:w3a--border-app-primary-500 dark:w3a--bg-transparent dark:w3a--text-app-primary-500"
527528
>
528-
{totalExternalWallets - 1}
529+
{remainingUndisplayedWallets}
529530
</div>
530531
)}
531532
<img

packages/modal/src/ui/components/Login/Login.type.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ export interface LoginProps {
3232
isEmailPasswordLessLoginVisible: boolean;
3333
isSmsPasswordLessLoginVisible: boolean;
3434
totalExternalWallets: number;
35+
remainingUndisplayedWallets: number;
3536
logoAlignment?: LogoAlignmentType;
3637
buttonRadius?: ButtonRadiusType;
3738
deviceDetails: { platform: platform; browser: browser; os: os };

packages/modal/src/ui/components/Root/Root.tsx

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -345,6 +345,18 @@ function Root(props: RootProps) {
345345
}).length;
346346
}, [allRegistryButtons, installedConnectorButtons]);
347347

348+
const remainingUndisplayedWallets = useMemo(() => {
349+
const uniqueButtonSet = new Set();
350+
const uniqueButtons = installedConnectorButtons.concat(allRegistryButtons).filter((button) => {
351+
if (uniqueButtonSet.has(button.name)) return false;
352+
uniqueButtonSet.add(button.name);
353+
return true;
354+
});
355+
return uniqueButtons.filter((button) => {
356+
return !topInstalledConnectorButtons.includes(button);
357+
}).length;
358+
}, [installedConnectorButtons, allRegistryButtons, topInstalledConnectorButtons]);
359+
348360
const handleSocialLoginHeight = () => {
349361
setIsSocialLoginsExpanded((prev) => !prev);
350362
};
@@ -482,6 +494,7 @@ function Root(props: RootProps) {
482494
isEmailPasswordLessLoginVisible={isEmailPasswordLessLoginVisible}
483495
isSmsPasswordLessLoginVisible={isSmsPasswordLessLoginVisible}
484496
totalExternalWallets={totalExternalWallets}
497+
remainingUndisplayedWallets={remainingUndisplayedWallets}
485498
logoAlignment={logoAlignment}
486499
buttonRadius={buttonRadiusType}
487500
deviceDetails={deviceDetails}

0 commit comments

Comments
 (0)