@@ -135,6 +135,27 @@ export const ConnectWalletSocialOptions = (
135135 const isEmailEnabled = emailIndex !== - 1 ;
136136 const phoneIndex = authOptions . indexOf ( "phone" ) ;
137137 const isPhoneEnabled = phoneIndex !== - 1 ;
138+ const socialLogins : SocialAuthOption [ ] = authOptions . filter ( ( o ) =>
139+ socialAuthOptions . includes ( o as SocialAuthOption ) ,
140+ ) as SocialAuthOption [ ] ;
141+
142+ const columnCount = useMemo ( ( ) => {
143+ switch ( socialLogins . length ) {
144+ case 7 :
145+ return 4 ;
146+ case 6 :
147+ return 4 ;
148+ default :
149+ return 5 ;
150+ }
151+ } , [ socialLogins . length ] ) ;
152+
153+ const socialLoginColumns : SocialAuthOption [ ] [ ] = useMemo ( ( ) => {
154+ return Array . from (
155+ { length : Math . ceil ( socialLogins . length / columnCount ) } ,
156+ ( _ , i ) => socialLogins . slice ( i * columnCount , ( i + 1 ) * columnCount ) ,
157+ ) ;
158+ } , [ socialLogins , columnCount ] ) ;
138159
139160 const [ manualInputMode , setManualInputMode ] = useState <
140161 "email" | "phone" | "none" | null
@@ -175,10 +196,6 @@ export const ConnectWalletSocialOptions = (
175196 type = "tel" ;
176197 }
177198
178- const socialLogins = authOptions . filter ( ( o ) =>
179- socialAuthOptions . includes ( o as SocialAuthOption ) ,
180- ) ;
181-
182199 const hasSocialLogins = socialLogins . length > 0 ;
183200 const ecosystemInfo = isEcosystemWallet ( wallet )
184201 ? {
@@ -315,49 +332,46 @@ export const ConnectWalletSocialOptions = (
315332 ) }
316333 { /* Social Login */ }
317334 { hasSocialLogins && (
318- < Container
319- flex = "row"
320- center = "x"
321- gap = { socialLogins . length > 4 ? "xs" : "sm" }
322- style = { {
323- justifyContent : "space-between" ,
324- display : "grid" ,
325- gridTemplateColumns : `repeat(${ socialLogins . length } , 1fr)` ,
326- } }
327- >
328- { socialLogins . map ( ( loginMethod ) => {
329- const imgIconSize = ( ( ) => {
330- if ( ! showOnlyIcons ) {
331- return iconSize . md ;
332- }
333- if ( socialLogins . length > 4 ) {
334- return iconSize . md ;
335- }
336- return iconSize . lg ;
337- } ) ( ) ;
338-
339- return (
340- < SocialButton
341- aria-label = { `Login with ${ loginMethod } ` }
342- data-variant = { showOnlyIcons ? "icon" : "full" }
343- key = { loginMethod }
344- variant = { "outline" }
345- disabled = { props . disabled }
346- onClick = { ( ) => {
347- handleSocialLogin ( loginMethod as SocialAuthOption ) ;
348- } }
349- >
350- < Img
351- src = { socialIcons [ loginMethod as SocialAuthOption ] }
352- width = { imgIconSize }
353- height = { imgIconSize }
354- client = { props . client }
355- />
356- { ! showOnlyIcons &&
357- `${ socialLogins . length === 1 ? "Continue with " : "" } ${ loginMethodsLabel [ loginMethod as SocialAuthOption ] } ` }
358- </ SocialButton >
359- ) ;
360- } ) }
335+ < Container flex = "column" gap = { socialLogins . length > 4 ? "xs" : "sm" } >
336+ { socialLoginColumns . map ( ( column ) => (
337+ < SocialButtonRow key = { column [ 0 ] } >
338+ { column . map ( ( loginMethod ) => {
339+ const imgIconSize = ( ( ) => {
340+ if ( ! showOnlyIcons ) {
341+ return iconSize . md ;
342+ }
343+ if ( socialLogins . length > 4 ) {
344+ return iconSize . md ;
345+ }
346+ return iconSize . lg ;
347+ } ) ( ) ;
348+ return (
349+ < SocialButton
350+ aria-label = { `Login with ${ loginMethod } ` }
351+ data-variant = { showOnlyIcons ? "icon" : "full" }
352+ key = { loginMethod }
353+ variant = { "outline" }
354+ disabled = { props . disabled }
355+ onClick = { ( ) => {
356+ handleSocialLogin ( loginMethod as SocialAuthOption ) ;
357+ } }
358+ style = { {
359+ flexGrow : socialLogins . length < 7 ? 1 : 0 ,
360+ } }
361+ >
362+ < Img
363+ src = { socialIcons [ loginMethod as SocialAuthOption ] }
364+ width = { imgIconSize }
365+ height = { imgIconSize }
366+ client = { props . client }
367+ />
368+ { ! showOnlyIcons &&
369+ `${ socialLogins . length === 1 ? "Continue with " : "" } ${ loginMethodsLabel [ loginMethod as SocialAuthOption ] } ` }
370+ </ SocialButton >
371+ ) ;
372+ } ) }
373+ </ SocialButtonRow >
374+ ) ) }
361375 </ Container >
362376 ) }
363377
@@ -476,8 +490,27 @@ export const ConnectWalletSocialOptions = (
476490 ) ;
477491} ;
478492
493+ const SocialButtonRow = ( props : { children : React . ReactNode [ ] } ) => (
494+ < Container
495+ flex = "row"
496+ center = "x"
497+ gap = { props . children . length > 4 ? "xs" : "sm" }
498+ style = { {
499+ justifyContent : "center" ,
500+ display : "flex" ,
501+ ...{
502+ "& > *" : {
503+ flexBasis : `${ 100 / props . children . length } %` ,
504+ maxWidth : `${ 100 / props . children . length } %` ,
505+ } ,
506+ } ,
507+ } }
508+ >
509+ { props . children }
510+ </ Container >
511+ ) ;
512+
479513const SocialButton = /* @__PURE__ */ styled ( Button ) ( {
480- flexGrow : 1 ,
481514 "&[data-variant='full']" : {
482515 display : "flex" ,
483516 justifyContent : "flex-start" ,
0 commit comments