Skip to content

Commit cf9826b

Browse files
committed
feat: got the connector color for loader
1 parent 3aa18f7 commit cf9826b

File tree

3 files changed

+39
-14
lines changed

3 files changed

+39
-14
lines changed

packages/modal/src/ui/components/Loader/Loader.tsx

Lines changed: 35 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -90,28 +90,37 @@ function ErroredStatus(props: ErroredStatusType) {
9090
}
9191

9292
function AuthorizingStatus(props: AuthorizingStatusType) {
93-
// const [t] = useTranslation(undefined, { i18n });
94-
const { connector, externalWalletsConfig } = props;
93+
const [t] = useTranslation(undefined, { i18n });
94+
const { connector, externalWalletsConfig, walletRegistry } = props;
9595

9696
// eslint-disable-next-line no-console
9797
console.log("externalWalletsConfig", externalWalletsConfig);
9898

99+
const registryItem = walletRegistry?.default?.[connector] || walletRegistry?.others?.[connector];
100+
const primaryColor = registryItem?.primaryColor || "";
101+
102+
// eslint-disable-next-line no-console
103+
console.log("registryItem", registryItem);
104+
99105
return (
100106
<div className="w3a--flex w3a--size-full w3a--flex-col w3a--items-center w3a--justify-between w3a--gap-y-6">
101107
<p className="w3a--p-2 w3a--text-center w3a--text-base w3a--font-semibold w3a--text-app-gray-900 dark:w3a--text-app-white">
102-
Verify on {externalWalletsConfig[connector].label}
108+
{t("modal.loader.authorizing-header", { connector: externalWalletsConfig[connector].label })}
103109
</p>
104110
<div className="w3a--flex w3a--justify-center">
105-
<CircularLoader width={95} height={95} thickness={6} arcSizeDeg={100}>
111+
<CircularLoader width={95} height={95} thickness={6} arcSizeDeg={100} arcColors={primaryColor ? [primaryColor, primaryColor] : undefined}>
106112
<Image imageId={`login-${connector}`} hoverImageId={`login-${connector}`} height="45" width="45" />
107113
</CircularLoader>
108114
</div>
109-
<p className="w3a--text-center w3a--text-sm w3a--text-app-gray-500 dark:w3a--text-app-gray-400">
110-
We’ve sent a request to your wallet. Verify on your wallet to confirm that you own this wallet.
111-
</p>
112-
<button className="w3a--w-full w3a--rounded-xl w3a--bg-app-gray-100 w3a--p-2 w3a--py-3 w3a--text-sm w3a--text-app-gray-900 dark:w3a--bg-app-gray-800 dark:w3a--text-app-white md:w3a--hidden">
113-
Click here to verify
114-
</button>
115+
<p className="w3a--text-center w3a--text-sm w3a--text-app-gray-500 dark:w3a--text-app-gray-400">{t("modal.loader.authorizing-message")}</p>
116+
<a
117+
href={"https://www.google.com"}
118+
target="_blank"
119+
rel="noopener noreferrer"
120+
className="w3a--w-full w3a--rounded-xl w3a--bg-app-gray-100 w3a--p-2 w3a--py-3 w3a--text-center w3a--text-sm w3a--text-app-gray-900 dark:w3a--bg-app-gray-800 dark:w3a--text-app-white md:w3a--hidden"
121+
>
122+
{t("modal.loader.authorizing-verify-btn")}
123+
</a>
115124
</div>
116125
);
117126
}
@@ -122,7 +131,19 @@ function AuthorizingStatus(props: AuthorizingStatusType) {
122131
* @returns Loader component
123132
*/
124133
function Loader(props: LoaderProps) {
125-
const { connector, connectorName, modalStatus, onClose, appLogo, message, isConnectAndSignAuthenticationMode, externalWalletsConfig } = props;
134+
const {
135+
connector,
136+
connectorName,
137+
modalStatus,
138+
onClose,
139+
appLogo,
140+
message,
141+
isConnectAndSignAuthenticationMode,
142+
externalWalletsConfig,
143+
walletRegistry,
144+
walletConnectUri,
145+
metamaskConnectUri,
146+
} = props;
126147

127148
// eslint-disable-next-line no-console
128149
console.log("connectorName", connectorName);
@@ -148,7 +169,9 @@ function Loader(props: LoaderProps) {
148169

149170
{modalStatus === MODAL_STATUS.ERRORED && <ErroredStatus message={message} />}
150171

151-
{modalStatus === MODAL_STATUS.AUTHORIZING && <AuthorizingStatus connector={connector} externalWalletsConfig={externalWalletsConfig} />}
172+
{modalStatus === MODAL_STATUS.AUTHORIZING && (
173+
<AuthorizingStatus connector={connector} externalWalletsConfig={externalWalletsConfig} walletRegistry={walletRegistry} />
174+
)}
152175
</div>
153176
);
154177
}

packages/modal/src/ui/components/Loader/Loader.type.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
1-
import { BaseConnectorConfig } from "@web3auth/no-modal";
1+
import { BaseConnectorConfig, WalletRegistry } from "@web3auth/no-modal";
22

33
import type { ModalStatusType } from "../../interfaces";
44

55
export interface LoaderProps {
66
externalWalletsConfig: Record<string, BaseConnectorConfig>;
7+
walletRegistry?: WalletRegistry;
78
message?: string;
89
appLogo?: string;
910
connector: string;
@@ -19,4 +20,4 @@ export type ConnectedStatusType = Pick<LoaderProps, "message">;
1920

2021
export type ErroredStatusType = Pick<LoaderProps, "message">;
2122

22-
export type AuthorizingStatusType = Pick<LoaderProps, "connector" | "externalWalletsConfig">;
23+
export type AuthorizingStatusType = Pick<LoaderProps, "connector" | "externalWalletsConfig" | "walletRegistry">;

packages/modal/src/ui/components/Root/Root.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -443,6 +443,7 @@ function Root(props: RootProps) {
443443
appLogo={appLogo}
444444
isConnectAndSignAuthenticationMode={isConnectAndSignAuthenticationMode}
445445
externalWalletsConfig={modalState.externalWalletsConfig}
446+
walletRegistry={walletRegistry}
446447
/>
447448
) : (
448449
<>

0 commit comments

Comments
 (0)