webapp/src/components/Author/AuthorRatingControl.tsx

43 lines
1.1 KiB
TypeScript
Raw Normal View History

import styles from './AuthorRatingControl.module.scss'
import { clsx } from 'clsx'
import type { Author } from '../../graphql/types.gen'
interface AuthorRatingControlProps {
author: Author
class?: string
}
export const AuthorRatingControl = (props: AuthorRatingControlProps) => {
const isUpvoted = false
const isDownvoted = false
2023-05-01 18:32:32 +00:00
// eslint-disable-next-line unicorn/consistent-function-scoping
const handleRatingChange = (isUpvote: boolean) => {
console.log('handleRatingChange', { isUpvote })
}
return (
<div
class={clsx(styles.rating, props.class, {
[styles.isUpvoted]: isUpvoted,
[styles.isDownvoted]: isDownvoted
})}
>
<button
class={clsx(styles.ratingControl, styles.downvoteButton)}
onClick={() => handleRatingChange(false)}
>
&minus;
</button>
{/*TODO*/}
<span class={styles.ratingValue}>{123}</span>
<button
class={clsx(styles.ratingControl, styles.upvoteButton)}
onClick={() => handleRatingChange(true)}
>
+
</button>
</div>
)
}