From 5dac2f2ed0517120bec47f452de44b63a3983e23 Mon Sep 17 00:00:00 2001 From: k00b Date: Tue, 19 Nov 2024 19:12:18 -0600 Subject: [PATCH] fix #1566 --- components/boost-button.js | 27 ++++++++++++--------------- components/upvote.js | 27 ++++++++------------------- components/upvote.module.css | 20 ++++++++++++++++++-- 3 files changed, 38 insertions(+), 36 deletions(-) diff --git a/components/boost-button.js b/components/boost-button.js index 8174fc91..499353d0 100644 --- a/components/boost-button.js +++ b/components/boost-button.js @@ -2,7 +2,7 @@ import { useShowModal } from './modal' import { useToast } from './toast' import ItemAct from './item-act' import AccordianItem from './accordian-item' -import { useMemo, useState } from 'react' +import { useMemo } from 'react' import getColor from '@/lib/rainbow' import BoostIcon from '@/svgs/arrow-up-double-line.svg' import styles from './upvote.module.css' @@ -12,32 +12,29 @@ import classNames from 'classnames' export default function Boost ({ item, className, ...props }) { const { boost } = item - const [hover, setHover] = useState(false) - const [color, nextColor] = useMemo(() => [getColor(boost), getColor(boost + BOOST_MULT)], [boost]) - const style = useMemo(() => (hover || boost - ? { - fill: hover ? nextColor : color, - filter: `drop-shadow(0 0 6px ${hover ? nextColor : color}90)` - } - : undefined), [boost, hover]) + const style = useMemo(() => ({ + '--hover-fill': nextColor, + '--hover-filter': `drop-shadow(0 0 6px ${nextColor}90)`, + '--fill': color, + '--filter': `drop-shadow(0 0 6px ${color}90)` + }), [color, nextColor]) return ( + item={item} As={oprops =>
setHover(true)} - onMouseLeave={() => setHover(false)} - onTouchEnd={() => setHover(false)} - className={classNames(styles.boost, className, boost && styles.voted)} + className={classNames(styles.boost, className, boost && styles.boosted)} />
} diff --git a/components/upvote.js b/components/upvote.js index 9db08819..a6ae97c3 100644 --- a/components/upvote.js +++ b/components/upvote.js @@ -109,7 +109,6 @@ export default function UpVote ({ item, className, collapsed }) { const [tipShow, _setTipShow] = useState(false) const ref = useRef() const { me } = useMe() - const [hover, setHover] = useState(false) const [setWalkthrough] = useMutation( gql` 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?.privates?.tipRandom, me?.privates?.tipRandomMin, me?.privates?.tipRandomMax, pending]) - const handleModalClosed = () => { - setHover(false) - } - const handleLongPress = (e) => { if (!item) return @@ -195,7 +190,7 @@ export default function UpVote ({ item, className, collapsed }) { setController(c) showModal(onClose => - , { onClose: handleModalClosed }) + ) } const handleShortPress = async () => { @@ -223,19 +218,16 @@ export default function UpVote ({ item, className, collapsed }) { await zap({ item, me, abortSignal: c.signal }) } else { - showModal(onClose => , { onClose: handleModalClosed }) + showModal(onClose => ) } } - const style = useMemo(() => { - const fillColor = pending || hover ? nextColor : color - return meSats || hover || pending - ? { - fill: fillColor, - filter: `drop-shadow(0 0 6px ${fillColor}90)` - } - : undefined - }, [hover, pending, nextColor, color, meSats]) + const style = useMemo(() => ({ + '--hover-fill': nextColor, + '--hover-filter': `drop-shadow(0 0 6px ${nextColor}90)`, + '--fill': color, + '--filter': `drop-shadow(0 0 6px ${color}90)` + }), [color, nextColor]) return (
@@ -246,9 +238,6 @@ export default function UpVote ({ item, className, collapsed }) {
setHover(true)} - onMouseLeave={() => setHover(false)} - onTouchEnd={() => setHover(false)} width={26} height={26} className={classNames(styles.upvote, diff --git a/components/upvote.module.css b/components/upvote.module.css index 0866e504..679a3868 100644 --- a/components/upvote.module.css +++ b/components/upvote.module.css @@ -5,6 +5,11 @@ -webkit-touch-callout: none; } +.upvote:hover { + fill: var(--hover-fill) !important; + filter: var(--hover-filter) !important; +} + .boost { fill: var(--theme-clickToContextColor); user-select: none; @@ -12,6 +17,16 @@ -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 { position: relative; padding-right: .2rem; @@ -28,8 +43,8 @@ } .upvote.voted { - fill: #F6911D; - filter: drop-shadow(0 0 6px #f6911d90); + fill: var(--fill); + filter: var(--filter); } .cover { @@ -43,6 +58,7 @@ } .pending { + fill: var(--hover-fill); animation-name: pulse; animation-iteration-count: infinite; animation-timing-function: linear;