diff --git a/src/components/Login/AccountDropdown.astro b/src/components/Login/AccountDropdown.astro new file mode 100644 index 000000000..8643c523a --- /dev/null +++ b/src/components/Login/AccountDropdown.astro @@ -0,0 +1,51 @@ + + + diff --git a/src/components/Login/AccountNavigation.astro b/src/components/Login/AccountNavigation.astro new file mode 100644 index 000000000..e07d01522 --- /dev/null +++ b/src/components/Login/AccountNavigation.astro @@ -0,0 +1,40 @@ +--- +import Spinner from '../Spinner.astro'; +import AccountDropdown from './AccountDropdown.astro'; +--- + +
+ + + + + +
+ + diff --git a/src/components/Login/account-dropdown.tsx b/src/components/Login/account-dropdown.tsx deleted file mode 100644 index 16fb057c7..000000000 --- a/src/components/Login/account-dropdown.tsx +++ /dev/null @@ -1,56 +0,0 @@ -import Cookies from 'js-cookie'; -import { TOKEN_COOKIE_NAME } from '../../lib/utils'; -import { useEffect, useState } from 'preact/hooks'; - -export default function AccountDropdown() { - const [isOpen, setIsOpen] = useState(false); - - useEffect(() => { - // If user click outside the dropdown, and dropdown is open then close it. - const handleOpen = () => { - if (isOpen) setIsOpen(false); - }; - - document.addEventListener('click', handleOpen); - return () => document.removeEventListener('click', handleOpen); - }, [isOpen]); - - return ( -
- - -
- -
-
- ); -} diff --git a/src/components/Login/account-nav.tsx b/src/components/Login/account-nav.tsx deleted file mode 100644 index 71765c654..000000000 --- a/src/components/Login/account-nav.tsx +++ /dev/null @@ -1,55 +0,0 @@ -import { useAuth } from '../../hooks/use-auth'; -import AccountDropdown from './account-dropdown'; - -export default function AccountNavigation() { - const { user, isLoading } = useAuth(); - - console.log('user', user, isLoading); - - return ( -
- {isLoading ? ( -
- -
- ) : ( - <> - {user ? ( - - ) : ( - - Register - - )} - - )} -
- ); -} - -export function Spinner({ className }: { className?: string }) { - return ( - - - - - ); -} diff --git a/src/components/Login/google-login.tsx b/src/components/Login/google-login.tsx index 0d103d0e2..35885fffd 100644 --- a/src/components/Login/google-login.tsx +++ b/src/components/Login/google-login.tsx @@ -1,7 +1,6 @@ import Cookies from 'js-cookie'; import { useEffect, useState } from 'preact/hooks'; import { TOKEN_COOKIE_NAME } from '../../lib/utils'; -import { Spinner } from './account-nav'; export default function GoogleLoginButton() { const [isLoading, setIsLoading] = useState(false); @@ -65,6 +64,30 @@ export default function GoogleLoginButton() { ); } +function Spinner({ className }: { className?: string }) { + return ( + + + + + ); +} + function GoogleLogo() { return ( @@ -28,8 +27,7 @@ import AccountNavigationAstro from './Login/account-navigation.astro'; Videos
  • - - +
  • diff --git a/src/components/Spinner.astro b/src/components/Spinner.astro new file mode 100644 index 000000000..a0e23961a --- /dev/null +++ b/src/components/Spinner.astro @@ -0,0 +1,23 @@ +--- +const { className = '', ...rest } = Astro.props; +--- + + + + + diff --git a/src/icons/google.svg b/src/icons/google.svg new file mode 100644 index 000000000..a2491e75b --- /dev/null +++ b/src/icons/google.svg @@ -0,0 +1,6 @@ + + + + + +