mango-web/components/PercentPill.tsx

21 lines
511 B
TypeScript
Raw Normal View History

interface PercentPillProps {
value: number
className?: string
2021-07-17 16:44:14 -07:00
bg?: string
}
const PercentPill = (props: PercentPillProps) => {
2021-07-17 16:44:14 -07:00
const bg = props.bg || (props.value > 0 ? 'bg-green-500' : 'bg-mango-red')
const displayValue = props.value.toFixed(props.value > 10 ? 0 : 1)
return (
<div
2021-07-18 13:48:18 -07:00
className={`${props.className} ${bg} inline-flex text-xs h-5 mt-1 items-center px-2 py-1 uppercase font-bold rounded-full`}
>
<p>{displayValue}%</p>
</div>
)
}
2021-07-12 04:47:55 -07:00
export default PercentPill