Skip to content

Commit 8eabbf4

Browse files
authored
feat: Add injected wallets to sign in page (#1928)
1 parent 0923fb4 commit 8eabbf4

File tree

7 files changed

+92
-10
lines changed

7 files changed

+92
-10
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@
5555
"@cosmjs/tendermint-rpc": "^0.32.1",
5656
"@datadog/browser-logs": "^5.23.3",
5757
"@dydxprotocol/v4-client-js": "3.0.3",
58-
"@dydxprotocol/v4-localization": "1.1.333",
58+
"@dydxprotocol/v4-localization": "1.1.334",
5959
"@dydxprotocol/v4-proto": "^7.0.0-dev.0",
6060
"@emotion/is-prop-valid": "^1.3.0",
6161
"@hugocxl/react-to-image": "^0.0.9",

pnpm-lock.yaml

Lines changed: 5 additions & 4 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/views/dialogs/OnboardingDialog.tsx

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -170,6 +170,7 @@ export const OnboardingDialog = ({
170170
children: (
171171
<$Content>
172172
<SignIn
173+
onChooseWallet={onChooseWallet}
173174
onDisplayChooseWallet={onDisplayChooseWallet}
174175
onSignInWithPasskey={onSignInWithPasskey}
175176
onSubmitEmail={({ userEmail }: { userEmail: string }) =>
@@ -280,6 +281,10 @@ const $Dialog = styled(Dialog)<{ width?: string }>`
280281
`}
281282
}
282283
284+
@media ${breakpoints.notTablet} {
285+
--dialog-header-backgroundColor: var(--color-layer-3);
286+
}
287+
283288
--dialog-icon-size: 1.25rem;
284289
`;
285290

src/views/dialogs/OnboardingDialog/AuthButtons/AppleAuth.tsx

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@ import { ButtonAction, ButtonSize, ButtonType } from '@/constants/buttons';
99

1010
import { useTurnkeyAuth } from '@/providers/TurnkeyAuthProvider';
1111

12+
import breakpoints from '@/styles/breakpoints';
13+
1214
import { Button } from '@/components/Button';
1315
import { Icon, IconName } from '@/components/Icon';
1416

@@ -106,8 +108,12 @@ export const AppleAuth = () => {
106108

107109
const $SocialLoginButton = styled(Button)`
108110
width: 100%;
109-
border-radius: 1rem;
111+
border-radius: 0.75rem;
110112
--icon-size: 1.5rem;
111113
overflow: hidden;
112114
position: relative;
115+
116+
@media ${breakpoints.tablet} {
117+
border-radius: 1rem;
118+
}
113119
`;

src/views/dialogs/OnboardingDialog/AuthButtons/GoogleAuth.tsx

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@ import { ButtonAction, ButtonSize, ButtonType } from '@/constants/buttons';
88

99
import { useTurnkeyAuth } from '@/providers/TurnkeyAuthProvider';
1010

11+
import breakpoints from '@/styles/breakpoints';
12+
1113
import { Button } from '@/components/Button';
1214
import { Icon, IconName } from '@/components/Icon';
1315

@@ -88,8 +90,12 @@ export const GoogleAuth = () => {
8890

8991
const $SocialLoginButton = styled(Button)`
9092
width: 100%;
91-
border-radius: 1rem;
93+
border-radius: 0.75rem;
9294
--icon-size: 1.5rem;
9395
overflow: hidden;
9496
position: relative;
97+
98+
@media ${breakpoints.tablet} {
99+
border-radius: 1rem;
100+
}
95101
`;

src/views/dialogs/OnboardingDialog/ChooseWallet.tsx

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -196,7 +196,11 @@ const $Link = styled(Link)`
196196

197197
const $OtherOptionButton = styled(Button)`
198198
width: 100%;
199-
border-radius: 1rem;
199+
border-radius: 0.75rem;
200200
justify-content: space-between;
201201
--icon-size: 1rem;
202+
203+
@media ${breakpoints.tablet} {
204+
border-radius: 1rem;
205+
}
202206
`;

src/views/dialogs/OnboardingDialog/SignIn.tsx

Lines changed: 62 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,19 +4,27 @@ import { logBonsaiError } from '@/bonsai/logs';
44
import { useTurnkey } from '@turnkey/sdk-react';
55
import styled, { css } from 'styled-components';
66

7+
import { AlertType } from '@/constants/alerts';
78
import { ButtonAction, ButtonSize, ButtonType } from '@/constants/buttons';
89
import { STRING_KEYS } from '@/constants/localization';
10+
import { ConnectorType, WalletInfo, wallets } from '@/constants/wallets';
911

12+
import { useAccounts } from '@/hooks/useAccounts';
13+
import { useDisplayedWallets } from '@/hooks/useDisplayedWallets';
1014
import { useStringGetter } from '@/hooks/useStringGetter';
1115
import { useURLConfigs } from '@/hooks/useURLConfigs';
1216
import { useTurnkeyAuth } from '@/providers/TurnkeyAuthProvider';
1317

18+
import breakpoints from '@/styles/breakpoints';
19+
20+
import { AlertMessage } from '@/components/AlertMessage';
1421
import { Button } from '@/components/Button';
1522
import { FormInput } from '@/components/FormInput';
1623
import { Icon, IconName } from '@/components/Icon';
1724
import { InputType } from '@/components/Input';
1825
import { Link } from '@/components/Link';
1926
import { HorizontalSeparatorFiller } from '@/components/Separator';
27+
import { WalletIcon } from '@/components/WalletIcon';
2028

2129
import { useAppSelector } from '@/state/appTypes';
2230
import { AppTheme } from '@/state/appUiConfigs';
@@ -30,10 +38,12 @@ import { GoogleAuth } from './AuthButtons/GoogleAuth';
3038

3139
export const SignIn = ({
3240
onDisplayChooseWallet,
41+
onChooseWallet,
3342
// eslint-disable-next-line @typescript-eslint/no-unused-vars
3443
onSignInWithPasskey,
3544
onSubmitEmail,
3645
}: {
46+
onChooseWallet: (wallet: WalletInfo) => void;
3747
onDisplayChooseWallet: () => void;
3848
onSignInWithPasskey: () => void;
3949
onSubmitEmail: ({ userEmail }: { userEmail: string }) => void;
@@ -45,6 +55,8 @@ export const SignIn = ({
4555
const { signInWithOtp } = useTurnkeyAuth();
4656
const appTheme = useAppSelector(getAppTheme);
4757
const { tos, privacy } = useURLConfigs();
58+
const displayedWallets = useDisplayedWallets();
59+
const { selectedWallet, selectedWalletError } = useAccounts();
4860

4961
const onSubmit = useCallback(
5062
async (e: React.FormEvent<HTMLFormElement>) => {
@@ -64,6 +76,25 @@ export const SignIn = ({
6476

6577
const hasValidEmail = isValidEmail(email);
6678

79+
const walletError = selectedWallet && selectedWalletError && (
80+
<$AlertMessage type={AlertType.Error}>
81+
<h4>
82+
{stringGetter({
83+
key: STRING_KEYS.COULD_NOT_CONNECT,
84+
params: {
85+
WALLET:
86+
selectedWallet.connectorType === ConnectorType.Injected
87+
? selectedWallet.name
88+
: stringGetter({
89+
key: wallets[selectedWallet.name as keyof typeof wallets].stringKey,
90+
}),
91+
},
92+
})}
93+
</h4>
94+
{selectedWalletError}
95+
</$AlertMessage>
96+
);
97+
6798
return (
6899
<form onSubmit={onSubmit} tw="flexColumn gap-1.25">
69100
<div tw="row gap-1">
@@ -121,6 +152,23 @@ export const SignIn = ({
121152
<Icon tw="text-color-layer-7" iconName={IconName.ChevronRight} />
122153
</$OtherOptionButton> */}
123154

155+
{displayedWallets
156+
.filter((wallet) => wallet.connectorType === ConnectorType.Injected)
157+
.map((wallet) => (
158+
<$OtherOptionButton
159+
key={wallet.name}
160+
type={ButtonType.Button}
161+
action={ButtonAction.Base}
162+
size={ButtonSize.BasePlus}
163+
onClick={() => onChooseWallet(wallet)}
164+
>
165+
<div tw="row gap-0.5">
166+
<WalletIcon wallet={wallet} />
167+
{wallet.name}
168+
</div>
169+
</$OtherOptionButton>
170+
))}
171+
124172
<$OtherOptionButton
125173
type={ButtonType.Button}
126174
action={ButtonAction.Base}
@@ -129,13 +177,15 @@ export const SignIn = ({
129177
>
130178
<div tw="row gap-0.5">
131179
<Icon iconName={IconName.Wallet2} />
132-
{stringGetter({ key: STRING_KEYS.SIGN_IN_WITH_WALLET })}
180+
{stringGetter({ key: STRING_KEYS.VIEW_MORE_WALLETS })}
133181
</div>
134182

135183
<Icon tw="text-color-layer-7" iconName={IconName.ChevronRight} />
136184
</$OtherOptionButton>
137185
</div>
138186

187+
{walletError}
188+
139189
<span tw="text-center font-mini-book">
140190
{stringGetter({
141191
key: STRING_KEYS.TOS_SHORT,
@@ -193,7 +243,17 @@ const $HorizontalSeparatorFiller = styled(HorizontalSeparatorFiller)<{ $isLightM
193243

194244
const $OtherOptionButton = styled(Button)`
195245
width: 100%;
196-
border-radius: 1rem;
246+
border-radius: 0.75rem;
197247
justify-content: space-between;
198248
--icon-size: 1rem;
249+
250+
@media ${breakpoints.tablet} {
251+
border-radius: 1rem;
252+
}
253+
`;
254+
255+
const $AlertMessage = styled(AlertMessage)`
256+
h4 {
257+
font: var(--font-small-medium);
258+
}
199259
`;

0 commit comments

Comments
 (0)