import { cx, css } from '@emotion/css'
import { useEffect, useState } from 'react'
import { useSnapshot } from 'valtio'
import uiStates from '@/web/states/uiStates'
import { AnimatePresence, motion, useAnimation } from 'framer-motion'
import { ease } from '@/web/utils/const'
import Icon from '@/web/components/Icon'
import LoginWithPhoneOrEmail from './LoginWithPhoneOrEmail'
import LoginWithQRCode from './LoginWithQRCode'
import persistedUiStates from '@/web/states/persistedUiStates'
const OR = ({
children,
onClick,
}: {
children: React.ReactNode
onClick: () => void
}) => {
return (
<>
>
)
}
const Login = () => {
const { loginType } = useSnapshot(persistedUiStates)
const { showLoginPanel } = useSnapshot(uiStates)
const [cardType, setCardType] = useState<'qrCode' | 'phone/email'>(
loginType === 'qrCode' ? 'qrCode' : 'phone/email'
)
const animateCard = useAnimation()
const handleSwitchCard = async () => {
const transition = { duration: 0.36, ease }
await animateCard.start({
rotateY: 90,
opacity: 0,
transition,
})
setCardType(cardType === 'qrCode' ? 'phone/email' : 'qrCode')
persistedUiStates.loginType = cardType === 'qrCode' ? 'phone' : 'qrCode'
await animateCard.start({
rotateY: 0,
opacity: 1,
transition,
})
}
return (
<>
{/* Blur bg */}
{showLoginPanel && (
)}
{/* Content */}
{showLoginPanel && (
{/* Login card */}
{cardType === 'qrCode' && }
{cardType === 'phone/email' && }
{cardType === 'qrCode'
? 'Use Phone or Email'
: 'Scan QR Code'}
{/* Close button */}
(uiStates.showLoginPanel = false)}
className='mt-10 flex h-14 w-14 items-center justify-center rounded-full bg-white/10'
>
)}
>
)
}
export default Login