33import { type UseQueryOptions , useQuery } from "@tanstack/react-query" ;
44import type { JSX } from "react" ;
55import { getWalletInfo } from "../../../../../wallets/__generated__/getWalletInfo.js" ;
6+ import type { AuthOption } from "../../../../../wallets/types.js" ;
67import type { WalletId } from "../../../../../wallets/wallet-types.js" ;
8+ import { getSocialIcon } from "../../../../core/utils/walletIcon.js" ;
79import { useWalletContext } from "./provider.js" ;
810
911export interface WalletIconProps
@@ -20,11 +22,11 @@ export interface WalletIconProps
2022 */
2123 loadingComponent ?: JSX . Element ;
2224 /**
23- * This component will be shown if the icon fails to be retreived
25+ * This component will be shown if the icon fails to be retrieved
2426 * If not passed, the component will return `null`.
2527 *
2628 * You can/should pass a descriptive text/component to this prop, indicating that the
27- * icon was not fetched succesfully
29+ * icon was not fetched successfully
2830 * @example
2931 * ```tsx
3032 * <WalletIcon fallbackComponent={<span>Failed to load</span>}
@@ -115,6 +117,35 @@ function useWalletIcon(props: {
115117export async function fetchWalletImage ( props : {
116118 id : WalletId ;
117119} ) {
118- const image_src = await getWalletInfo ( props . id , true ) ;
119- return image_src ;
120+ return getWalletInfo ( props . id , true ) ;
121+ }
122+
123+ interface SocialIconProps
124+ extends Omit < React . ImgHTMLAttributes < HTMLImageElement > , "src" > {
125+ provider : AuthOption | string ;
126+ }
127+
128+ /**
129+ * Social auth provider icon
130+ * @returns an <img /> component with the src set to the svg
131+ *
132+ * @example
133+ * ```tsx
134+ * import { SocialIcon } from "thirdweb/react";
135+ *
136+ * <SocialIcon provider="google" />
137+ * ```
138+ *
139+ * Result: An <img /> component with the src of the icon
140+ * ```html
141+ * <img src="google-icon-svg" />
142+ * ```
143+ *
144+ * @component
145+ * @wallet
146+ * @beta
147+ */
148+ export function SocialIcon ( { provider, ...restProps } : SocialIconProps ) {
149+ const src = getSocialIcon ( provider ) ;
150+ return < img src = { src } { ...restProps } alt = { restProps . alt } /> ;
120151}
0 commit comments