@@ -2,7 +2,12 @@ import {
2
2
SetModalConfigCtx ,
3
3
WalletUIStatesProvider ,
4
4
} from "../../../providers/wallet-ui-states-provider.js" ;
5
- import { modalMaxWidthCompact , defaultTheme } from "../constants.js" ;
5
+ import {
6
+ modalMaxWidthCompact ,
7
+ defaultTheme ,
8
+ modalMaxWidthWide ,
9
+ wideModalMaxHeight ,
10
+ } from "../constants.js" ;
6
11
import { useSetupScreen } from "./screen.js" ;
7
12
import { type ComponentProps , useContext , useEffect , useState } from "react" ;
8
13
import { radius , type Theme } from "../../design-system/index.js" ;
@@ -300,6 +305,15 @@ export type ConnectEmbedProps = {
300
305
* You can disable this button by setting `showAllWallets` prop to `false`
301
306
*/
302
307
showAllWallets ?: boolean ;
308
+
309
+ /**
310
+ * ConnectEmbed supports two modal size variants: `compact` and `wide`.
311
+ *
312
+ * By default it is set to `compact`, you can set it to `wide` if you want to show a wider modal.
313
+ *
314
+ * Note that if the screen width can not fit the wide modal, the `compact` version will be shown regardless of this `modalSize` options provided
315
+ */
316
+ modalSize ?: "compact" | "wide" ;
303
317
} ;
304
318
305
319
/**
@@ -338,9 +352,13 @@ export function ConnectEmbed(props: ConnectEmbedProps) {
338
352
339
353
const contextTheme = useCustomTheme ( ) ;
340
354
355
+ const modalSize = ! canFitWideModal ( )
356
+ ? "compact"
357
+ : props . modalSize || ( "compact" as const ) ;
358
+
341
359
const walletUIStatesProps = {
342
360
theme : props . theme || contextTheme || defaultTheme ,
343
- modalSize : "compact" as const ,
361
+ modalSize : modalSize ,
344
362
title : undefined ,
345
363
termsOfServiceUrl : props . termsOfServiceUrl ,
346
364
privacyPolicyUrl : props . privacyPolicyUrl ,
@@ -368,7 +386,9 @@ export function ConnectEmbed(props: ConnectEmbedProps) {
368
386
return (
369
387
< >
370
388
{ autoConnectComp }
371
- < LoadingScreen /> ;
389
+ < EmbedContainer modalSize = { modalSize } >
390
+ < LoadingScreen />
391
+ </ EmbedContainer >
372
392
</ >
373
393
) ;
374
394
}
@@ -419,6 +439,10 @@ const ConnectEmbedContent = (
419
439
420
440
let content = null ;
421
441
442
+ const modalSize = ! canFitWideModal ( )
443
+ ? "compact"
444
+ : props . modalSize || ( "compact" as const ) ;
445
+
422
446
// show spinner on page load and during auto connecting a wallet
423
447
if ( isAutoConnecting ) {
424
448
content = < LoadingScreen /> ;
@@ -439,14 +463,15 @@ const ConnectEmbedContent = (
439
463
440
464
return (
441
465
< EmbedContainer
466
+ modalSize = { modalSize }
442
467
className = { props . className }
443
- style = { {
444
- height : "auto" ,
445
- maxWidth : modalMaxWidthCompact ,
446
- ...props . style ,
447
- } }
468
+ style = { props . style }
448
469
>
449
- < DynamicHeight > { content } </ DynamicHeight >
470
+ { modalSize === "wide" ? (
471
+ content
472
+ ) : (
473
+ < DynamicHeight > { content } </ DynamicHeight >
474
+ ) }
450
475
</ EmbedContainer >
451
476
) ;
452
477
} ;
@@ -489,22 +514,29 @@ export function SyncedWalletUIStates(
489
514
return < WalletUIStatesProvider { ...props } /> ;
490
515
}
491
516
492
- const EmbedContainer = /* @__PURE__ */ StyledDiv ( ( ) => {
493
- const theme = useCustomTheme ( ) ;
494
- return {
495
- color : theme . colors . primaryText ,
496
- background : theme . colors . modalBg ,
497
- width : "100%" ,
498
- boxSizing : "border-box" ,
499
- position : "relative" ,
500
- lineHeight : "normal" ,
501
- borderRadius : radius . xl ,
502
- border : `1px solid ${ theme . colors . borderColor } ` ,
503
- overflow : "hidden" ,
504
- fontFamily : theme . fontFamily ,
505
- "& *::selection" : {
506
- backgroundColor : theme . colors . primaryText ,
507
- color : theme . colors . modalBg ,
508
- } ,
509
- } ;
510
- } ) ;
517
+ const EmbedContainer = /* @__PURE__ */ StyledDiv (
518
+ ( props : { modalSize : "compact" | "wide" } ) => {
519
+ const { modalSize } = props ;
520
+ const theme = useCustomTheme ( ) ;
521
+ return {
522
+ color : theme . colors . primaryText ,
523
+ background : theme . colors . modalBg ,
524
+ height : modalSize === "compact" ? "auto" : wideModalMaxHeight ,
525
+ width : modalSize === "compact" ? modalMaxWidthCompact : modalMaxWidthWide ,
526
+ boxSizing : "border-box" ,
527
+ position : "relative" ,
528
+ lineHeight : "normal" ,
529
+ borderRadius : radius . xl ,
530
+ border : `1px solid ${ theme . colors . borderColor } ` ,
531
+ overflow : "hidden" ,
532
+ fontFamily : theme . fontFamily ,
533
+ "& *::selection" : {
534
+ backgroundColor : theme . colors . primaryText ,
535
+ color : theme . colors . modalBg ,
536
+ } ,
537
+ "& *" : {
538
+ boxSizing : "border-box" ,
539
+ } ,
540
+ } ;
541
+ } ,
542
+ ) ;
0 commit comments