File tree Expand file tree Collapse file tree 5 files changed +31
-12
lines changed
packages/thirdweb/src/react/web/ui/Bridge/common Expand file tree Collapse file tree 5 files changed +31
-12
lines changed Original file line number Diff line number Diff line change 1+ ---
2+ " thirdweb " : patch
3+ ---
4+
5+ Handle non urls for metadata images in payment widgets
Original file line number Diff line number Diff line change @@ -277,7 +277,7 @@ export function LeftSection(props: {
277277 < div className = "grid grid-cols-1 gap-6 md:grid-cols-2 md:gap-4" >
278278 { /* Modal title */ }
279279 < div className = "flex flex-col gap-2" >
280- < Label htmlFor = { modalTitleId } > Title </ Label >
280+ < Label htmlFor = { modalTitleId } > Name </ Label >
281281 < Input
282282 className = "bg-card"
283283 id = { modalTitleId }
@@ -318,7 +318,7 @@ export function LeftSection(props: {
318318
319319 { /* Modal description */ }
320320 < div className = "flex flex-col gap-2" >
321- < Label htmlFor = { modalDescriptionId } > Image </ Label >
321+ < Label htmlFor = { modalDescriptionId } > Description </ Label >
322322 < Input
323323 className = "bg-card"
324324 id = { modalDescriptionId }
Original file line number Diff line number Diff line change @@ -71,14 +71,10 @@ export function RightSection(props: {
7171 amount = { props . options . payOptions . buyTokenAmount }
7272 chain = { props . options . payOptions . buyTokenChain }
7373 client = { THIRDWEB_CLIENT }
74- name = { props . options . payOptions . title }
74+ name = { props . options . payOptions . title || "Your Product Name" }
75+ description = { props . options . payOptions . description || "Your Product Description" }
76+ image = { props . options . payOptions . image || getDefaultImage ( props . options . theme . type ) }
7577 presetOptions = { [ 1 , 2 , 3 ] }
76- purchaseData = { {
77- description : "Size L | Ships worldwide." ,
78- image :
79- "https://placehold.co/600x400/1d1d23/7c7a85?text=Your%20Product%20Here&font=roboto" ,
80- name : "Black Hoodie" ,
81- } }
8278 seller = { props . options . payOptions . sellerAddress }
8379 theme = { themeObj }
8480 tokenAddress = { props . options . payOptions . buyTokenAddress }
@@ -181,3 +177,10 @@ function TabButtons(props: {
181177 </ div >
182178 ) ;
183179}
180+
181+
182+ function getDefaultImage ( theme : "dark" | "light" ) {
183+ return theme === "dark"
184+ ? "https://placehold.co/600x400/1d1d23/7c7a85?text=Your%20Product%20Here&font=roboto"
185+ : "https://placehold.co/600x400/f2eff3/6f6d78?text=Your%20Product%20Here&font=roboto" ;
186+ }
Original file line number Diff line number Diff line change @@ -11,6 +11,7 @@ export function BuyMerchPreview() {
1111 chain = { base }
1212 client = { THIRDWEB_CLIENT }
1313 description = "Size L | Ships worldwide."
14+ image = "/drip-hoodie.png"
1415 feePayer = "seller"
1516 name = "Black Hoodie"
1617 seller = "0xEb0effdFB4dC5b3d5d3aC6ce29F3ED213E95d675"
Original file line number Diff line number Diff line change @@ -27,10 +27,10 @@ export function WithHeader({
2727 style = { {
2828 aspectRatio : "16/9" ,
2929 backgroundColor : theme . colors . tertiaryBg ,
30- backgroundImage : `url(${ resolveScheme ( {
30+ backgroundImage : `url(${ getUrl (
3131 client ,
32- uri : uiOptions . metadata . image ,
33- } ) } )`,
32+ uiOptions . metadata . image ,
33+ ) } )`,
3434 backgroundPosition : "center" ,
3535 backgroundSize : "cover" ,
3636 borderRadius : `${ radius . md } ${ radius . md } 0 0` ,
@@ -63,3 +63,13 @@ export function WithHeader({
6363 </ Container >
6464 ) ;
6565}
66+
67+ function getUrl ( client : ThirdwebClient , uri : string ) {
68+ if ( ! uri . startsWith ( "ipfs://" ) ) {
69+ return uri ;
70+ }
71+ return resolveScheme ( {
72+ client,
73+ uri,
74+ } ) ;
75+ }
You can’t perform that action at this time.
0 commit comments