diff --git a/components/boost-button.js b/components/boost-button.js index 6386c161..8174fc91 100644 --- a/components/boost-button.js +++ b/components/boost-button.js @@ -2,9 +2,9 @@ import { useShowModal } from './modal' import { useToast } from './toast' import ItemAct from './item-act' import AccordianItem from './accordian-item' -import { useMemo } from 'react' +import { useMemo, useState } from 'react' import getColor from '@/lib/rainbow' -import UpBolt from '@/svgs/bolt.svg' +import BoostIcon from '@/svgs/arrow-up-double-line.svg' import styles from './upvote.module.css' import { BoostHelp } from './adv-post-form' import { BOOST_MULT } from '@/lib/constants' @@ -12,15 +12,17 @@ import classNames from 'classnames' export default function Boost ({ item, className, ...props }) { const { boost } = item - const style = useMemo(() => (boost + const [hover, setHover] = useState(false) + + const [color, nextColor] = useMemo(() => [getColor(boost), getColor(boost + BOOST_MULT)], [boost]) + + const style = useMemo(() => (hover || boost ? { - fill: getColor(boost), - filter: `drop-shadow(0 0 6px ${getColor(boost)}90)`, - transform: 'scaleX(-1)' + fill: hover ? nextColor : color, + filter: `drop-shadow(0 0 6px ${hover ? nextColor : color}90)` } - : { - transform: 'scaleX(-1)' - }), [boost]) + : undefined), [boost, hover]) + return ( @@ -28,11 +30,14 @@ export default function Boost ({ item, className, ...props }) {
- setHover(true)} + onMouseLeave={() => setHover(false)} + onTouchEnd={() => setHover(false)} + className={classNames(styles.boost, className, boost && styles.voted)} />
} diff --git a/components/upvote.module.css b/components/upvote.module.css index 01460769..0866e504 100644 --- a/components/upvote.module.css +++ b/components/upvote.module.css @@ -5,6 +5,13 @@ -webkit-touch-callout: none; } +.boost { + fill: var(--theme-clickToContextColor); + user-select: none; + -webkit-user-select: none; + -webkit-touch-callout: none; +} + .upvoteWrapper { position: relative; padding-right: .2rem; diff --git a/svgs/arrow-up-double-line.svg b/svgs/arrow-up-double-line.svg new file mode 100644 index 00000000..efed6af8 --- /dev/null +++ b/svgs/arrow-up-double-line.svg @@ -0,0 +1 @@ + \ No newline at end of file