added cancelling tipping and lil coin
This commit is contained in:
parent
3508c94634
commit
1d9b0c5d2d
|
@ -108,7 +108,7 @@ export function IconButton(props: {
|
||||||
className={clsx(
|
className={clsx(
|
||||||
'inline-flex items-center justify-center transition-colors disabled:cursor-not-allowed',
|
'inline-flex items-center justify-center transition-colors disabled:cursor-not-allowed',
|
||||||
sizeClasses[size],
|
sizeClasses[size],
|
||||||
'disabled:text-greyscale-2 text-greyscale-6 hover:text-indigo-600',
|
'disabled:text-greyscale-2 text-greyscale-5 hover:text-greyscale-6',
|
||||||
className
|
className
|
||||||
)}
|
)}
|
||||||
disabled={disabled || loading}
|
disabled={disabled || loading}
|
||||||
|
|
|
@ -4,6 +4,7 @@ import { Col } from 'web/components/layout/col'
|
||||||
import { Tooltip } from '../tooltip'
|
import { Tooltip } from '../tooltip'
|
||||||
import TipJar from 'web/public/custom-components/tipJar'
|
import TipJar from 'web/public/custom-components/tipJar'
|
||||||
import { useState } from 'react'
|
import { useState } from 'react'
|
||||||
|
import Coin from 'web/public/custom-components/coin'
|
||||||
|
|
||||||
export function TipButton(props: {
|
export function TipButton(props: {
|
||||||
tipAmount: number
|
tipAmount: number
|
||||||
|
@ -35,16 +36,44 @@ export function TipButton(props: {
|
||||||
disabled={disabled}
|
disabled={disabled}
|
||||||
className={clsx(
|
className={clsx(
|
||||||
'px-2 py-1 text-xs', //2xs button
|
'px-2 py-1 text-xs', //2xs button
|
||||||
'text-greyscale-6 transition-transform hover:text-indigo-600 disabled:cursor-not-allowed',
|
'text-greyscale-5 transition-transform disabled:cursor-not-allowed',
|
||||||
!disabled ? 'hover:rotate-12' : ''
|
!disabled ? 'hover:text-greyscale-6' : ''
|
||||||
)}
|
)}
|
||||||
onMouseOver={() => setHover(true)}
|
onMouseOver={() => {
|
||||||
|
if (!disabled) {
|
||||||
|
setHover(true)
|
||||||
|
}
|
||||||
|
}}
|
||||||
onMouseLeave={() => setHover(false)}
|
onMouseLeave={() => setHover(false)}
|
||||||
>
|
>
|
||||||
<Col className={clsx('relative', disabled ? 'opacity-30' : '')}>
|
<Col className={clsx('relative')}>
|
||||||
|
<div
|
||||||
|
className={clsx(
|
||||||
|
'absolute transition-all',
|
||||||
|
hover ? 'left-[6px] -top-[9px]' : 'left-[8px] -top-[10px]'
|
||||||
|
)}
|
||||||
|
>
|
||||||
|
<Coin
|
||||||
|
size={10}
|
||||||
|
color={
|
||||||
|
hover && !userTipped
|
||||||
|
? '#66667C'
|
||||||
|
: userTipped
|
||||||
|
? '#4f46e5'
|
||||||
|
: '#9191a7'
|
||||||
|
}
|
||||||
|
strokeWidth={2}
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
<TipJar
|
<TipJar
|
||||||
size={18}
|
size={18}
|
||||||
color={userTipped || (hover && !disabled) ? '#4f46e5' : '#66667C'}
|
color={
|
||||||
|
hover && !disabled && !userTipped
|
||||||
|
? '#66667C'
|
||||||
|
: userTipped
|
||||||
|
? '#4f46e5'
|
||||||
|
: '#9191a7'
|
||||||
|
}
|
||||||
/>
|
/>
|
||||||
<div
|
<div
|
||||||
className={clsx(
|
className={clsx(
|
||||||
|
|
|
@ -11,6 +11,8 @@ import { TipButton } from './contract/tip-button'
|
||||||
import { Row } from './layout/row'
|
import { Row } from './layout/row'
|
||||||
import { LIKE_TIP_AMOUNT } from 'common/like'
|
import { LIKE_TIP_AMOUNT } from 'common/like'
|
||||||
import { formatMoney } from 'common/util/format'
|
import { formatMoney } from 'common/util/format'
|
||||||
|
import { Button } from './button'
|
||||||
|
import clsx from 'clsx'
|
||||||
|
|
||||||
export function Tipper(prop: {
|
export function Tipper(prop: {
|
||||||
comment: Comment
|
comment: Comment
|
||||||
|
@ -73,9 +75,34 @@ export function Tipper(prop: {
|
||||||
useEffect(() => () => void saveTip.flush(), [saveTip])
|
useEffect(() => () => void saveTip.flush(), [saveTip])
|
||||||
|
|
||||||
const addTip = (delta: number) => {
|
const addTip = (delta: number) => {
|
||||||
|
let cancelled = false
|
||||||
setLocalTip(localTip + delta)
|
setLocalTip(localTip + delta)
|
||||||
me && saveTip(me, comment, localTip - myTip + delta)
|
const timeoutId = setTimeout(() => {
|
||||||
toast(`You tipped ${comment.userName} ${formatMoney(LIKE_TIP_AMOUNT)}!`)
|
me && saveTip(me, comment, localTip - myTip + delta)
|
||||||
|
}, 5000)
|
||||||
|
toast.custom((t) => (
|
||||||
|
<Row className="text-greyscale-6 items-center gap-4 rounded-lg bg-white px-4 py-2 text-sm drop-shadow-md">
|
||||||
|
<div className={clsx(cancelled ? 'hidden' : 'inline')}>
|
||||||
|
You tipped {comment.userName} {formatMoney(LIKE_TIP_AMOUNT)}!
|
||||||
|
</div>
|
||||||
|
<div className={clsx('py-1', cancelled ? 'inline' : 'hidden')}>
|
||||||
|
Cancelled tipping
|
||||||
|
</div>
|
||||||
|
<Button
|
||||||
|
className={clsx(cancelled ? 'hidden' : 'inline')}
|
||||||
|
size="xs"
|
||||||
|
color="gray-outline"
|
||||||
|
onClick={() => {
|
||||||
|
clearTimeout(timeoutId)
|
||||||
|
setLocalTip(localTip)
|
||||||
|
cancelled = true
|
||||||
|
}}
|
||||||
|
disabled={cancelled}
|
||||||
|
>
|
||||||
|
Undo
|
||||||
|
</Button>
|
||||||
|
</Row>
|
||||||
|
))
|
||||||
}
|
}
|
||||||
|
|
||||||
const canUp =
|
const canUp =
|
||||||
|
|
Loading…
Reference in New Issue
Block a user