Add tooltips to market header icons (#924)
This commit is contained in:
parent
c15285aa64
commit
4412d0195c
|
@ -1,6 +1,4 @@
|
||||||
import clsx from 'clsx'
|
|
||||||
import { ShareIcon } from '@heroicons/react/outline'
|
import { ShareIcon } from '@heroicons/react/outline'
|
||||||
|
|
||||||
import { Row } from '../layout/row'
|
import { Row } from '../layout/row'
|
||||||
import { Contract } from 'web/lib/firebase/contracts'
|
import { Contract } from 'web/lib/firebase/contracts'
|
||||||
import React, { useState } from 'react'
|
import React, { useState } from 'react'
|
||||||
|
@ -10,7 +8,7 @@ import { ShareModal } from './share-modal'
|
||||||
import { FollowMarketButton } from 'web/components/follow-market-button'
|
import { FollowMarketButton } from 'web/components/follow-market-button'
|
||||||
import { LikeMarketButton } from 'web/components/contract/like-market-button'
|
import { LikeMarketButton } from 'web/components/contract/like-market-button'
|
||||||
import { ContractInfoDialog } from 'web/components/contract/contract-info-dialog'
|
import { ContractInfoDialog } from 'web/components/contract/contract-info-dialog'
|
||||||
import { Col } from 'web/components/layout/col'
|
import { Tooltip } from '../tooltip'
|
||||||
|
|
||||||
export function ExtraContractActionsRow(props: { contract: Contract }) {
|
export function ExtraContractActionsRow(props: { contract: Contract }) {
|
||||||
const { contract } = props
|
const { contract } = props
|
||||||
|
@ -23,27 +21,23 @@ export function ExtraContractActionsRow(props: { contract: Contract }) {
|
||||||
{user?.id !== contract.creatorId && (
|
{user?.id !== contract.creatorId && (
|
||||||
<LikeMarketButton contract={contract} user={user} />
|
<LikeMarketButton contract={contract} user={user} />
|
||||||
)}
|
)}
|
||||||
<Button
|
<Tooltip text="Share" placement="bottom" noTap noFade>
|
||||||
size="sm"
|
<Button
|
||||||
color="gray-white"
|
size="sm"
|
||||||
className={'flex'}
|
color="gray-white"
|
||||||
onClick={() => {
|
className={'flex'}
|
||||||
setShareOpen(true)
|
onClick={() => setShareOpen(true)}
|
||||||
}}
|
>
|
||||||
>
|
<ShareIcon className="h-5 w-5" aria-hidden />
|
||||||
<Row>
|
<ShareModal
|
||||||
<ShareIcon className={clsx('h-5 w-5')} aria-hidden="true" />
|
isOpen={isShareOpen}
|
||||||
</Row>
|
setOpen={setShareOpen}
|
||||||
<ShareModal
|
contract={contract}
|
||||||
isOpen={isShareOpen}
|
user={user}
|
||||||
setOpen={setShareOpen}
|
/>
|
||||||
contract={contract}
|
</Button>
|
||||||
user={user}
|
</Tooltip>
|
||||||
/>
|
<ContractInfoDialog contract={contract} />
|
||||||
</Button>
|
|
||||||
<Col className={'justify-center'}>
|
|
||||||
<ContractInfoDialog contract={contract} />
|
|
||||||
</Col>
|
|
||||||
</Row>
|
</Row>
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
|
@ -13,6 +13,7 @@ import { Col } from 'web/components/layout/col'
|
||||||
import { firebaseLogin } from 'web/lib/firebase/users'
|
import { firebaseLogin } from 'web/lib/firebase/users'
|
||||||
import { useMarketTipTxns } from 'web/hooks/use-tip-txns'
|
import { useMarketTipTxns } from 'web/hooks/use-tip-txns'
|
||||||
import { sum } from 'lodash'
|
import { sum } from 'lodash'
|
||||||
|
import { Tooltip } from '../tooltip'
|
||||||
|
|
||||||
export function LikeMarketButton(props: {
|
export function LikeMarketButton(props: {
|
||||||
contract: Contract
|
contract: Contract
|
||||||
|
@ -37,37 +38,44 @@ export function LikeMarketButton(props: {
|
||||||
}
|
}
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Button
|
<Tooltip
|
||||||
size={'sm'}
|
text={`Tip ${formatMoney(LIKE_TIP_AMOUNT)}`}
|
||||||
className={'max-w-xs self-center'}
|
placement="bottom"
|
||||||
color={'gray-white'}
|
noTap
|
||||||
onClick={onLike}
|
noFade
|
||||||
>
|
>
|
||||||
<Col className={'relative items-center sm:flex-row'}>
|
<Button
|
||||||
<HeartIcon
|
size={'sm'}
|
||||||
className={clsx(
|
className={'max-w-xs self-center'}
|
||||||
'h-5 w-5 sm:h-6 sm:w-6',
|
color={'gray-white'}
|
||||||
totalTipped > 0 ? 'mr-2' : '',
|
onClick={onLike}
|
||||||
user &&
|
>
|
||||||
(userLikedContractIds?.includes(contract.id) ||
|
<Col className={'relative items-center sm:flex-row'}>
|
||||||
(!likes && contract.likedByUserIds?.includes(user.id)))
|
<HeartIcon
|
||||||
? 'fill-red-500 text-red-500'
|
|
||||||
: ''
|
|
||||||
)}
|
|
||||||
/>
|
|
||||||
{totalTipped > 0 && (
|
|
||||||
<div
|
|
||||||
className={clsx(
|
className={clsx(
|
||||||
'bg-greyscale-6 absolute ml-3.5 mt-2 h-4 w-4 rounded-full align-middle text-white sm:mt-3 sm:h-5 sm:w-5 sm:px-1',
|
'h-5 w-5 sm:h-6 sm:w-6',
|
||||||
totalTipped > 99
|
totalTipped > 0 ? 'mr-2' : '',
|
||||||
? 'text-[0.4rem] sm:text-[0.5rem]'
|
user &&
|
||||||
: 'sm:text-2xs text-[0.5rem]'
|
(userLikedContractIds?.includes(contract.id) ||
|
||||||
|
(!likes && contract.likedByUserIds?.includes(user.id)))
|
||||||
|
? 'fill-red-500 text-red-500'
|
||||||
|
: ''
|
||||||
)}
|
)}
|
||||||
>
|
/>
|
||||||
{totalTipped}
|
{totalTipped > 0 && (
|
||||||
</div>
|
<div
|
||||||
)}
|
className={clsx(
|
||||||
</Col>
|
'bg-greyscale-6 absolute ml-3.5 mt-2 h-4 w-4 rounded-full align-middle text-white sm:mt-3 sm:h-5 sm:w-5 sm:px-1',
|
||||||
</Button>
|
totalTipped > 99
|
||||||
|
? 'text-[0.4rem] sm:text-[0.5rem]'
|
||||||
|
: 'sm:text-2xs text-[0.5rem]'
|
||||||
|
)}
|
||||||
|
>
|
||||||
|
{totalTipped}
|
||||||
|
</div>
|
||||||
|
)}
|
||||||
|
</Col>
|
||||||
|
</Button>
|
||||||
|
</Tooltip>
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
|
@ -14,6 +14,7 @@ import { track } from 'web/lib/service/analytics'
|
||||||
import { WatchMarketModal } from 'web/components/contract/watch-market-modal'
|
import { WatchMarketModal } from 'web/components/contract/watch-market-modal'
|
||||||
import { useState } from 'react'
|
import { useState } from 'react'
|
||||||
import { Col } from 'web/components/layout/col'
|
import { Col } from 'web/components/layout/col'
|
||||||
|
import { Tooltip } from './tooltip'
|
||||||
|
|
||||||
export const FollowMarketButton = (props: {
|
export const FollowMarketButton = (props: {
|
||||||
contract: Contract
|
contract: Contract
|
||||||
|
@ -23,61 +24,70 @@ export const FollowMarketButton = (props: {
|
||||||
const followers = useContractFollows(contract.id)
|
const followers = useContractFollows(contract.id)
|
||||||
const [open, setOpen] = useState(false)
|
const [open, setOpen] = useState(false)
|
||||||
|
|
||||||
|
const watching = followers?.includes(user?.id ?? 'nope')
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Button
|
<Tooltip
|
||||||
size={'sm'}
|
text={watching ? 'Unfollow' : 'Follow'}
|
||||||
color={'gray-white'}
|
placement="bottom"
|
||||||
onClick={async () => {
|
noTap
|
||||||
if (!user) return firebaseLogin()
|
noFade
|
||||||
if (followers?.includes(user.id)) {
|
|
||||||
await unFollowContract(contract.id, user.id)
|
|
||||||
toast("You'll no longer receive notifications from this market", {
|
|
||||||
icon: <CheckIcon className={'text-primary h-5 w-5'} />,
|
|
||||||
})
|
|
||||||
track('Unwatch Market', {
|
|
||||||
slug: contract.slug,
|
|
||||||
})
|
|
||||||
} else {
|
|
||||||
await followContract(contract.id, user.id)
|
|
||||||
toast("You'll now receive notifications from this market!", {
|
|
||||||
icon: <CheckIcon className={'text-primary h-5 w-5'} />,
|
|
||||||
})
|
|
||||||
track('Watch Market', {
|
|
||||||
slug: contract.slug,
|
|
||||||
})
|
|
||||||
}
|
|
||||||
if (!user.hasSeenContractFollowModal) {
|
|
||||||
await updateUser(user.id, {
|
|
||||||
hasSeenContractFollowModal: true,
|
|
||||||
})
|
|
||||||
setOpen(true)
|
|
||||||
}
|
|
||||||
}}
|
|
||||||
>
|
>
|
||||||
{followers?.includes(user?.id ?? 'nope') ? (
|
<Button
|
||||||
<Col className={'items-center gap-x-2 sm:flex-row'}>
|
size={'sm'}
|
||||||
<EyeOffIcon
|
color={'gray-white'}
|
||||||
className={clsx('h-5 w-5 sm:h-6 sm:w-6')}
|
onClick={async () => {
|
||||||
aria-hidden="true"
|
if (!user) return firebaseLogin()
|
||||||
/>
|
if (followers?.includes(user.id)) {
|
||||||
{/* Unwatch */}
|
await unFollowContract(contract.id, user.id)
|
||||||
</Col>
|
toast("You'll no longer receive notifications from this market", {
|
||||||
) : (
|
icon: <CheckIcon className={'text-primary h-5 w-5'} />,
|
||||||
<Col className={'items-center gap-x-2 sm:flex-row'}>
|
})
|
||||||
<EyeIcon
|
track('Unwatch Market', {
|
||||||
className={clsx('h-5 w-5 sm:h-6 sm:w-6')}
|
slug: contract.slug,
|
||||||
aria-hidden="true"
|
})
|
||||||
/>
|
} else {
|
||||||
{/* Watch */}
|
await followContract(contract.id, user.id)
|
||||||
</Col>
|
toast("You'll now receive notifications from this market!", {
|
||||||
)}
|
icon: <CheckIcon className={'text-primary h-5 w-5'} />,
|
||||||
<WatchMarketModal
|
})
|
||||||
open={open}
|
track('Watch Market', {
|
||||||
setOpen={setOpen}
|
slug: contract.slug,
|
||||||
title={`You ${
|
})
|
||||||
followers?.includes(user?.id ?? 'nope') ? 'watched' : 'unwatched'
|
}
|
||||||
} a question!`}
|
if (!user.hasSeenContractFollowModal) {
|
||||||
/>
|
await updateUser(user.id, {
|
||||||
</Button>
|
hasSeenContractFollowModal: true,
|
||||||
|
})
|
||||||
|
setOpen(true)
|
||||||
|
}
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
{watching ? (
|
||||||
|
<Col className={'items-center gap-x-2 sm:flex-row'}>
|
||||||
|
<EyeOffIcon
|
||||||
|
className={clsx('h-5 w-5 sm:h-6 sm:w-6')}
|
||||||
|
aria-hidden="true"
|
||||||
|
/>
|
||||||
|
{/* Unwatch */}
|
||||||
|
</Col>
|
||||||
|
) : (
|
||||||
|
<Col className={'items-center gap-x-2 sm:flex-row'}>
|
||||||
|
<EyeIcon
|
||||||
|
className={clsx('h-5 w-5 sm:h-6 sm:w-6')}
|
||||||
|
aria-hidden="true"
|
||||||
|
/>
|
||||||
|
{/* Watch */}
|
||||||
|
</Col>
|
||||||
|
)}
|
||||||
|
<WatchMarketModal
|
||||||
|
open={open}
|
||||||
|
setOpen={setOpen}
|
||||||
|
title={`You ${
|
||||||
|
followers?.includes(user?.id ?? 'nope') ? 'watched' : 'unwatched'
|
||||||
|
} a question!`}
|
||||||
|
/>
|
||||||
|
</Button>
|
||||||
|
</Tooltip>
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user