mirror of
https://github.com/Athou/commafeed.git
synced 2026-03-21 21:37:29 +00:00
30 lines
1.0 KiB
TypeScript
30 lines
1.0 KiB
TypeScript
import { Trans } from "@lingui/macro"
|
|
import { ActionIcon, Tooltip } from "@mantine/core"
|
|
import { Constants } from "app/constants"
|
|
import { starEntry } from "app/entries/thunks"
|
|
import { useAppDispatch } from "app/store"
|
|
import type { Entry } from "app/types"
|
|
import { TbStar, TbStarFilled } from "react-icons/tb"
|
|
|
|
export function Star(props: { entry: Entry }) {
|
|
const dispatch = useAppDispatch()
|
|
const onClick = (e: React.MouseEvent) => {
|
|
e.stopPropagation()
|
|
e.preventDefault()
|
|
dispatch(
|
|
starEntry({
|
|
entry: props.entry,
|
|
starred: !props.entry.starred,
|
|
})
|
|
)
|
|
}
|
|
|
|
return (
|
|
<Tooltip label={props.entry.starred ? <Trans>Unstar</Trans> : <Trans>Star</Trans>} openDelay={Constants.tooltip.delay}>
|
|
<ActionIcon variant="transparent" onClick={onClick}>
|
|
{props.entry.starred ? <TbStarFilled size={18} /> : <TbStar size={18} />}
|
|
</ActionIcon>
|
|
</Tooltip>
|
|
)
|
|
}
|