Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/sixty-clubs-fix.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"thirdweb": patch
---

Update in-app wallet icon in wide connect ui
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
import { Text } from "../components/text.js";
import { WalletImage } from "../components/WalletImage.js";
import { StyledButton } from "../design-system/elements.js";
import { InAppWalletIcon } from "./in-app-wallet-icon.js";
import type { ConnectLocale } from "./locale/types.js";

/**
Expand Down Expand Up @@ -52,9 +53,20 @@
wallet && walletId === "inApp"
? (wallet.getConfig() as InAppWalletCreationOptions)?.metadata
: undefined;
const nameOverride = customMeta?.name || walletName;
let nameOverride = customMeta?.name || walletName;

Check warning on line 56 in packages/thirdweb/src/react/web/ui/ConnectWallet/WalletEntryButton.tsx

View check run for this annotation

Codecov / codecov/patch

packages/thirdweb/src/react/web/ui/ConnectWallet/WalletEntryButton.tsx#L56

Added line #L56 was not covered by tests
const iconOverride = customMeta?.icon;

// change "Social Login" to name of the login method if only 1 method is enabled
if (wallet.id === "inApp") {
const config = wallet.getConfig() as InAppWalletCreationOptions;
if (config?.auth?.options.length === 1) {
const name = config.auth?.options[0];
if (name) {
nameOverride = uppercaseFirstLetter({ text: name });
}
}
}

Check warning on line 68 in packages/thirdweb/src/react/web/ui/ConnectWallet/WalletEntryButton.tsx

View check run for this annotation

Codecov / codecov/patch

packages/thirdweb/src/react/web/ui/ConnectWallet/WalletEntryButton.tsx#L60-L68

Added lines #L60 - L68 were not covered by tests

return (
<WalletButtonEl
className={props.className}
Expand All @@ -64,12 +76,17 @@
>
{iconOverride ? (
<Img
alt={nameOverride}
alt=""

Check warning on line 79 in packages/thirdweb/src/react/web/ui/ConnectWallet/WalletEntryButton.tsx

View check run for this annotation

Codecov / codecov/patch

packages/thirdweb/src/react/web/ui/ConnectWallet/WalletEntryButton.tsx#L79

Added line #L79 was not covered by tests
client={props.client}
height={`${iconSize.xl}`}
src={iconOverride}
width={`${iconSize.xl}`}
/>
) : wallet.id === "inApp" ? (
<InAppWalletIcon
client={props.client}
wallet={wallet as Wallet<"inApp">}
/>

Check warning on line 89 in packages/thirdweb/src/react/web/ui/ConnectWallet/WalletEntryButton.tsx

View check run for this annotation

Codecov / codecov/patch

packages/thirdweb/src/react/web/ui/ConnectWallet/WalletEntryButton.tsx#L85-L89

Added lines #L85 - L89 were not covered by tests
) : (
<WalletImage client={props.client} id={walletId} size={iconSize.xl} />
)}
Expand Down Expand Up @@ -119,3 +136,7 @@
width: "100%",
};
});

function uppercaseFirstLetter(props: { text: string }) {
return props.text.charAt(0).toUpperCase() + props.text.slice(1);
}

Check warning on line 142 in packages/thirdweb/src/react/web/ui/ConnectWallet/WalletEntryButton.tsx

View check run for this annotation

Codecov / codecov/patch

packages/thirdweb/src/react/web/ui/ConnectWallet/WalletEntryButton.tsx#L140-L142

Added lines #L140 - L142 were not covered by tests
Original file line number Diff line number Diff line change
@@ -1,30 +1,23 @@
import type { IconFC } from "./types.js";

/**
* @internal
*/
export const EmailIcon: IconFC = (props) => {
return (
<svg
fill="none"
xmlns="http://www.w3.org/2000/svg"
width={props.size}
height={props.size}
viewBox="0 0 24 24"
role="presentation"
viewBox="0 0 16 16"
width={props.size}
xmlns="http://www.w3.org/2000/svg"
fill="none"
stroke="currentColor"
strokeWidth="2"
strokeLinecap="round"
strokeLinejoin="round"
className="lucide lucide-mail-icon lucide-mail"
style={{ color: props.color }}
>
<path
d="M13.3335 2.6665H2.66683C1.93045 2.6665 1.3335 3.26346 1.3335 3.99984V11.9998C1.3335 12.7362 1.93045 13.3332 2.66683 13.3332H13.3335C14.0699 13.3332 14.6668 12.7362 14.6668 11.9998V3.99984C14.6668 3.26346 14.0699 2.6665 13.3335 2.6665Z"
stroke={props.color ?? "currentColor"}
strokeLinecap="round"
strokeLinejoin="round"
/>
<path
d="M14.6668 4.6665L8.68683 8.4665C8.48101 8.59545 8.24304 8.66384 8.00016 8.66384C7.75728 8.66384 7.51931 8.59545 7.3135 8.4665L1.3335 4.6665"
stroke={props.color ?? "currentColor"}
strokeLinecap="round"
strokeLinejoin="round"
/>
<path d="m22 7-8.991 5.727a2 2 0 0 1-2.009 0L2 7" />
<rect x="2" y="4" width="20" height="16" rx="2" />
</svg>
);
};
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
viewBox="0 0 18 18"
width={props.size}
height={props.size}
style={{ color: props.color }}

Check warning on line 14 in packages/thirdweb/src/react/web/ui/ConnectWallet/icons/WalletDotIcon.tsx

View check run for this annotation

Codecov / codecov/patch

packages/thirdweb/src/react/web/ui/ConnectWallet/icons/WalletDotIcon.tsx#L14

Added line #L14 was not covered by tests
role="presentation"
>
<path
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,195 @@
"use client";
import type { ThirdwebClient } from "../../../../client/client.js";
import type { Wallet } from "../../../../wallets/interfaces/wallet.js";
import type { AuthOption } from "../../../../wallets/types.js";
import { useCustomTheme } from "../../../core/design-system/CustomThemeProvider.js";
import {
iconSize,
radius,
spacing,
} from "../../../core/design-system/index.js";
import { socialIcons } from "../../../core/utils/walletIcon.js";
import { defaultAuthOptions } from "../../wallets/shared/ConnectWalletSocialOptions.js";
import { Img } from "../components/Img.js";
import { EmailIcon } from "./icons/EmailIcon.js";
import { FingerPrintIcon } from "./icons/FingerPrintIcon.js";
import { GuestIcon } from "./icons/GuestIcon.js";
import { PhoneIcon } from "./icons/PhoneIcon.js";

export function InAppWalletIcon(props: {
client: ThirdwebClient;
wallet: Wallet<"inApp">;
}) {
const enabledAuthMethods = (
props.wallet.getConfig()?.auth?.options || defaultAuthOptions

Check warning on line 24 in packages/thirdweb/src/react/web/ui/ConnectWallet/in-app-wallet-icon.tsx

View check run for this annotation

Codecov / codecov/patch

packages/thirdweb/src/react/web/ui/ConnectWallet/in-app-wallet-icon.tsx#L22-L24

Added lines #L22 - L24 were not covered by tests
)
.slice() // clone
.sort((a, b) => {
if (a in socialIcons && !(b in socialIcons)) {
return -1;
}
if (!(a in socialIcons) && b in socialIcons) {
return 1;
}
return 0;
});

Check warning on line 35 in packages/thirdweb/src/react/web/ui/ConnectWallet/in-app-wallet-icon.tsx

View check run for this annotation

Codecov / codecov/patch

packages/thirdweb/src/react/web/ui/ConnectWallet/in-app-wallet-icon.tsx#L26-L35

Added lines #L26 - L35 were not covered by tests

const theme = useCustomTheme();

Check warning on line 37 in packages/thirdweb/src/react/web/ui/ConnectWallet/in-app-wallet-icon.tsx

View check run for this annotation

Codecov / codecov/patch

packages/thirdweb/src/react/web/ui/ConnectWallet/in-app-wallet-icon.tsx#L37

Added line #L37 was not covered by tests

const firstMethod = enabledAuthMethods[0];
const secondMethod = enabledAuthMethods[1];
const thirdMethod = enabledAuthMethods[2];
const fourthMethod = enabledAuthMethods[3];

Check warning on line 42 in packages/thirdweb/src/react/web/ui/ConnectWallet/in-app-wallet-icon.tsx

View check run for this annotation

Codecov / codecov/patch

packages/thirdweb/src/react/web/ui/ConnectWallet/in-app-wallet-icon.tsx#L39-L42

Added lines #L39 - L42 were not covered by tests

const offset = "4px";
const offset2 = "6px";
const smallIconSize = "20";
const extraIconSize = "12";

Check warning on line 47 in packages/thirdweb/src/react/web/ui/ConnectWallet/in-app-wallet-icon.tsx

View check run for this annotation

Codecov / codecov/patch

packages/thirdweb/src/react/web/ui/ConnectWallet/in-app-wallet-icon.tsx#L44-L47

Added lines #L44 - L47 were not covered by tests

if (firstMethod && secondMethod) {
return (
<div
style={{
width: `${iconSize.xl}px`,
height: `${iconSize.xl}px`,
position: "relative",
gap: spacing["3xs"],
border: `1px solid ${theme.colors.borderColor}`,
borderRadius: radius.md,
backgroundColor: theme.colors.tertiaryBg,
}}

Check warning on line 60 in packages/thirdweb/src/react/web/ui/ConnectWallet/in-app-wallet-icon.tsx

View check run for this annotation

Codecov / codecov/patch

packages/thirdweb/src/react/web/ui/ConnectWallet/in-app-wallet-icon.tsx#L49-L60

Added lines #L49 - L60 were not covered by tests
>
<div
style={{
position: "absolute",
top: offset,
left: offset,
display: "flex",
}}

Check warning on line 68 in packages/thirdweb/src/react/web/ui/ConnectWallet/in-app-wallet-icon.tsx

View check run for this annotation

Codecov / codecov/patch

packages/thirdweb/src/react/web/ui/ConnectWallet/in-app-wallet-icon.tsx#L62-L68

Added lines #L62 - L68 were not covered by tests
>
<AuthOptionIcon
authOption={firstMethod}
client={props.client}
size={smallIconSize}
/>
</div>

Check warning on line 75 in packages/thirdweb/src/react/web/ui/ConnectWallet/in-app-wallet-icon.tsx

View check run for this annotation

Codecov / codecov/patch

packages/thirdweb/src/react/web/ui/ConnectWallet/in-app-wallet-icon.tsx#L70-L75

Added lines #L70 - L75 were not covered by tests

<div
style={{
position: "absolute",
bottom: offset,
right: offset,
display: "flex",
}}

Check warning on line 83 in packages/thirdweb/src/react/web/ui/ConnectWallet/in-app-wallet-icon.tsx

View check run for this annotation

Codecov / codecov/patch

packages/thirdweb/src/react/web/ui/ConnectWallet/in-app-wallet-icon.tsx#L77-L83

Added lines #L77 - L83 were not covered by tests
>
<AuthOptionIcon
authOption={secondMethod}
client={props.client}
size={smallIconSize}
/>
</div>

Check warning on line 90 in packages/thirdweb/src/react/web/ui/ConnectWallet/in-app-wallet-icon.tsx

View check run for this annotation

Codecov / codecov/patch

packages/thirdweb/src/react/web/ui/ConnectWallet/in-app-wallet-icon.tsx#L85-L90

Added lines #L85 - L90 were not covered by tests

<div>
{thirdMethod && (
<div
style={{
position: "absolute",
top: offset2,
right: offset2,
display: "flex",
}}

Check warning on line 100 in packages/thirdweb/src/react/web/ui/ConnectWallet/in-app-wallet-icon.tsx

View check run for this annotation

Codecov / codecov/patch

packages/thirdweb/src/react/web/ui/ConnectWallet/in-app-wallet-icon.tsx#L92-L100

Added lines #L92 - L100 were not covered by tests
>
<AuthOptionIcon
authOption={thirdMethod}
client={props.client}
size={extraIconSize}
/>
</div>

Check warning on line 107 in packages/thirdweb/src/react/web/ui/ConnectWallet/in-app-wallet-icon.tsx

View check run for this annotation

Codecov / codecov/patch

packages/thirdweb/src/react/web/ui/ConnectWallet/in-app-wallet-icon.tsx#L102-L107

Added lines #L102 - L107 were not covered by tests
)}

{fourthMethod && (
<div
style={{
position: "absolute",
bottom: offset2,
left: offset2,
display: "flex",
}}

Check warning on line 117 in packages/thirdweb/src/react/web/ui/ConnectWallet/in-app-wallet-icon.tsx

View check run for this annotation

Codecov / codecov/patch

packages/thirdweb/src/react/web/ui/ConnectWallet/in-app-wallet-icon.tsx#L110-L117

Added lines #L110 - L117 were not covered by tests
>
<AuthOptionIcon
authOption={fourthMethod}
client={props.client}
size={extraIconSize}
/>
</div>

Check warning on line 124 in packages/thirdweb/src/react/web/ui/ConnectWallet/in-app-wallet-icon.tsx

View check run for this annotation

Codecov / codecov/patch

packages/thirdweb/src/react/web/ui/ConnectWallet/in-app-wallet-icon.tsx#L119-L124

Added lines #L119 - L124 were not covered by tests
)}
</div>
</div>

Check warning on line 127 in packages/thirdweb/src/react/web/ui/ConnectWallet/in-app-wallet-icon.tsx

View check run for this annotation

Codecov / codecov/patch

packages/thirdweb/src/react/web/ui/ConnectWallet/in-app-wallet-icon.tsx#L126-L127

Added lines #L126 - L127 were not covered by tests
);
}

Check warning on line 129 in packages/thirdweb/src/react/web/ui/ConnectWallet/in-app-wallet-icon.tsx

View check run for this annotation

Codecov / codecov/patch

packages/thirdweb/src/react/web/ui/ConnectWallet/in-app-wallet-icon.tsx#L129

Added line #L129 was not covered by tests

if (firstMethod) {
return (
<div
style={{
width: `${iconSize.xl}px`,
height: `${iconSize.xl}px`,
display: "flex",
justifyContent: "center",
alignItems: "center",
border: `1px solid ${theme.colors.borderColor}`,
borderRadius: radius.md,
backgroundColor: theme.colors.tertiaryBg,
}}

Check warning on line 143 in packages/thirdweb/src/react/web/ui/ConnectWallet/in-app-wallet-icon.tsx

View check run for this annotation

Codecov / codecov/patch

packages/thirdweb/src/react/web/ui/ConnectWallet/in-app-wallet-icon.tsx#L131-L143

Added lines #L131 - L143 were not covered by tests
>
<AuthOptionIcon
authOption={firstMethod}
client={props.client}
key={firstMethod}
size={iconSize.lg}
/>
</div>

Check warning on line 151 in packages/thirdweb/src/react/web/ui/ConnectWallet/in-app-wallet-icon.tsx

View check run for this annotation

Codecov / codecov/patch

packages/thirdweb/src/react/web/ui/ConnectWallet/in-app-wallet-icon.tsx#L145-L151

Added lines #L145 - L151 were not covered by tests
);
}

Check warning on line 153 in packages/thirdweb/src/react/web/ui/ConnectWallet/in-app-wallet-icon.tsx

View check run for this annotation

Codecov / codecov/patch

packages/thirdweb/src/react/web/ui/ConnectWallet/in-app-wallet-icon.tsx#L153

Added line #L153 was not covered by tests

return null;
}

Check warning on line 156 in packages/thirdweb/src/react/web/ui/ConnectWallet/in-app-wallet-icon.tsx

View check run for this annotation

Codecov / codecov/patch

packages/thirdweb/src/react/web/ui/ConnectWallet/in-app-wallet-icon.tsx#L155-L156

Added lines #L155 - L156 were not covered by tests

function AuthOptionIcon(props: {

Check warning on line 158 in packages/thirdweb/src/react/web/ui/ConnectWallet/in-app-wallet-icon.tsx

View check run for this annotation

Codecov / codecov/patch

packages/thirdweb/src/react/web/ui/ConnectWallet/in-app-wallet-icon.tsx#L158

Added line #L158 was not covered by tests
authOption: AuthOption;
client: ThirdwebClient;
size: string;
}) {
const theme = useCustomTheme();
if (props.authOption in socialIcons) {
const icon = socialIcons[props.authOption as keyof typeof socialIcons];
return (
<Img
src={icon}
width={props.size}
height={props.size}
client={props.client}
/>

Check warning on line 172 in packages/thirdweb/src/react/web/ui/ConnectWallet/in-app-wallet-icon.tsx

View check run for this annotation

Codecov / codecov/patch

packages/thirdweb/src/react/web/ui/ConnectWallet/in-app-wallet-icon.tsx#L162-L172

Added lines #L162 - L172 were not covered by tests
);
}

Check warning on line 174 in packages/thirdweb/src/react/web/ui/ConnectWallet/in-app-wallet-icon.tsx

View check run for this annotation

Codecov / codecov/patch

packages/thirdweb/src/react/web/ui/ConnectWallet/in-app-wallet-icon.tsx#L174

Added line #L174 was not covered by tests

if (props.authOption === "phone") {
return <PhoneIcon size={props.size} color={theme.colors.secondaryText} />;
}

Check warning on line 178 in packages/thirdweb/src/react/web/ui/ConnectWallet/in-app-wallet-icon.tsx

View check run for this annotation

Codecov / codecov/patch

packages/thirdweb/src/react/web/ui/ConnectWallet/in-app-wallet-icon.tsx#L176-L178

Added lines #L176 - L178 were not covered by tests

if (props.authOption === "email") {
return <EmailIcon size={props.size} color={theme.colors.secondaryText} />;
}

Check warning on line 182 in packages/thirdweb/src/react/web/ui/ConnectWallet/in-app-wallet-icon.tsx

View check run for this annotation

Codecov / codecov/patch

packages/thirdweb/src/react/web/ui/ConnectWallet/in-app-wallet-icon.tsx#L180-L182

Added lines #L180 - L182 were not covered by tests

if (props.authOption === "passkey") {
return (
<FingerPrintIcon size={props.size} color={theme.colors.secondaryText} />

Check warning on line 186 in packages/thirdweb/src/react/web/ui/ConnectWallet/in-app-wallet-icon.tsx

View check run for this annotation

Codecov / codecov/patch

packages/thirdweb/src/react/web/ui/ConnectWallet/in-app-wallet-icon.tsx#L184-L186

Added lines #L184 - L186 were not covered by tests
);
}

Check warning on line 188 in packages/thirdweb/src/react/web/ui/ConnectWallet/in-app-wallet-icon.tsx

View check run for this annotation

Codecov / codecov/patch

packages/thirdweb/src/react/web/ui/ConnectWallet/in-app-wallet-icon.tsx#L188

Added line #L188 was not covered by tests

if (props.authOption === "guest") {
return <GuestIcon size={props.size} color={theme.colors.secondaryText} />;
}

Check warning on line 192 in packages/thirdweb/src/react/web/ui/ConnectWallet/in-app-wallet-icon.tsx

View check run for this annotation

Codecov / codecov/patch

packages/thirdweb/src/react/web/ui/ConnectWallet/in-app-wallet-icon.tsx#L190-L192

Added lines #L190 - L192 were not covered by tests

return null;
}

Check warning on line 195 in packages/thirdweb/src/react/web/ui/ConnectWallet/in-app-wallet-icon.tsx

View check run for this annotation

Codecov / codecov/patch

packages/thirdweb/src/react/web/ui/ConnectWallet/in-app-wallet-icon.tsx#L194-L195

Added lines #L194 - L195 were not covered by tests
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ export type ConnectWalletSelectUIState =
};
};

const defaultAuthOptions: AuthOption[] = [
export const defaultAuthOptions: AuthOption[] = [
"email",
"phone",
"google",
Expand Down
55 changes: 55 additions & 0 deletions packages/thirdweb/src/stories/ConnectEmbed.stories.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import type { Meta } from "@storybook/react";
import { ConnectButton } from "../react/web/ui/ConnectWallet/ConnectButton.js";
import { ConnectEmbed } from "../react/web/ui/ConnectWallet/Modal/ConnectEmbed.js";
import { createWallet } from "../wallets/create-wallet.js";
import { ecosystemWallet } from "../wallets/in-app/web/ecosystem.js";
import { inAppWallet } from "../wallets/in-app/web/in-app.js";
import { storyClient } from "./utils.js";
Expand Down Expand Up @@ -110,6 +111,60 @@ export function AllInAppWalletAuthMethods() {
);
}

export function ConfiguredInAppWalletWideModal() {
return (
<ConnectEmbed
client={storyClient}
className="foo-bar"
modalSize="wide"
wallets={[
createWallet("io.metamask"),
inAppWallet({
auth: {
options: ["google", "github", "email"],
},
}),
]}
/>
);
}

export function GoogleLoginWideModal() {
return (
<ConnectEmbed
client={storyClient}
className="foo-bar"
modalSize="wide"
wallets={[
createWallet("io.metamask"),
inAppWallet({
auth: {
options: ["google"],
},
}),
]}
/>
);
}

export function GithubLoginWideModal() {
return (
<ConnectEmbed
client={storyClient}
className="foo-bar"
modalSize="wide"
wallets={[
createWallet("io.metamask"),
inAppWallet({
auth: {
options: ["github"],
},
}),
]}
/>
);
}

export function EcosystemWallet() {
return (
<ConnectEmbed
Expand Down
Loading
Loading