1
1
import { FollowIcon } from "@follow/components/icons/follow.jsx"
2
2
import { MotionButtonBase } from "@follow/components/ui/button/index.js"
3
3
import { LoadingCircle } from "@follow/components/ui/loading/index.jsx"
4
+ import { authProvidersConfig } from "@follow/constants"
4
5
import { stopPropagation } from "@follow/utils/dom"
5
6
import clsx from "clsx"
6
7
import { AnimatePresence , m } from "framer-motion"
@@ -11,6 +12,7 @@ import { modalMontionConfig } from "~/components/ui/modal/stacked/constants"
11
12
import { useCurrentModal } from "~/components/ui/modal/stacked/hooks"
12
13
import type { LoginRuntime } from "~/lib/auth"
13
14
import { loginHandler } from "~/lib/auth"
15
+ import { useAuthProviders } from "~/queries/users"
14
16
15
17
interface LoginModalContentProps {
16
18
runtime ?: LoginRuntime
@@ -22,6 +24,7 @@ export const LoginModalContent = (props: LoginModalContentProps) => {
22
24
const { canClose = true , runtime } = props
23
25
24
26
const { t } = useTranslation ( )
27
+ const { data : authProviders } = useAuthProviders ( )
25
28
26
29
const [ loadingLockSet , _setLoadingLockSet ] = useState < string > ( "" )
27
30
@@ -60,46 +63,30 @@ export const LoginModalContent = (props: LoginModalContentProps) => {
60
63
</ span >
61
64
</ div >
62
65
< div className = "flex flex-col gap-4" >
63
- < MotionButtonBase
64
- className = { clsx (
65
- "center h-[48px] w-[320px] rounded-[8px] !bg-black font-sans text-base font-medium text-white hover:!bg-black/80 focus:!border-black/80 focus:!ring-black/80" ,
66
- disabled && "pointer-events-none opacity-50" ,
67
- "overflow-hidden" ,
68
- ) }
69
- disabled = { disabled }
70
- onClick = { ( ) => {
71
- loginHandler ( "github" , runtime )
72
- setLoadingLockSet ( "github" )
73
- window . analytics ?. capture ( "login" , {
74
- type : "github" ,
75
- } )
76
- } }
77
- >
78
- < LoginButtonContent isLoading = { loadingLockSet === "github" } >
79
- < i className = "i-mgc-github-cute-fi mr-2 text-xl" />
80
- { t ( "signin.continue_with_github" ) }
81
- </ LoginButtonContent >
82
- </ MotionButtonBase >
83
- < MotionButtonBase
84
- disabled = { disabled }
85
- className = { clsx (
86
- "center h-[48px] w-[320px] rounded-[8px] bg-blue-500 font-sans text-base font-medium text-white hover:bg-blue-500/90 focus:!border-blue-500/80 focus:!ring-blue-500/80" ,
87
- disabled && "pointer-events-none opacity-50" ,
88
- "overflow-hidden" ,
89
- ) }
90
- onClick = { ( ) => {
91
- loginHandler ( "google" , runtime )
92
- setLoadingLockSet ( "google" )
93
- window . analytics ?. capture ( "login" , {
94
- type : "google" ,
95
- } )
96
- } }
97
- >
98
- < LoginButtonContent isLoading = { loadingLockSet === "google" } >
99
- < i className = "i-mgc-google-cute-fi mr-2 text-xl" />
100
- { t ( "signin.continue_with_google" ) }
101
- </ LoginButtonContent >
102
- </ MotionButtonBase >
66
+ { Object . entries ( authProviders || [ ] ) . map ( ( [ key , provider ] ) => (
67
+ < MotionButtonBase
68
+ key = { key }
69
+ className = { clsx (
70
+ "center h-[48px] w-[320px] rounded-[8px] font-sans text-base font-medium text-white" ,
71
+ disabled && "pointer-events-none opacity-50" ,
72
+ "overflow-hidden" ,
73
+ authProvidersConfig [ key ] ?. buttonClassName ,
74
+ ) }
75
+ disabled = { disabled }
76
+ onClick = { ( ) => {
77
+ loginHandler ( key , runtime )
78
+ setLoadingLockSet ( key )
79
+ window . analytics ?. capture ( "login" , {
80
+ type : key ,
81
+ } )
82
+ } }
83
+ >
84
+ < LoginButtonContent isLoading = { loadingLockSet === key } >
85
+ < i className = { clsx ( "mr-2 text-xl" , authProvidersConfig [ key ] . iconClassName ) } /> { " " }
86
+ { t ( "signin.continue_with" , { provider : provider . name } ) }
87
+ </ LoginButtonContent >
88
+ </ MotionButtonBase >
89
+ ) ) }
103
90
</ div >
104
91
</ m . div >
105
92
</ div >
0 commit comments