fix #1566
This commit is contained in:
parent
9179688abc
commit
5dac2f2ed0
|
@ -2,7 +2,7 @@ import { useShowModal } from './modal'
|
||||||
import { useToast } from './toast'
|
import { useToast } from './toast'
|
||||||
import ItemAct from './item-act'
|
import ItemAct from './item-act'
|
||||||
import AccordianItem from './accordian-item'
|
import AccordianItem from './accordian-item'
|
||||||
import { useMemo, useState } from 'react'
|
import { useMemo } from 'react'
|
||||||
import getColor from '@/lib/rainbow'
|
import getColor from '@/lib/rainbow'
|
||||||
import BoostIcon from '@/svgs/arrow-up-double-line.svg'
|
import BoostIcon from '@/svgs/arrow-up-double-line.svg'
|
||||||
import styles from './upvote.module.css'
|
import styles from './upvote.module.css'
|
||||||
|
@ -12,32 +12,29 @@ import classNames from 'classnames'
|
||||||
|
|
||||||
export default function Boost ({ item, className, ...props }) {
|
export default function Boost ({ item, className, ...props }) {
|
||||||
const { boost } = item
|
const { boost } = item
|
||||||
const [hover, setHover] = useState(false)
|
|
||||||
|
|
||||||
const [color, nextColor] = useMemo(() => [getColor(boost), getColor(boost + BOOST_MULT)], [boost])
|
const [color, nextColor] = useMemo(() => [getColor(boost), getColor(boost + BOOST_MULT)], [boost])
|
||||||
|
|
||||||
const style = useMemo(() => (hover || boost
|
const style = useMemo(() => ({
|
||||||
? {
|
'--hover-fill': nextColor,
|
||||||
fill: hover ? nextColor : color,
|
'--hover-filter': `drop-shadow(0 0 6px ${nextColor}90)`,
|
||||||
filter: `drop-shadow(0 0 6px ${hover ? nextColor : color}90)`
|
'--fill': color,
|
||||||
}
|
'--filter': `drop-shadow(0 0 6px ${color}90)`
|
||||||
: undefined), [boost, hover])
|
}), [color, nextColor])
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Booster
|
<Booster
|
||||||
item={item} As={({ ...oprops }) =>
|
item={item} As={oprops =>
|
||||||
<div className='upvoteParent'>
|
<div className='upvoteParent'>
|
||||||
<div
|
<div
|
||||||
className={styles.upvoteWrapper}
|
className={styles.upvoteWrapper}
|
||||||
>
|
>
|
||||||
<BoostIcon
|
<BoostIcon
|
||||||
{...props} {...oprops} style={style}
|
{...props}
|
||||||
|
{...oprops}
|
||||||
|
style={style}
|
||||||
width={26}
|
width={26}
|
||||||
height={26}
|
height={26}
|
||||||
onPointerEnter={() => setHover(true)}
|
className={classNames(styles.boost, className, boost && styles.boosted)}
|
||||||
onMouseLeave={() => setHover(false)}
|
|
||||||
onTouchEnd={() => setHover(false)}
|
|
||||||
className={classNames(styles.boost, className, boost && styles.voted)}
|
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
</div>}
|
</div>}
|
||||||
|
|
|
@ -109,7 +109,6 @@ export default function UpVote ({ item, className, collapsed }) {
|
||||||
const [tipShow, _setTipShow] = useState(false)
|
const [tipShow, _setTipShow] = useState(false)
|
||||||
const ref = useRef()
|
const ref = useRef()
|
||||||
const { me } = useMe()
|
const { me } = useMe()
|
||||||
const [hover, setHover] = useState(false)
|
|
||||||
const [setWalkthrough] = useMutation(
|
const [setWalkthrough] = useMutation(
|
||||||
gql`
|
gql`
|
||||||
mutation setWalkthrough($upvotePopover: Boolean, $tipPopover: Boolean) {
|
mutation setWalkthrough($upvotePopover: Boolean, $tipPopover: Boolean) {
|
||||||
|
@ -172,10 +171,6 @@ export default function UpVote ({ item, className, collapsed }) {
|
||||||
me, item?.meSats, item?.meAnonSats, me?.privates?.tipDefault, me?.privates?.turboDefault,
|
me, item?.meSats, item?.meAnonSats, me?.privates?.tipDefault, me?.privates?.turboDefault,
|
||||||
me?.privates?.tipRandom, me?.privates?.tipRandomMin, me?.privates?.tipRandomMax, pending])
|
me?.privates?.tipRandom, me?.privates?.tipRandomMin, me?.privates?.tipRandomMax, pending])
|
||||||
|
|
||||||
const handleModalClosed = () => {
|
|
||||||
setHover(false)
|
|
||||||
}
|
|
||||||
|
|
||||||
const handleLongPress = (e) => {
|
const handleLongPress = (e) => {
|
||||||
if (!item) return
|
if (!item) return
|
||||||
|
|
||||||
|
@ -195,7 +190,7 @@ export default function UpVote ({ item, className, collapsed }) {
|
||||||
setController(c)
|
setController(c)
|
||||||
|
|
||||||
showModal(onClose =>
|
showModal(onClose =>
|
||||||
<ItemAct onClose={onClose} item={item} abortSignal={c.signal} />, { onClose: handleModalClosed })
|
<ItemAct onClose={onClose} item={item} abortSignal={c.signal} />)
|
||||||
}
|
}
|
||||||
|
|
||||||
const handleShortPress = async () => {
|
const handleShortPress = async () => {
|
||||||
|
@ -223,19 +218,16 @@ export default function UpVote ({ item, className, collapsed }) {
|
||||||
|
|
||||||
await zap({ item, me, abortSignal: c.signal })
|
await zap({ item, me, abortSignal: c.signal })
|
||||||
} else {
|
} else {
|
||||||
showModal(onClose => <ItemAct onClose={onClose} item={item} />, { onClose: handleModalClosed })
|
showModal(onClose => <ItemAct onClose={onClose} item={item} />)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const style = useMemo(() => {
|
const style = useMemo(() => ({
|
||||||
const fillColor = pending || hover ? nextColor : color
|
'--hover-fill': nextColor,
|
||||||
return meSats || hover || pending
|
'--hover-filter': `drop-shadow(0 0 6px ${nextColor}90)`,
|
||||||
? {
|
'--fill': color,
|
||||||
fill: fillColor,
|
'--filter': `drop-shadow(0 0 6px ${color}90)`
|
||||||
filter: `drop-shadow(0 0 6px ${fillColor}90)`
|
}), [color, nextColor])
|
||||||
}
|
|
||||||
: undefined
|
|
||||||
}, [hover, pending, nextColor, color, meSats])
|
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div ref={ref} className='upvoteParent'>
|
<div ref={ref} className='upvoteParent'>
|
||||||
|
@ -246,9 +238,6 @@ export default function UpVote ({ item, className, collapsed }) {
|
||||||
<ActionTooltip notForm disable={disabled} overlayText={overlayText}>
|
<ActionTooltip notForm disable={disabled} overlayText={overlayText}>
|
||||||
<div className={classNames(disabled && styles.noSelfTips, styles.upvoteWrapper)}>
|
<div className={classNames(disabled && styles.noSelfTips, styles.upvoteWrapper)}>
|
||||||
<UpBolt
|
<UpBolt
|
||||||
onPointerEnter={() => setHover(true)}
|
|
||||||
onMouseLeave={() => setHover(false)}
|
|
||||||
onTouchEnd={() => setHover(false)}
|
|
||||||
width={26}
|
width={26}
|
||||||
height={26}
|
height={26}
|
||||||
className={classNames(styles.upvote,
|
className={classNames(styles.upvote,
|
||||||
|
|
|
@ -5,6 +5,11 @@
|
||||||
-webkit-touch-callout: none;
|
-webkit-touch-callout: none;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.upvote:hover {
|
||||||
|
fill: var(--hover-fill) !important;
|
||||||
|
filter: var(--hover-filter) !important;
|
||||||
|
}
|
||||||
|
|
||||||
.boost {
|
.boost {
|
||||||
fill: var(--theme-clickToContextColor);
|
fill: var(--theme-clickToContextColor);
|
||||||
user-select: none;
|
user-select: none;
|
||||||
|
@ -12,6 +17,16 @@
|
||||||
-webkit-touch-callout: none;
|
-webkit-touch-callout: none;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.boost:hover {
|
||||||
|
fill: var(--hover-fill) !important;
|
||||||
|
filter: var(--hover-filter) !important;
|
||||||
|
}
|
||||||
|
|
||||||
|
.boost.boosted {
|
||||||
|
fill: var(--fill);
|
||||||
|
filter: var(--filter);
|
||||||
|
}
|
||||||
|
|
||||||
.upvoteWrapper {
|
.upvoteWrapper {
|
||||||
position: relative;
|
position: relative;
|
||||||
padding-right: .2rem;
|
padding-right: .2rem;
|
||||||
|
@ -28,8 +43,8 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
.upvote.voted {
|
.upvote.voted {
|
||||||
fill: #F6911D;
|
fill: var(--fill);
|
||||||
filter: drop-shadow(0 0 6px #f6911d90);
|
filter: var(--filter);
|
||||||
}
|
}
|
||||||
|
|
||||||
.cover {
|
.cover {
|
||||||
|
@ -43,6 +58,7 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
.pending {
|
.pending {
|
||||||
|
fill: var(--hover-fill);
|
||||||
animation-name: pulse;
|
animation-name: pulse;
|
||||||
animation-iteration-count: infinite;
|
animation-iteration-count: infinite;
|
||||||
animation-timing-function: linear;
|
animation-timing-function: linear;
|
||||||
|
|
Loading…
Reference in New Issue