Skip to content

Commit

Permalink
feat: add super likes tooltip
Browse files Browse the repository at this point in the history
  • Loading branch information
teodorus-nathaniel committed Jan 4, 2024
1 parent 7d5d445 commit 0edc6a4
Showing 1 changed file with 24 additions and 2 deletions.
26 changes: 24 additions & 2 deletions src/components/voting/SuperLike.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { PostStruct } from '@subsocial/api/types'
import { Button, ButtonProps, Image } from 'antd'
import { Button, ButtonProps, Image, Tooltip } from 'antd'
import clsx from 'clsx'
import dayjs from 'dayjs'
import { ComponentProps, useEffect, useState } from 'react'
Expand Down Expand Up @@ -52,7 +52,8 @@ export default function SuperLike({ post, ...props }: SuperLikeProps) {
const isMyPost = post.ownerId === myAddress

const isActive = hasILikedOptimistic
const isDisabled = !clientCanPostSuperLiked || !canPostSuperLiked || isMyPost || loadingTotalStake
const isPostCreatedMoreThan1Week = !clientCanPostSuperLiked || !canPostSuperLiked
const isDisabled = isPostCreatedMoreThan1Week || isMyPost || loadingTotalStake

const { openSignInModal } = useAuth()

Expand Down Expand Up @@ -92,8 +93,29 @@ export default function SuperLike({ post, ...props }: SuperLikeProps) {
/>
)

let tooltipTitle = ''
if (isPostCreatedMoreThan1Week)
tooltipTitle = 'You cannot super like posts that are older than 7 days'
else if (isMyPost) tooltipTitle = 'You cannot like your own post'

const button = (
<Button
className={clsx(
'FontSmall',
styles.SuperLike,
isActive && styles.SuperLikeActive,
props.className,
)}
onClick={onClick}
disabled={isDisabled}
>
<IconWithLabel renderZeroCount icon={icon} count={optimisticCount} />
</Button>
)

return (
<>
{tooltipTitle ? <Tooltip title={tooltipTitle}>{button}</Tooltip> : button}
<Button
className={clsx(
'FontSmall',
Expand Down

0 comments on commit 0edc6a4

Please sign in to comment.