import { cx, css } from '@emotion/css'
import { useEffect, useState } from 'react'
import { state } from '@/web/store'
import { useSnapshot } from 'valtio'
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'
const OR = ({
children,
onClick,
}: {
children: React.ReactNode
onClick: () => void
}) => {
return (
<>
>
)
}
const Login = () => {
const { uiStates, persistedUiStates } = useSnapshot(state)
const [cardType, setCardType] = useState<'qrCode' | 'phone/email'>(
persistedUiStates.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')
state.persistedUiStates.loginType =
cardType === 'qrCode' ? 'phone' : 'qrCode'
await animateCard.start({
rotateY: 0,
opacity: 1,
transition,
})
}
return (
<>
{/* Blur bg */}
{uiStates.showLoginPanel && (
)}
{/* Content */}
{uiStates.showLoginPanel && (
{/* Login card */}
{cardType === 'qrCode' && }
{cardType === 'phone/email' && }
{cardType === 'qrCode'
? 'Use Phone or Email'
: 'Scan QR Code'}
{/* Close button */}
(state.uiStates.showLoginPanel = false)}
className='mt-10 flex h-14 w-14 items-center justify-center rounded-full bg-white/10'
>
)}
>
)
}
export default Login