2022-08-10 04:17:10 -07:00
|
|
|
import { useTranslation } from 'next-i18next'
|
|
|
|
import { FunctionComponent } from 'react'
|
|
|
|
|
|
|
|
interface TabButtonsProps {
|
|
|
|
activeValue: string
|
2022-09-21 22:28:53 -07:00
|
|
|
onChange: (x: any) => void
|
2022-08-10 04:17:10 -07:00
|
|
|
values: Array<any>
|
2022-09-14 23:06:23 -07:00
|
|
|
showBorders?: boolean
|
|
|
|
rounded?: boolean
|
2022-09-21 22:28:53 -07:00
|
|
|
fillWidth?: 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-09-21 22:28:53 -07:00
|
|
|
fillWidth = false,
|
2022-08-10 04:17:10 -07:00
|
|
|
}) => {
|
2022-09-14 18:06:00 -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-21 22:28:53 -07:00
|
|
|
<div className={fillWidth ? 'flex-1' : ''} key={v + i}>
|
2022-08-10 04:17:10 -07:00
|
|
|
<button
|
2022-09-21 22:28:53 -07:00
|
|
|
className={`default-transition h-12 w-full px-6 font-bold ${
|
2022-09-16 03:49:10 -07:00
|
|
|
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
|