mirror of
https://gitlab.com/MrFry/qmining-page
synced 2025-04-01 20:23:44 +02:00
Added user file vote
This commit is contained in:
parent
9ef2c10af1
commit
d3f45e62f5
4 changed files with 207 additions and 23 deletions
src/components
48
src/components/upDownVote.js
Normal file
48
src/components/upDownVote.js
Normal file
|
@ -0,0 +1,48 @@
|
|||
import React from 'react'
|
||||
|
||||
import styles from './upDownVote.module.css'
|
||||
|
||||
export default function UpDownVote({
|
||||
onUp,
|
||||
onDown,
|
||||
onClear,
|
||||
upvotes,
|
||||
downvotes,
|
||||
userId,
|
||||
}) {
|
||||
const upvoted = upvotes.includes(userId)
|
||||
const downvoted = downvotes.includes(userId)
|
||||
|
||||
return (
|
||||
<div className={styles.container}>
|
||||
<div
|
||||
className={styles.action}
|
||||
onClick={(e) => {
|
||||
e.stopPropagation()
|
||||
if (!upvoted) {
|
||||
onUp()
|
||||
} else {
|
||||
onClear()
|
||||
}
|
||||
}}
|
||||
>
|
||||
<div>👍</div>
|
||||
<div className={`${upvoted && styles.voted}`}>{upvotes.length}</div>
|
||||
</div>
|
||||
<div
|
||||
className={styles.action}
|
||||
onClick={(e) => {
|
||||
e.stopPropagation()
|
||||
if (!downvoted) {
|
||||
onDown()
|
||||
} else {
|
||||
onClear()
|
||||
}
|
||||
}}
|
||||
>
|
||||
<div>👎</div>
|
||||
<div className={`${downvoted && styles.voted}`}>{downvotes.length}</div>
|
||||
</div>
|
||||
</div>
|
||||
)
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue