sign in button
This commit is contained in:
parent
926929880a
commit
cae2154893
|
@ -52,7 +52,7 @@ export function Button(props: {
|
||||||
color === 'yellow' && 'bg-yellow-400 text-white hover:bg-yellow-500',
|
color === 'yellow' && 'bg-yellow-400 text-white hover:bg-yellow-500',
|
||||||
color === 'blue' && 'bg-blue-400 text-white hover:bg-blue-500',
|
color === 'blue' && 'bg-blue-400 text-white hover:bg-blue-500',
|
||||||
color === 'indigo' && 'bg-indigo-500 text-white hover:bg-indigo-600',
|
color === 'indigo' && 'bg-indigo-500 text-white hover:bg-indigo-600',
|
||||||
color === 'gray' && 'bg-gray-100 text-gray-600 hover:bg-gray-200',
|
color === 'gray' && 'bg-gray-50 text-gray-600 hover:bg-gray-200',
|
||||||
color === 'gradient' &&
|
color === 'gradient' &&
|
||||||
'bg-gradient-to-r from-indigo-500 to-blue-500 text-white hover:from-indigo-700 hover:to-blue-700',
|
'bg-gradient-to-r from-indigo-500 to-blue-500 text-white hover:from-indigo-700 hover:to-blue-700',
|
||||||
color === 'gray-white' &&
|
color === 'gray-white' &&
|
||||||
|
|
|
@ -1,8 +1,8 @@
|
||||||
import Link from 'next/link'
|
|
||||||
import { useRouter } from 'next/router'
|
|
||||||
import clsx from 'clsx'
|
|
||||||
import { firebaseLogin, User } from 'web/lib/firebase/users'
|
|
||||||
import React from 'react'
|
import React from 'react'
|
||||||
|
import Link from 'next/link'
|
||||||
|
import clsx from 'clsx'
|
||||||
|
|
||||||
|
import { User } from 'web/lib/firebase/users'
|
||||||
|
|
||||||
export const createButtonStyle =
|
export const createButtonStyle =
|
||||||
'border-w-0 mx-auto mt-4 -ml-1 w-full rounded-md bg-gradient-to-r py-2.5 text-base font-semibold text-white shadow-sm lg:-ml-0 h-11'
|
'border-w-0 mx-auto mt-4 -ml-1 w-full rounded-md bg-gradient-to-r py-2.5 text-base font-semibold text-white shadow-sm lg:-ml-0 h-11'
|
||||||
|
@ -17,31 +17,16 @@ export const CreateQuestionButton = (props: {
|
||||||
'from-indigo-500 to-blue-500 hover:from-indigo-700 hover:to-blue-700'
|
'from-indigo-500 to-blue-500 hover:from-indigo-700 hover:to-blue-700'
|
||||||
|
|
||||||
const { user, overrideText, className, query } = props
|
const { user, overrideText, className, query } = props
|
||||||
const router = useRouter()
|
|
||||||
|
|
||||||
if (user?.isBannedFromPosting) return <></>
|
if (!user || user?.isBannedFromPosting) return <></>
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className={clsx('flex justify-center', className)}>
|
<div className={clsx('flex justify-center', className)}>
|
||||||
{user ? (
|
|
||||||
<Link href={`/create${query ? query : ''}`} passHref>
|
<Link href={`/create${query ? query : ''}`} passHref>
|
||||||
<button className={clsx(gradient, createButtonStyle)}>
|
<button className={clsx(gradient, createButtonStyle)}>
|
||||||
{overrideText ? overrideText : 'Create a market'}
|
{overrideText ? overrideText : 'Create a market'}
|
||||||
</button>
|
</button>
|
||||||
</Link>
|
</Link>
|
||||||
) : (
|
|
||||||
<button
|
|
||||||
onClick={async () => {
|
|
||||||
// login, and then reload the page, to hit any SSR redirect (e.g.
|
|
||||||
// redirecting from / to /home for logged in users)
|
|
||||||
await firebaseLogin()
|
|
||||||
router.replace(router.asPath)
|
|
||||||
}}
|
|
||||||
className={clsx(gradient, createButtonStyle)}
|
|
||||||
>
|
|
||||||
Sign in
|
|
||||||
</button>
|
|
||||||
)}
|
|
||||||
</div>
|
</div>
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
|
@ -28,6 +28,7 @@ import { Spacer } from '../layout/spacer'
|
||||||
import { CHALLENGES_ENABLED } from 'common/challenge'
|
import { CHALLENGES_ENABLED } from 'common/challenge'
|
||||||
import { buildArray } from 'common/util/array'
|
import { buildArray } from 'common/util/array'
|
||||||
import TrophyIcon from 'web/lib/icons/trophy-icon'
|
import TrophyIcon from 'web/lib/icons/trophy-icon'
|
||||||
|
import { SignInButton } from '../sign-in-button'
|
||||||
|
|
||||||
const logout = async () => {
|
const logout = async () => {
|
||||||
// log out, and then reload the page, in case SSR wants to boot them out
|
// log out, and then reload the page, in case SSR wants to boot them out
|
||||||
|
@ -240,7 +241,8 @@ export default function Sidebar(props: { className?: string }) {
|
||||||
>
|
>
|
||||||
<ManifoldLogo className="py-6" twoLine />
|
<ManifoldLogo className="py-6" twoLine />
|
||||||
|
|
||||||
<CreateQuestionButton user={user} />
|
{user ? <CreateQuestionButton user={user} /> : <SignInButton />}
|
||||||
|
|
||||||
<Spacer h={4} />
|
<Spacer h={4} />
|
||||||
{user && (
|
{user && (
|
||||||
<div className="min-h-[80px] w-full">
|
<div className="min-h-[80px] w-full">
|
||||||
|
|
25
web/components/sign-in-button.tsx
Normal file
25
web/components/sign-in-button.tsx
Normal file
|
@ -0,0 +1,25 @@
|
||||||
|
import React from 'react'
|
||||||
|
import { useRouter } from 'next/router'
|
||||||
|
|
||||||
|
import { firebaseLogin, User } from 'web/lib/firebase/users'
|
||||||
|
import { Button } from './button'
|
||||||
|
|
||||||
|
export const SignInButton = (props: {
|
||||||
|
}) => {
|
||||||
|
const router = useRouter()
|
||||||
|
|
||||||
|
return (
|
||||||
|
<Button
|
||||||
|
size='lg'
|
||||||
|
color='gray'
|
||||||
|
onClick={async () => {
|
||||||
|
// login, and then reload the page, to hit any SSR redirect (e.g.
|
||||||
|
// redirecting from / to /home for logged in users)
|
||||||
|
await firebaseLogin()
|
||||||
|
router.replace(router.asPath)
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
Sign in
|
||||||
|
</Button>
|
||||||
|
)
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user