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
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>
|
||||
)
|
||||
}
|
26
src/components/upDownVote.module.css
Normal file
26
src/components/upDownVote.module.css
Normal file
|
@ -0,0 +1,26 @@
|
|||
.container {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
padding: 3px;
|
||||
}
|
||||
|
||||
.container > div {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
}
|
||||
|
||||
.container > div > * {
|
||||
padding: 3px;
|
||||
}
|
||||
|
||||
.action {
|
||||
border-radius: 3px;
|
||||
}
|
||||
|
||||
.action:hover {
|
||||
background-color: #555;
|
||||
}
|
||||
|
||||
.voted {
|
||||
color: var(--text-color);
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue