|
|
@ -5,14 +5,15 @@ type VoteButtonProps = { |
|
|
|
icon: LucideIcon; |
|
|
|
icon: LucideIcon; |
|
|
|
isActive: boolean; |
|
|
|
isActive: boolean; |
|
|
|
count: number; |
|
|
|
count: number; |
|
|
|
|
|
|
|
hideCount?: boolean; |
|
|
|
onClick: () => void; |
|
|
|
onClick: () => void; |
|
|
|
}; |
|
|
|
}; |
|
|
|
export function VoteButton(props: VoteButtonProps) { |
|
|
|
export function VoteButton(props: VoteButtonProps) { |
|
|
|
const { icon: VoteIcon, isActive, count, onClick } = props; |
|
|
|
const { icon: VoteIcon, isActive, hideCount = false, count, onClick } = props; |
|
|
|
return ( |
|
|
|
return ( |
|
|
|
<button |
|
|
|
<button |
|
|
|
className={cn( |
|
|
|
className={cn( |
|
|
|
'flex items-center gap-1 px-2 py-1 text-sm text-gray-500 hover:bg-gray-100 hover:text-black focus:outline-none', |
|
|
|
'flex gap-1 px-2 py-1 text-sm text-gray-500 hover:bg-gray-100 hover:text-black focus:outline-none', |
|
|
|
{ |
|
|
|
{ |
|
|
|
'bg-gray-100 text-orange-600 hover:text-orange-700': isActive, |
|
|
|
'bg-gray-100 text-orange-600 hover:text-orange-700': isActive, |
|
|
|
'bg-transparent text-gray-500 hover:text-black': !isActive, |
|
|
|
'bg-transparent text-gray-500 hover:text-black': !isActive, |
|
|
@ -21,10 +22,14 @@ export function VoteButton(props: VoteButtonProps) { |
|
|
|
disabled={isActive} |
|
|
|
disabled={isActive} |
|
|
|
onClick={onClick} |
|
|
|
onClick={onClick} |
|
|
|
> |
|
|
|
> |
|
|
|
<VoteIcon className={cn('size-3.5 stroke-[2.5px]')} /> |
|
|
|
<VoteIcon className={cn('size-3.5 stroke-[2.5px]', { |
|
|
|
<span className="relative -top-[0.5px] text-xs font-medium tabular-nums"> |
|
|
|
'top-[1.5px] relative mr-0.5': hideCount |
|
|
|
{count} |
|
|
|
})} /> |
|
|
|
</span> |
|
|
|
{!hideCount && ( |
|
|
|
|
|
|
|
<span className="relative -top-[0.5px] text-xs font-medium tabular-nums"> |
|
|
|
|
|
|
|
{count} |
|
|
|
|
|
|
|
</span> |
|
|
|
|
|
|
|
)} |
|
|
|
</button> |
|
|
|
</button> |
|
|
|
); |
|
|
|
); |
|
|
|
} |
|
|
|
} |
|
|
|