diff --git a/src/Components/VoteButton/VoteButton.tsx b/src/Components/VoteButton/VoteButton.tsx index aae357e..8880e0f 100644 --- a/src/Components/VoteButton/VoteButton.tsx +++ b/src/Components/VoteButton/VoteButton.tsx @@ -19,11 +19,18 @@ interface Particle { } type Props = { - initVotes: number - onVote: (Vote: number) => void + initVotes: number, + onVote: (Vote: number) => void, + fillType: 'leftRight' | 'upDown' | "background" + disableCounter?: boolean } & Omit, 'children'> -export default function VoteButton({ initVotes, onVote = () => { }, ...props }: Props) { +export default function VoteButton({ + disableCounter = false, + fillType = 'leftRight', + initVotes, + onVote = () => { }, + ...props }: Props) { const [voteCnt, setVoteCnt] = useState(0) const voteCntRef = useRef(0); const [sparks, setSparks] = useState([]); @@ -48,13 +55,14 @@ export default function VoteButton({ initVotes, onVote = () => { }, ...props }: incrementsCountRef.current += 1; setIncrementsCount(v => incrementsCountRef.current); - setIncrements(v => { - const genId = Math.random().toString(); - setTimeout(() => { - setIncrements(v => v.filter(e => e.id !== genId)) - }, 500) - return [...v, { id: genId, value: _incStep }] - }); + if (!disableCounter) + setIncrements(v => { + const genId = Math.random().toString(); + setTimeout(() => { + setIncrements(v => v.filter(e => e.id !== genId)) + }, 500) + return [...v, { id: genId, value: _incStep }] + }); setVoteCnt(s => { const newValue = s + _incStep; @@ -70,7 +78,7 @@ export default function VoteButton({ initVotes, onVote = () => { }, ...props }: animation: randomItem(styles.fly_spark_1, styles.fly_spark_1), animationSpeed: randomItem(1, 1.5, 2), color: `hsl(0deg 86% ${random(50, 63)}%)`, - scale: random(1.2, 1.8) + scale: random(1, 1.5) })) // if on mobile screen, reduce number of sparks particles to 60% @@ -108,22 +116,31 @@ export default function VoteButton({ initVotes, onVote = () => { }, ...props }: } return ( - + ) } diff --git a/src/Components/VoteButton/styles.module.css b/src/Components/VoteButton/styles.module.css index e2c7297..5bf9509 100644 --- a/src/Components/VoteButton/styles.module.css +++ b/src/Components/VoteButton/styles.module.css @@ -33,11 +33,25 @@ width: 100%; height: 100%; position: absolute; +} + +.color_overlay__background::before { + top: 0; + right: 0; +} + +.color_overlay__leftRight::before { top: 0; right: 100%; transform: translateX(var(--offset)); } +.color_overlay__upDown::before { + top: 100%; + right: 0; + transform: translateY(calc(-1 * var(--offset))); +} + @keyframes fly_value { 0% { transform: translate(-50%, 0) scale(0.5); @@ -45,12 +59,12 @@ } 66% { - transform: translate(-50%, -36px) scale(1.2); + transform: translate(-50%, -26px) scale(1.2); opacity: 0.6; } 100% { - transform: translate(-50%, -48px) scale(0.8); + transform: translate(-50%, -38px) scale(0.8); opacity: 0; } }