mango-v4-ui/components/shared/SideBadge.tsx

31 lines
798 B
TypeScript
Raw Normal View History

2022-09-13 23:24:26 -07:00
import React, { FunctionComponent } from 'react'
import { useTranslation } from 'next-i18next'
2022-10-31 11:26:17 -07:00
import { PerpOrderSide } from '@blockworks-foundation/mango-v4'
2022-09-13 23:24:26 -07:00
type SideBadgeProps = {
2022-10-31 11:26:17 -07:00
side: string | PerpOrderSide
2022-09-13 23:24:26 -07:00
}
const SideBadge: FunctionComponent<SideBadgeProps> = ({ side }) => {
const { t } = useTranslation('common')
return (
<div
className={`inline-block rounded uppercase ${
2022-11-01 08:54:29 -07:00
side === 'buy' || side === 'long' || side === PerpOrderSide.bid
2022-09-13 23:24:26 -07:00
? 'border border-th-green text-th-green'
: 'border border-th-red text-th-red'
}
-my-0.5 px-1.5 py-0.5 text-xs uppercase`}
>
2022-10-31 11:26:17 -07:00
{typeof side === 'string'
? t(side)
: side === PerpOrderSide.bid
? 'Buy'
: 'Sell'}
2022-09-13 23:24:26 -07:00
</div>
)
}
export default SideBadge