Compare commits

..
Author SHA1 Message Date
github-actions[bot]andgithub-actions[bot] 44c9ccd65d Version Packages (#1963)
Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
2023-11-16 10:21:09 -08:00
Manan Tank 7912c26323 [react] use custom theme context in styled components (#1954) 2023-11-16 17:53:44 +00:00
iketwandManan Tank 69d68f5a25 [RN/React] Enables FB and Apple sign in for embedded wallet (#1945)
Co-authored-by: Manan Tank <[email protected]>
2023-11-16 13:31:22 +00:00
github-actions[bot]andgithub-actions[bot] 836be52724 Version Packages (#1959)
Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
2023-11-15 20:26:55 -08:00
Joaquim Verges 9f993dcc1e [EmbeddedWallet] fix switch chains logic (#1958) 2023-11-15 16:56:19 -08:00
87 changed files with 1804 additions and 1375 deletions
+14
View File
@@ -1,5 +1,19 @@
# @thirdweb-dev/auth # @thirdweb-dev/auth
## 4.1.8
### Patch Changes
- Updated dependencies [[`69d68f5a`](https://github.com/thirdweb-dev/js/commit/69d68f5a25877bf5ea694719d2cf4ca8388f3091)]:
- @thirdweb-dev/wallets@2.1.5
## 4.1.7
### Patch Changes
- Updated dependencies [[`9f993dcc`](https://github.com/thirdweb-dev/js/commit/9f993dcc1e60cc087850b8fb9ce09524073ce0b5)]:
- @thirdweb-dev/wallets@2.1.4
## 4.1.6 ## 4.1.6
### Patch Changes ### Patch Changes
+1 -1
View File
@@ -1,6 +1,6 @@
{ {
"name": "@thirdweb-dev/auth", "name": "@thirdweb-dev/auth",
"version": "4.1.6", "version": "4.1.8",
"main": "dist/thirdweb-dev-auth.cjs.js", "main": "dist/thirdweb-dev-auth.cjs.js",
"module": "dist/thirdweb-dev-auth.esm.js", "module": "dist/thirdweb-dev-auth.esm.js",
"browser": { "browser": {
+16
View File
@@ -1,5 +1,21 @@
# thirdweb # thirdweb
## 0.13.16
### Patch Changes
- Updated dependencies [[`69d68f5a`](https://github.com/thirdweb-dev/js/commit/69d68f5a25877bf5ea694719d2cf4ca8388f3091)]:
- @thirdweb-dev/wallets@2.1.5
- @thirdweb-dev/auth@4.1.8
## 0.13.15
### Patch Changes
- Updated dependencies [[`9f993dcc`](https://github.com/thirdweb-dev/js/commit/9f993dcc1e60cc087850b8fb9ce09524073ce0b5)]:
- @thirdweb-dev/wallets@2.1.4
- @thirdweb-dev/auth@4.1.7
## 0.13.14 ## 0.13.14
### Patch Changes ### Patch Changes
+1 -1
View File
@@ -1,7 +1,7 @@
{ {
"name": "thirdweb", "name": "thirdweb",
"main": "dist/cli/index.js", "main": "dist/cli/index.js",
"version": "0.13.14", "version": "0.13.16",
"repository": "https://github.com/thirdweb-dev/js/tree/main/packages/cli", "repository": "https://github.com/thirdweb-dev/js/tree/main/packages/cli",
"author": "thirdweb eng <[email protected]>", "author": "thirdweb eng <[email protected]>",
"license": "Apache-2.0", "license": "Apache-2.0",
+16
View File
@@ -1,5 +1,21 @@
# @thirdweb-dev/react-core # @thirdweb-dev/react-core
## 4.1.6
### Patch Changes
- Updated dependencies [[`69d68f5a`](https://github.com/thirdweb-dev/js/commit/69d68f5a25877bf5ea694719d2cf4ca8388f3091)]:
- @thirdweb-dev/wallets@2.1.5
- @thirdweb-dev/auth@4.1.8
## 4.1.5
### Patch Changes
- Updated dependencies [[`9f993dcc`](https://github.com/thirdweb-dev/js/commit/9f993dcc1e60cc087850b8fb9ce09524073ce0b5)]:
- @thirdweb-dev/wallets@2.1.4
- @thirdweb-dev/auth@4.1.7
## 4.1.4 ## 4.1.4
### Patch Changes ### Patch Changes
+1 -1
View File
@@ -1,6 +1,6 @@
{ {
"name": "@thirdweb-dev/react-core", "name": "@thirdweb-dev/react-core",
"version": "4.1.4", "version": "4.1.6",
"repository": "https://github.com/thirdweb-dev/js/tree/main/packages/react-core", "repository": "https://github.com/thirdweb-dev/js/tree/main/packages/react-core",
"author": "thirdweb eng <[email protected]>", "author": "thirdweb eng <[email protected]>",
"license": "Apache-2.0", "license": "Apache-2.0",
@@ -1,5 +1,9 @@
# @thirdweb-dev/react-native-compat # @thirdweb-dev/react-native-compat
## 0.4.6
## 0.4.5
## 0.4.4 ## 0.4.4
## 0.4.3 ## 0.4.3
+1 -1
View File
@@ -1,7 +1,7 @@
{ {
"name": "@thirdweb-dev/react-native-compat", "name": "@thirdweb-dev/react-native-compat",
"description": "Shims for Thirdweb in React Native Projects", "description": "Shims for Thirdweb in React Native Projects",
"version": "0.4.4", "version": "0.4.6",
"author": "thirdweb eng <[email protected]>", "author": "thirdweb eng <[email protected]>",
"repository": "https://github.com/thirdweb-dev/js/tree/main/packages/react-native-compat", "repository": "https://github.com/thirdweb-dev/js/tree/main/packages/react-native-compat",
"license": "Apache-2.0", "license": "Apache-2.0",
+18
View File
@@ -1,5 +1,23 @@
# @thirdweb-dev/react-native # @thirdweb-dev/react-native
## 0.4.6
### Patch Changes
- [#1945](https://github.com/thirdweb-dev/js/pull/1945) [`69d68f5a`](https://github.com/thirdweb-dev/js/commit/69d68f5a25877bf5ea694719d2cf4ca8388f3091) Thanks [@iketw](https://github.com/iketw)! - Enable Facebook Sign In for embedded wallet
- Updated dependencies [[`69d68f5a`](https://github.com/thirdweb-dev/js/commit/69d68f5a25877bf5ea694719d2cf4ca8388f3091)]:
- @thirdweb-dev/wallets@2.1.5
- @thirdweb-dev/react-core@4.1.6
## 0.4.5
### Patch Changes
- Updated dependencies [[`9f993dcc`](https://github.com/thirdweb-dev/js/commit/9f993dcc1e60cc087850b8fb9ce09524073ce0b5)]:
- @thirdweb-dev/wallets@2.1.4
- @thirdweb-dev/react-core@4.1.5
## 0.4.4 ## 0.4.4
### Patch Changes ### Patch Changes
+1 -1
View File
@@ -1,6 +1,6 @@
{ {
"name": "@thirdweb-dev/react-native", "name": "@thirdweb-dev/react-native",
"version": "0.4.4", "version": "0.4.6",
"repository": "https://github.com/thirdweb-dev/js/tree/main/packages/react-native", "repository": "https://github.com/thirdweb-dev/js/tree/main/packages/react-native",
"author": "thirdweb eng <[email protected]>", "author": "thirdweb eng <[email protected]>",
"license": "Apache-2.0", "license": "Apache-2.0",
@@ -176,16 +176,17 @@ export const ExportLocalWalletModal = ({
<Text variant="bodySmall" color="red" mt="xs" textAlign="left"> <Text variant="bodySmall" color="red" mt="xs" textAlign="left">
{error} {error}
</Text> </Text>
<Box flexDirection="row" justifyContent="flex-end" mt="lg"> <Box flexDirection="row" justifyContent="flex-end" mt="xs">
<BaseButton <BaseButton
backgroundColor="white" backgroundColor="accentButtonColor"
borderColor="accentButtonColor"
style={styles.modalButton} style={styles.modalButton}
onPress={onContinuePress} onPress={onContinuePress}
> >
{isExporting ? ( {isExporting ? (
<ActivityIndicator size="small" color="black" /> <ActivityIndicator size="small" color="black" />
) : ( ) : (
<Text variant="bodySmall" color="black"> <Text variant="bodySmall" color="accentButtonTextColor">
{l.connect_wallet_details.backup} {l.connect_wallet_details.backup}
</Text> </Text>
)} )}
@@ -1,7 +1,7 @@
import { walletIds } from "@thirdweb-dev/wallets"; import { walletIds } from "@thirdweb-dev/wallets";
import { ModalHeaderTextClose } from "../../base/modal/ModalHeaderTextClose"; import { ModalHeaderTextClose } from "../../base/modal/ModalHeaderTextClose";
import { WalletConfig } from "@thirdweb-dev/react-core"; import { WalletConfig } from "@thirdweb-dev/react-core";
import { ReactNode, useState } from "react"; import { ReactNode, useMemo, useState } from "react";
import Box from "../../base/Box"; import Box from "../../base/Box";
import Text from "../../base/Text"; import Text from "../../base/Text";
import ThirdwebLogo from "../../../assets/thirdweb-logo"; import ThirdwebLogo from "../../../assets/thirdweb-logo";
@@ -33,7 +33,6 @@ export function ChooseWallet({
onChooseWallet, onChooseWallet,
modalTitleIconUrl, modalTitleIconUrl,
onClose, onClose,
excludeWalletIds = [],
termsOfServiceUrl, termsOfServiceUrl,
privacyPolicyUrl, privacyPolicyUrl,
}: ChooseWalletProps) { }: ChooseWalletProps) {
@@ -49,14 +48,25 @@ export function ChooseWallet({
w.id === walletIds.magicLink || w.id === walletIds.magicLink ||
(w.id === walletIds.embeddedWallet && w.selectUI), (w.id === walletIds.embeddedWallet && w.selectUI),
); );
const connectionWallets = wallets
.filter( const walletsToDisplay = useMemo(() => {
const filteredWallets = wallets.filter(
(wallet) => (wallet) =>
wallet.id !== walletIds.magicLink && wallet.id !== walletIds.magicLink &&
wallet.id !== walletIds.embeddedWallet && wallet.id !== walletIds.embeddedWallet &&
wallet.id !== walletIds.localWallet, wallet.id !== walletIds.localWallet,
) );
.slice(0, 2);
const trueItems = filteredWallets.filter(
(item) => item.recommended === true,
);
const falseItems = filteredWallets.filter(
(item) => item.recommended !== true,
);
const sortedWallets = [...trueItems, ...falseItems];
return sortedWallets;
}, [wallets]);
const showToSPrivacyPolicy = termsOfServiceUrl || privacyPolicyUrl; const showToSPrivacyPolicy = termsOfServiceUrl || privacyPolicyUrl;
@@ -74,7 +84,7 @@ export function ChooseWallet({
}; };
const onSingleWalletPress = () => { const onSingleWalletPress = () => {
onChooseWallet(connectionWallets[0]); onChooseWallet(walletsToDisplay[0]);
}; };
const onBackPress = () => { const onBackPress = () => {
@@ -135,13 +145,7 @@ export function ChooseWallet({
{!emailWallet || isConnectAWalletEnabled ? ( {!emailWallet || isConnectAWalletEnabled ? (
<> <>
<ChooseWalletContent <ChooseWalletContent
wallets={wallets} wallets={walletsToDisplay}
excludeWalletIds={[
...excludeWalletIds,
walletIds.localWallet,
walletIds.magicLink,
walletIds.embeddedWallet,
]}
onChooseWallet={onChooseWallet} onChooseWallet={onChooseWallet}
/> />
@@ -176,7 +180,7 @@ export function ChooseWallet({
) : null} ) : null}
{emailWallet && {emailWallet &&
!isConnectAWalletEnabled && !isConnectAWalletEnabled &&
(guestWallet || connectionWallets.length > 0) ? ( (guestWallet || walletsToDisplay.length > 0) ? (
<Box <Box
mt="md" mt="md"
marginHorizontal="xl" marginHorizontal="xl"
@@ -193,15 +197,15 @@ export function ChooseWallet({
) : null} ) : null}
{emailWallet && {emailWallet &&
!isConnectAWalletEnabled && !isConnectAWalletEnabled &&
connectionWallets.length > 0 ? ( walletsToDisplay.length > 0 ? (
connectionWallets.length === 1 ? ( walletsToDisplay.length === 1 ? (
<WalletButton <WalletButton
marginHorizontal="xl" marginHorizontal="xl"
paddingHorizontal="none" paddingHorizontal="none"
paddingVertical="none" paddingVertical="none"
mt="md" mt="md"
walletIconUrl={connectionWallets[0].meta.iconURL} walletIconUrl={walletsToDisplay[0].meta.iconURL}
name={connectionWallets[0].meta.name} name={walletsToDisplay[0].meta.name}
onPress={onSingleWalletPress} onPress={onSingleWalletPress}
/> />
) : ( ) : (
@@ -217,7 +221,10 @@ export function ChooseWallet({
borderWidth={1} borderWidth={1}
onPress={onConnectAWalletPress} onPress={onConnectAWalletPress}
> >
{connectionWallets.map((wallet) => { {walletsToDisplay.map((wallet, index) => {
if (index > 1) {
return null;
}
return ( return (
<Box key={wallet.meta.name} mr="xxs"> <Box key={wallet.meta.name} mr="xxs">
<ImageSvgUri <ImageSvgUri
@@ -1,4 +1,3 @@
import { useMemo } from "react";
import type { WalletConfig } from "@thirdweb-dev/react-core"; import type { WalletConfig } from "@thirdweb-dev/react-core";
import { Dimensions, ScrollView, View } from "react-native"; import { Dimensions, ScrollView, View } from "react-native";
import { WalletButton } from "../../base/WalletButton"; import { WalletButton } from "../../base/WalletButton";
@@ -7,7 +6,6 @@ import { useTheme } from "@shopify/restyle";
interface ChooseWalletContentProps { interface ChooseWalletContentProps {
wallets: WalletConfig[]; wallets: WalletConfig[];
excludeWalletIds?: string[];
onChooseWallet: (wallet: WalletConfig, data?: any) => void; onChooseWallet: (wallet: WalletConfig, data?: any) => void;
} }
@@ -15,27 +13,10 @@ const MAX_HEIGHT = Dimensions.get("window").height * 0.3;
export const ChooseWalletContent = ({ export const ChooseWalletContent = ({
wallets, wallets,
excludeWalletIds,
onChooseWallet, onChooseWallet,
}: ChooseWalletContentProps) => { }: ChooseWalletContentProps) => {
const theme = useTheme(); const theme = useTheme();
const walletsToDisplay = useMemo(() => {
const filteredWallets = wallets.filter(
(w) => !!!excludeWalletIds?.find((ewId) => ewId === w.id),
);
const trueItems = filteredWallets.filter(
(item) => item.recommended === true,
);
const falseItems = filteredWallets.filter(
(item) => item.recommended !== true,
);
const sortedWallets = [...trueItems, ...falseItems];
return sortedWallets;
}, [wallets, excludeWalletIds]);
return ( return (
<View style={{ flexDirection: "column", maxHeight: MAX_HEIGHT }}> <View style={{ flexDirection: "column", maxHeight: MAX_HEIGHT }}>
<ScrollView <ScrollView
@@ -45,9 +26,8 @@ export const ChooseWalletContent = ({
paddingHorizontal: 16, paddingHorizontal: 16,
}} }}
> >
{walletsToDisplay.map((item, index) => { {wallets.map((item, index) => {
const marginBottom = const marginBottom = index === wallets.length - 1 ? "none" : "xxs";
index === walletsToDisplay.length - 1 ? "none" : "xxs";
return ( return (
<Box key={item.id}> <Box key={item.id}>
{item.selectUI ? ( {item.selectUI ? (
@@ -188,14 +188,21 @@ export const LocalWalletImportModal = ({
{l.common.password} {l.common.password}
</Text> </Text>
<PasswordInput onChangeText={onChangeText} /> <PasswordInput onChangeText={onChangeText} />
<Text variant="bodySmall" color="red" mt="xs" textAlign="left"> {error ? (
{error} <Text
</Text> variant="bodySmall"
color="red"
marginVertical="xxs"
textAlign="left"
>
{error}
</Text>
) : null}
<Box <Box
mb="xs"
flexDirection="row" flexDirection="row"
justifyContent="center" justifyContent="center"
alignItems="center" alignItems="center"
mt="sm"
> >
<Box height={1} flex={1} backgroundColor="border" /> <Box height={1} flex={1} backgroundColor="border" />
<Text variant="bodySmall" textAlign="center" marginHorizontal="xxs"> <Text variant="bodySmall" textAlign="center" marginHorizontal="xxs">
@@ -214,23 +221,19 @@ export const LocalWalletImportModal = ({
fontFamily: theme.textVariants.defaults.fontFamily, fontFamily: theme.textVariants.defaults.fontFamily,
}, },
}} }}
containerProps={{ pl: "xxs" }} containerProps={{ pl: "xxs", mt: "sm" }}
/> />
<Box <Box flexDirection="row" justifyContent="flex-end" mt="lg">
flexDirection="row"
justifyContent="center"
paddingHorizontal="md"
mt="lg"
>
<BaseButton <BaseButton
backgroundColor="white" backgroundColor="accentButtonColor"
borderColor="accentButtonColor"
style={styles.modalButton} style={styles.modalButton}
onPress={onImportPress} onPress={onImportPress}
> >
{isImporting ? ( {isImporting ? (
<ActivityIndicator size="small" color="black" /> <ActivityIndicator size="small" color="accentButtonTextColor" />
) : ( ) : (
<Text variant="bodySmall" color="black"> <Text variant="bodySmall" color="accentButtonTextColor">
{l.common.import} {l.common.import}
</Text> </Text>
)} )}
@@ -338,6 +338,7 @@ const SendFundsForm = ({
<BaseButton <BaseButton
mt="md" mt="md"
backgroundColor="accentButtonColor" backgroundColor="accentButtonColor"
borderColor="accentButtonColor"
flexDirection="row" flexDirection="row"
alignItems="center" alignItems="center"
justifyContent="center" justifyContent="center"
@@ -85,7 +85,7 @@ export const NetworkButton = ({
> >
<Box flexDirection="row" alignItems="center"> <Box flexDirection="row" alignItems="center">
<ChainIcon chainIconUrl={chain?.icon?.url} size={28} /> <ChainIcon chainIconUrl={chain?.icon?.url} size={28} />
<Box ml="md" alignItems="flex-start" justifyContent="center"> <Box ml="sm" alignItems="flex-start" justifyContent="center">
<Text variant="bodyLarge"> <Text variant="bodyLarge">
{chain?.name || l.common.unknown_network} {chain?.name || l.common.unknown_network}
</Text> </Text>
@@ -161,8 +161,10 @@ export const SwitchChainModal = ({
return ( return (
<NetworkButton <NetworkButton
mt="xxs" mt="xxs"
padding="none"
key={chain.chainId} key={chain.chainId}
backgroundColor="backgroundHighlight" backgroundColor="transparent"
borderColor="transparent"
chain={chain} chain={chain}
enableSwitchModal={false} enableSwitchModal={false}
switchChainOnPress={true} switchChainOnPress={true}
@@ -1,5 +1,4 @@
import BaseButton from "./BaseButton"; import BaseButton from "./BaseButton";
import Box from "./Box";
import ImageSvgUri from "./ImageSvgUri"; import ImageSvgUri from "./ImageSvgUri";
import Text from "./Text"; import Text from "./Text";
@@ -22,16 +21,14 @@ export const SquareButton = ({
flexDirection="column" flexDirection="column"
alignItems="center" alignItems="center"
justifyContent="center" justifyContent="center"
borderWidth={0} borderWidth={1}
borderRadius="sm" borderRadius="sm"
width={size} borderColor="border"
height={size} padding="sm"
onPress={onPress} onPress={onPress}
{...props} {...props}
> >
<Box borderWidth={0} borderRadius="lg"> <ImageSvgUri imageUrl={iconUrl} width={size} height={size} />
<ImageSvgUri imageUrl={iconUrl} width={size} height={size} />
</Box>
{name ? ( {name ? (
<Text <Text
variant="bodySmallSecondary" variant="bodySmallSecondary"
@@ -26,6 +26,7 @@ export type Palette = {
black: string; black: string;
white: string; white: string;
red: string; red: string;
transparent: string;
warning: string; warning: string;
@@ -38,6 +39,7 @@ export const paletteBase = {
red: "red", red: "red",
warning: "#F46565", warning: "#F46565",
error: "#D85252", error: "#D85252",
transparent: "transparent",
}; };
export const paletteLight: Palette = { export const paletteLight: Palette = {
@@ -19,8 +19,11 @@ import {
import { getEthersSigner } from "./embedded/signer"; import { getEthersSigner } from "./embedded/signer";
import { logoutUser } from "./embedded/helpers/auth/logout"; import { logoutUser } from "./embedded/helpers/auth/logout";
import { import {
clearConnectedAuthStrategy,
clearConnectedEmail, clearConnectedEmail,
getConnectedAuthStrategy,
getConnectedEmail, getConnectedEmail,
saveConnectedAuthStrategy,
saveConnectedEmail, saveConnectedEmail,
} from "./embedded/helpers/storage/local"; } from "./embedded/helpers/storage/local";
import { import {
@@ -39,11 +42,15 @@ export class EmbeddedWalletConnector extends Connector<EmbeddedWalletConnectionA
email?: string; email?: string;
connectedAuthStrategy?: AuthParams["strategy"];
constructor(options: EmbeddedWalletConnectorOptions) { constructor(options: EmbeddedWalletConnectorOptions) {
super(); super();
this.options = options; this.options = options;
this.email = getConnectedEmail(); this.email = getConnectedEmail();
this.connectedAuthStrategy = getConnectedAuthStrategy();
} }
async connect(options?: EmbeddedWalletConnectionArgs) { async connect(options?: EmbeddedWalletConnectionArgs) {
@@ -59,14 +66,12 @@ export class EmbeddedWalletConnector extends Connector<EmbeddedWalletConnectionA
await this.switchChain(options.chainId); await this.switchChain(options.chainId);
} }
if (this.email) {
saveConnectedEmail(this.email);
}
return this.getAddress(); return this.getAddress();
} }
async authenticate(params: AuthParams): Promise<AuthResult> { async authenticate(params: AuthParams): Promise<AuthResult> {
const strategy = params.strategy; const strategy = params.strategy;
this.connectedAuthStrategy = strategy;
switch (strategy) { switch (strategy) {
case "email_verification": { case "email_verification": {
return await this.validateEmailOTP({ return await this.validateEmailOTP({
@@ -172,7 +177,6 @@ export class EmbeddedWalletConnector extends Connector<EmbeddedWalletConnectionA
this.options.clientId, this.options.clientId,
); );
this.email = email; this.email = email;
saveConnectedEmail(email);
return { return {
user: { user: {
@@ -228,6 +232,7 @@ export class EmbeddedWalletConnector extends Connector<EmbeddedWalletConnectionA
async disconnect(): Promise<void> { async disconnect(): Promise<void> {
clearConnectedEmail(); clearConnectedEmail();
clearConnectedAuthStrategy();
await logoutUser(this.options.clientId); await logoutUser(this.options.clientId);
await this.onDisconnect(); await this.onDisconnect();
this.signer = undefined; this.signer = undefined;
@@ -274,6 +279,13 @@ export class EmbeddedWalletConnector extends Connector<EmbeddedWalletConnectionA
); );
} }
if (this.email) {
saveConnectedEmail(this.email);
}
if (this.connectedAuthStrategy) {
saveConnectedAuthStrategy(this.connectedAuthStrategy);
}
return signer; return signer;
} }
@@ -347,6 +359,10 @@ export class EmbeddedWalletConnector extends Connector<EmbeddedWalletConnectionA
getEmail() { getEmail() {
return this.email; return this.email;
} }
getConnectedAuthStrategy() {
return this.connectedAuthStrategy;
}
} }
function assertUnreachable(x: never): never { function assertUnreachable(x: never): never {
@@ -220,7 +220,7 @@ export async function socialLogin(oauthOptions: OauthOption, clientId: string) {
if (parts.length < 2) { if (parts.length < 2) {
// assume error // assume error
const error = decodedUrl.split("?error=")?.[1]; const error = decodedUrl.split("?error=")?.[1];
throw new Error(`Something went wrong. Please, try again later: ${error}`); throw new Error(`Something went wrong: ${error}`);
} }
const authResult = parts[1]; const authResult = parts[1];
@@ -6,8 +6,11 @@ import {
} from "@paperxyz/embedded-wallet-service-sdk"; } from "@paperxyz/embedded-wallet-service-sdk";
import { MMKV } from "react-native-mmkv"; import { MMKV } from "react-native-mmkv";
import { DEVICE_SHARE_MISSING_MESSAGE } from "../constants"; import { DEVICE_SHARE_MISSING_MESSAGE } from "../constants";
import { AuthParams } from "../../../types";
const CONNECTED_EMAIL_LOCAL_STORAGE_NAME = "embedded-wallet-connected-email"; const CONNECTED_EMAIL_LOCAL_STORAGE_NAME = "embedded-wallet-connected-email";
const CONNECTED_AUTH_STRATEGY_LOCAL_STORAGE_NAME =
"embedded-wallet-connected-auth-params";
const storage = new MMKV(); const storage = new MMKV();
@@ -34,6 +37,23 @@ export function clearConnectedEmail() {
removeItemInAsyncStorage(CONNECTED_EMAIL_LOCAL_STORAGE_NAME); removeItemInAsyncStorage(CONNECTED_EMAIL_LOCAL_STORAGE_NAME);
} }
export function getConnectedAuthStrategy(): AuthParams["strategy"] | undefined {
return getItemFromAsyncStorage(CONNECTED_AUTH_STRATEGY_LOCAL_STORAGE_NAME) as
| AuthParams["strategy"]
| undefined;
}
export function saveConnectedAuthStrategy(authStrategy: string) {
setItemInAsyncStorage(
CONNECTED_AUTH_STRATEGY_LOCAL_STORAGE_NAME,
authStrategy,
);
}
export function clearConnectedAuthStrategy() {
removeItemInAsyncStorage(CONNECTED_AUTH_STRATEGY_LOCAL_STORAGE_NAME);
}
export async function isDeviceSharePresentForUser( export async function isDeviceSharePresentForUser(
clientId: string, clientId: string,
walletUserId?: string, walletUserId?: string,
@@ -1,9 +1,14 @@
import { APPLE_ICON, EMAIL_WALLET_ICON, GOOGLE_ICON } from "../../assets"; import {
APPLE_ICON,
EMAIL_WALLET_ICON,
FACEBOOK_ICON,
GOOGLE_ICON,
} from "../../assets";
import { LocaleType } from "../../i18n/types"; import { LocaleType } from "../../i18n/types";
export type AuthOption = "email" | SocialLogin; export type AuthOption = "email" | SocialLogin;
export type SocialLogin = "google" | "apple"; export type SocialLogin = "google" | "apple" | "facebook";
export type AuthOptionDictionary = Record<AuthOption, string>; export type AuthOptionDictionary = Record<AuthOption, string>;
@@ -11,6 +16,7 @@ export const AUTH_OPTIONS_ICONS: AuthOptionDictionary = {
google: GOOGLE_ICON, google: GOOGLE_ICON,
email: EMAIL_WALLET_ICON, email: EMAIL_WALLET_ICON,
apple: APPLE_ICON, apple: APPLE_ICON,
facebook: FACEBOOK_ICON,
}; };
export const AUTH_OPTIONS_TEXT: Record< export const AUTH_OPTIONS_TEXT: Record<
@@ -20,4 +26,5 @@ export const AUTH_OPTIONS_TEXT: Record<
google: "sign_in_google", google: "sign_in_google",
email: "sign_in_email", email: "sign_in_email",
apple: "sign_in_apple", apple: "sign_in_apple",
facebook: "sign_in_facebook",
}; };
@@ -108,9 +108,9 @@ export const EmailSelectionUI: React.FC<
iconWidth={28} iconWidth={28}
borderRadius="lg" borderRadius="lg"
borderWidth={1} borderWidth={1}
borderColor="buttonBackgroundColor" borderColor="backgroundHighlight"
backgroundColor="buttonBackgroundColor" backgroundColor="backgroundHighlight"
nameColor="buttonTextColor" nameColor="textPrimary"
flex={1} flex={1}
justifyContent="center" justifyContent="center"
name={l.embedded_wallet[AUTH_OPTIONS_TEXT[socialLogins[0]]]} name={l.embedded_wallet[AUTH_OPTIONS_TEXT[socialLogins[0]]]}
@@ -118,15 +118,18 @@ export const EmailSelectionUI: React.FC<
onPress={() => onProviderPress(socialLogins[0])} onPress={() => onProviderPress(socialLogins[0])}
/> />
) : ( ) : (
socialLogins.map((provider, index) => ( <Box flexDirection="row" width="100%">
<SquareButton {socialLogins.map((provider, index) => (
key={provider} <SquareButton
ml={index === 0 ? 0 : "md"} key={provider}
onPress={() => onProviderPress(provider)} ml={index === 0 ? 0 : "md"}
iconUrl={AUTH_OPTIONS_ICONS[provider]} flex={1}
size={40} onPress={() => onProviderPress(provider)}
/> iconUrl={AUTH_OPTIONS_ICONS[provider]}
)) size={32}
/>
))}
</Box>
)} )}
</Box> </Box>
{isEmailEnabled && supportedWallets.length === 1 ? ( {isEmailEnabled && supportedWallets.length === 1 ? (
@@ -148,7 +151,7 @@ export const EmailSelectionUI: React.FC<
<Box height={1} flex={1} backgroundColor="border" /> <Box height={1} flex={1} backgroundColor="border" />
</Box> </Box>
) : ( ) : (
<Box mt="md" /> <Box mt={isEmailEnabled ? "md" : "none"} />
)} )}
</Box> </Box>
) : null} ) : null}
@@ -187,8 +190,8 @@ export const EmailSelectionUI: React.FC<
paddingVertical="md" paddingVertical="md"
borderRadius="lg" borderRadius="lg"
borderWidth={1} borderWidth={1}
borderColor="border"
backgroundColor="accentButtonColor" backgroundColor="accentButtonColor"
borderColor="accentButtonColor"
onPress={handleNetworkCall} onPress={handleNetworkCall}
> >
{isFetching ? ( {isFetching ? (
@@ -11,6 +11,8 @@ import {
EmbeddedWalletConnectionArgs, EmbeddedWalletConnectionArgs,
} from "../../connectors/embedded-wallet/types"; } from "../../connectors/embedded-wallet/types";
import { EMAIL_WALLET_ICON } from "../../../assets/svgs"; import { EMAIL_WALLET_ICON } from "../../../assets/svgs";
import { WalletMeta } from "@thirdweb-dev/wallets/dist/declarations/src/evm/wallets/base";
import { AUTH_OPTIONS_ICONS } from "../../types/embedded-wallet";
export type EmbeddedWalletOptions = WalletOptions< export type EmbeddedWalletOptions = WalletOptions<
EmbeddedWalletAdditionalOptions & WalletConnectReceiverConfig EmbeddedWalletAdditionalOptions & WalletConnectReceiverConfig
@@ -79,6 +81,22 @@ export class EmbeddedWallet extends AbstractClientWallet<
return connector.authenticate(params); return connector.authenticate(params);
} }
getMeta(): WalletMeta {
const strategy = this.connector?.getConnectedAuthStrategy();
const meta = (this.constructor as typeof AbstractClientWallet).meta;
switch (strategy) {
case "facebook":
case "apple":
case "google":
return {
...meta,
iconURL: AUTH_OPTIONS_ICONS[strategy],
};
default:
return meta;
}
}
onConnected = () => { onConnected = () => {
this.emit("message", { type: "connected" }); this.emit("message", { type: "connected" });
}; };
+20
View File
@@ -1,5 +1,25 @@
# @thirdweb-dev/react # @thirdweb-dev/react
## 4.1.6
### Patch Changes
- [#1954](https://github.com/thirdweb-dev/js/pull/1954) [`7912c263`](https://github.com/thirdweb-dev/js/commit/7912c263237708e9d2e9471873db7679e783b6f8) Thanks [@MananTank](https://github.com/MananTank)! - use Custom Theme context in styled components to prevent theme conflicts
- [#1945](https://github.com/thirdweb-dev/js/pull/1945) [`69d68f5a`](https://github.com/thirdweb-dev/js/commit/69d68f5a25877bf5ea694719d2cf4ca8388f3091) Thanks [@iketw](https://github.com/iketw)! - Enable Facebook Sign In for embedded wallet
- Updated dependencies [[`69d68f5a`](https://github.com/thirdweb-dev/js/commit/69d68f5a25877bf5ea694719d2cf4ca8388f3091)]:
- @thirdweb-dev/wallets@2.1.5
- @thirdweb-dev/react-core@4.1.6
## 4.1.5
### Patch Changes
- Updated dependencies [[`9f993dcc`](https://github.com/thirdweb-dev/js/commit/9f993dcc1e60cc087850b8fb9ce09524073ce0b5)]:
- @thirdweb-dev/wallets@2.1.4
- @thirdweb-dev/react-core@4.1.5
## 4.1.4 ## 4.1.4
### Patch Changes ### Patch Changes
+1 -1
View File
@@ -1,6 +1,6 @@
{ {
"name": "@thirdweb-dev/react", "name": "@thirdweb-dev/react",
"version": "4.1.4", "version": "4.1.6",
"repository": "https://github.com/thirdweb-dev/js/tree/main/packages/react", "repository": "https://github.com/thirdweb-dev/js/tree/main/packages/react",
"author": "thirdweb eng <[email protected]>", "author": "thirdweb eng <[email protected]>",
"license": "Apache-2.0", "license": "Apache-2.0",
+11 -12
View File
@@ -1,7 +1,6 @@
import type { Theme } from "../design-system";
import styled from "@emotion/styled";
import { Chain } from "@thirdweb-dev/chains"; import { Chain } from "@thirdweb-dev/chains";
import { useStorage } from "@thirdweb-dev/react-core"; import { useStorage } from "@thirdweb-dev/react-core";
import { StyledDiv } from "../design-system/elements";
const defaultChainIcon = const defaultChainIcon =
"ipfs://QmcxZHpyJa8T4i63xqjPYrZ6tKrt55tZJpbXcjSDKuKaf9/ethereum/512.png"; "ipfs://QmcxZHpyJa8T4i63xqjPYrZ6tKrt55tZJpbXcjSDKuKaf9/ethereum/512.png";
@@ -52,13 +51,13 @@ export const ChainIcon: React.FC<{
); );
}; };
const ActiveDot = styled.div<{ theme?: Theme }>` const ActiveDot = /* @__PURE__ */ StyledDiv({
width: 28%; width: "28%",
height: 28%; height: "28%",
border-radius: 50%; borderRadius: "50%",
position: absolute; position: "absolute",
top: 60%; top: "60%",
right: 0px; right: 0,
background-color: #00d395; backgroundColor: "#00d395",
box-shadow: 0 0 0 2px var(--bg); boxShadow: `0 0 0 2px var(--bg)`,
`; });
+7 -4
View File
@@ -1,4 +1,4 @@
import type { Theme } from "../design-system"; import { useCustomTheme } from "../design-system/CustomThemeProvider";
import { useClipboard } from "../evm/components/hooks/useCopyClipboard"; import { useClipboard } from "../evm/components/hooks/useCopyClipboard";
import { ToolTip } from "./Tooltip"; import { ToolTip } from "./Tooltip";
import styled from "@emotion/styled"; import styled from "@emotion/styled";
@@ -29,6 +29,9 @@ export const CopyIcon: React.FC<{
); );
}; };
const CheckIconStyled = /* @__PURE__ */ styled(CheckIcon)<{ theme?: Theme }>` const CheckIconStyled = /* @__PURE__ */ styled(CheckIcon)(() => {
color: ${(p) => p.theme.colors.success}; const theme = useCustomTheme();
`; return {
color: theme.colors.success,
};
});
+32 -29
View File
@@ -1,12 +1,14 @@
import { useState } from "react"; import { useState } from "react";
import { UploadIcon } from "@radix-ui/react-icons"; import { UploadIcon } from "@radix-ui/react-icons";
import { Theme, iconSize, radius, spacing } from "../design-system"; import { iconSize, radius, spacing } from "../design-system";
import styled from "@emotion/styled"; import styled from "@emotion/styled";
import { Spacer } from "./Spacer"; import { Spacer } from "./Spacer";
import { isMobile } from "../evm/utils/isMobile"; import { isMobile } from "../evm/utils/isMobile";
import type { IconFC } from "../wallet/ConnectWallet/icons/types"; import type { IconFC } from "../wallet/ConnectWallet/icons/types";
import { Text } from "./text"; import { Text } from "./text";
import { Container } from "./basic"; import { Container } from "./basic";
import { StyledDiv } from "../design-system/elements";
import { useCustomTheme } from "../design-system/CustomThemeProvider";
export const DragNDrop: React.FC<{ export const DragNDrop: React.FC<{
extension: string; extension: string;
@@ -132,37 +134,38 @@ export const DragNDrop: React.FC<{
); );
}; };
const UploadIconSecondary = /* @__PURE__ */ styled(UploadIcon)<{ const UploadIconSecondary = /* @__PURE__ */ styled(UploadIcon)(() => {
theme?: Theme; const theme = useCustomTheme();
}>` return {
color: ${(props) => props.theme.colors.secondaryIconColor}; color: theme.colors.secondaryIconColor,
transition: transition: "transform 200ms ease, color 200ms ease",
transform 200ms ease, };
color 200ms ease; });
`;
const DropContainer = styled.div<{ theme?: Theme }>` const DropContainer = /* @__PURE__ */ StyledDiv(() => {
border: 2px solid ${(p) => p.theme.colors.borderColor}; const theme = useCustomTheme();
border-radius: ${radius.md}; return {
padding: ${spacing.xl} ${spacing.md}; border: `2px solid ${theme.colors.borderColor}`,
display: flex; borderRadius: radius.md,
align-items: center; padding: `${spacing.xl} ${spacing.md}`,
flex-direction: column; display: "flex",
cursor: pointer; alignItems: "center",
transition: border-color 200ms ease; flexDirection: "column",
cursor: "pointer",
transition: "border-color 200ms ease",
&:hover, "&:hover, &[data-is-dragging='true']": {
&[data-is-dragging="true"] { borderColor: theme.colors.accentText,
border-color: ${(p) => p.theme.colors.accentText}; svg: {
svg { color: theme.colors.accentText,
color: ${(p) => p.theme.colors.accentText}; },
} },
}
&[data-error="true"] { "&[data-error='true']": {
border-color: ${(p) => p.theme.colors.danger}; borderColor: theme.colors.danger,
} },
`; };
});
const CheckCircleIcon: IconFC = (props) => ( const CheckCircleIcon: IconFC = (props) => (
<svg <svg
+4 -4
View File
@@ -1,6 +1,6 @@
import styled from "@emotion/styled";
import { fadeInAnimation } from "../design-system/animations"; import { fadeInAnimation } from "../design-system/animations";
import { StyledDiv } from "../design-system/elements";
export const FadeIn = styled.div` export const FadeIn = /* @__PURE__ */ StyledDiv({
animation: ${fadeInAnimation} 0.15s ease-in; animation: `${fadeInAnimation} 0.15s ease-in`,
`; });
+53 -61
View File
@@ -1,11 +1,4 @@
import { import { media, spacing, shadow, radius, iconSize } from "../design-system";
Theme,
media,
spacing,
shadow,
radius,
iconSize,
} from "../design-system";
import { import {
wideModalMaxHeight, wideModalMaxHeight,
modalMaxWidthCompact, modalMaxWidthCompact,
@@ -17,11 +10,12 @@ import { Overlay } from "./Overlay";
import { noScrollBar } from "./basic"; import { noScrollBar } from "./basic";
import { IconButton } from "./buttons"; import { IconButton } from "./buttons";
import { keyframes } from "@emotion/react"; import { keyframes } from "@emotion/react";
import styled from "@emotion/styled";
import * as Dialog from "@radix-ui/react-dialog"; import * as Dialog from "@radix-ui/react-dialog";
import { Cross2Icon } from "@radix-ui/react-icons"; import { Cross2Icon } from "@radix-ui/react-icons";
import { DynamicHeight } from "./DynamicHeight"; import { DynamicHeight } from "./DynamicHeight";
import { useEffect, useRef, useState } from "react"; import { useEffect, useRef, useState } from "react";
import { useCustomTheme } from "../design-system/CustomThemeProvider";
import { StyledDiv } from "../design-system/elements";
export const Modal: React.FC<{ export const Modal: React.FC<{
trigger?: React.ReactNode; trigger?: React.ReactNode;
@@ -127,16 +121,15 @@ export const Modal: React.FC<{
); );
}; };
export const CrossContainer = styled.div` export const CrossContainer = /* @__PURE__ */ StyledDiv({
position: absolute; position: "absolute",
top: ${spacing.lg}; top: spacing.lg,
right: ${spacing.lg}; right: spacing.lg,
transform: translateX(15%); transform: "translateX(15%)",
[media.mobile]: {
${media.mobile} { right: spacing.md,
right: ${spacing.md}; },
} });
`;
const modalAnimationDesktop = keyframes` const modalAnimationDesktop = keyframes`
from { from {
@@ -160,46 +153,45 @@ const modalAnimationMobile = keyframes`
} }
`; `;
const DialogContent = styled.div<{ theme?: Theme }>` const DialogContent = /* @__PURE__ */ StyledDiv(() => {
z-index: 10000; const theme = useCustomTheme();
background: ${(p) => p.theme.colors.modalBg};
--bg: ${(p) => p.theme.colors.modalBg};
color: ${(p) => p.theme.colors.primaryText};
border-radius: ${radius.xl};
position: fixed;
top: 50%;
left: 50%;
transform: translate(-50%, -50%);
width: calc(100vw - 40px);
box-sizing: border-box;
animation: ${modalAnimationDesktop} 300ms ease;
box-shadow: ${shadow.lg};
line-height: normal;
border: 1px solid ${(p) => p.theme.colors.borderColor};
outline: none;
overflow: hidden;
font-family: ${(p) => p.theme.fontFamily};
${noScrollBar} return {
zIndex: 10000,
/* open from bottom on mobile */ background: theme.colors.modalBg,
${media.mobile} { "--bg": theme.colors.modalBg,
top: auto; color: theme.colors.primaryText,
bottom: 0; borderRadius: radius.xl,
left: 0; position: "fixed",
right: 0; top: "50%",
max-width: 100vw; left: "50%",
transform: none; transform: "translate(-50%, -50%)",
width: 100vw; width: "calc(100vw - 40px)",
animation: ${modalAnimationMobile} 0.35s cubic-bezier(0.15, 1.15, 0.6, 1); boxSizing: "border-box",
border-radius: ${radius.xxl}; animation: `${modalAnimationDesktop} 300ms ease`,
border-bottom-right-radius: 0; boxShadow: shadow.lg,
border-bottom-left-radius: 0; lineHeight: "normal",
max-width: none !important; border: `1px solid ${theme.colors.borderColor}`,
} outline: "none",
overflow: "hidden",
& *::selection { fontFamily: theme.fontFamily,
background-color: ${(p) => p.theme.colors.selectedTextBg}; [media.mobile]: {
color: ${(p) => p.theme.colors.selectedTextColor}; top: "auto",
} bottom: 0,
`; left: 0,
right: 0,
transform: "none",
width: "100vw",
animation: `${modalAnimationMobile} 0.35s cubic-bezier(0.15, 1.15, 0.6, 1)`,
borderRadius: radius.xxl,
borderBottomRightRadius: 0,
borderBottomLeftRadius: 0,
maxWidth: "none !important",
},
"& *::selection": {
backgroundColor: theme.colors.selectedTextBg,
color: theme.colors.selectedTextColor,
},
...noScrollBar,
};
});
+21 -17
View File
@@ -3,6 +3,7 @@ import { Input } from "./formElements";
import { Container } from "./basic"; import { Container } from "./basic";
import { media, fontSize, spacing } from "../design-system"; import { media, fontSize, spacing } from "../design-system";
import styled from "@emotion/styled"; import styled from "@emotion/styled";
import { useCustomTheme } from "../design-system/CustomThemeProvider";
export function OTPInput(props: { export function OTPInput(props: {
digits: number; digits: number;
@@ -115,20 +116,23 @@ export function OTPInput(props: {
); );
} }
const OTPInputBox = /* @__PURE__ */ styled(Input)` const OTPInputBox = /* @__PURE__ */ styled(Input)(() => {
appearance: none; const theme = useCustomTheme();
-webkit-appearance: none; return {
width: 40px; appearance: "none",
height: 40px; WebkitAppearance: "none",
text-align: center; width: "40px",
font-size: ${fontSize.md}; height: "40px",
padding: ${spacing.xs}; textAlign: "center",
${media.mobile} { fontSize: fontSize.md,
width: 35px; padding: spacing.xs,
height: 35px; [media.mobile]: {
} width: "35px",
&[data-verify-status="invalid"] { height: "35px",
color: ${(p) => p.theme.colors.danger}; },
border-color: ${(p) => p.theme.colors.danger}; "&[data-verify-status='invalid']": {
} color: theme.colors.danger,
`; borderColor: theme.colors.danger,
},
};
});
+13 -10
View File
@@ -1,6 +1,6 @@
import type { Theme } from "../design-system";
import { keyframes } from "@emotion/react"; import { keyframes } from "@emotion/react";
import styled from "@emotion/styled"; import { StyledDiv } from "../design-system/elements";
import { useCustomTheme } from "../design-system/CustomThemeProvider";
const overlayEnter = keyframes` const overlayEnter = keyframes`
from { from {
@@ -11,11 +11,14 @@ const overlayEnter = keyframes`
} }
`; `;
export const Overlay = styled.div<{ theme?: Theme }>` export const Overlay = /* @__PURE__ */ StyledDiv(() => {
background-color: ${(p) => p.theme.colors.modalOverlayBg}; const theme = useCustomTheme();
z-index: 9999; return {
position: fixed; backgroundColor: theme.colors.modalOverlayBg,
inset: 0; zIndex: 9999,
animation: ${overlayEnter} 400ms cubic-bezier(0.16, 1, 0.3, 1); position: "fixed",
backdrop-filter: blur(10px); inset: 0,
`; animation: `${overlayEnter} 400ms cubic-bezier(0.16, 1, 0.3, 1)`,
backdropFilter: "blur(10px)",
};
});
+23 -24
View File
@@ -1,14 +1,9 @@
import { import { fontSize, radius, shadow, spacing } from "../design-system";
fontSize,
radius,
shadow,
spacing,
type Theme,
} from "../design-system";
import { keyframes } from "@emotion/react"; import { keyframes } from "@emotion/react";
import styled from "@emotion/styled"; import styled from "@emotion/styled";
import * as RXPopover from "@radix-ui/react-popover"; import * as RXPopover from "@radix-ui/react-popover";
import { Container } from "./basic"; import { Container } from "./basic";
import { useCustomTheme } from "../design-system/CustomThemeProvider";
export type PopoverProps = { export type PopoverProps = {
children: React.ReactNode; children: React.ReactNode;
@@ -53,21 +48,25 @@ from {
} }
`; `;
const PopoverContent = /* @__PURE__ */ (() => styled(RXPopover.Content)<{ const PopoverContent = /* @__PURE__ */ (() =>
theme?: Theme; styled(RXPopover.Content)(() => {
}>` const theme = useCustomTheme();
border-radius: ${radius.sm}; return {
padding: ${spacing.sm} ${spacing.md}; borderRadius: radius.sm,
background-color: ${(p) => p.theme.colors.tooltipBg}; padding: `${spacing.sm} ${spacing.md}`,
box-shadow: ${shadow.md}; backgroundColor: theme.colors.tooltipBg,
will-change: transform, opacity; boxShadow: shadow.md,
animation: ${slideUpAndFade} 400ms cubic-bezier(0.16, 1, 0.3, 1); willChange: "transform, opacity",
color: ${(p) => p.theme.colors.tooltipText}; animation: `${slideUpAndFade} 400ms cubic-bezier(0.16, 1, 0.3, 1)`,
font-size: ${fontSize.md}; color: theme.colors.tooltipText,
`)(); fontSize: fontSize.md,
};
}))();
const PopoverArrow = /* @__PURE__ */ (() => styled(RXPopover.Arrow)<{ const PopoverArrow = /* @__PURE__ */ (() =>
theme?: Theme; styled(RXPopover.Arrow)(() => {
}>` const theme = useCustomTheme();
fill: ${(p) => p.theme.colors.tooltipBg}; return {
`)(); fill: theme.colors.tooltipBg,
};
}))();
+92 -94
View File
@@ -1,9 +1,10 @@
import { keyframes } from "@emotion/react"; import { keyframes } from "@emotion/react";
import { Theme, radius } from "../design-system"; import { radius } from "../design-system";
import styled from "@emotion/styled";
import QRCodeUtil from "qrcode"; import QRCodeUtil from "qrcode";
import React, { ReactElement, useMemo } from "react"; import React, { ReactElement, useMemo } from "react";
import { fadeInAnimation } from "../design-system/animations"; import { fadeInAnimation } from "../design-system/animations";
import { StyledDiv } from "../design-system/elements";
import { useCustomTheme } from "../design-system/CustomThemeProvider";
export const QRCode: React.FC<{ export const QRCode: React.FC<{
qrCodeUri?: string; qrCodeUri?: string;
@@ -48,23 +49,26 @@ export const QRCode: React.FC<{
); );
}; };
const IconContainer = styled.div` const IconContainer = /* @__PURE__ */ StyledDiv({
position: absolute; position: "absolute",
top: 50%; top: "50%",
left: 50%; left: "50%",
transform: translate(-50%, -50%); transform: "translate(-50%, -50%)",
display: flex; display: "flex",
justify-content: center; justifyContent: "center",
align-content: center; alignContent: "center",
z-index: 1000; zIndex: 1000,
`; });
const QRCodeContainer = styled.div<{ theme?: Theme }>` const QRCodeContainer = /* @__PURE__ */ StyledDiv(() => {
animation: ${fadeInAnimation} 600ms ease; const theme = useCustomTheme();
--ck-qr-dot-color: ${(p) => p.theme.colors.primaryText}; return {
--ck-body-background: ${(p) => p.theme.colors.modalBg}; animation: `${fadeInAnimation} 600ms ease`,
--ck-qr-background: ${(p) => p.theme.colors.modalBg}; "--ck-qr-dot-color": theme.colors.primaryText,
`; "--ck-body-background": theme.colors.modalBg,
"--ck-qr-background": theme.colors.modalBg,
};
});
const generateMatrix = ( const generateMatrix = (
value: string, value: string,
@@ -98,82 +102,76 @@ export const PlaceholderKeyframes = keyframes`
100%{ background-position: -100% 0; } 100%{ background-position: -100% 0; }
`; `;
export const QRPlaceholder = styled.div<{ theme?: Theme }>` export const QRPlaceholder = /* @__PURE__ */ StyledDiv(() => {
--color: ${(p) => p.theme.colors.skeletonBg}; const theme = useCustomTheme();
--bg: ${(p) => p.theme.colors.modalBg}; return {
"--color": theme.colors.skeletonBg,
overflow: hidden; "--bg": theme.colors.modalBg,
position: relative; overflow: "hidden",
display: flex; position: "relative",
align-items: center; display: "flex",
justify-content: center; alignItems: "center",
border-radius: ${radius.md}; justifyContent: "center",
borderRadius: radius.md,
> div { "> div": {
z-index: 4; zIndex: 4,
position: relative; position: "relative",
width: 28%; width: "28%",
height: 28%; height: "28%",
border-radius: 5px; borderRadius: "5px",
background: var(--bg); background: "var(--bg)",
box-shadow: 0 0 0 7px var(--bg); boxShadow: "0 0 0 7px var(--bg)",
} },
"> span": {
> span { zIndex: 4,
z-index: 4; position: "absolute",
position: absolute; background: "var(--color)",
background: var(--color); borderRadius: "12px",
border-radius: 12px; width: "13.25%",
width: 13.25%; height: "13.25%",
height: 13.25%; boxShadow: "0 0 0 4px var(--bg)",
box-shadow: 0 0 0 4px var(--bg); "&:before": {
&:before { content: '""',
content: ""; position: "absolute",
position: absolute; inset: "9px",
inset: 9px; borderRadius: "3px",
border-radius: 3px; boxShadow: "0 0 0 4px var(--bg)",
box-shadow: 0 0 0 4px var(--bg); },
} "&[data-v1]": {
&[data-v1] { top: 0,
top: 0; left: 0,
left: 0; },
} "&[data-v2]": {
&[data-v2] { top: 0,
top: 0; right: 0,
right: 0; },
} "&[data-v3]": {
&[data-v3] { bottom: 0,
bottom: 0; left: 0,
left: 0; },
} },
} "&:before": {
zIndex: 3,
&:before { content: '""',
z-index: 3; position: "absolute",
content: ""; inset: 0,
position: absolute; background: "repeat",
inset: 0; backgroundSize: "1.888% 1.888%",
background: repeat; backgroundImage: "radial-gradient(var(--color) 41%, transparent 41%)",
background-size: 1.888% 1.888%; },
background-image: radial-gradient(var(--color) 41%, transparent 41%); "&::after": {
} zIndex: 100,
content: '""',
&:after { position: "absolute",
z-index: 100; inset: 0,
content: ""; transform: "scale(1.5) rotate(45deg)",
position: absolute; background:
inset: 0; "linear-gradient(90deg, transparent 50%, var(--color), transparent)",
transform: scale(1.5) rotate(45deg); backgroundSize: "200% 100%",
background-image: linear-gradient( animation: `${PlaceholderKeyframes} 1000ms linear infinite both`,
90deg, },
transparent 50%, };
${(p) => p.theme.colors.skeletonBg}, });
transparent
);
background-size: 200% 100%;
animation: ${PlaceholderKeyframes} 1000ms linear infinite both;
}
`;
export function QRCodeRenderer({ export function QRCodeRenderer({
ecl = "M", ecl = "M",
+12 -8
View File
@@ -1,6 +1,7 @@
import { radius, Theme } from "../design-system"; import { radius } from "../design-system";
import { keyframes } from "@emotion/react"; import { keyframes } from "@emotion/react";
import styled from "@emotion/styled"; import { StyledDiv } from "../design-system/elements";
import { useCustomTheme } from "../design-system/CustomThemeProvider";
export const Skeleton: React.FC<{ export const Skeleton: React.FC<{
height: string; height: string;
@@ -25,9 +26,12 @@ const skeletonAnimation = keyframes`
} }
`; `;
const SkeletonDiv = styled.div<{ theme?: Theme }>` const SkeletonDiv = /* @__PURE__ */ StyledDiv(() => {
background-size: 200% 200%; const theme = useCustomTheme();
background-color: ${(p) => p.theme.colors.skeletonBg}; return {
animation: ${skeletonAnimation} 500ms ease-in-out infinite alternate; backgroundSize: "200% 200%",
border-radius: ${radius.sm}; backgroundColor: theme.colors.skeletonBg,
`; animation: `${skeletonAnimation} 500ms ease-in-out infinite alternate`,
borderRadius: radius.sm,
};
});
+15 -15
View File
@@ -1,12 +1,13 @@
import { iconSize, type Theme } from "../design-system"; import { iconSize, type Theme } from "../design-system";
import { keyframes, useTheme } from "@emotion/react"; import { keyframes } from "@emotion/react";
import styled from "@emotion/styled"; import { StyledCircle, StyledSvg } from "../design-system/elements";
import { useCustomTheme } from "../design-system/CustomThemeProvider";
export const Spinner: React.FC<{ export const Spinner: React.FC<{
color: keyof Theme["colors"]; color: keyof Theme["colors"];
size: keyof typeof iconSize; size: keyof typeof iconSize;
}> = (props) => { }> = (props) => {
const theme = useTheme() as Theme; const theme = useCustomTheme();
return ( return (
<Svg <Svg
style={{ style={{
@@ -29,7 +30,7 @@ export const Spinner: React.FC<{
// animations // animations
const dashAnimation = keyframes` const dashAnimation = keyframes`
0% { 0% {
stroke-dasharray: 1, 150; stroke-dasharray: 1, 150;
stroke-dashoffset: 0; stroke-dashoffset: 0;
} }
@@ -44,19 +45,18 @@ const dashAnimation = keyframes`
`; `;
const rotateAnimation = keyframes` const rotateAnimation = keyframes`
100% { 100% {
transform: rotate(360deg); transform: rotate(360deg);
} }
`; `;
// styles const Svg = /* @__PURE__ */ StyledSvg({
const Svg = styled.svg` animation: `${rotateAnimation} 2s linear infinite`,
animation: ${rotateAnimation} 2s linear infinite; width: "1em",
width: 1em; height: "1em",
height: 1em; });
`;
const Circle = styled.circle` const Circle = /* @__PURE__ */ StyledCircle({
stroke-linecap: round; strokeLinecap: "round",
animation: ${dashAnimation} 1.5s ease-in-out infinite; animation: `${dashAnimation} 1.5s ease-in-out infinite`,
`; });
+20 -18
View File
@@ -1,5 +1,6 @@
import styled from "@emotion/styled"; import { fontSize, spacing } from "../design-system";
import { fontSize, spacing, Theme } from "../design-system"; import { StyledDiv } from "../design-system/elements";
import { useCustomTheme } from "../design-system/CustomThemeProvider";
export const TextDivider = (props: { export const TextDivider = (props: {
text: string; text: string;
@@ -16,19 +17,20 @@ export const TextDivider = (props: {
); );
}; };
export const TextDividerEl = styled.div<{ theme?: Theme }>` export const TextDividerEl = /* @__PURE__ */ StyledDiv(() => {
display: flex; const theme = useCustomTheme();
align-items: center; return {
color: ${(p) => p.theme.colors.secondaryText}; display: "flex",
font-size: ${fontSize.sm}; alignItems: "center",
&::before, color: theme.colors.secondaryText,
&::after { fontSize: fontSize.sm,
content: ""; "&::before, &::after": {
flex: 1; content: '""',
border-bottom: 1px solid ${(p) => p.theme.colors.separatorLine}; flex: 1,
} borderBottom: `1px solid ${theme.colors.separatorLine}`,
},
span { span: {
margin: 0 1rem; margin: "0 16px",
} },
`; };
});
+27 -23
View File
@@ -1,7 +1,8 @@
import { fontSize, radius, shadow, spacing, Theme } from "../design-system"; import { fontSize, radius, shadow, spacing } from "../design-system";
import { keyframes } from "@emotion/react"; import { keyframes } from "@emotion/react";
import styled from "@emotion/styled"; import styled from "@emotion/styled";
import * as RadixTooltip from "@radix-ui/react-tooltip"; import * as RadixTooltip from "@radix-ui/react-tooltip";
import { useCustomTheme } from "../design-system/CustomThemeProvider";
export const ToolTip: React.FC<{ export const ToolTip: React.FC<{
children: React.ReactNode; children: React.ReactNode;
@@ -40,26 +41,29 @@ to {
} }
`; `;
const TooltipContent = /* @__PURE__ */ (() => styled(RadixTooltip.Content)<{ const TooltipContent = /* @__PURE__ */ (() =>
theme?: Theme; styled(RadixTooltip.Content)(() => {
}>` const theme = useCustomTheme();
background: ${(p) => p.theme.colors.tooltipBg}; return {
color: ${(p) => p.theme.colors.tooltipText}; background: theme.colors.tooltipBg,
border-radius: ${radius.sm}; color: theme.colors.tooltipText,
line-height: normal; borderRadius: radius.sm,
padding: ${spacing.sm} ${spacing.md}; padding: `${spacing.sm} ${spacing.md}`,
font-size: ${fontSize.sm}; fontSize: fontSize.sm,
box-shadow: ${shadow.sm}; boxShadow: shadow.sm,
user-select: none; userSelect: "none",
will-change: transform, opacity; willChange: "transform, opacity",
animation: ${slideUpAndFade} 200ms cubic-bezier(0.16, 1, 0.3, 1); animation: `${slideUpAndFade} 200ms cubic-bezier(0.16, 1, 0.3, 1)`,
z-index: 999999999999999; zIndex: 999999999999999,
max-width: 300px; maxWidth: "300px",
line-height: 1.5; lineHeight: 1.5,
`)(); };
}))();
const TooltipArrow = /* @__PURE__ */ (() => styled(RadixTooltip.Arrow)<{ const TooltipArrow = /* @__PURE__ */ (() =>
theme?: Theme; styled(RadixTooltip.Arrow)(() => {
}>` const theme = useCustomTheme();
fill: ${(p) => p.theme.colors.tooltipBg}; return {
`)(); fill: theme.colors.tooltipBg,
};
}))();
+52 -43
View File
@@ -1,4 +1,3 @@
import styled from "@emotion/styled";
import { Theme, iconSize, spacing } from "../design-system"; import { Theme, iconSize, spacing } from "../design-system";
import { BackButton, ModalTitle } from "./modalElements"; import { BackButton, ModalTitle } from "./modalElements";
import { Img } from "./Img"; import { Img } from "./Img";
@@ -7,22 +6,28 @@ import {
floatDownAnimation, floatDownAnimation,
floatUpAnimation, floatUpAnimation,
} from "../design-system/animations"; } from "../design-system/animations";
import { StyledDiv } from "../design-system/elements";
import { useCustomTheme } from "../design-system/CustomThemeProvider";
import type { CSSObject } from "@emotion/react";
export const ScreenBottomContainer = styled.div<{ theme?: Theme }>` export const ScreenBottomContainer = /* @__PURE__ */ StyledDiv(() => {
border-top: 1px solid ${(p) => p.theme.colors.separatorLine}; const theme = useCustomTheme();
display: flex; return {
flex-direction: column; borderTop: `1px solid ${theme.colors.separatorLine}`,
gap: ${spacing.lg}; display: "flex",
padding: ${spacing.lg}; flexDirection: "column",
`; gap: spacing.lg,
padding: spacing.lg,
};
});
export const noScrollBar = ` export const noScrollBar: CSSObject = /* @__PURE__ */ {
scrollbar-width: none; scrollbarWidth: "none",
&::-webkit-scrollbar { "&::-webkit-scrollbar": {
width: 0px; width: 0,
display: none; display: "none",
} },
`; };
export function ModalHeader(props: { export function ModalHeader(props: {
onBack?: () => void; onBack?: () => void;
@@ -59,12 +64,13 @@ export function ModalHeader(props: {
); );
} }
export const Line = styled.div<{ export const Line = /* @__PURE__ */ StyledDiv(() => {
theme?: Theme; const theme = useCustomTheme();
}>` return {
height: 1px; height: "1px",
background: ${(p) => p.theme.colors.separatorLine}; background: theme.colors.separatorLine,
`; };
});
export function Container(props: { export function Container(props: {
animate?: "fadein" | "floatup" | "floatdown"; animate?: "fadein" | "floatup" | "floatdown";
@@ -165,26 +171,29 @@ export function Container(props: {
); );
} }
const Box = styled.div<{ theme?: Theme; color?: keyof Theme["colors"] }>` type BoxProps = {
color: ${(p) => (p.color ? p.theme.colors[p.color] : "inherit")}; color?: keyof Theme["colors"];
};
&[data-animate="fadein"] { const Box = /* @__PURE__ */ StyledDiv((props: BoxProps) => {
opacity: 0; const theme = useCustomTheme();
animation: ${fadeInAnimation} 350ms ease forwards; return {
} color: props.color ? theme.colors[props.color] : "inherit",
"&[data-animate='fadein']": {
&[data-animate="floatup"] { opacity: 0,
opacity: 0; animation: `${fadeInAnimation} 350ms ease forwards`,
animation: ${floatUpAnimation} 350ms ease forwards; },
} "&[data-animate='floatup']": {
opacity: 0,
&[data-animate="floatdown"] { animation: `${floatUpAnimation} 350ms ease forwards`,
opacity: 0; },
animation: ${floatDownAnimation} 350ms ease forwards; "&[data-animate='floatdown']": {
} opacity: 0,
animation: `${floatDownAnimation} 350ms ease forwards`,
&[data-scrolly="true"] { },
overflow-y: auto; "&[data-scrolly='true']": {
${noScrollBar} overflowY: "auto",
} ...noScrollBar,
`; },
};
});
+121 -122
View File
@@ -1,135 +1,134 @@
import { fontSize, radius, spacing, Theme } from "../design-system"; import { fontSize, radius, spacing, Theme } from "../design-system";
import styled from "@emotion/styled"; import { StyledButton } from "../design-system/elements";
import { useCustomTheme } from "../design-system/CustomThemeProvider";
export const Button = styled.button<{ type ButtonProps = {
variant: "primary" | "secondary" | "link" | "accent" | "outline"; variant: "primary" | "secondary" | "link" | "accent" | "outline";
theme?: Theme; theme?: Theme;
fullWidth?: boolean; fullWidth?: boolean;
gap?: keyof typeof spacing; gap?: keyof typeof spacing;
}>` };
all: unset;
cursor: pointer;
display: inline-flex;
align-items: center;
justify-content: center;
border-radius: ${radius.md};
padding: ${fontSize.sm} ${fontSize.sm};
font-size: ${fontSize.md};
font-weight: 500;
box-sizing: border-box;
-webkit-tap-highlight-color: transparent;
line-height: normal;
flex-shrink: 0;
transition: border 200ms ease;
gap: ${(p) => (p.gap && spacing[p.gap]) || 0};
${(p) => p.fullWidth && `width: 100%;`}; export const Button = /* @__PURE__ */ StyledButton((props: ButtonProps) => {
const theme = useCustomTheme();
background: ${(p) => { return {
switch (p.variant) { all: "unset",
case "primary": cursor: "pointer",
return p.theme.colors.primaryButtonBg; display: "inline-flex",
case "accent": alignItems: "center",
return p.theme.colors.accentButtonBg; justifyContent: "center",
case "secondary": borderRadius: radius.md,
return p.theme.colors.secondaryButtonBg; padding: `${fontSize.sm} ${fontSize.sm}`,
default: fontSize: fontSize.md,
return "none"; fontWeight: 500,
} boxSizing: "border-box",
}}; WebkitTapHighlightColor: "transparent",
lineHeight: "normal",
color: ${(p) => { flexShrink: 0,
switch (p.variant) { transition: "border 200ms ease",
case "primary": gap: (props.gap && spacing[props.gap]) || 0,
return p.theme.colors.primaryButtonText; width: props.fullWidth ? "100%" : undefined,
case "accent": background: (() => {
return p.theme.colors.accentButtonText; switch (props.variant) {
case "secondary": case "primary":
return p.theme.colors.secondaryButtonText; return theme.colors.primaryButtonBg;
case "outline": case "accent":
return p.theme.colors.secondaryButtonText; return theme.colors.accentButtonBg;
case "link": case "secondary":
return p.theme.colors.accentText; return theme.colors.secondaryButtonBg;
default: default:
return p.theme.colors.primaryButtonText; return "none";
}
}};
${(p) => {
if (p.variant === "outline") {
return `
border: 1.5px solid ${p.theme.colors.borderColor};
&:hover {
border-color: ${p.theme.colors.accentText};
} }
`; })(),
} color: (() => {
switch (props.variant) {
if (p.variant === "secondary") { case "primary":
return ` return theme.colors.primaryButtonText;
&:hover { case "accent":
background: ${p.theme.colors.secondaryButtonHoverBg}; return theme.colors.accentButtonText;
case "secondary":
return theme.colors.secondaryButtonText;
case "outline":
return theme.colors.secondaryButtonText;
case "link":
return theme.colors.accentText;
default:
return theme.colors.primaryButtonText;
}
})(),
"&:active": {
transform: "translateY(1px)",
},
"&[disabled]": {
cursor: "not-allowed",
},
...(() => {
if (props.variant === "outline") {
return {
border: `1.5px solid ${theme.colors.borderColor}`,
"&:hover": {
borderColor: theme.colors.accentText,
},
};
} }
`;
}
}}
${(p) => { if (props.variant === "secondary") {
if (p.variant === "link") { return {
return ` "&:hover": {
padding: 0; background: theme.colors.secondaryButtonHoverBg,
&:hover { },
color: ${p.theme.colors.primaryText}; };
}`; }
}
}}
/* pressed effect */ if (props.variant === "link") {
&:active { return {
transform: translateY(1px); padding: 0,
} "&:hover": {
color: theme.colors.primaryText,
},
};
}
})(),
};
});
&[disabled] { export const IconButton = /* @__PURE__ */ StyledButton(() => {
cursor: not-allowed; const theme = useCustomTheme();
} return {
`; all: "unset",
cursor: "pointer",
display: "inline-flex",
alignItems: "center",
justifyContent: "center",
borderRadius: radius.sm,
WebkitTapHighlightColor: "transparent",
color: theme.colors.secondaryIconColor,
padding: "2px",
transition: "background 200ms ease, color 200ms ease",
"&:hover": {
background: theme.colors.secondaryIconHoverBg,
color: theme.colors.secondaryIconHoverColor,
},
};
});
export const IconButton = styled.button<{ export const InputButton = /* @__PURE__ */ StyledButton(() => {
theme?: Theme; const theme = useCustomTheme();
}>` return {
all: unset; all: "unset",
cursor: pointer; display: "flex",
display: inline-flex; alignItems: "center",
align-items: center; justifyContent: "center",
justify-content: center; borderRadius: radius.sm,
border-radius: ${radius.sm}; padding: spacing.sm,
-webkit-tap-highlight-color: transparent; cursor: "pointer",
color: ${(p) => p.theme.colors.secondaryIconColor}; WebkitTapHighlightColor: "transparent",
padding: 2px; color: theme.colors.secondaryText,
transition: "&:hover": {
background 0.2s ease, color: theme.colors.primaryText,
color 0.2s ease; },
"&[disabled]": {
&:hover { cursor: "not-allowed",
background: ${(p) => p.theme.colors.secondaryIconHoverBg}; },
color: ${(p) => p.theme.colors.secondaryIconHoverColor}; };
} });
`;
export const InputButton = styled.button<{ theme?: Theme }>`
all: unset;
display: flex;
align-items: center;
justify-content: center;
border-radius: ${radius.sm};
padding: ${spacing.sm};
cursor: pointer;
-webkit-tap-highlight-color: transparent;
color: ${(p) => p.theme.colors.secondaryText};
&:hover {
color: ${(p) => p.theme.colors.primaryText};
}
&[disabled] {
cursor: not-allowed;
}
`;
+90 -103
View File
@@ -1,113 +1,100 @@
import { fontSize, radius, Theme, spacing } from "../design-system"; import { fontSize, radius, Theme, spacing } from "../design-system";
import styled from "@emotion/styled"; import { StyledDiv, StyledInput, StyledLabel } from "../design-system/elements";
import { useCustomTheme } from "../design-system/CustomThemeProvider";
export const Label = styled.label<{ type LabelProps = {
theme?: Theme;
color?: keyof Theme["colors"]; color?: keyof Theme["colors"];
}>` };
font-size: ${fontSize.sm};
color: ${(p) => p.theme.colors[p.color || "primaryText"]};
display: block;
font-weight: 500;
`;
export const Input = styled.input<{ export const Label = /* @__PURE__ */ StyledLabel((props: LabelProps) => {
const theme = useCustomTheme();
return {
fontSize: fontSize.sm,
color: theme.colors[props.color || "primaryText"],
display: "block",
fontWeight: 500,
};
});
type InputProps = {
variant: "outline" | "transparent"; variant: "outline" | "transparent";
sm?: boolean; sm?: boolean;
theme?: Theme; theme?: Theme;
}>` };
font-size: ${fontSize.md};
display: block;
padding: ${(p) => (p.sm ? spacing.sm : fontSize.sm)};
box-sizing: border-box;
width: 100%;
outline: none;
border: none;
border-radius: 6px;
color: ${(p) => p.theme.colors.primaryText};
-webkit-appearance: none;
appearance: none;
background: transparent;
&::placeholder { export const Input = /* @__PURE__ */ StyledInput((props: InputProps) => {
color: ${(p) => p.theme.colors.secondaryText}; const theme = useCustomTheme();
} return {
fontSize: fontSize.md,
box-shadow: 0 0 0 1.5px display: "block",
${(p) => { padding: props.sm ? spacing.sm : fontSize.sm,
switch (p.variant) { boxSizing: "border-box",
case "outline": width: "100%",
return p.theme.colors.borderColor; outline: "none",
default: border: "none",
return "transparent"; borderRadius: "6px",
} color: theme.colors.primaryText,
}}; WebkitAppearance: "none",
appearance: "none",
/* when browser auto-fills the input */ background: "transparent",
&:-webkit-autofill { "&::placeholder": {
-webkit-text-fill-color: ${(p) => p.theme.colors.primaryText}; color: theme.colors.secondaryText,
-webkit-box-shadow: 0 0 0px 1000px ${(p) => p.theme.colors.inputAutofillBg} },
inset !important; boxShadow: `0 0 0 1.5px ${
box-shadow: 0 0 0px 1000px ${(p) => p.theme.colors.inputAutofillBg} inset !important; props.variant === "outline" ? theme.colors.borderColor : "transparent"
transition: background-color 5000s ease-in-out 0s; }`,
} "&:-webkit-autofill": {
WebkitTextFillColor: theme.colors.primaryText,
&:-webkit-autofill:focus { WebkitBoxShadow: `0 0 0px 1000px ${theme.colors.inputAutofillBg} inset !important`,
-webkit-box-shadow: boxShadow: `0 0 0px 1000px ${theme.colors.inputAutofillBg} inset !important`,
0 0 0px 1000px ${(p) => p.theme.colors.inputAutofillBg} inset, transition: "background-color 5000s ease-in-out 0s",
0 0 0 2px ${(p) => p.theme.colors.accentText} !important; },
box-shadow: "&:-webkit-autofill:focus": {
0 0 0px 1000px ${(p) => p.theme.colors.inputAutofillBg} inset, WebkitBoxShadow: `0 0 0px 1000px ${theme.colors.inputAutofillBg} inset, 0 0 0 2px ${theme.colors.accentText} !important`,
0 0 0 2px ${(p) => p.theme.colors.accentText} !important; boxShadow: `0 0 0px 1000px ${theme.colors.inputAutofillBg} inset, 0 0 0 2px ${theme.colors.accentText} !important`,
} },
"&:focus": {
&:focus { boxShadow: `0 0 0 2px ${theme.colors.accentText}`,
box-shadow: 0 0 0 2px ${(p) => p.theme.colors.accentText}; },
} "&:not([type='password'])": {
overflow: "hidden",
/* show overflow ellipsis for long text - but not if it's a type="password" */ textOverflow: "ellipsis",
&:not([type="password"]) { whiteSpace: "nowrap",
overflow: hidden; },
text-overflow: ellipsis; "&[data-error='true']": {
white-space: nowrap; boxShadow: `0 0 0 2px ${theme.colors.danger} !important`,
} },
"&[disabled]": {
&[data-error="true"] { cursor: "not-allowed",
box-shadow: 0 0 0 2px ${(p) => p.theme.colors.danger} !important; },
} "&[type='number']::-webkit-outer-spin-button, &[type='number']::-webkit-inner-spin-button":
{
&[disabled] { WebkitAppearance: "none",
cursor: not-allowed; margin: 0,
} },
"&[type='number']": {
&[type="number"]::-webkit-outer-spin-button, appearance: "none",
&[type="number"]::-webkit-inner-spin-button { MozAppearance: "textfield",
-webkit-appearance: none; },
margin: 0; };
} });
&[type="number"] {
appearance: none;
-moz-appearance: textfield;
}
`;
// for rendering a input and a button side by side // for rendering a input and a button side by side
export const InputContainer = styled.div<{ theme?: Theme }>` export const InputContainer = /* @__PURE__ */ StyledDiv(() => {
display: flex; const theme = useCustomTheme();
border-radius: ${radius.sm}; return {
box-shadow: 0 0 0px 1.5px ${(p) => p.theme.colors.borderColor}; display: "flex",
borderRadius: radius.sm,
/* show focus ring on container instead of input */ boxShadow: `0 0 0px 1.5px ${theme.colors.borderColor}`,
&:focus-within { "&:focus-within": {
box-shadow: 0 0 0px 2px ${(p) => p.theme.colors.accentText}; boxShadow: `0 0 0px 2px ${theme.colors.accentText}`,
} },
"input:focus": {
input:focus { boxShadow: "none",
box-shadow: none; },
} // show error ring on container instead of input
"&[data-error='true']": {
/* show error ring on container instead of input */ boxShadow: `0 0 0px 2px ${theme.colors.danger}`,
&[data-error="true"] { },
box-shadow: 0 0 0px 2px ${(p) => p.theme.colors.danger}; };
} });
`;
+58 -44
View File
@@ -1,38 +1,47 @@
import { type Theme, fontSize, media } from "../design-system"; import { fontSize, media } from "../design-system";
import { iconSize } from "../design-system"; import { iconSize } from "../design-system";
import { useCustomTheme } from "../design-system/CustomThemeProvider";
import { StyledAnchor, StyledH2, StyledP } from "../design-system/elements";
import { IconButton } from "./buttons"; import { IconButton } from "./buttons";
import styled from "@emotion/styled";
import { ChevronLeftIcon } from "@radix-ui/react-icons"; import { ChevronLeftIcon } from "@radix-ui/react-icons";
export const ModalTitle = /* @__PURE__ */ styled.h2<{ export const ModalTitle = /* @__PURE__ */ StyledH2(
theme?: Theme; (props: { centerOnMobile?: boolean }) => {
centerOnMobile?: boolean; const theme = useCustomTheme();
}>` return {
margin: 0; margin: 0,
font-weight: 600; fontWeight: 600,
font-size: ${fontSize.lg}; fontSize: fontSize.lg,
color: ${(p) => p.theme.colors.primaryText}; color: theme.colors.primaryText,
line-height: 1.3; lineHeight: 1.3,
text-align: left; textAlign: "left",
${media.mobile} { [media.mobile]: {
text-align: ${(p) => (p.centerOnMobile ? "center" : "left")}; textAlign: props.centerOnMobile ? "center" : "left",
} },
`; };
},
);
export const ModalDescription = styled.p<{ type ModalDescriptionProps = {
theme?: Theme;
centerOnMobile?: boolean; centerOnMobile?: boolean;
sm?: boolean; sm?: boolean;
}>` };
all: unset;
display: block; export const ModalDescription = /* @__PURE__ */ StyledP(
font-size: ${(p) => (p.sm ? fontSize.sm : fontSize.md)}; (props: ModalDescriptionProps) => {
color: ${(p) => p.theme.colors.secondaryText}; const theme = useCustomTheme();
line-height: 1.5; return {
${media.mobile} { all: "unset",
text-align: ${(p) => (p.centerOnMobile ? "center" : "left")}; display: "block",
} fontSize: props.sm ? fontSize.sm : fontSize.md,
`; color: theme.colors.secondaryText,
lineHeight: 1.5,
[media.mobile]: {
textAlign: props.centerOnMobile ? "center" : "left",
},
};
},
);
export const BackButton: React.FC<{ export const BackButton: React.FC<{
onClick: () => void; onClick: () => void;
@@ -49,19 +58,24 @@ export const BackButton: React.FC<{
); );
}; };
export const HelperLink = styled.a<{ theme?: Theme; md?: boolean }>` export const HelperLink = /* @__PURE__ */ StyledAnchor(
all: unset; (props: { md?: boolean }) => {
cursor: pointer; const theme = useCustomTheme();
color: ${(p) => p.theme.colors.accentText}; return {
font-size: ${(p) => (p.md ? fontSize.md : fontSize.sm)}; all: "unset",
text-decoration: none; cursor: "pointer",
display: block; color: theme.colors.accentText,
line-height: 1.5; fontSize: props.md ? fontSize.md : fontSize.sm,
${media.mobile} { textDecoration: "none",
text-align: center; display: "block",
} lineHeight: 1.5,
&:hover { [media.mobile]: {
color: ${(p) => p.theme.colors.primaryText}; textAlign: "center",
text-decoration: none; },
} "&:hover": {
`; color: theme.colors.primaryText,
textDecoration: "none",
},
};
},
);
+42 -32
View File
@@ -1,7 +1,8 @@
import styled from "@emotion/styled";
import { fontSize, Theme } from "../design-system"; import { fontSize, Theme } from "../design-system";
import { StyledAnchor, StyledSpan } from "../design-system/elements";
import { useCustomTheme } from "../design-system/CustomThemeProvider";
export const Text = styled.span<{ type TextProps = {
theme?: Theme; theme?: Theme;
color?: keyof Theme["colors"]; color?: keyof Theme["colors"];
center?: boolean; center?: boolean;
@@ -10,21 +11,26 @@ export const Text = styled.span<{
weight?: 400 | 500 | 600 | 700; weight?: 400 | 500 | 600 | 700;
multiline?: boolean; multiline?: boolean;
balance?: boolean; balance?: boolean;
}>` };
font-size: ${(p) => fontSize[p.size || "md"]};
color: ${(p) => p.theme.colors[p.color || "secondaryText"]};
margin: 0;
display: ${(p) => (p.inline ? "inline" : "block")};
font-weight: ${(p) => p.weight || 500};
line-height: ${(p) => (p.multiline ? 1.5 : "normal")};
${(p) => (p.center ? `text-align: center;` : "")};
text-wrap: ${(p) => (p.balance ? "balance" : "inherit")};
max-width: 100%;
overflow: hidden;
text-overflow: ellipsis;
`;
export const Link = styled.a<{ export const Text = /* @__PURE__ */ StyledSpan((p: TextProps) => {
const theme = useCustomTheme();
return {
fontSize: fontSize[p.size || "md"],
color: theme.colors[p.color || "secondaryText"],
margin: 0,
display: p.inline ? "inline" : "block",
fontWeight: p.weight || 500,
lineHeight: p.multiline ? 1.5 : "normal",
textAlign: p.center ? "center" : "left",
textWrap: p.balance ? "balance" : "inherit",
maxWidth: "100%",
overflow: "hidden",
textOverflow: "ellipsis",
};
});
type LinkProps = {
theme?: Theme; theme?: Theme;
size?: keyof typeof fontSize; size?: keyof typeof fontSize;
weight?: 400 | 500 | 600 | 700; weight?: 400 | 500 | 600 | 700;
@@ -32,20 +38,24 @@ export const Link = styled.a<{
center?: boolean; center?: boolean;
color?: keyof Theme["colors"]; color?: keyof Theme["colors"];
hoverColor?: keyof Theme["colors"]; hoverColor?: keyof Theme["colors"];
}>` };
all: unset;
cursor: pointer;
color: ${(p) => p.theme.colors[p.color || "accentText"]};
font-size: ${(p) => fontSize[p.size || "md"]};
text-decoration: none;
text-align: ${(p) => (p.center ? "center" : "left")};
display: ${(p) => (p.inline ? "inline" : "block")};
font-weight: ${(p) => p.weight || 500};
line-height: normal;
transition: color 0.2s ease;
&:hover { export const Link = /* @__PURE__ */ StyledAnchor((p: LinkProps) => {
color: ${(p) => p.theme.colors[p.hoverColor || "primaryText"]}; const theme = useCustomTheme();
text-decoration: none; return {
} all: "unset",
`; cursor: "pointer",
color: theme.colors[p.color || "accentText"],
fontSize: fontSize[p.size || "md"],
textDecoration: "none",
textAlign: p.center ? "center" : "left",
display: p.inline ? "inline" : "block",
fontWeight: p.weight || 500,
lineHeight: "normal",
transition: "color 0.2s ease",
"&:hover": {
color: theme.colors[p.hoverColor || "primaryText"],
textDecoration: "none",
},
};
});
@@ -1,5 +1,7 @@
import { ThemeProvider } from "@emotion/react";
import { Theme, darkThemeObj, lightThemeObj } from "./index"; import { Theme, darkThemeObj, lightThemeObj } from "./index";
import { createContext, useContext } from "react";
const CustomThemeCtx = /* @__PURE__ */ createContext(darkThemeObj);
export function CustomThemeProvider(props: { export function CustomThemeProvider(props: {
children: React.ReactNode; children: React.ReactNode;
@@ -14,5 +16,13 @@ export function CustomThemeProvider(props: {
themeObj = theme; themeObj = theme;
} }
return <ThemeProvider theme={themeObj}>{children}</ThemeProvider>; return (
<CustomThemeCtx.Provider value={themeObj}>
{children}
</CustomThemeCtx.Provider>
);
}
export function useCustomTheme() {
return useContext(CustomThemeCtx);
} }
@@ -0,0 +1,14 @@
import styled from "@emotion/styled";
export const StyledDiv = /* @__PURE__ */ styled.div;
export const StyledSvg = /* @__PURE__ */ styled.svg;
export const StyledCircle = /* @__PURE__ */ styled.circle;
export const StyledSpan = /* @__PURE__ */ styled.span;
export const StyledAnchor = /* @__PURE__ */ styled.a;
export const StyledButton = /* @__PURE__ */ styled.button;
export const StyledLabel = /* @__PURE__ */ styled.label;
export const StyledInput = /* @__PURE__ */ styled.input;
export const StyledH2 = /* @__PURE__ */ styled.h2;
export const StyledP = /* @__PURE__ */ styled.p;
export const StyledUl = /* @__PURE__ */ styled.ul;
export const StyledSelect = /* @__PURE__ */ styled.select;
+13 -7
View File
@@ -142,26 +142,32 @@ export const shadow = {
xl: "0 20px 25px -5px rgb(0 0 0 / 0.1), 0 8px 10px -6px rgb(0 0 0 / 0.1)", xl: "0 20px 25px -5px rgb(0 0 0 / 0.1), 0 8px 10px -6px rgb(0 0 0 / 0.1)",
}; };
export function lightTheme(overrides: ThemeOverrides): Theme { export function lightTheme(overrides?: ThemeOverrides): Theme {
if (!overrides) {
return lightThemeObj;
}
return applyThemeOverrides(lightThemeObj, overrides); return applyThemeOverrides(lightThemeObj, overrides);
} }
export function darkTheme(overrides: ThemeOverrides): Theme { export function darkTheme(overrides?: ThemeOverrides): Theme {
if (!overrides) {
return darkThemeObj;
}
return applyThemeOverrides(darkThemeObj, overrides); return applyThemeOverrides(darkThemeObj, overrides);
} }
export function applyThemeOverrides( export function applyThemeOverrides(
baseTheme: Theme, baseTheme: Theme,
themeOverides: ThemeOverrides, themeOverrides: ThemeOverrides,
): Theme { ): Theme {
const theme = { ...baseTheme }; const theme = { ...baseTheme };
if (themeOverides.colors) { if (themeOverrides.colors) {
theme.colors = { ...theme.colors, ...themeOverides.colors }; theme.colors = { ...theme.colors, ...themeOverrides.colors };
} }
if (themeOverides.fontFamily) { if (themeOverrides.fontFamily) {
theme.fontFamily = themeOverides.fontFamily; theme.fontFamily = themeOverrides.fontFamily;
} }
return theme; return theme;
@@ -1,7 +1,7 @@
import { Popover } from "../../../components/Popover"; import { Popover } from "../../../components/Popover";
import { Spinner } from "../../../components/Spinner"; import { Spinner } from "../../../components/Spinner";
import { Button } from "../../../components/buttons"; import { Button } from "../../../components/buttons";
import { Theme, ThemeObjectOrType } from "../../../design-system"; import { Theme } from "../../../design-system";
import { import {
ConnectWallet, ConnectWallet,
ConnectWalletProps, ConnectWalletProps,
@@ -20,8 +20,10 @@ import type { SmartContract } from "@thirdweb-dev/sdk";
import type { CallOverrides, ContractInterface } from "ethers"; import type { CallOverrides, ContractInterface } from "ethers";
import { PropsWithChildren, useState } from "react"; import { PropsWithChildren, useState } from "react";
import invariant from "tiny-invariant"; import invariant from "tiny-invariant";
import { CustomThemeProvider } from "../../../design-system/CustomThemeProvider"; import {
import { useTheme } from "@emotion/react"; CustomThemeProvider,
useCustomTheme,
} from "../../../design-system/CustomThemeProvider";
import { useTWLocale } from "../../providers/locale-provider"; import { useTWLocale } from "../../providers/locale-provider";
type ActionFn = (contract: SmartContract) => any; type ActionFn = (contract: SmartContract) => any;
@@ -106,7 +108,7 @@ export const Web3Button = <TAction extends ActionFn>(
const requiresConfirmation = !useIsHeadlessWallet(); const requiresConfirmation = !useIsHeadlessWallet();
const { contract } = useContract(contractAddress, contractAbi || "custom"); const { contract } = useContract(contractAddress, contractAbi || "custom");
const contextTheme = useTheme() as ThemeObjectOrType; const contextTheme = useCustomTheme();
const theme = props.theme || contextTheme || "dark"; const theme = props.theme || contextTheme || "dark";
const locale = useTWLocale(); const locale = useTWLocale();
@@ -2,6 +2,7 @@ import {
useCreateWalletInstance, useCreateWalletInstance,
useSetConnectedWallet, useSetConnectedWallet,
useSetConnectionStatus, useSetConnectionStatus,
useWallet,
useWalletContext, useWalletContext,
useWallets, useWallets,
} from "@thirdweb-dev/react-core"; } from "@thirdweb-dev/react-core";
@@ -10,8 +11,13 @@ import {
type AuthParams, type AuthParams,
EmbeddedWallet, EmbeddedWallet,
} from "@thirdweb-dev/wallets"; } from "@thirdweb-dev/wallets";
import { useCallback } from "react"; import { useCallback, useEffect } from "react";
import { embeddedWallet } from "../../../wallet/wallets/embeddedWallet/embeddedWallet"; import { embeddedWallet } from "../../../wallet/wallets/embeddedWallet/embeddedWallet";
import {
UseQueryResult,
useQuery,
useQueryClient,
} from "@tanstack/react-query";
/** /**
* Hook to authenticate and connect to an embedded wallet * Hook to authenticate and connect to an embedded wallet
@@ -72,3 +78,30 @@ export function useEmbeddedWallet() {
sendVerificationEmail, sendVerificationEmail,
}; };
} }
export function useEmbeddedWalletUserEmail(): UseQueryResult<
string | undefined
> {
const wallet = useWallet();
const queryClient = useQueryClient();
const emailQuery = useQuery<string | undefined, string>(
[wallet?.walletId, "embeddedWallet-email"],
() => {
if (wallet && wallet.walletId === walletIds.embeddedWallet) {
return (wallet as EmbeddedWallet).getEmail();
}
},
{
retry: false,
enabled: wallet?.walletId === walletIds.embeddedWallet,
},
);
// Invalidate the query when the wallet changes
useEffect(() => {
queryClient.invalidateQueries([wallet?.walletId, "embeddedWallet-email"]);
}, [wallet, queryClient]);
return emailQuery;
}
+1
View File
@@ -117,6 +117,7 @@ export function enDefault() {
approveTransactionInSafe: "Approve transaction in Safe", approveTransactionInSafe: "Approve transaction in Safe",
tryAgain: "Try Again", tryAgain: "Try Again",
failedToSignIn: "Failed to Sign in", failedToSignIn: "Failed to Sign in",
inProgress: "Awaiting Confirmation",
}, },
}, },
}, },
+1
View File
@@ -120,6 +120,7 @@ export function esDefault(): ThirdwebLocale {
approveTransactionInSafe: "Aprobar transacción en Safe", approveTransactionInSafe: "Aprobar transacción en Safe",
tryAgain: "Intentar de nuevo", tryAgain: "Intentar de nuevo",
failedToSignIn: "Error al iniciar sesión", failedToSignIn: "Error al iniciar sesión",
inProgress: "Esperando confirmación",
}, },
}, },
}, },
+1
View File
@@ -119,6 +119,7 @@ export function jaDefault(): ThirdwebLocale {
approveTransactionInSafe: "Safeで取引を承認", approveTransactionInSafe: "Safeで取引を承認",
tryAgain: "再試行", tryAgain: "再試行",
failedToSignIn: "サインインに失敗しました", failedToSignIn: "サインインに失敗しました",
inProgress: "確認待ち",
}, },
}, },
}, },
@@ -1,4 +1,4 @@
import { Theme, ThemeObjectOrType, iconSize } from "../../design-system"; import { Theme, iconSize } from "../../design-system";
import { ConnectedWalletDetails, type DropDownPosition } from "./Details"; import { ConnectedWalletDetails, type DropDownPosition } from "./Details";
import { import {
useAddress, useAddress,
@@ -24,9 +24,11 @@ import styled from "@emotion/styled";
import type { NetworkSelectorProps } from "./NetworkSelector"; import type { NetworkSelectorProps } from "./NetworkSelector";
import { onModalUnmount } from "./constants"; import { onModalUnmount } from "./constants";
import { isMobile } from "../../evm/utils/isMobile"; import { isMobile } from "../../evm/utils/isMobile";
import { CustomThemeProvider } from "../../design-system/CustomThemeProvider"; import {
CustomThemeProvider,
useCustomTheme,
} from "../../design-system/CustomThemeProvider";
import { WelcomeScreen } from "./screens/types"; import { WelcomeScreen } from "./screens/types";
import { useTheme } from "@emotion/react";
import { fadeInAnimation } from "../../design-system/animations"; import { fadeInAnimation } from "../../design-system/animations";
import { SupportedTokens, defaultTokens } from "./defaultTokens"; import { SupportedTokens, defaultTokens } from "./defaultTokens";
import { Container } from "../../components/basic"; import { Container } from "../../components/basic";
@@ -153,7 +155,7 @@ const TW_CONNECT_WALLET = "tw-connect-wallet";
*/ */
export const ConnectWallet: React.FC<ConnectWalletProps> = (props) => { export const ConnectWallet: React.FC<ConnectWalletProps> = (props) => {
const activeWallet = useWallet(); const activeWallet = useWallet();
const contextTheme = useTheme() as ThemeObjectOrType; const contextTheme = useCustomTheme();
const theme = props.theme || contextTheme || "dark"; const theme = props.theme || contextTheme || "dark";
const connectionStatus = useConnectionStatus(); const connectionStatus = useConnectionStatus();
const locale = useTWLocale(); const locale = useTWLocale();
@@ -397,6 +399,6 @@ function SwitchNetworkButton(props: {
); );
} }
const AnimatedButton = /* @__PURE__ */ styled(Button)` const AnimatedButton = /* @__PURE__ */ styled(Button)({
animation: ${fadeInAnimation} 300ms ease; animation: `${fadeInAnimation} 300ms ease`,
`; });
@@ -46,6 +46,7 @@ import {
MetaMaskWallet, MetaMaskWallet,
type SmartWallet, type SmartWallet,
walletIds, walletIds,
type EmbeddedWallet,
} from "@thirdweb-dev/wallets"; } from "@thirdweb-dev/wallets";
import { Container } from "../../components/basic"; import { Container } from "../../components/basic";
import { FundsIcon } from "./icons/FundsIcon"; import { FundsIcon } from "./icons/FundsIcon";
@@ -61,6 +62,18 @@ import { ReceiveFunds } from "./ReceiveFunds";
import { smartWalletIcon } from "./icons/dataUris"; import { smartWalletIcon } from "./icons/dataUris";
import { useTWLocale } from "../../evm/providers/locale-provider"; import { useTWLocale } from "../../evm/providers/locale-provider";
import { shortenString } from "@thirdweb-dev/react-core"; import { shortenString } from "@thirdweb-dev/react-core";
import {
StyledButton,
StyledDiv,
StyledLabel,
} from "../../design-system/elements";
import { useCustomTheme } from "../../design-system/CustomThemeProvider";
import {
appleIconUri,
facebookIconUri,
googleIconUri,
} from "./icons/socialLogins";
import { useEmbeddedWalletUserEmail } from "../../evm/hooks/wallets/useEmbeddedWallet";
export type DropDownPosition = { export type DropDownPosition = {
side: "top" | "bottom" | "left" | "right"; side: "top" | "bottom" | "left" | "right";
@@ -108,7 +121,9 @@ export const ConnectedWalletDetails: React.FC<{
>(); >();
const walletContext = useWalletContext(); const walletContext = useWalletContext();
let activeWalletIconURL = activeWalletConfig?.meta.iconURL || ""; const [overrideWalletIconUrl, setOverrideWalletIconUrl] = useState<
string | undefined
>(undefined);
// modals // modals
const [showNetworkSelector, setShowNetworkSelector] = useState(false); const [showNetworkSelector, setShowNetworkSelector] = useState(false);
@@ -137,15 +152,35 @@ export const ConnectedWalletDetails: React.FC<{
const shortAddress = address ? shortenString(address) : ""; const shortAddress = address ? shortenString(address) : "";
const isSmartWallet = activeWallet?.walletId === walletIds.smartWallet;
if (isSmartWallet) {
activeWalletIconURL = smartWalletIcon;
}
const addressOrENS = ensQuery.data?.ens || shortAddress; const addressOrENS = ensQuery.data?.ens || shortAddress;
const avatarUrl = ensQuery.data?.avatarUrl; const avatarUrl = ensQuery.data?.avatarUrl;
useEffect(() => {
if (activeWallet) {
if (activeWallet.walletId === walletIds.embeddedWallet) {
(activeWallet as EmbeddedWallet)
.getLastUsedAuthStrategy()
.then((auth) => {
if (auth === "apple") {
setOverrideWalletIconUrl(appleIconUri);
} else if (auth === "google") {
setOverrideWalletIconUrl(googleIconUri);
} else if (auth === "facebook") {
setOverrideWalletIconUrl(facebookIconUri);
}
});
} else if (activeWallet.walletId === walletIds.smartWallet) {
setOverrideWalletIconUrl(smartWalletIcon);
}
} else {
setOverrideWalletIconUrl(undefined);
}
}, [activeWallet]);
const walletIconUrl =
overrideWalletIconUrl || activeWalletConfig?.meta.iconURL || "";
const avatarOrWalletIconUrl = avatarUrl || walletIconUrl;
const trigger = props.detailsBtn ? ( const trigger = props.detailsBtn ? (
<div> <div>
<props.detailsBtn /> <props.detailsBtn />
@@ -160,7 +195,7 @@ export const ConnectedWalletDetails: React.FC<{
<Img <Img
width={iconSize.lg} width={iconSize.lg}
height={iconSize.lg} height={iconSize.lg}
src={avatarUrl || activeWalletIconURL} src={avatarOrWalletIconUrl}
className={`${TW_CONNECTED_WALLET}__wallet-icon`} className={`${TW_CONNECTED_WALLET}__wallet-icon`}
style={{ style={{
borderRadius: radius.sm, borderRadius: radius.sm,
@@ -254,7 +289,7 @@ export const ConnectedWalletDetails: React.FC<{
<Img <Img
width={iconSize.xl} width={iconSize.xl}
height={iconSize.xl} height={iconSize.xl}
src={avatarUrl || activeWalletIconURL} src={avatarOrWalletIconUrl}
alt="" alt=""
style={{ style={{
borderRadius: radius.sm, borderRadius: radius.sm,
@@ -328,6 +363,7 @@ export const ConnectedWalletDetails: React.FC<{
<Spacer y="lg" /> <Spacer y="lg" />
<ConnectedToSmartWallet /> <ConnectedToSmartWallet />
<EmbeddedWalletEmail />
{/* Send and Receive */} {/* Send and Receive */}
<Container <Container
@@ -580,7 +616,7 @@ export const ConnectedWalletDetails: React.FC<{
open={showReceiveModal} open={showReceiveModal}
setOpen={setShowReceiveModal} setOpen={setShowReceiveModal}
> >
<ReceiveFunds iconUrl={activeWalletIconURL} /> <ReceiveFunds iconUrl={walletIconUrl} />
</Modal> </Modal>
</> </>
); );
@@ -597,129 +633,127 @@ const dropdownContentFade = keyframes`
} }
`; `;
const DropDownContent = /* @__PURE__ */ (() => styled(DropdownMenu.Content)<{ const DropDownContent = /* @__PURE__ */ (() =>
theme?: Theme; styled(DropdownMenu.Content)(() => {
}>` const theme = useCustomTheme();
width: 360px; return {
box-sizing: border-box; width: "360px",
max-width: 100%; boxSizing: "border-box",
border-radius: ${radius.lg}; maxWidth: "100%",
padding: ${spacing.lg}; borderRadius: radius.lg,
animation: ${dropdownContentFade} 400ms cubic-bezier(0.16, 1, 0.3, 1); padding: spacing.lg,
will-change: transform, opacity; animation: `${dropdownContentFade} 400ms cubic-bezier(0.16, 1, 0.3, 1)`,
border: 1px solid ${(props) => props.theme.colors.borderColor}; willChange: "transform, opacity",
background-color: ${(props) => props.theme.colors.dropdownBg}; border: `1px solid ${theme.colors.borderColor}`,
--bg: ${(props) => props.theme.colors.dropdownBg}; backgroundColor: theme.colors.dropdownBg,
z-index: 1000000; "--bg": theme.colors.dropdownBg,
line-height: normal; zIndex: 1000000,
`)(); lineHeight: "normal",
};
}))();
const WalletInfoButton = styled.button<{ theme?: Theme }>` const WalletInfoButton = /* @__PURE__ */ StyledButton(() => {
all: unset; const theme = useCustomTheme();
background: ${(props) => props.theme.colors.connectedButtonBg}; return {
border: 1px solid ${(props) => props.theme.colors.borderColor}; all: "unset",
padding: ${spacing.sm} ${spacing.sm}; background: theme.colors.connectedButtonBg,
border-radius: ${radius.lg}; border: `1px solid ${theme.colors.borderColor}`,
cursor: pointer; padding: `${spacing.sm} ${spacing.sm}`,
display: inline-flex; borderRadius: radius.lg,
align-items: center; cursor: "pointer",
min-width: 180px; display: "inline-flex",
gap: ${spacing.sm}; alignItems: "center",
box-sizing: border-box; minWidth: "180px",
-webkit-tap-highlight-color: transparent; gap: spacing.sm,
line-height: normal; boxSizing: "border-box",
animation: ${fadeInAnimation} 300ms ease; WebkitTapHighlightColor: "transparent",
lineHeight: "normal",
animation: `${fadeInAnimation} 300ms ease`,
[media.mobile]: {
gap: spacing.sm,
padding: `${spacing.xs} ${spacing.sm}`,
img: {
width: `${iconSize.md}px`,
height: `${iconSize.md}px`,
},
},
"&:hover": {
transition: "background 250ms ease",
background: theme.colors.connectedButtonBgHover,
},
};
});
${media.mobile} { const DropdownLabel = /* @__PURE__ */ StyledLabel(() => {
gap: ${spacing.sm}; const theme = useCustomTheme();
padding: ${spacing.xs} ${spacing.sm}; return {
img { fontSize: fontSize.sm,
width: ${iconSize.md}px; color: theme.colors.secondaryText,
height: ${iconSize.md}px; fontWeight: 500,
} };
} });
&:hover { const MenuButton = /* @__PURE__ */ StyledButton(() => {
transition: background 250ms ease; const theme = useCustomTheme();
background: ${(props) => props.theme.colors.connectedButtonBgHover}; return {
} all: "unset",
`; padding: `${spacing.sm} ${spacing.sm}`,
borderRadius: radius.md,
const DropdownLabel = styled.label<{ theme?: Theme }>` backgroundColor: "transparent",
font-size: ${fontSize.sm}; border: `1px solid ${theme.colors.borderColor}`,
color: ${(props) => props.theme.colors.secondaryText}; boxSizing: "border-box",
font-weight: 500; display: "flex",
`; alignItems: "center",
width: "100%",
const MenuButton = styled.button<{ theme?: Theme }>` cursor: "pointer",
all: unset; fontSize: fontSize.md,
padding: ${spacing.sm} ${spacing.sm}; fontWeight: 500,
border-radius: ${radius.md}; color: `${theme.colors.primaryText} !important`,
background-color: transparent; gap: spacing.sm,
border: 1px solid ${(props) => props.theme.colors.borderColor}; WebkitTapHighlightColor: "transparent",
box-sizing: border-box; lineHeight: 1.3,
display: flex; "&:not([disabled]):hover": {
align-items: center; transition: "box-shadow 250ms ease, border-color 250ms ease",
width: 100%; border: `1px solid ${theme.colors.accentText}`,
cursor: pointer; boxShadow: `0 0 0 1px ${theme.colors.accentText}`,
font-size: ${fontSize.md}; },
font-weight: 500; "&[disabled]": {
color: ${(props) => props.theme.colors.primaryText} !important; cursor: "not-allowed",
gap: ${spacing.sm}; svg: {
-webkit-tap-highlight-color: transparent; display: "none",
line-height: 1.3; },
},
&:not([disabled]):hover { "&[disabled]:hover": {
transition: transition: "box-shadow 250ms ease, border-color 250ms ease",
box-shadow 250ms ease, border: `1px solid ${theme.colors.danger}`,
border-color 250ms ease; boxShadow: `0 0 0 1px ${theme.colors.danger}`,
border: 1px solid ${(props) => props.theme.colors.accentText}; },
box-shadow: 0 0 0 1px ${(props) => props.theme.colors.accentText}; };
} });
&[disabled] {
cursor: not-allowed;
svg {
display: none;
}
}
&[disabled]:hover {
transition:
box-shadow 250ms ease,
border-color 250ms ease;
border: 1px solid ${(props) => props.theme.colors.danger};
box-shadow: 0 0 0 1px ${(props) => props.theme.colors.danger};
}
`;
const MenuLink = /* @__PURE__ */ (() => MenuButton.withComponent("a"))(); const MenuLink = /* @__PURE__ */ (() => MenuButton.withComponent("a"))();
export const DropdownMenuItem = /* @__PURE__ */ (() => styled(
DropdownMenu.Item,
)<{ theme?: Theme }>`
outline: none;
`)();
export const StyledChevronRightIcon = /* @__PURE__ */ styled( export const StyledChevronRightIcon = /* @__PURE__ */ styled(
/* @__PURE__ */ ChevronRightIcon, /* @__PURE__ */ ChevronRightIcon,
)<{ )(() => {
theme?: Theme; const theme = useCustomTheme();
}>` return {
color: ${(props) => props.theme.colors.secondaryText}; color: theme.colors.secondaryText,
`; };
});
const DisconnectIconButton = /* @__PURE__ */ styled(IconButton)<{ const DisconnectIconButton = /* @__PURE__ */ styled(IconButton)(() => {
theme?: Theme; const theme = useCustomTheme();
}>` return {
margin-right: -${spacing.xxs}; marginRight: `-${spacing.xxs}`,
margin-left: auto; marginLeft: "auto",
color: ${(props) => props.theme.colors.secondaryText}; color: theme.colors.secondaryText,
&:hover { "&:hover": {
color: ${(props) => props.theme.colors.danger}; color: theme.colors.danger,
background: none; background: "none",
} },
`; };
});
function WalletSwitcher({ function WalletSwitcher({
wallet, wallet,
@@ -752,12 +786,15 @@ function WalletSwitcher({
); );
} }
const ActiveDot = styled.div<{ theme?: Theme }>` const ActiveDot = /* @__PURE__ */ StyledDiv(() => {
width: 8px; const theme = useCustomTheme();
height: 8px; return {
border-radius: 50%; width: "8px",
background-color: ${(props) => props.theme.colors.success}; height: "8px",
`; borderRadius: "50%",
backgroundColor: theme.colors.success,
};
});
function ConnectedToSmartWallet() { function ConnectedToSmartWallet() {
const activeWallet = useWallet(); const activeWallet = useWallet();
@@ -822,3 +859,21 @@ function ConnectedToSmartWallet() {
return null; return null;
} }
function EmbeddedWalletEmail() {
const emailQuery = useEmbeddedWalletUserEmail();
if (emailQuery.data) {
return (
<Container
style={{
paddingBottom: spacing.md,
}}
>
<Text color="primaryText">{emailQuery.data}</Text>
</Container>
);
}
return undefined;
}
@@ -22,13 +22,15 @@ import {
onModalUnmount, onModalUnmount,
} from "../constants"; } from "../constants";
import { HeadlessConnectUI } from "../../wallets/headlessConnectUI"; import { HeadlessConnectUI } from "../../wallets/headlessConnectUI";
import styled from "@emotion/styled";
import { Container, noScrollBar } from "../../../components/basic"; import { Container, noScrollBar } from "../../../components/basic";
import { ScreenContext, useScreen } from "./screen"; import { ScreenContext, useScreen } from "./screen";
import { StartScreen } from "../screens/StartScreen"; import { StartScreen } from "../screens/StartScreen";
import { CustomThemeProvider } from "../../../design-system/CustomThemeProvider"; import {
import { Theme } from "../../../design-system"; CustomThemeProvider,
useCustomTheme,
} from "../../../design-system/CustomThemeProvider";
import { SignatureScreen } from "../SignatureScreen"; import { SignatureScreen } from "../SignatureScreen";
import { StyledDiv } from "../../../design-system/elements";
export const ConnectModalContent = (props: { export const ConnectModalContent = (props: {
screen: string | WalletConfig; screen: string | WalletConfig;
@@ -293,13 +295,14 @@ export const ConnectModal = () => {
); );
}; };
const LeftContainer = /* @__PURE__ */ styled.div<{ const LeftContainer = /* @__PURE__ */ StyledDiv(() => {
theme?: Theme; const theme = useCustomTheme();
}>` return {
display: flex; display: "flex",
flex-direction: column; flexDirection: "column",
overflow-y: auto; overflowY: "auto",
${noScrollBar} ...noScrollBar,
position: relative; position: "relative",
border-right: 1px solid ${(p) => p.theme.colors.separatorLine}; borderRight: `1px solid ${theme.colors.separatorLine}`,
`; };
});
@@ -1,5 +1,3 @@
import { Theme } from "../../../design-system";
import styled from "@emotion/styled";
import { Cross2Icon } from "@radix-ui/react-icons"; import { Cross2Icon } from "@radix-ui/react-icons";
import { CrossContainer } from "../../../components/Modal"; import { CrossContainer } from "../../../components/Modal";
import { IconButton } from "../../../components/buttons"; import { IconButton } from "../../../components/buttons";
@@ -12,17 +10,20 @@ import {
wideModalMaxHeight, wideModalMaxHeight,
modalMaxWidthCompact, modalMaxWidthCompact,
modalMaxWidthWide, modalMaxWidthWide,
defaultTheme,
} from "../constants"; } from "../constants";
import { ConnectModalContent } from "./ConnectModal"; import { ConnectModalContent } from "./ConnectModal";
import { useScreen } from "./screen"; import { useScreen } from "./screen";
import { isMobile } from "../../../evm/utils/isMobile"; import { isMobile } from "../../../evm/utils/isMobile";
import { useWallets } from "@thirdweb-dev/react-core"; import { useWallets } from "@thirdweb-dev/react-core";
import { DynamicHeight } from "../../../components/DynamicHeight"; import { DynamicHeight } from "../../../components/DynamicHeight";
import { CustomThemeProvider } from "../../../design-system/CustomThemeProvider"; import {
CustomThemeProvider,
useCustomTheme,
} from "../../../design-system/CustomThemeProvider";
import { ComponentProps, useContext, useEffect } from "react"; import { ComponentProps, useContext, useEffect } from "react";
import { ConnectWalletProps } from "../ConnectWallet"; import { ConnectWalletProps } from "../ConnectWallet";
import { useTWLocale } from "../../../evm/providers/locale-provider"; import { useTWLocale } from "../../../evm/providers/locale-provider";
import { StyledDiv } from "../../../design-system/elements";
export const ConnectModalInline = ( export const ConnectModalInline = (
props: Omit< props: Omit<
@@ -43,6 +44,7 @@ export const ConnectModalInline = (
const walletConfigs = useWallets(); const walletConfigs = useWallets();
const modalSize = const modalSize =
isMobile() || walletConfigs.length === 1 ? "compact" : props.modalSize; isMobile() || walletConfigs.length === 1 ? "compact" : props.modalSize;
const ctxTheme = useCustomTheme();
const content = ( const content = (
<> <>
@@ -73,7 +75,7 @@ export const ConnectModalInline = (
); );
const walletUIStatesProps = { const walletUIStatesProps = {
theme: props.theme || defaultTheme, theme: props.theme || ctxTheme,
modalSize: modalSize, modalSize: modalSize,
title: props.modalTitle, title: props.modalTitle,
termsOfServiceUrl: props.termsOfServiceUrl, termsOfServiceUrl: props.termsOfServiceUrl,
@@ -140,21 +142,24 @@ function SyncedWalletUIStates(
return <WalletUIStatesProvider {...props} />; return <WalletUIStatesProvider {...props} />;
} }
const ConnectModalInlineContainer = styled.div<{ theme?: Theme }>` const ConnectModalInlineContainer = /* @__PURE__ */ StyledDiv(() => {
background: ${(p) => p.theme.colors.modalBg}; const theme = useCustomTheme();
color: ${(p) => p.theme.colors.primaryText}; return {
transition: background 0.2s ease; background: theme.colors.modalBg,
border-radius: ${radius.xl}; color: theme.colors.primaryText,
width: 100%; transition: "background 0.2s ease",
box-sizing: border-box; borderRadius: radius.xl,
box-shadow: ${shadow.lg}; width: "100%",
position: relative; boxSizing: "border-box",
border: 1px solid ${(p) => p.theme.colors.borderColor}; boxShadow: shadow.lg,
line-height: normal; position: "relative",
overflow: hidden; border: `1px solid ${theme.colors.borderColor}`,
font-family: ${(p) => p.theme.fontFamily}; lineHeight: "normal",
& *::selection { overflow: "hidden",
background-color: ${(p) => p.theme.colors.primaryText}; fontFamily: theme.fontFamily,
color: ${(p) => p.theme.colors.modalBg}; "& *::selection": {
} backgroundColor: theme.colors.primaryText,
`; color: theme.colors.modalBg,
},
};
});
@@ -10,7 +10,6 @@ import {
radius, radius,
spacing, spacing,
Theme, Theme,
ThemeObjectOrType,
} from "../../design-system"; } from "../../design-system";
import styled from "@emotion/styled"; import styled from "@emotion/styled";
import { MagnifyingGlassIcon } from "@radix-ui/react-icons"; import { MagnifyingGlassIcon } from "@radix-ui/react-icons";
@@ -28,9 +27,12 @@ import { useEffect } from "react";
import { Container, Line } from "../../components/basic"; import { Container, Line } from "../../components/basic";
import { Text } from "../../components/text"; import { Text } from "../../components/text";
import { ModalTitle } from "../../components/modalElements"; import { ModalTitle } from "../../components/modalElements";
import { CustomThemeProvider } from "../../design-system/CustomThemeProvider"; import {
import { useTheme } from "@emotion/react"; CustomThemeProvider,
useCustomTheme,
} from "../../design-system/CustomThemeProvider";
import { useTWLocale } from "../../evm/providers/locale-provider"; import { useTWLocale } from "../../evm/providers/locale-provider";
import { StyledButton, StyledP, StyledUl } from "../../design-system/elements";
type RenderChain = React.FC<{ type RenderChain = React.FC<{
chain: Chain; chain: Chain;
@@ -69,7 +71,7 @@ const fuseConfig = {
export const NetworkSelector: React.FC<NetworkSelectorProps> = (props) => { export const NetworkSelector: React.FC<NetworkSelectorProps> = (props) => {
const [searchTerm, setSearchTerm] = useState(""); const [searchTerm, setSearchTerm] = useState("");
const deferredSearchTerm = useDeferredValue(searchTerm); const deferredSearchTerm = useDeferredValue(searchTerm);
const themeFromContext = useTheme() as ThemeObjectOrType; const themeFromContext = useCustomTheme();
const theme = props.theme || themeFromContext || "dark"; const theme = props.theme || themeFromContext || "dark";
const supportedChains = useSupportedChains(); const supportedChains = useSupportedChains();
const chains = props.chains || supportedChains; const chains = props.chains || supportedChains;
@@ -544,72 +546,81 @@ const NetworkList = /* @__PURE__ */ memo(function NetworkList(props: {
); );
}); });
const TabButton = /* @__PURE__ */ (() => styled(Tabs.Trigger)<{ const TabButton = /* @__PURE__ */ (() =>
theme?: Theme; styled(Tabs.Trigger)(() => {
}>` const theme = useCustomTheme();
all: unset; return {
font-size: ${fontSize.sm}; all: "unset",
font-weight: 500; fontSize: fontSize.sm,
color: ${(p) => p.theme.colors.secondaryText}; fontWeight: 500,
cursor: pointer; color: theme.colors.secondaryText,
padding: ${spacing.sm} ${spacing.sm}; cursor: "pointer",
-webkit-tap-highlight-color: transparent; padding: `${spacing.sm} ${spacing.sm}`,
border-radius: ${radius.lg}; WebkitTapHighlightColor: "transparent",
transition: borderRadius: radius.lg,
background 0.2s ease, transition: "background 0.2s ease, color 0.2s ease",
color 0.2s ease;
&[data-state="active"] { "&[data-state='active']": {
background: ${(p) => p.theme.colors.secondaryButtonBg}; background: theme.colors.secondaryButtonBg,
color: ${(p) => p.theme.colors.primaryText}; color: theme.colors.primaryText,
} },
`)(); };
}))();
const SectionLabel = styled.p<{ theme?: Theme }>` const SectionLabel = /* @__PURE__ */ StyledP(() => {
font-size: ${fontSize.sm}; const theme = useCustomTheme();
color: ${(p) => p.theme.colors.secondaryText}; return {
margin: 0; fontSize: fontSize.sm,
display: block; color: theme.colors.secondaryText,
padding: 0 ${spacing.xs}; margin: 0,
`; display: "block",
padding: `0 ${spacing.xs}`,
};
});
const NetworkListUl = styled.ul<{ theme?: Theme }>` const NetworkListUl = /* @__PURE__ */ StyledUl({
padding: 0; padding: 0,
margin: 0; margin: 0,
list-style: none; listStyle: "none",
display: flex; display: "flex",
flex-direction: column; flexDirection: "column",
gap: ${spacing.xs}; gap: spacing.xs,
box-sizing: border-box; boxSizing: "border-box",
`; });
const NetworkButton = styled.button<{ theme?: Theme }>` const NetworkButton = /* @__PURE__ */ StyledButton(() => {
all: unset; const theme = useCustomTheme();
display: flex; return {
width: 100%; all: "unset",
box-sizing: border-box; display: "flex",
align-items: center; width: "100%",
gap: ${spacing.md}; boxSizing: "border-box",
padding: ${spacing.xs} ${spacing.sm}; alignItems: "center",
border-radius: ${radius.md}; gap: spacing.md,
cursor: pointer; padding: `${spacing.xs} ${spacing.sm}`,
transition: background 0.2s ease; borderRadius: radius.md,
color: ${(p) => p.theme.colors.primaryText}; cursor: "pointer",
font-weight: 500; transition: "background 0.2s ease",
font-size: ${fontSize.md}; color: theme.colors.primaryText,
&:hover { fontWeight: 500,
background: ${(p) => p.theme.colors.secondaryButtonBg}; fontSize: fontSize.md,
} "&:hover": {
background: theme.colors.secondaryButtonBg,
},
${media.mobile} { [media.mobile]: {
font-size: ${fontSize.sm}; fontSize: fontSize.sm,
} },
`; };
});
const StyledMagnifyingGlassIcon = /* @__PURE__ */ styled(MagnifyingGlassIcon)<{ const StyledMagnifyingGlassIcon = /* @__PURE__ */ styled(MagnifyingGlassIcon)(
theme?: Theme; () => {
}>` const theme = useCustomTheme();
color: ${(p) => p.theme.colors.secondaryText}; return {
position: absolute; color: theme.colors.secondaryText,
left: ${spacing.sm}; position: "absolute",
`; left: spacing.sm,
};
},
);
@@ -3,13 +3,14 @@ import { Spacer } from "../../components/Spacer";
import { Container, ModalHeader } from "../../components/basic"; import { Container, ModalHeader } from "../../components/basic";
import { Text } from "../../components/text"; import { Text } from "../../components/text";
import { CopyIcon } from "../../components/CopyIcon"; import { CopyIcon } from "../../components/CopyIcon";
import styled from "@emotion/styled"; import { iconSize, radius, spacing } from "../../design-system";
import { Theme, iconSize, radius, spacing } from "../../design-system";
import { QRCode } from "../../components/QRCode"; import { QRCode } from "../../components/QRCode";
import { Img } from "../../components/Img"; import { Img } from "../../components/Img";
import { useClipboard } from "../../evm/components/hooks/useCopyClipboard"; import { useClipboard } from "../../evm/components/hooks/useCopyClipboard";
import { useTWLocale } from "../../evm/providers/locale-provider"; import { useTWLocale } from "../../evm/providers/locale-provider";
import { shortenString } from "@thirdweb-dev/react-core"; import { shortenString } from "@thirdweb-dev/react-core";
import { StyledButton } from "../../design-system/elements";
import { useCustomTheme } from "../../design-system/CustomThemeProvider";
export function ReceiveFunds(props: { iconUrl: string }) { export function ReceiveFunds(props: { iconUrl: string }) {
const address = useAddress(); const address = useAddress();
@@ -57,18 +58,21 @@ export function ReceiveFunds(props: { iconUrl: string }) {
); );
} }
const WalletAddressContainer = styled.button<{ theme?: Theme }>` const WalletAddressContainer = /* @__PURE__ */ StyledButton(() => {
all: unset; const theme = useCustomTheme();
width: 100%; return {
box-sizing: border-box; all: "unset",
cursor: pointer; width: "100%",
padding: ${spacing.md}; boxSizing: "border-box",
display: flex; cursor: "pointer",
justify-content: space-between; padding: spacing.md,
border: 1px solid ${(p) => p.theme.colors.borderColor}; display: "flex",
border-radius: ${radius.md}; justifyContent: "space-between",
transition: border-color 200ms ease; border: `1px solid ${theme.colors.borderColor}`,
&:hover { borderRadius: radius.md,
border-color: ${(p) => p.theme.colors.accentText}; transition: "border-color 200ms ease",
} "&:hover": {
`; borderColor: theme.colors.accentText,
},
};
});
@@ -10,7 +10,7 @@ import {
useWallet, useWallet,
} from "@thirdweb-dev/react-core"; } from "@thirdweb-dev/react-core";
import { ChainIcon } from "../../components/ChainIcon"; import { ChainIcon } from "../../components/ChainIcon";
import { Theme, fontSize, iconSize, spacing } from "../../design-system"; import { fontSize, iconSize, spacing } from "../../design-system";
import { Text } from "../../components/text"; import { Text } from "../../components/text";
import { Skeleton } from "../../components/Skeleton"; import { Skeleton } from "../../components/Skeleton";
import { useMutation } from "@tanstack/react-query"; import { useMutation } from "@tanstack/react-query";
@@ -24,6 +24,8 @@ import { Img } from "../../components/Img";
import styled from "@emotion/styled"; import styled from "@emotion/styled";
import { NATIVE_TOKEN_ADDRESS } from "@thirdweb-dev/sdk"; import { NATIVE_TOKEN_ADDRESS } from "@thirdweb-dev/sdk";
import { useTWLocale } from "../../evm/providers/locale-provider"; import { useTWLocale } from "../../evm/providers/locale-provider";
import { StyledDiv } from "../../design-system/elements";
import { useCustomTheme } from "../../design-system/CustomThemeProvider";
// TODO - use a better way to fetch token Info instead of useBalance // TODO - use a better way to fetch token Info instead of useBalance
@@ -529,19 +531,20 @@ function SelectTokenButton(props: { token?: TokenInfo; onClick: () => void }) {
); );
} }
const SelectTokenBtn = /* @__PURE__ */ styled(Button)<{ theme?: Theme }>` const SelectTokenBtn = /* @__PURE__ */ styled(Button)(() => {
background: transparent; const theme = useCustomTheme();
justify-content: flex-start; return {
gap: ${spacing.sm}; background: "transparent",
padding: ${fontSize.xs}; justifyContent: "flex-start",
&:hover { gap: spacing.sm,
background: ${(p) => p.theme.colors.secondaryButtonBg}; padding: spacing.sm,
transform: scale(1.01); "&:hover": {
} background: theme.colors.secondaryButtonBg,
transition: transform: "scale(1.01)",
background 200ms ease, },
transform 150ms ease; transition: "background 200ms ease, transform 150ms ease",
`; };
});
function formatBalance(balanceData: { function formatBalance(balanceData: {
symbol: string; symbol: string;
@@ -552,9 +555,9 @@ function formatBalance(balanceData: {
return Number(balanceData.displayValue).toFixed(3) + " " + balanceData.symbol; return Number(balanceData.displayValue).toFixed(3) + " " + balanceData.symbol;
} }
const CurrencyBadge = styled.div<{ theme?: Theme }>` const CurrencyBadge = /* @__PURE__ */ StyledDiv({
position: absolute; position: "absolute",
top: 50%; top: "50%",
transform: translateY(-50%); transform: "translateY(-50%)",
right: ${spacing.sm}; right: spacing.sm,
`; });
@@ -15,20 +15,21 @@ import { useCallback, useContext, useEffect, useRef, useState } from "react";
import { ModalConfigCtx } from "../../evm/providers/wallet-ui-states-provider"; import { ModalConfigCtx } from "../../evm/providers/wallet-ui-states-provider";
import { wait } from "../../utils/wait"; import { wait } from "../../utils/wait";
import { Button } from "../../components/buttons"; import { Button } from "../../components/buttons";
import { Theme, iconSize, radius, spacing } from "../../design-system"; import { iconSize, radius, spacing } from "../../design-system";
import { import {
CrossCircledIcon, CrossCircledIcon,
ExternalLinkIcon, ExternalLinkIcon,
ReloadIcon, ReloadIcon,
} from "@radix-ui/react-icons"; } from "@radix-ui/react-icons";
import { Img } from "../../components/Img"; import { Img } from "../../components/Img";
import styled from "@emotion/styled";
import { walletIds } from "@thirdweb-dev/wallets"; import { walletIds } from "@thirdweb-dev/wallets";
import { safeChainIdToSlug } from "../wallets/safe/safeChainSlug"; import { safeChainIdToSlug } from "../wallets/safe/safeChainSlug";
import { TOS } from "./Modal/TOS"; import { TOS } from "./Modal/TOS";
import { keyframes } from "@emotion/react"; import { keyframes } from "@emotion/react";
import { Spinner } from "../../components/Spinner"; import { Spinner } from "../../components/Spinner";
import { useTWLocale } from "../../evm/providers/locale-provider"; import { useTWLocale } from "../../evm/providers/locale-provider";
import { StyledDiv } from "../../design-system/elements";
import { useCustomTheme } from "../../design-system/CustomThemeProvider";
type Status = "signing" | "failed" | "idle"; type Status = "signing" | "failed" | "idle";
@@ -160,8 +161,8 @@ export const SignatureScreen: React.FC<{
<Container flex="column" gap="md" animate="fadein" key={status}> <Container flex="column" gap="md" animate="fadein" key={status}>
<Text size="lg" center color="primaryText"> <Text size="lg" center color="primaryText">
{status === "failed" {status === "failed"
? "Failed to sign in" ? locale.signingScreen.failedToSignIn
: "Awaiting Confirmation"} : locale.signingScreen.inProgress}
</Text> </Text>
{status === "signing" && ( {status === "signing" && (
@@ -314,21 +315,22 @@ const plusAnimation = keyframes`
} }
`; `;
const PulsatingContainer = styled.div<{ theme?: Theme }>` const PulsatingContainer = /* @__PURE__ */ StyledDiv(() => {
position: relative; const theme = useCustomTheme();
return {
&::before { position: "relative",
content: ""; "&::before": {
display: block; content: '""',
position: absolute; display: "block",
left: 0; position: "absolute",
top: 0; left: 0,
bottom: 0; top: 0,
right: 0; bottom: 0,
background: ${(p) => p.theme.colors.accentText}; right: 0,
animation: ${plusAnimation} 2s cubic-bezier(0.175, 0.885, 0.32, 1.1) background: theme.colors.accentText,
infinite; animation: `${plusAnimation} 2s cubic-bezier(0.175, 0.885, 0.32, 1.1) infinite`,
z-index: -1; zIndex: -1,
border-radius: ${radius.xl}; borderRadius: radius.xl,
} },
`; };
});
@@ -9,8 +9,7 @@ import {
} from "../../components/basic"; } from "../../components/basic";
import { Button } from "../../components/buttons"; import { Button } from "../../components/buttons";
import { ModalTitle } from "../../components/modalElements"; import { ModalTitle } from "../../components/modalElements";
import { iconSize, radius, spacing, Theme } from "../../design-system"; import { iconSize, radius, spacing } from "../../design-system";
import styled from "@emotion/styled";
import { import {
WalletConfig, WalletConfig,
useConnectionStatus, useConnectionStatus,
@@ -27,6 +26,8 @@ import { Spacer } from "../../components/Spacer";
import { TextDivider } from "../../components/TextDivider"; import { TextDivider } from "../../components/TextDivider";
import { TOS } from "./Modal/TOS"; import { TOS } from "./Modal/TOS";
import { useTWLocale } from "../../evm/providers/locale-provider"; import { useTWLocale } from "../../evm/providers/locale-provider";
import { StyledButton, StyledUl } from "../../design-system/elements";
import { useCustomTheme } from "../../design-system/CustomThemeProvider";
export const WalletSelector: React.FC<{ export const WalletSelector: React.FC<{
walletConfigs: WalletConfig[]; walletConfigs: WalletConfig[];
@@ -454,50 +455,44 @@ export function WalletEntryButton(props: {
); );
} }
const WalletList = styled.ul<{ theme?: Theme }>` const WalletList = /* @__PURE__ */ StyledUl({
all: unset; all: "unset",
list-style-type: none; listStyleType: "none",
display: flex; display: "flex",
flex-direction: column; flexDirection: "column",
gap: 2px; gap: "2px",
box-sizing: border-box; boxSizing: "border-box",
overflow-y: auto; overflowY: "auto",
flex: 1; flex: 1,
${noScrollBar} ...noScrollBar,
// to show the box-shadow of inputs that overflows
padding: "2px",
margin: "-2px",
marginBottom: 0,
paddingBottom: spacing.lg,
});
/* to show the box-shadow of inputs that overflows */ const WalletButton = /* @__PURE__ */ StyledButton(() => {
padding: 2px; const theme = useCustomTheme();
margin: -2px; return {
padding-bottom: 0; all: "unset",
margin-bottom: 0; display: "flex",
padding-bottom: ${spacing.lg}; alignItems: "center",
`; gap: spacing.sm,
cursor: "pointer",
const WalletButton = styled.button<{ theme?: Theme }>` boxSizing: "border-box",
all: unset; width: "100%",
display: flex; color: theme.colors.secondaryText,
align-items: center; position: "relative",
gap: ${spacing.sm}; borderRadius: radius.md,
cursor: pointer; padding: `${spacing.xs} ${spacing.xs}`,
box-sizing: border-box; "&:hover": {
width: 100%; backgroundColor: theme.colors.walletSelectorButtonHoverBg,
color: ${(p) => p.theme.colors.secondaryText}; transform: "scale(1.01)",
position: relative; },
border-radius: ${radius.md}; transition: "background-color 200ms ease, transform 200ms ease",
padding: ${spacing.xs} ${spacing.xs}; };
});
&:hover {
background-color: ${(p) => p.theme.colors.walletSelectorButtonHoverBg};
}
transition:
background-color 200ms ease,
transform 200ms ease;
&:hover {
transform: scale(1.01);
}
`;
function sortWalletConfigs(walletConfigs: WalletConfig[]) { function sortWalletConfigs(walletConfigs: WalletConfig[]) {
return ( return (
@@ -3,16 +3,16 @@ import { QRCode } from "../../../components/QRCode";
import { Spacer } from "../../../components/Spacer"; import { Spacer } from "../../../components/Spacer";
import { Container, ModalHeader } from "../../../components/basic"; import { Container, ModalHeader } from "../../../components/basic";
import { iconSize, radius, spacing } from "../../../design-system"; import { iconSize, radius, spacing } from "../../../design-system";
import type { Theme } from "../../../design-system/index";
import { isMobile } from "../../../evm/utils/isMobile"; import { isMobile } from "../../../evm/utils/isMobile";
import { openWindow } from "../../utils/openWindow"; import { openWindow } from "../../utils/openWindow";
import styled from "@emotion/styled";
import { useState } from "react"; import { useState } from "react";
import { AppleIcon } from "../icons/AppleIcon"; import { AppleIcon } from "../icons/AppleIcon";
import { ChromeIcon } from "../icons/ChromeIcon"; import { ChromeIcon } from "../icons/ChromeIcon";
import { PlayStoreIcon } from "../icons/PlayStoreIcon"; import { PlayStoreIcon } from "../icons/PlayStoreIcon";
import { Text } from "../../../components/text"; import { Text } from "../../../components/text";
import { useTWLocale } from "../../../evm/providers/locale-provider"; import { useTWLocale } from "../../../evm/providers/locale-provider";
import { StyledButton } from "../../../design-system/elements";
import { useCustomTheme } from "../../../design-system/CustomThemeProvider";
export const GetStartedScreen: React.FC<{ export const GetStartedScreen: React.FC<{
onBack?: () => void; onBack?: () => void;
@@ -206,24 +206,27 @@ const InstallScanScreen: React.FC<{
); );
}; };
export const ButtonLink = styled.button<{ theme?: Theme }>` export const ButtonLink = /* @__PURE__ */ StyledButton(() => {
all: unset; const theme = useCustomTheme();
text-decoration: none; return {
padding: ${spacing.sm} ${spacing.md}; all: "unset",
border-radius: ${radius.sm}; textDecoration: "none",
display: flex; padding: `${spacing.sm} ${spacing.md}`,
align-items: center; borderRadius: radius.sm,
gap: ${spacing.md}; display: "flex",
cursor: pointer; alignItems: "center",
box-sizing: border-box; gap: spacing.md,
width: 100%; cursor: "pointer",
font-weight: 500; boxSizing: "border-box",
color: ${(p) => p.theme.colors.secondaryButtonText}; width: "100%",
background: ${(p) => p.theme.colors.secondaryButtonBg}; fontWeight: 500,
transition: 100ms ease; color: theme.colors.secondaryButtonText,
&:hover { background: theme.colors.secondaryButtonBg,
background: ${(p) => p.theme.colors.secondaryButtonHoverBg}; transition: "100ms ease",
text-decoration: none; "&:hover": {
color: ${(p) => p.theme.colors.primaryText}; background: theme.colors.secondaryButtonHoverBg,
} textDecoration: "none",
`; color: theme.colors.primaryText,
},
};
});
@@ -5,11 +5,11 @@ import { useContext } from "react";
import { ModalConfigCtx } from "../../../evm/providers/wallet-ui-states-provider"; import { ModalConfigCtx } from "../../../evm/providers/wallet-ui-states-provider";
import { TOS } from "../Modal/TOS"; import { TOS } from "../Modal/TOS";
import { GlobeIcon } from "../icons/GlobalIcon"; import { GlobeIcon } from "../icons/GlobalIcon";
import styled from "@emotion/styled";
import { Theme } from "../../../design-system";
import { keyframes } from "@emotion/react"; import { keyframes } from "@emotion/react";
import { Img } from "../../../components/Img"; import { Img } from "../../../components/Img";
import { useTWLocale } from "../../../evm/providers/locale-provider"; import { useTWLocale } from "../../../evm/providers/locale-provider";
import { StyledDiv } from "../../../design-system/elements";
import { useCustomTheme } from "../../../design-system/CustomThemeProvider";
export function StartScreen() { export function StartScreen() {
const { const {
@@ -111,8 +111,11 @@ const floatingAnimation = keyframes`
} }
`; `;
const GlobalContainer = styled.div<{ theme?: Theme }>` const GlobalContainer = /* @__PURE__ */ StyledDiv(() => {
color: ${(p) => p.theme.colors.accentText}; const theme = useCustomTheme();
filter: drop-shadow(0px 6px 10px ${(p) => p.theme.colors.accentText}); return {
animation: ${floatingAnimation} 2s ease infinite alternate; color: theme.colors.accentText,
`; filter: `drop-shadow(0px 6px 10px ${theme.colors.accentText})`,
animation: `${floatingAnimation} 2s ease infinite alternate`,
};
});
@@ -1,8 +1,9 @@
import { keyframes } from "@emotion/react"; import { keyframes } from "@emotion/react";
import styled from "@emotion/styled";
import { Img } from "../../../components/Img"; import { Img } from "../../../components/Img";
import { radius, Theme } from "../../../design-system"; import { radius } from "../../../design-system";
import { fadeInAnimation } from "../../../design-system/animations"; import { fadeInAnimation } from "../../../design-system/animations";
import { StyledDiv } from "../../../design-system/elements";
import { useCustomTheme } from "../../../design-system/CustomThemeProvider";
export function WalletLogoSpinner(props: { error: boolean; iconUrl: string }) { export function WalletLogoSpinner(props: { error: boolean; iconUrl: string }) {
const loaderRadius = 20; const loaderRadius = 20;
@@ -84,50 +85,52 @@ const plusAnimation = keyframes`
} }
`; `;
const LogoContainer = styled.div<{ theme?: Theme }>` const LogoContainer = /* @__PURE__ */ StyledDiv(() => {
display: flex; const theme = useCustomTheme();
justify-content: center; return {
position: relative; display: "flex",
border-radius: ${radius.xl}; justifyContent: "center",
position: "relative",
borderRadius: radius.xl,
[data-img-container] { "[data-img-container]": {
display: flex; display: "flex",
justify-content: center; justifyContent: "center",
align-items: center; alignItems: "center",
position: relative; position: "relative",
} },
&[data-error="true"] [data-container] { "&[data-error='true'] [data-container]": {
animation: ${shakeErrorAnimation} 0.25s linear; animation: `${shakeErrorAnimation} 0.25s linear`,
} },
&[data-error="true"] [data-img-container]::before { "&[data-error='true'] [data-img-container]::before": {
content: ""; content: '""',
position: absolute; position: "absolute",
inset: 0; inset: 0,
animation: none; background: theme.colors.danger,
background: ${(p) => p.theme.colors.danger}; animation: `${plusAnimation} 1.5s ease infinite`,
animation: ${plusAnimation} 1.5s ease infinite; borderRadius: "20px",
border-radius: 20px; zIndex: -1,
z-index: -1; },
}
svg { svg: {
position: absolute; position: "absolute",
/* can't use inset because safari doesn't like it */ /* can't use inset because safari doesn't like it */
left: -8px; left: "-8px",
top: -8px; top: "-8px",
width: calc(100% + 16px); width: "calc(100% + 16px)",
height: calc(100% + 16px); height: "calc(100% + 16px)",
animation: ${fadeInAnimation} 400ms ease; animation: `${fadeInAnimation} 400ms ease`,
} },
img { img: {
z-index: 100; zIndex: 100,
} },
rect { rect: {
animation: ${dashRotateAnimation} 1.2s linear infinite; animation: `${dashRotateAnimation} 1.2s linear infinite`,
stroke: ${(p) => p.theme.colors.accentText}; stroke: theme.colors.accentText,
} },
`; };
});
@@ -14,8 +14,8 @@ function getBodyTitle(authOption: EmbeddedWalletOauthStrategy) {
function getWidthAndHeight(authOption: EmbeddedWalletOauthStrategy) { function getWidthAndHeight(authOption: EmbeddedWalletOauthStrategy) {
switch (authOption) { switch (authOption) {
// case "facebook": case "facebook":
// return { width: 715, height: 555 }; return { width: 715, height: 555 };
default: default:
return { width: 350, height: 500 }; return { width: 350, height: 500 };
} }
@@ -1,4 +1,3 @@
import { useTheme } from "@emotion/react";
import styled from "@emotion/styled"; import styled from "@emotion/styled";
import { import {
WalletConfig, WalletConfig,
@@ -15,12 +14,13 @@ import { Spacer } from "../../../components/Spacer";
import { TextDivider } from "../../../components/TextDivider"; import { TextDivider } from "../../../components/TextDivider";
import { Container, ModalHeader } from "../../../components/basic"; import { Container, ModalHeader } from "../../../components/basic";
import { Button } from "../../../components/buttons"; import { Button } from "../../../components/buttons";
import { Theme, fontSize, iconSize, spacing } from "../../../design-system"; import { fontSize, iconSize, spacing } from "../../../design-system";
import { useTWLocale } from "../../../evm/providers/locale-provider"; import { useTWLocale } from "../../../evm/providers/locale-provider";
import { openOauthSignInWindow } from "../../utils/openOauthSignInWindow"; import { openOauthSignInWindow } from "../../utils/openOauthSignInWindow";
import { InputSelectionUI } from "../InputSelectionUI"; import { InputSelectionUI } from "../InputSelectionUI";
import { socialIcons } from "./socialIcons"; import { socialIcons } from "./socialIcons";
import type { AuthOption, EmbeddedWalletLoginType } from "./types"; import type { AuthOption, EmbeddedWalletLoginType } from "./types";
import { useCustomTheme } from "../../../design-system/CustomThemeProvider";
export const EmbeddedWalletFormUI = (props: { export const EmbeddedWalletFormUI = (props: {
onSelect: (loginType: EmbeddedWalletLoginType) => void; onSelect: (loginType: EmbeddedWalletLoginType) => void;
@@ -33,11 +33,11 @@ export const EmbeddedWalletFormUI = (props: {
const createWalletInstance = useCreateWalletInstance(); const createWalletInstance = useCreateWalletInstance();
const setConnectionStatus = useSetConnectionStatus(); const setConnectionStatus = useSetConnectionStatus();
const setConnectedWallet = useSetConnectedWallet(); const setConnectedWallet = useSetConnectedWallet();
const themeObj = useTheme() as Theme; const themeObj = useCustomTheme();
const loginMethodsLabel: Record<EmbeddedWalletOauthStrategy, string> = { const loginMethodsLabel: Record<EmbeddedWalletOauthStrategy, string> = {
google: locale.signInWithGoogle, google: locale.signInWithGoogle,
// facebook: locale.signInWithFacebook, facebook: locale.signInWithFacebook,
apple: locale.signInWithApple, apple: locale.signInWithApple,
}; };
@@ -76,13 +76,20 @@ export const EmbeddedWalletFormUI = (props: {
} }
}; };
const showOnlyIcons = socialLogins.length > 2; const showOnlyIcons = socialLogins.length > 1;
return ( return (
<Container flex="column" gap="lg"> <Container flex="column" gap="lg">
{/* Social Login */} {/* Social Login */}
{hasSocialLogins && ( {hasSocialLogins && (
<Container flex={showOnlyIcons ? "row" : "column"} center="x" gap="sm"> <Container
flex={showOnlyIcons ? "row" : "column"}
center="x"
gap="sm"
style={{
justifyContent: "space-between",
}}
>
{socialLogins.map((loginMethod) => { {socialLogins.map((loginMethod) => {
const imgIconSize = showOnlyIcons ? iconSize.lg : iconSize.md; const imgIconSize = showOnlyIcons ? iconSize.lg : iconSize.md;
return ( return (
@@ -176,19 +183,19 @@ export const EmbeddedWalletFormUIScreen: React.FC<{
); );
}; };
const SocialButton = /* @__PURE__ */ styled(Button)<{ theme?: Theme }>` const SocialButton = /* @__PURE__ */ styled(Button)({
&[data-variant="full"] { "&[data-variant='full']": {
display: flex; display: "flex",
justify-content: flex-start; justifyContent: "flex-start",
gap: ${spacing.md}; gap: spacing.md,
font-size: ${fontSize.md}; fontSize: fontSize.md,
transition: background-color 0.2s ease; transition: "background-color 0.2s ease",
&:active { "&:active": {
box-shadow: none; boxShadow: "none",
} },
} },
"&[data-variant='icon']": {
&[data-variant="icon"] { padding: spacing.sm,
padding: ${spacing.sm}; flexGrow: 1,
} },
`; });
@@ -1,4 +1,3 @@
import styled from "@emotion/styled";
import { ConnectUIProps, useWalletContext } from "@thirdweb-dev/react-core"; import { ConnectUIProps, useWalletContext } from "@thirdweb-dev/react-core";
import { EmbeddedWallet, SendEmailOtpReturnType } from "@thirdweb-dev/wallets"; import { EmbeddedWallet, SendEmailOtpReturnType } from "@thirdweb-dev/wallets";
import { useCallback, useEffect, useRef, useState } from "react"; import { useCallback, useEffect, useRef, useState } from "react";
@@ -9,10 +8,12 @@ import { Spinner } from "../../../components/Spinner";
import { Container, Line, ModalHeader } from "../../../components/basic"; import { Container, Line, ModalHeader } from "../../../components/basic";
import { Button } from "../../../components/buttons"; import { Button } from "../../../components/buttons";
import { Text } from "../../../components/text"; import { Text } from "../../../components/text";
import { Theme, fontSize } from "../../../design-system"; import { fontSize } from "../../../design-system";
import { CreatePassword } from "./USER_MANAGED/CreatePassword"; import { CreatePassword } from "./USER_MANAGED/CreatePassword";
import { EnterPasswordOrRecovery } from "./USER_MANAGED/EnterPassword"; import { EnterPasswordOrRecovery } from "./USER_MANAGED/EnterPassword";
import { useTWLocale } from "../../../evm/providers/locale-provider"; import { useTWLocale } from "../../../evm/providers/locale-provider";
import { StyledButton } from "../../../design-system/elements";
import { useCustomTheme } from "../../../design-system/CustomThemeProvider";
type EmbeddedWalletOTPLoginUIProps = ConnectUIProps<EmbeddedWallet>; type EmbeddedWalletOTPLoginUIProps = ConnectUIProps<EmbeddedWallet>;
@@ -28,7 +29,7 @@ export const EmbeddedWalletOTPLoginUI: React.FC<
> = (props) => { > = (props) => {
const email = props.selectionData; const email = props.selectionData;
const isWideModal = props.modalSize === "wide"; const isWideModal = props.modalSize === "wide";
const locale = useTWLocale().wallets.embeddedWallet.emailLoginScreen; const locale = useTWLocale().wallets.embeddedWallet;
const [otpInput, setOtpInput] = useState(""); const [otpInput, setOtpInput] = useState("");
const { createWalletInstance, setConnectedWallet, setConnectionStatus } = const { createWalletInstance, setConnectedWallet, setConnectionStatus } =
@@ -212,7 +213,7 @@ export const EmbeddedWalletOTPLoginUI: React.FC<
return ( return (
<Container fullHeight flex="column" animate="fadein"> <Container fullHeight flex="column" animate="fadein">
<Container p="lg"> <Container p="lg">
<ModalHeader title="Sign in" onBack={props.goBack} /> <ModalHeader title={locale.signIn} onBack={props.goBack} />
</Container> </Container>
<Container expand flex="column" center="y"> <Container expand flex="column" center="y">
@@ -227,7 +228,7 @@ export const EmbeddedWalletOTPLoginUI: React.FC<
}} }}
> >
{!isWideModal && <Spacer y="xl" />} {!isWideModal && <Spacer y="xl" />}
<Text>{locale.enterCodeSendTo}</Text> <Text>{locale.emailLoginScreen.enterCodeSendTo}</Text>
<Spacer y="sm" /> <Spacer y="sm" />
<Text color="primaryText">{email}</Text> <Text color="primaryText">{email}</Text>
<Spacer y="xl" /> <Spacer y="xl" />
@@ -251,7 +252,7 @@ export const EmbeddedWalletOTPLoginUI: React.FC<
<FadeIn> <FadeIn>
<Spacer y="md" /> <Spacer y="md" />
<Text size="sm" color="danger" center> <Text size="sm" color="danger" center>
{locale.invalidCode} {locale.emailLoginScreen.invalidCode}
</Text> </Text>
</FadeIn> </FadeIn>
)} )}
@@ -275,7 +276,7 @@ export const EmbeddedWalletOTPLoginUI: React.FC<
width: "100%", width: "100%",
}} }}
> >
{locale.verify} {locale.emailLoginScreen.verify}
</Button> </Button>
</Container> </Container>
)} )}
@@ -289,7 +290,7 @@ export const EmbeddedWalletOTPLoginUI: React.FC<
{emailStatus === "error" && ( {emailStatus === "error" && (
<> <>
<Text size="sm" center color="danger"> <Text size="sm" center color="danger">
{locale.failedToSendCode} {locale.emailLoginScreen.failedToSendCode}
</Text> </Text>
</> </>
)} )}
@@ -303,14 +304,14 @@ export const EmbeddedWalletOTPLoginUI: React.FC<
textAlign: "center", textAlign: "center",
}} }}
> >
<Text size="sm">{locale.sendingCode}</Text> <Text size="sm">{locale.emailLoginScreen.sendingCode}</Text>
<Spinner size="xs" color="secondaryText" /> <Spinner size="xs" color="secondaryText" />
</Container> </Container>
)} )}
{typeof emailStatus === "object" && ( {typeof emailStatus === "object" && (
<LinkButton onClick={sendEmail} type="button"> <LinkButton onClick={sendEmail} type="button">
{locale.resendCode} {locale.emailLoginScreen.resendCode}
</LinkButton> </LinkButton>
)} )}
</Container> </Container>
@@ -323,15 +324,18 @@ export const EmbeddedWalletOTPLoginUI: React.FC<
return null; return null;
}; };
const LinkButton = styled.button<{ theme?: Theme }>` const LinkButton = /* @__PURE__ */ StyledButton(() => {
all: unset; const theme = useCustomTheme();
color: ${(p) => p.theme.colors.accentText}; return {
font-size: ${fontSize.sm}; all: "unset",
cursor: pointer; color: theme.colors.accentText,
text-align: center; fontSize: fontSize.sm,
font-weight: 500; cursor: "pointer",
width: 100%; textAlign: "center",
&:hover { fontWeight: 500,
color: ${(p) => p.theme.colors.primaryText}; width: "100%",
} "&:hover": {
`; color: theme.colors.primaryText,
},
};
});
@@ -1,4 +1,3 @@
import { useTheme } from "@emotion/react";
import { import {
ConnectUIProps, ConnectUIProps,
useConnectionStatus, useConnectionStatus,
@@ -16,9 +15,9 @@ import { Spinner } from "../../../components/Spinner";
import { Container, ModalHeader } from "../../../components/basic"; import { Container, ModalHeader } from "../../../components/basic";
import { Button } from "../../../components/buttons"; import { Button } from "../../../components/buttons";
import { Text } from "../../../components/text"; import { Text } from "../../../components/text";
import { Theme } from "../../../design-system";
import { useTWLocale } from "../../../evm/providers/locale-provider"; import { useTWLocale } from "../../../evm/providers/locale-provider";
import { openOauthSignInWindow } from "../../utils/openOauthSignInWindow"; import { openOauthSignInWindow } from "../../utils/openOauthSignInWindow";
import { useCustomTheme } from "../../../design-system/CustomThemeProvider";
export const EmbeddedWalletSocialLogin = ( export const EmbeddedWalletSocialLogin = (
props: ConnectUIProps<EmbeddedWallet> & { props: ConnectUIProps<EmbeddedWallet> & {
@@ -31,19 +30,19 @@ export const EmbeddedWalletSocialLogin = (
const setConnectionStatus = useSetConnectionStatus(); const setConnectionStatus = useSetConnectionStatus();
const setConnectedWallet = useSetConnectedWallet(); const setConnectedWallet = useSetConnectedWallet();
const connectionStatus = useConnectionStatus(); const connectionStatus = useConnectionStatus();
const themeObj = useTheme() as Theme; const themeObj = useCustomTheme();
const googleLogin = async () => { const socialLogin = async () => {
try { try {
const embeddedWallet = createWalletInstance(props.walletConfig); const embeddedWallet = createWalletInstance(props.walletConfig);
setConnectionStatus("connecting"); setConnectionStatus("connecting");
const googleWindow = openOauthSignInWindow("google", themeObj); const socialWindow = openOauthSignInWindow(props.strategy, themeObj);
if (!googleWindow) { if (!socialWindow) {
throw new Error("Failed to open google login window"); throw new Error(`Failed to open ${props.strategy} login window`);
} }
const authResult = await embeddedWallet.authenticate({ const authResult = await embeddedWallet.authenticate({
strategy: "google", strategy: props.strategy,
openedWindow: googleWindow, openedWindow: socialWindow,
closeOpenedWindow: (openedWindow) => { closeOpenedWindow: (openedWindow) => {
openedWindow.close(); openedWindow.close();
}, },
@@ -55,7 +54,7 @@ export const EmbeddedWalletSocialLogin = (
props.connected(); props.connected();
} catch (e) { } catch (e) {
setConnectionStatus("disconnected"); setConnectionStatus("disconnected");
console.error("Error logging into google", e); console.error(`Error sign in with ${props.strategy}`, e);
} }
}; };
@@ -94,6 +93,7 @@ export const EmbeddedWalletSocialLogin = (
<Container animate="fadein"> <Container animate="fadein">
<Text <Text
color="primaryText" color="primaryText"
center
multiline multiline
style={{ style={{
maxWidth: "250px", maxWidth: "250px",
@@ -114,7 +114,7 @@ export const EmbeddedWalletSocialLogin = (
<Container animate="fadein"> <Container animate="fadein">
<Text color="danger">{locale.failed}</Text> <Text color="danger">{locale.failed}</Text>
<Spacer y="lg" /> <Spacer y="lg" />
<Button variant="primary" onClick={googleLogin}> <Button variant="primary" onClick={socialLogin}>
{locale.retry} {locale.retry}
</Button> </Button>
<Spacer y="xxl" /> <Spacer y="xxl" />
@@ -5,11 +5,13 @@ import { Spacer } from "../../../../components/Spacer";
import { Spinner } from "../../../../components/Spinner"; import { Spinner } from "../../../../components/Spinner";
import { Container, ModalHeader, Line } from "../../../../components/basic"; import { Container, ModalHeader, Line } from "../../../../components/basic";
import { Button, IconButton } from "../../../../components/buttons"; import { Button, IconButton } from "../../../../components/buttons";
import { spacing, Theme, radius, iconSize } from "../../../../design-system"; import { spacing, radius, iconSize } from "../../../../design-system";
import { Text } from "../../../../components/text"; import { Text } from "../../../../components/text";
import styled from "@emotion/styled"; import styled from "@emotion/styled";
import { useClipboard } from "../../../../evm/components/hooks/useCopyClipboard"; import { useClipboard } from "../../../../evm/components/hooks/useCopyClipboard";
import { CheckIcon, CopyIcon } from "@radix-ui/react-icons"; import { CheckIcon, CopyIcon } from "@radix-ui/react-icons";
import { StyledDiv } from "../../../../design-system/elements";
import { useCustomTheme } from "../../../../design-system/CustomThemeProvider";
// TODO (ews) - this is unused right now, no backup codes are generated // TODO (ews) - this is unused right now, no backup codes are generated
export function BackupAccount(props: { export function BackupAccount(props: {
@@ -214,22 +216,27 @@ function CopyRecoveryCode(props: { code: string }) {
); );
} }
const CopyContainer = styled.div<{ theme?: Theme }>` const CopyContainer = /* @__PURE__ */ StyledDiv(() => {
padding: ${spacing.md}; const theme = useCustomTheme();
border: 1px solid ${(p) => p.theme.colors.borderColor}; return {
border-radius: ${radius.md}; padding: spacing.md,
`; border: `1px solid ${theme.colors.borderColor}`,
borderRadius: radius.md,
};
});
const CheckboxButton = /* @__PURE__ */ styled(IconButton)<{ theme?: Theme }>` const CheckboxButton = /* @__PURE__ */ styled(IconButton)(() => {
border: 2px solid ${(p) => p.theme.colors.accentText}; const theme = useCustomTheme();
color: ${(p) => p.theme.colors.accentText} !important; return {
padding: 0; border: `2px solid ${theme.colors.accentText}`,
color: `${theme.colors.accentText} !important`,
&[aria-checked="true"] { padding: 0,
background: ${(p) => p.theme.colors.accentText}; "&[aria-checked='true']": {
color: ${(p) => p.theme.colors.modalBg} !important; background: theme.colors.accentText,
} color: `${theme.colors.modalBg} !important`,
`; },
};
});
function downloadRecoveryCodes(codes: string, fileName: string) { function downloadRecoveryCodes(codes: string, fileName: string) {
const blob = new Blob([codes], { const blob = new Blob([codes], {
@@ -11,7 +11,7 @@ import {
InputButton, InputButton,
} from "../../../../components/buttons"; } from "../../../../components/buttons";
import { Input, InputContainer } from "../../../../components/formElements"; import { Input, InputContainer } from "../../../../components/formElements";
import { Theme, iconSize } from "../../../../design-system"; import { iconSize } from "../../../../design-system";
import { keyframes } from "@emotion/react"; import { keyframes } from "@emotion/react";
import styled from "@emotion/styled"; import styled from "@emotion/styled";
import { Text } from "../../../../components/text"; import { Text } from "../../../../components/text";
@@ -19,6 +19,8 @@ import { useState } from "react";
import { Spinner } from "../../../../components/Spinner"; import { Spinner } from "../../../../components/Spinner";
import { CheckIcon } from "@radix-ui/react-icons"; import { CheckIcon } from "@radix-ui/react-icons";
import { useTWLocale } from "../../../../evm/providers/locale-provider"; import { useTWLocale } from "../../../../evm/providers/locale-provider";
import { StyledDiv } from "../../../../design-system/elements";
import { useCustomTheme } from "../../../../design-system/CustomThemeProvider";
export function CreatePassword(props: { export function CreatePassword(props: {
goBack: () => void; goBack: () => void;
@@ -173,16 +175,18 @@ export function CreatePassword(props: {
); );
} }
const CheckboxButton = /* @__PURE__ */ styled(IconButton)<{ theme?: Theme }>` const CheckboxButton = /* @__PURE__ */ styled(IconButton)(() => {
border: 2px solid ${(p) => p.theme.colors.accentText}; const theme = useCustomTheme();
color: ${(p) => p.theme.colors.accentText} !important; return {
padding: 0; border: `2px solid ${theme.colors.accentText}`,
color: `${theme.colors.accentText} !important`,
&[aria-checked="true"] { padding: 0,
background: ${(p) => p.theme.colors.accentText}; "&[aria-checked='true']": {
color: ${(p) => p.theme.colors.modalBg} !important; background: theme.colors.accentText,
} color: `${theme.colors.modalBg} !important`,
`; },
};
});
const bounceAnimation = keyframes` const bounceAnimation = keyframes`
from { from {
@@ -193,6 +197,6 @@ to {
} }
`; `;
const BounceContainer = styled.div` const BounceContainer = /* @__PURE__ */ StyledDiv({
animation: ${bounceAnimation} 1s ease-in-out infinite alternate; animation: `${bounceAnimation} 1s ease-in-out infinite alternate`,
`; });
@@ -14,7 +14,7 @@ import {
EmbeddedWalletFormUI, EmbeddedWalletFormUI,
EmbeddedWalletFormUIScreen, EmbeddedWalletFormUIScreen,
} from "./EmbeddedWalletFormUI"; } from "./EmbeddedWalletFormUI";
import { EmbeddedWalletSocialLogin } from "./EmbeddedWalletGoogleLogin"; import { EmbeddedWalletSocialLogin } from "./EmbeddedWalletSocialLogin";
import { EmbeddedWalletOTPLoginUI } from "./EmbeddedWalletOTPLoginUI"; import { EmbeddedWalletOTPLoginUI } from "./EmbeddedWalletOTPLoginUI";
import { import {
AuthOption, AuthOption,
@@ -26,7 +26,7 @@ const DEFAULT_AUTH_OPTIONS: AuthOption[] = [
"email", "email",
"google", "google",
"apple", "apple",
// "facebook", "facebook",
]; ];
export const embeddedWallet = ( export const embeddedWallet = (
@@ -1,11 +1,12 @@
import { EmbeddedWalletOauthStrategy } from "@thirdweb-dev/wallets"; import { EmbeddedWalletOauthStrategy } from "@thirdweb-dev/wallets";
import { import {
appleIconUri, appleIconUri,
facebookIconUri,
googleIconUri, googleIconUri,
} from "../../ConnectWallet/icons/socialLogins"; } from "../../ConnectWallet/icons/socialLogins";
export const socialIcons: Record<EmbeddedWalletOauthStrategy, string> = { export const socialIcons: Record<EmbeddedWalletOauthStrategy, string> = {
google: googleIconUri, google: googleIconUri,
apple: appleIconUri, apple: appleIconUri,
// facebook: facebookIconUri, facebook: facebookIconUri,
}; };
@@ -16,7 +16,7 @@ export type EmbeddedWalletConfig = Omit<
/** /**
* Choose which auth providers to show in the wallet connection UI * Choose which auth providers to show in the wallet connection UI
* @defaultValue `auth: { options: ["email", "google", "apple"] }` * @defaultValue `auth: { options: ["email", "google", "apple", "facebook"] }`
*/ */
auth?: { auth?: {
options: AuthOption[]; options: AuthOption[];
@@ -2,8 +2,7 @@ import { Spacer } from "../../../components/Spacer";
import { Button } from "../../../components/buttons"; import { Button } from "../../../components/buttons";
import { Label } from "../../../components/formElements"; import { Label } from "../../../components/formElements";
import { ModalDescription } from "../../../components/modalElements"; import { ModalDescription } from "../../../components/modalElements";
import { Theme, iconSize, spacing } from "../../../design-system"; import { iconSize, spacing } from "../../../design-system";
import styled from "@emotion/styled";
import { fontSize } from "../../../design-system"; import { fontSize } from "../../../design-system";
import { import {
EyeClosedIcon, EyeClosedIcon,
@@ -29,6 +28,8 @@ import {
} from "@thirdweb-dev/react-core"; } from "@thirdweb-dev/react-core";
import type { LocalWalletConfig } from "./types"; import type { LocalWalletConfig } from "./types";
import { useTWLocale } from "../../../evm/providers/locale-provider"; import { useTWLocale } from "../../../evm/providers/locale-provider";
import { StyledP } from "../../../design-system/elements";
import { useCustomTheme } from "../../../design-system/CustomThemeProvider";
export const ExportLocalWallet: React.FC<{ export const ExportLocalWallet: React.FC<{
onBack?: () => void; onBack?: () => void;
@@ -259,8 +260,11 @@ function downloadJsonWalletFile(data: string) {
URL.revokeObjectURL(a.href); URL.revokeObjectURL(a.href);
} }
const SavedWalletAddress = styled.p<{ theme?: Theme }>` const SavedWalletAddress = /* @__PURE__ */ StyledP(() => {
font-size: ${fontSize.md}; const theme = useCustomTheme();
color: ${(props) => props.theme.colors.secondaryText}; return {
margin: 0; fontSize: fontSize.md,
`; color: theme.colors.secondaryText,
margin: 0,
};
});
@@ -12,7 +12,7 @@ import { Spinner } from "../../../components/Spinner";
import { Container, ModalHeader } from "../../../components/basic"; import { Container, ModalHeader } from "../../../components/basic";
import { InputSelectionUI } from "../InputSelectionUI"; import { InputSelectionUI } from "../InputSelectionUI";
import { Img } from "../../../components/Img"; import { Img } from "../../../components/Img";
import { Theme, fontSize, iconSize, spacing } from "../../../design-system"; import { fontSize, iconSize, spacing } from "../../../design-system";
import { Button, IconButton } from "../../../components/buttons"; import { Button, IconButton } from "../../../components/buttons";
import { ToolTip } from "../../../components/Tooltip"; import { ToolTip } from "../../../components/Tooltip";
import styled from "@emotion/styled"; import styled from "@emotion/styled";
@@ -40,6 +40,7 @@ import {
twitchIconUri, twitchIconUri,
twitterIconUri, twitterIconUri,
} from "../../ConnectWallet/icons/socialLogins"; } from "../../ConnectWallet/icons/socialLogins";
import { useCustomTheme } from "../../../design-system/CustomThemeProvider";
export function magicLink( export function magicLink(
config: MagicLinkAdditionalOptions & { config: MagicLinkAdditionalOptions & {
@@ -507,21 +508,32 @@ function upperCaseFirstLetter(string: string) {
return string.charAt(0).toUpperCase() + string.slice(1); return string.charAt(0).toUpperCase() + string.slice(1);
} }
const SocialButtonLarge = /* @__PURE__ */ styled(Button)<{ theme?: Theme }>` const SocialButtonLarge = /* @__PURE__ */ styled(Button)(() => {
display: flex; const theme = useCustomTheme();
justify-content: flex-start; return {
gap: ${spacing.md}; display: "flex",
font-size: ${fontSize.md}; justifyContent: "flex-start",
transition: background-color 0.2s ease; gap: spacing.md,
&:hover { fontSize: fontSize.md,
background-color: ${(p) => p.theme.colors.secondaryButtonBg}; transition: "background-color 0.2s ease",
} "&:hover": {
&:active { backgroundColor: theme.colors.secondaryButtonBg,
box-shadow: none; },
} "&:active": {
`; boxShadow: "none",
},
};
});
const SocialIconButton = /* @__PURE__ */ styled(IconButton)<{ theme?: Theme }>` const SocialIconButton = /* @__PURE__ */ styled(IconButton)(() => {
border: 1px solid ${(p) => p.theme.colors.borderColor}; const theme = useCustomTheme();
padding: ${spacing.xs}; return {
`; border: `1px solid ${theme.colors.borderColor}`,
padding: spacing.sm,
transition: "border-color 0.2s ease",
"&:hover": {
borderColor: theme.colors.accentText,
background: "transparent",
},
};
});
@@ -1,4 +1,3 @@
import { useTheme } from "@emotion/react";
import styled from "@emotion/styled"; import styled from "@emotion/styled";
import { import {
WalletConfig, WalletConfig,
@@ -11,13 +10,14 @@ import { Spacer } from "../../../components/Spacer";
import { TextDivider } from "../../../components/TextDivider"; import { TextDivider } from "../../../components/TextDivider";
import { Container, ModalHeader } from "../../../components/basic"; import { Container, ModalHeader } from "../../../components/basic";
import { Button } from "../../../components/buttons"; import { Button } from "../../../components/buttons";
import { Theme, iconSize, spacing } from "../../../design-system"; import { iconSize, spacing } from "../../../design-system";
import { useTWLocale } from "../../../evm/providers/locale-provider"; import { useTWLocale } from "../../../evm/providers/locale-provider";
import { openOauthSignInWindow } from "../../utils/openOauthSignInWindow"; import { openOauthSignInWindow } from "../../utils/openOauthSignInWindow";
import { InputSelectionUI } from "../InputSelectionUI"; import { InputSelectionUI } from "../InputSelectionUI";
import { PaperLoginType } from "./types"; import { PaperLoginType } from "./types";
import { Img } from "../../../components/Img"; import { Img } from "../../../components/Img";
import { googleIconUri } from "../../ConnectWallet/icons/socialLogins"; import { googleIconUri } from "../../ConnectWallet/icons/socialLogins";
import { useCustomTheme } from "../../../design-system/CustomThemeProvider";
export const PaperFormUI = (props: { export const PaperFormUI = (props: {
onSelect: (loginType: PaperLoginType) => void; onSelect: (loginType: PaperLoginType) => void;
@@ -29,7 +29,7 @@ export const PaperFormUI = (props: {
const createWalletInstance = useCreateWalletInstance(); const createWalletInstance = useCreateWalletInstance();
const setConnectionStatus = useSetConnectionStatus(); const setConnectionStatus = useSetConnectionStatus();
const setConnectedWallet = useSetConnectedWallet(); const setConnectedWallet = useSetConnectedWallet();
const themeObj = useTheme() as Theme; const themeObj = useCustomTheme();
// Need to trigger google login on button click to avoid popup from being blocked // Need to trigger google login on button click to avoid popup from being blocked
const googleLogin = async () => { const googleLogin = async () => {
@@ -133,8 +133,8 @@ export const PaperFormUIScreen: React.FC<{
); );
}; };
const SocialButton = /* @__PURE__ */ styled(Button)<{ theme?: Theme }>` const SocialButton = /* @__PURE__ */ styled(Button)({
display: flex; display: "flex",
justify-content: center; justifyContent: "center",
gap: ${spacing.sm}; gap: spacing.sm,
`; });
@@ -1,4 +1,3 @@
import { useTheme } from "@emotion/react";
import { import {
ConnectUIProps, ConnectUIProps,
useConnectionStatus, useConnectionStatus,
@@ -14,11 +13,12 @@ import { Container, ModalHeader } from "../../../components/basic";
import { Button } from "../../../components/buttons"; import { Button } from "../../../components/buttons";
import { ModalTitle } from "../../../components/modalElements"; import { ModalTitle } from "../../../components/modalElements";
import { Text } from "../../../components/text"; import { Text } from "../../../components/text";
import { Theme, iconSize } from "../../../design-system"; import { iconSize } from "../../../design-system";
import { useTWLocale } from "../../../evm/providers/locale-provider"; import { useTWLocale } from "../../../evm/providers/locale-provider";
import { openOauthSignInWindow } from "../../utils/openOauthSignInWindow"; import { openOauthSignInWindow } from "../../utils/openOauthSignInWindow";
import { Img } from "../../../components/Img"; import { Img } from "../../../components/Img";
import { googleIconUri } from "../../ConnectWallet/icons/socialLogins"; import { googleIconUri } from "../../ConnectWallet/icons/socialLogins";
import { useCustomTheme } from "../../../design-system/CustomThemeProvider";
export const PaperGoogleLogin = (props: ConnectUIProps<PaperWallet>) => { export const PaperGoogleLogin = (props: ConnectUIProps<PaperWallet>) => {
const { goBack, modalSize, connected } = props; const { goBack, modalSize, connected } = props;
@@ -28,7 +28,7 @@ export const PaperGoogleLogin = (props: ConnectUIProps<PaperWallet>) => {
const setConnectionStatus = useSetConnectionStatus(); const setConnectionStatus = useSetConnectionStatus();
const setConnectedWallet = useSetConnectedWallet(); const setConnectedWallet = useSetConnectedWallet();
const connectionStatus = useConnectionStatus(); const connectionStatus = useConnectionStatus();
const themeObj = useTheme() as Theme; const themeObj = useCustomTheme();
// Need to trigger google login on button click to avoid popup from being blocked // Need to trigger google login on button click to avoid popup from being blocked
const googleLogin = async () => { const googleLogin = async () => {
@@ -1,4 +1,3 @@
import styled from "@emotion/styled";
import { ConnectUIProps, useWalletContext } from "@thirdweb-dev/react-core"; import { ConnectUIProps, useWalletContext } from "@thirdweb-dev/react-core";
import { PaperWallet } from "@thirdweb-dev/wallets"; import { PaperWallet } from "@thirdweb-dev/wallets";
import { useCallback, useEffect, useRef, useState } from "react"; import { useCallback, useEffect, useRef, useState } from "react";
@@ -9,9 +8,11 @@ import { Container, Line, ModalHeader } from "../../../components/basic";
import { Button } from "../../../components/buttons"; import { Button } from "../../../components/buttons";
import { Input } from "../../../components/formElements"; import { Input } from "../../../components/formElements";
import { Text } from "../../../components/text"; import { Text } from "../../../components/text";
import { Theme, fontSize } from "../../../design-system"; import { fontSize } from "../../../design-system";
import { RecoveryShareManagement } from "./types"; import { RecoveryShareManagement } from "./types";
import { useTWLocale } from "../../../evm/providers/locale-provider"; import { useTWLocale } from "../../../evm/providers/locale-provider";
import { StyledButton } from "../../../design-system/elements";
import { useCustomTheme } from "../../../design-system/CustomThemeProvider";
type PaperOTPLoginUIProps = ConnectUIProps<PaperWallet> & { type PaperOTPLoginUIProps = ConnectUIProps<PaperWallet> & {
recoveryShareManagement: RecoveryShareManagement; recoveryShareManagement: RecoveryShareManagement;
@@ -273,14 +274,17 @@ export const PaperOTPLoginUI: React.FC<PaperOTPLoginUIProps> = (props) => {
); );
}; };
const LinkButton = styled.button<{ theme?: Theme }>` const LinkButton = /* @__PURE__ */ StyledButton(() => {
all: unset; const theme = useCustomTheme();
color: ${(p) => p.theme.colors.accentText}; return {
font-size: ${fontSize.sm}; all: "unset",
cursor: pointer; color: theme.colors.accentText,
text-align: center; fontSize: fontSize.sm,
width: 100%; cursor: "pointer",
&:hover { textAlign: "center",
color: ${(p) => p.theme.colors.primaryText}; width: "100%",
} "&:hover": {
`; color: theme.colors.primaryText,
},
};
});
@@ -4,7 +4,7 @@ import { Button } from "../../../components/buttons";
import { Label } from "../../../components/formElements"; import { Label } from "../../../components/formElements";
import { FormField } from "../../../components/formFields"; import { FormField } from "../../../components/formFields";
import { ModalDescription } from "../../../components/modalElements"; import { ModalDescription } from "../../../components/modalElements";
import { iconSize, spacing, Theme, fontSize } from "../../../design-system"; import { iconSize, spacing, fontSize } from "../../../design-system";
import styled from "@emotion/styled"; import styled from "@emotion/styled";
import { import {
ChevronDownIcon, ChevronDownIcon,
@@ -28,6 +28,8 @@ import { Link, Text } from "../../../components/text";
import { ModalConfigCtx } from "../../../evm/providers/wallet-ui-states-provider"; import { ModalConfigCtx } from "../../../evm/providers/wallet-ui-states-provider";
import { safeSlugToChainId } from "./safeChainSlug"; import { safeSlugToChainId } from "./safeChainSlug";
import { useTWLocale } from "../../../evm/providers/locale-provider"; import { useTWLocale } from "../../../evm/providers/locale-provider";
import { StyledSelect } from "../../../design-system/elements";
import { useCustomTheme } from "../../../design-system/CustomThemeProvider";
export const SelectAccount: React.FC<{ export const SelectAccount: React.FC<{
onBack: () => void; onBack: () => void;
@@ -373,38 +375,39 @@ export const SelectAccount: React.FC<{
); );
}; };
const NetworkSelect = styled.select<{ theme?: Theme }>` const NetworkSelect = /* @__PURE__ */ StyledSelect(() => {
width: 100%; const theme = useCustomTheme();
padding: ${spacing.sm}; return {
box-sizing: border-box; width: "100%",
outline: none; padding: spacing.sm,
border: none; boxSizing: "border-box",
border-radius: 6px; outline: "none",
color: ${(p) => p.theme.colors.primaryText}; border: "none",
background: none; borderRadius: "6px",
font-size: ${fontSize.md}; color: theme.colors.primaryText,
box-shadow: 0 0 0 1.5px ${(p) => p.theme.colors.secondaryButtonBg}; background: "none",
appearance: none; fontSize: fontSize.md,
boxShadow: `0 0 0 1.5px ${theme.colors.secondaryButtonBg}`,
appearance: "none",
"&:focus": {
boxShadow: `0 0 0 2px ${theme.colors.accentText}`,
},
"&:invalid": {
color: theme.colors.secondaryText,
},
"&[data-error='true']": {
boxShadow: `0 0 0 1.5px ${theme.colors.danger}`,
},
"&[disabled]": {
opacity: 1,
cursor: "not-allowed",
},
};
});
&:focus { const StyledChevronDownIcon = /* @__PURE__ */ styled(ChevronDownIcon)(() => {
box-shadow: 0 0 0 2px ${(p) => p.theme.colors.accentText}; const theme = useCustomTheme();
} return {
color: theme.colors.secondaryText,
&:invalid { };
color: ${(p) => p.theme.colors.secondaryText}; });
}
&[data-error="true"] {
box-shadow: 0 0 0 1.5px ${(p) => p.theme.colors.danger};
}
&[disabled] {
opacity: 1;
cursor: not-allowed;
}
`;
const StyledChevronDownIcon = /* @__PURE__ */ styled(ChevronDownIcon)<{
theme?: Theme;
}>`
color: ${(p) => p.theme.colors.secondaryText};
`;
+16
View File
@@ -1,5 +1,21 @@
# @thirdweb-dev/unity-js-bridge # @thirdweb-dev/unity-js-bridge
## 0.2.102
### Patch Changes
- Updated dependencies [[`69d68f5a`](https://github.com/thirdweb-dev/js/commit/69d68f5a25877bf5ea694719d2cf4ca8388f3091)]:
- @thirdweb-dev/wallets@2.1.5
- @thirdweb-dev/auth@4.1.8
## 0.2.101
### Patch Changes
- Updated dependencies [[`9f993dcc`](https://github.com/thirdweb-dev/js/commit/9f993dcc1e60cc087850b8fb9ce09524073ce0b5)]:
- @thirdweb-dev/wallets@2.1.4
- @thirdweb-dev/auth@4.1.7
## 0.2.100 ## 0.2.100
### Patch Changes ### Patch Changes
+1 -1
View File
@@ -1,6 +1,6 @@
{ {
"name": "@thirdweb-dev/unity-js-bridge", "name": "@thirdweb-dev/unity-js-bridge",
"version": "0.2.100", "version": "0.2.102",
"main": "dist/thirdweb-unity-bridge.js", "main": "dist/thirdweb-unity-bridge.js",
"repository": "https://github.com/thirdweb-dev/js/tree/main/packages/unity-js-bridge", "repository": "https://github.com/thirdweb-dev/js/tree/main/packages/unity-js-bridge",
"license": "Apache-2.0", "license": "Apache-2.0",
+12
View File
@@ -1,5 +1,17 @@
# @thirdweb-dev/wallets # @thirdweb-dev/wallets
## 2.1.5
### Patch Changes
- [#1945](https://github.com/thirdweb-dev/js/pull/1945) [`69d68f5a`](https://github.com/thirdweb-dev/js/commit/69d68f5a25877bf5ea694719d2cf4ca8388f3091) Thanks [@iketw](https://github.com/iketw)! - Enable Facebook Sign In for embedded wallet
## 2.1.4
### Patch Changes
- [#1958](https://github.com/thirdweb-dev/js/pull/1958) [`9f993dcc`](https://github.com/thirdweb-dev/js/commit/9f993dcc1e60cc087850b8fb9ce09524073ce0b5) Thanks [@joaquim-verges](https://github.com/joaquim-verges)! - Fix switch chain logic for embedded wallets
## 2.1.3 ## 2.1.3
### Patch Changes ### Patch Changes
+1 -1
View File
@@ -1,6 +1,6 @@
{ {
"name": "@thirdweb-dev/wallets", "name": "@thirdweb-dev/wallets",
"version": "2.1.3", "version": "2.1.5",
"main": "dist/thirdweb-dev-wallets.cjs.js", "main": "dist/thirdweb-dev-wallets.cjs.js",
"module": "dist/thirdweb-dev-wallets.esm.js", "module": "dist/thirdweb-dev-wallets.esm.js",
"types": "dist/thirdweb-dev-wallets.cjs.d.ts", "types": "dist/thirdweb-dev-wallets.cjs.d.ts",
@@ -138,11 +138,7 @@ export class EmbeddedWalletConnector extends Connector<EmbeddedWalletConnectionA
throw new Error("Chain not configured"); throw new Error("Chain not configured");
} }
if ( try {
!this.user ||
!this.user.wallet ||
typeof this.user.wallet.getEthersJsSigner !== "function"
) {
// update chain in wallet // update chain in wallet
await this.user?.wallet.setChain({ chain: "Ethereum" }); // just pass Ethereum no matter what chain we are going to connect await this.user?.wallet.setChain({ chain: "Ethereum" }); // just pass Ethereum no matter what chain we are going to connect
// update signer // update signer
@@ -150,6 +146,8 @@ export class EmbeddedWalletConnector extends Connector<EmbeddedWalletConnectionA
rpcEndpoint: chain.rpc[0] || "", rpcEndpoint: chain.rpc[0] || "",
}); });
this.emit("change", { chain: { id: chainId, unsupported: false } }); this.emit("change", { chain: { id: chainId, unsupported: false } });
} catch (e) {
console.warn("Failed to switch chain", e);
} }
} }
@@ -239,7 +237,7 @@ export class EmbeddedWalletConnector extends Connector<EmbeddedWalletConnectionA
}); });
} }
case "apple": case "apple":
// case "facebook": case "facebook":
case "google": { case "google": {
const oauthProvider = oauthStrategyToAuthProvider[strategy]; const oauthProvider = oauthStrategyToAuthProvider[strategy];
return ewSDK.auth.loginWithOauth({ return ewSDK.auth.loginWithOauth({
@@ -278,6 +276,6 @@ const oauthStrategyToAuthProvider: Record<
AuthProvider AuthProvider
> = { > = {
google: AuthProvider.GOOGLE, google: AuthProvider.GOOGLE,
// facebook: AuthProvider.FACEBOOK, facebook: AuthProvider.FACEBOOK,
apple: AuthProvider.APPLE, apple: AuthProvider.APPLE,
}; };
@@ -26,7 +26,7 @@ type EmailVerificationAuthParams = {
recoveryCode?: string; recoveryCode?: string;
}; };
export type EmbeddedWalletOauthStrategy = "google" | "apple"; // | "facebook" export type EmbeddedWalletOauthStrategy = "google" | "apple" | "facebook";
type OauthAuthParams = { type OauthAuthParams = {
strategy: EmbeddedWalletOauthStrategy; strategy: EmbeddedWalletOauthStrategy;
+1
View File
@@ -41,6 +41,7 @@ export abstract class AbstractClientWallet<
protected options?: WalletOptions<TAdditionalOpts>; protected options?: WalletOptions<TAdditionalOpts>;
static meta: WalletMeta; static meta: WalletMeta;
#connectParams: ConnectParams<TConnectParams> | undefined; #connectParams: ConnectParams<TConnectParams> | undefined;
getMeta() { getMeta() {
return (this.constructor as typeof AbstractClientWallet).meta; return (this.constructor as typeof AbstractClientWallet).meta;
} }
@@ -146,6 +146,30 @@ export class EmbeddedWallet extends AbstractClientWallet<
async authenticate(params: AuthParams) { async authenticate(params: AuthParams) {
const connector = (await this.getConnector()) as EmbeddedWalletConnector; const connector = (await this.getConnector()) as EmbeddedWalletConnector;
return connector.authenticate(params);
const authResult = connector.authenticate(params);
try {
await this.walletStorage.setItem(
LAST_USED_AUTH_STRATEGY,
params.strategy,
);
} catch {
// noop
}
return authResult;
}
async getLastUsedAuthStrategy(): Promise<AuthParams["strategy"] | null> {
try {
return (await this.walletStorage.getItem(LAST_USED_AUTH_STRATEGY)) as
| AuthParams["strategy"]
| null;
} catch {
return null;
}
} }
} }
const LAST_USED_AUTH_STRATEGY = "lastUsedAuthStrategy";