Skip to content

Commit b56c366

Browse files
author
Guru
committed
feat: select blockchain dropdown
1 parent f15f703 commit b56c366

File tree

1 file changed

+47
-5
lines changed

1 file changed

+47
-5
lines changed

demo/redirect-flow-example/src/components/LoginCard.tsx

Lines changed: 47 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,20 +6,38 @@ import { Button } from "./Button";
66
import { LoginForm } from "./LoginForm";
77
import { useSocialLogins } from "./useSocialLogin";
88
import { SocialLoginObj } from "./types";
9+
import { Dropdown } from "./DropDown";
10+
import { KeyType } from "@tkey/common-types";
11+
import { useCoreKit } from "../composibles/useCoreKit";
912

1013
interface LoginCardProps {
1114
handleEmailPasswordLess: () => void;
1215
handleSocialLogin: (item: SocialLoginObj) => void;
1316
}
1417

15-
const LoginCard: React.FC<LoginCardProps> = ({handleEmailPasswordLess, handleSocialLogin}) => {
18+
const LoginCard: React.FC<LoginCardProps> = ({ handleEmailPasswordLess, handleSocialLogin }) => {
19+
const { setKeyType } = useCoreKit();
1620
const [loginHint, setLoginHint] = React.useState<string>("");
21+
const [defaultValue, setDefaultValue] = React.useState(localStorage.getItem("keyType") || KeyType.secp256k1);
22+
const keyOptions = [
23+
{
24+
name: "Ethereum (secp256k1)",
25+
value: KeyType.secp256k1,
26+
icon: <img src={"https://cryptologos.cc/logos/ethereum-eth-logo.svg?v=040"} alt={"Ethereum"} width={20} height={20} className="h-5 w-5" />,
27+
},
28+
{
29+
name: "Solana (ed25519)",
30+
value: KeyType.ed25519,
31+
icon: (
32+
<img src={"https://solana.com/_next/static/media/solanaLogoMark.17260911.svg"} alt={"Solana"} width={20} height={20} className="h-5 w-5" />
33+
),
34+
},
35+
];
1736

1837
const socialLogins = useSocialLogins();
1938

2039
const handlePasswordlessLogin = (e: React.FormEvent) => {
2140
e.preventDefault();
22-
console.log("loginHint", loginHint);
2341
// Handle passwordless login
2442
handleEmailPasswordLess();
2543
};
@@ -29,6 +47,12 @@ const LoginCard: React.FC<LoginCardProps> = ({handleEmailPasswordLess, handleSoc
2947
handleSocialLogin(item);
3048
};
3149

50+
const handleSwitchKey = (val: string | string[]) => {
51+
const keyType = val as KeyType;
52+
if (!keyType || !setKeyType) throw new Error("key type is undefined");
53+
setKeyType(keyType);
54+
};
55+
3256
return (
3357
<div className="mb-6 mt-24 flex justify-center items-center">
3458
<Card
@@ -39,8 +63,26 @@ const LoginCard: React.FC<LoginCardProps> = ({handleEmailPasswordLess, handleSoc
3963
<div className="mb-6 flex justify-center items-center">
4064
<img className="h-11 w-auto" src="https://images.web3auth.io/web3auth-logo-w.svg" alt="" />
4165
</div>
42-
<p className="text-2xl text-center font-bold text-app-gray-900 dark:text-app-white">Welcome to Web3Auth</p>
43-
<p className="text-base text-center mb-5 text-app-gray-500 dark:text-app-gray-400">Login to continue</p>
66+
<p className="text-2xl text-start pl-4 font-bold text-app-gray-900 dark:text-app-white">Welcome to Web3Auth</p>
67+
<div className="flex flex-col gap-y-2 justify-around items-center mt-4">
68+
<span className="flex flex-row justify-center items-center gap-x-2">
69+
<p className="text-lg font-bold text-center text-app-gray-500 dark:text-app-gray-400">Your</p>
70+
<Dropdown
71+
options={keyOptions}
72+
defaultValue={defaultValue}
73+
classes={{
74+
container: "w-fit",
75+
inputContainer: "bg-app-primary-100 dark:bg-app-primary-500",
76+
}}
77+
inputSize="sm"
78+
onChange={handleSwitchKey}
79+
/>
80+
</span>
81+
</div>
82+
<div className="pl-4 flex flex-col gap-y-2 mb-4">
83+
<p className="text-lg font-bold text-start text-app-gray-500 dark:text-app-gray-400">Wallet in one Click</p>
84+
<p className="text-base text-center text-app-gray-500 dark:text-app-gray-400">Login to continue</p>
85+
</div>
4486
</div>
4587
<LoginForm
4688
pill
@@ -55,7 +97,7 @@ const LoginCard: React.FC<LoginCardProps> = ({handleEmailPasswordLess, handleSoc
5597
expandLabel="View more"
5698
collapseLabel="View less"
5799
primaryBtn="input"
58-
onSocialLoginClick={ handleSocial }
100+
onSocialLoginClick={handleSocial}
59101
>
60102
<form onSubmit={handlePasswordlessLogin} className="mt-4">
61103
<TextField

0 commit comments

Comments
 (0)