-
Notifications
You must be signed in to change notification settings - Fork 635
[PRO-144] SDK: Update in-app wallet icon in wide connect ui #8556
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
31 changes: 12 additions & 19 deletions
31
packages/thirdweb/src/react/web/ui/ConnectWallet/icons/EmailIcon.tsx
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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> | ||
| ); | ||
| }; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
195 changes: 195 additions & 0 deletions
195
packages/thirdweb/src/react/web/ui/ConnectWallet/in-app-wallet-icon.tsx
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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">; | ||
| }) { | ||
MananTank marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| 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 ( | ||
| <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, | ||
| }} | ||
| > | ||
| <div | ||
| style={{ | ||
| position: "absolute", | ||
| top: offset, | ||
| left: offset, | ||
| display: "flex", | ||
| }} | ||
| > | ||
| <AuthOptionIcon | ||
| authOption={firstMethod} | ||
| client={props.client} | ||
| size={smallIconSize} | ||
| /> | ||
| </div> | ||
|
|
||
| <div | ||
| style={{ | ||
| position: "absolute", | ||
| bottom: offset, | ||
| right: offset, | ||
| display: "flex", | ||
| }} | ||
| > | ||
| <AuthOptionIcon | ||
| authOption={secondMethod} | ||
| client={props.client} | ||
| size={smallIconSize} | ||
| /> | ||
| </div> | ||
|
|
||
| <div> | ||
| {thirdMethod && ( | ||
| <div | ||
| style={{ | ||
| position: "absolute", | ||
| top: offset2, | ||
| right: offset2, | ||
| display: "flex", | ||
| }} | ||
| > | ||
| <AuthOptionIcon | ||
| authOption={thirdMethod} | ||
| client={props.client} | ||
| size={extraIconSize} | ||
| /> | ||
| </div> | ||
| )} | ||
|
|
||
| {fourthMethod && ( | ||
| <div | ||
| style={{ | ||
| position: "absolute", | ||
| bottom: offset2, | ||
| left: offset2, | ||
| display: "flex", | ||
| }} | ||
| > | ||
| <AuthOptionIcon | ||
| authOption={fourthMethod} | ||
| client={props.client} | ||
| size={extraIconSize} | ||
| /> | ||
| </div> | ||
| )} | ||
| </div> | ||
| </div> | ||
| ); | ||
| } | ||
|
|
||
| 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, | ||
| }} | ||
| > | ||
| <AuthOptionIcon | ||
| authOption={firstMethod} | ||
| client={props.client} | ||
| key={firstMethod} | ||
| size={iconSize.lg} | ||
| /> | ||
| </div> | ||
| ); | ||
| } | ||
|
|
||
| return null; | ||
| } | ||
|
|
||
| function AuthOptionIcon(props: { | ||
| authOption: AuthOption; | ||
| client: ThirdwebClient; | ||
| size: string; | ||
| }) { | ||
MananTank marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| 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} | ||
| /> | ||
| ); | ||
| } | ||
MananTank marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
|
||
| if (props.authOption === "phone") { | ||
| return <PhoneIcon size={props.size} color={theme.colors.secondaryText} />; | ||
| } | ||
|
|
||
| if (props.authOption === "email") { | ||
| return <EmailIcon size={props.size} color={theme.colors.secondaryText} />; | ||
| } | ||
|
|
||
| if (props.authOption === "passkey") { | ||
| return ( | ||
| <FingerPrintIcon size={props.size} color={theme.colors.secondaryText} /> | ||
| ); | ||
| } | ||
|
|
||
| if (props.authOption === "guest") { | ||
| return <GuestIcon size={props.size} color={theme.colors.secondaryText} />; | ||
| } | ||
|
|
||
| return null; | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.