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

49 lines
1.2 KiB
TypeScript
Raw Normal View History

2022-08-10 04:17:10 -07:00
import { useTranslation } from 'next-i18next'
import { FunctionComponent } from 'react'
interface TabButtonsProps {
activeValue: string
onChange: (x: string) => void
values: Array<any>
2022-09-14 23:06:23 -07:00
showBorders?: boolean
rounded?: boolean
2022-08-10 04:17:10 -07:00
}
const TabButtons: FunctionComponent<TabButtonsProps> = ({
activeValue,
values,
onChange,
2022-09-14 23:06:23 -07:00
showBorders = false,
rounded = false,
2022-08-10 04:17:10 -07:00
}) => {
const { t } = useTranslation(['common', 'swap'])
2022-08-10 04:17:10 -07:00
return (
2022-09-14 23:06:23 -07:00
<div
className={`flex bg-th-bkg-1 text-th-fgd-4 ${
2022-09-16 03:49:10 -07:00
showBorders ? 'border-b border-th-bkg-3' : ''
2022-09-14 23:06:23 -07:00
}`}
>
2022-08-10 04:17:10 -07:00
{values.map((v, i) => (
2022-09-14 23:06:23 -07:00
<div key={v + i}>
2022-08-10 04:17:10 -07:00
<button
2022-09-16 03:49:10 -07:00
className={`default-transition h-12 px-6 font-bold ${
rounded ? 'rounded-md' : 'rounded-none'
} ${showBorders ? 'border-r border-th-bkg-3' : ''} ${
2022-09-14 23:06:23 -07:00
v === activeValue
? 'bg-th-bkg-2 text-th-primary'
: 'hover:cursor-pointer hover:text-th-fgd-2'
}`}
2022-08-10 04:17:10 -07:00
key={`${v}${i}`}
onClick={() => onChange(v)}
>
{t(v)}
</button>
</div>
))}
</div>
)
}
export default TabButtons