webapp/src/components/Author/AuthorShoutsRating.tsx

26 lines
663 B
TypeScript
Raw Normal View History

2023-12-27 23:35:43 +00:00
import type { Author } from '../../graphql/schema/core.gen'
import { clsx } from 'clsx'
import { createMemo } from 'solid-js'
import styles from './AuthorRatingControl.module.scss'
interface AuthorShoutsRating {
author: Author
class?: string
}
export const AuthorShoutsRating = (props: AuthorShoutsRating) => {
const isUpvoted = createMemo(() => props.author?.stat?.rating_shouts > 0)
return (
<div
class={clsx(styles.rating, props.class, {
[styles.isUpvoted]: isUpvoted(),
[styles.isDownvoted]: !isUpvoted(),
})}
>
<span class={styles.ratingValue}>{props.author?.stat?.rating_shouts}</span>
</div>
)
}