diff --git a/.changeset/sixty-clubs-fix.md b/.changeset/sixty-clubs-fix.md new file mode 100644 index 00000000000..bd35d270cc3 --- /dev/null +++ b/.changeset/sixty-clubs-fix.md @@ -0,0 +1,5 @@ +--- +"thirdweb": patch +--- + +Update in-app wallet icon in wide connect ui diff --git a/packages/thirdweb/src/react/web/ui/ConnectWallet/WalletEntryButton.tsx b/packages/thirdweb/src/react/web/ui/ConnectWallet/WalletEntryButton.tsx index 54bf16365d4..9edbf7dd9fd 100644 --- a/packages/thirdweb/src/react/web/ui/ConnectWallet/WalletEntryButton.tsx +++ b/packages/thirdweb/src/react/web/ui/ConnectWallet/WalletEntryButton.tsx @@ -17,6 +17,7 @@ import { Skeleton } from "../components/Skeleton.js"; 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"; /** @@ -52,9 +53,20 @@ export function WalletEntryButton(props: { wallet && walletId === "inApp" ? (wallet.getConfig() as InAppWalletCreationOptions)?.metadata : undefined; - const nameOverride = customMeta?.name || walletName; + let nameOverride = customMeta?.name || walletName; 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 }); + } + } + } + return ( {iconOverride ? ( {nameOverride} + ) : wallet.id === "inApp" ? ( + } + /> ) : ( )} @@ -119,3 +136,7 @@ export const WalletButtonEl = /* @__PURE__ */ StyledButton((_) => { width: "100%", }; }); + +function uppercaseFirstLetter(props: { text: string }) { + return props.text.charAt(0).toUpperCase() + props.text.slice(1); +} diff --git a/packages/thirdweb/src/react/web/ui/ConnectWallet/icons/EmailIcon.tsx b/packages/thirdweb/src/react/web/ui/ConnectWallet/icons/EmailIcon.tsx index bf07dfe1c11..2d30d782e90 100644 --- a/packages/thirdweb/src/react/web/ui/ConnectWallet/icons/EmailIcon.tsx +++ b/packages/thirdweb/src/react/web/ui/ConnectWallet/icons/EmailIcon.tsx @@ -1,30 +1,23 @@ import type { IconFC } from "./types.js"; -/** - * @internal - */ export const EmailIcon: IconFC = (props) => { return ( - - + + ); }; diff --git a/packages/thirdweb/src/react/web/ui/ConnectWallet/icons/WalletDotIcon.tsx b/packages/thirdweb/src/react/web/ui/ConnectWallet/icons/WalletDotIcon.tsx index e67119812cd..e424675e497 100644 --- a/packages/thirdweb/src/react/web/ui/ConnectWallet/icons/WalletDotIcon.tsx +++ b/packages/thirdweb/src/react/web/ui/ConnectWallet/icons/WalletDotIcon.tsx @@ -11,6 +11,7 @@ export const WalletDotIcon: IconFC = (props) => { viewBox="0 0 18 18" width={props.size} height={props.size} + style={{ color: props.color }} role="presentation" > ; +}) { + const enabledAuthMethods = ( + props.wallet.getConfig()?.auth?.options || defaultAuthOptions + ) + .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; + }); + + const theme = useCustomTheme(); + + const firstMethod = enabledAuthMethods[0]; + const secondMethod = enabledAuthMethods[1]; + const thirdMethod = enabledAuthMethods[2]; + const fourthMethod = enabledAuthMethods[3]; + + const offset = "4px"; + const offset2 = "6px"; + const smallIconSize = "20"; + const extraIconSize = "12"; + + if (firstMethod && secondMethod) { + return ( +
+
+ +
+ +
+ +
+ +
+ {thirdMethod && ( +
+ +
+ )} + + {fourthMethod && ( +
+ +
+ )} +
+
+ ); + } + + if (firstMethod) { + return ( +
+ +
+ ); + } + + return null; +} + +function AuthOptionIcon(props: { + authOption: AuthOption; + client: ThirdwebClient; + size: string; +}) { + const theme = useCustomTheme(); + if (props.authOption in socialIcons) { + const icon = socialIcons[props.authOption as keyof typeof socialIcons]; + return ( + + ); + } + + if (props.authOption === "phone") { + return ; + } + + if (props.authOption === "email") { + return ; + } + + if (props.authOption === "passkey") { + return ( + + ); + } + + if (props.authOption === "guest") { + return ; + } + + return null; +} diff --git a/packages/thirdweb/src/react/web/wallets/shared/ConnectWalletSocialOptions.tsx b/packages/thirdweb/src/react/web/wallets/shared/ConnectWalletSocialOptions.tsx index e959e82899a..3864e72951f 100644 --- a/packages/thirdweb/src/react/web/wallets/shared/ConnectWalletSocialOptions.tsx +++ b/packages/thirdweb/src/react/web/wallets/shared/ConnectWalletSocialOptions.tsx @@ -61,7 +61,7 @@ export type ConnectWalletSelectUIState = }; }; -const defaultAuthOptions: AuthOption[] = [ +export const defaultAuthOptions: AuthOption[] = [ "email", "phone", "google", diff --git a/packages/thirdweb/src/stories/ConnectEmbed.stories.tsx b/packages/thirdweb/src/stories/ConnectEmbed.stories.tsx index cab7b800bf7..32e0ccc09c9 100644 --- a/packages/thirdweb/src/stories/ConnectEmbed.stories.tsx +++ b/packages/thirdweb/src/stories/ConnectEmbed.stories.tsx @@ -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"; @@ -110,6 +111,60 @@ export function AllInAppWalletAuthMethods() { ); } +export function ConfiguredInAppWalletWideModal() { + return ( + + ); +} + +export function GoogleLoginWideModal() { + return ( + + ); +} + +export function GithubLoginWideModal() { + return ( + + ); +} + export function EcosystemWallet() { return ( = { + title: "Components/in-app-wallet-icon", + decorators: [ + (Story) => { + return ( + + + + ); + }, + ], +}; +export default meta; + +function Variants() { + const theme = useCustomTheme(); + return ( +
+
+ + +
+ +
+ +
+ + + + + + + + + + + + + + + + + + +
+
+ +
+ +
+ + + + + + + + + + + + + + +
+
+ +
+ +
+ + + + + +
+
+ +
+ +
+ + + + + +
+
+
+ ); +} + +export function LightTheme() { + return ; +} + +export function DarkTheme() { + return ; +} + +function ThemeSetup(props: { theme: "light" | "dark" }) { + return ( + + + + ); +} + +function Variant(props: { authOptions: AuthOption[] }) { + return ( + + ); +} + +function SectionTitle(props: { title: string }) { + const theme = useCustomTheme(); + return ( +

+ {props.title} +

+ ); +}