This commit is contained in:
commit
db9e82091c
|
@ -5,57 +5,52 @@ import { useFollows } from 'web/hooks/use-follows'
|
||||||
import { useUser } from 'web/hooks/use-user'
|
import { useUser } from 'web/hooks/use-user'
|
||||||
import { follow, unfollow } from 'web/lib/firebase/users'
|
import { follow, unfollow } from 'web/lib/firebase/users'
|
||||||
import { withTracking } from 'web/lib/service/analytics'
|
import { withTracking } from 'web/lib/service/analytics'
|
||||||
|
import { Button } from './button'
|
||||||
|
|
||||||
export function FollowButton(props: {
|
export function FollowButton(props: {
|
||||||
isFollowing: boolean | undefined
|
isFollowing: boolean | undefined
|
||||||
onFollow: () => void
|
onFollow: () => void
|
||||||
onUnfollow: () => void
|
onUnfollow: () => void
|
||||||
small?: boolean
|
|
||||||
className?: string
|
className?: string
|
||||||
}) {
|
}) {
|
||||||
const { isFollowing, onFollow, onUnfollow, small, className } = props
|
const { isFollowing, onFollow, onUnfollow, className } = props
|
||||||
|
|
||||||
const user = useUser()
|
const user = useUser()
|
||||||
|
|
||||||
const smallStyle =
|
|
||||||
'btn !btn-xs border-2 border-gray-500 bg-white normal-case text-gray-500 hover:border-gray-500 hover:bg-white hover:text-gray-500'
|
|
||||||
|
|
||||||
if (!user || isFollowing === undefined)
|
if (!user || isFollowing === undefined)
|
||||||
return (
|
return (
|
||||||
<button
|
<Button size="sm" color="gray" className={clsx(className, 'invisible')}>
|
||||||
className={clsx('btn btn-sm invisible', small && smallStyle, className)}
|
|
||||||
>
|
|
||||||
Follow
|
Follow
|
||||||
</button>
|
</Button>
|
||||||
)
|
)
|
||||||
|
|
||||||
if (isFollowing) {
|
if (isFollowing) {
|
||||||
return (
|
return (
|
||||||
<button
|
<Button
|
||||||
className={clsx(
|
size="sm"
|
||||||
'btn btn-outline btn-sm',
|
color="gray-outline"
|
||||||
small && smallStyle,
|
className={clsx('my-auto', className)}
|
||||||
className
|
|
||||||
)}
|
|
||||||
onClick={withTracking(onUnfollow, 'unfollow')}
|
onClick={withTracking(onUnfollow, 'unfollow')}
|
||||||
>
|
>
|
||||||
Following
|
Following
|
||||||
</button>
|
</Button>
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<button
|
<Button
|
||||||
className={clsx('btn btn-sm', small && smallStyle, className)}
|
size="sm"
|
||||||
|
color="indigo"
|
||||||
|
className={clsx(className, 'my-auto')}
|
||||||
onClick={withTracking(onFollow, 'follow')}
|
onClick={withTracking(onFollow, 'follow')}
|
||||||
>
|
>
|
||||||
Follow
|
Follow
|
||||||
</button>
|
</Button>
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
export function UserFollowButton(props: { userId: string; small?: boolean }) {
|
export function UserFollowButton(props: { userId: string }) {
|
||||||
const { userId, small } = props
|
const { userId } = props
|
||||||
const user = useUser()
|
const user = useUser()
|
||||||
const following = useFollows(user?.id)
|
const following = useFollows(user?.id)
|
||||||
const isFollowing = following?.includes(userId)
|
const isFollowing = following?.includes(userId)
|
||||||
|
@ -67,7 +62,6 @@ export function UserFollowButton(props: { userId: string; small?: boolean }) {
|
||||||
isFollowing={isFollowing}
|
isFollowing={isFollowing}
|
||||||
onFollow={() => follow(user.id, userId)}
|
onFollow={() => follow(user.id, userId)}
|
||||||
onUnfollow={() => unfollow(user.id, userId)}
|
onUnfollow={() => unfollow(user.id, userId)}
|
||||||
small={small}
|
|
||||||
/>
|
/>
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
|
@ -10,7 +10,7 @@ export const SignInButton = (props: { className?: string }) => {
|
||||||
return (
|
return (
|
||||||
<Button
|
<Button
|
||||||
size="lg"
|
size="lg"
|
||||||
color="gray"
|
color="gradient"
|
||||||
onClick={async () => {
|
onClick={async () => {
|
||||||
// login, and then reload the page, to hit any SSR redirect (e.g.
|
// login, and then reload the page, to hit any SSR redirect (e.g.
|
||||||
// redirecting from / to /home for logged in users)
|
// redirecting from / to /home for logged in users)
|
||||||
|
|
Loading…
Reference in New Issue
Block a user