2022-08-10 04:17:10 -07:00
|
|
|
import { useTranslation } from 'next-i18next'
|
|
|
|
import { FunctionComponent } from 'react'
|
|
|
|
|
|
|
|
interface TabButtonsProps {
|
|
|
|
activeValue: string
|
|
|
|
className?: string
|
|
|
|
onChange: (x: string) => void
|
|
|
|
values: Array<any>
|
|
|
|
large?: boolean
|
|
|
|
}
|
|
|
|
|
|
|
|
const TabButtons: FunctionComponent<TabButtonsProps> = ({
|
|
|
|
activeValue,
|
|
|
|
className,
|
|
|
|
values,
|
|
|
|
onChange,
|
|
|
|
large,
|
|
|
|
}) => {
|
2022-09-14 18:06:00 -07:00
|
|
|
const { t } = useTranslation(['common', 'swap'])
|
2022-08-10 04:17:10 -07:00
|
|
|
|
|
|
|
return (
|
|
|
|
<div className="flex w-max space-x-8">
|
|
|
|
{values.map((v, i) => (
|
|
|
|
<div className="relative" key={v + i}>
|
|
|
|
<div
|
2022-08-16 15:29:24 -07:00
|
|
|
className={`absolute top-9 h-[2px] w-full bg-th-primary transition-all duration-200 ease-in`}
|
2022-08-10 04:17:10 -07:00
|
|
|
style={
|
|
|
|
v === activeValue
|
|
|
|
? { transform: 'scale3d(1,1,1)', opacity: 1 }
|
|
|
|
: { transform: 'scale3d(0,1,1)', opacity: 0 }
|
|
|
|
}
|
|
|
|
/>
|
|
|
|
<button
|
2022-08-16 15:29:24 -07:00
|
|
|
className={`${className} relative cursor-pointer rounded-md text-center font-bold ${
|
2022-08-10 04:17:10 -07:00
|
|
|
large ? 'text-xl' : 'text-base'
|
|
|
|
}
|
|
|
|
${
|
|
|
|
v === activeValue
|
|
|
|
? `text-th-fgd-1`
|
|
|
|
: `text-th-fgd-4 md:hover:text-th-fgd-1`
|
|
|
|
}
|
|
|
|
`}
|
|
|
|
key={`${v}${i}`}
|
|
|
|
onClick={() => onChange(v)}
|
|
|
|
>
|
|
|
|
{t(v)}
|
|
|
|
</button>
|
|
|
|
</div>
|
|
|
|
))}
|
|
|
|
</div>
|
|
|
|
)
|
|
|
|
}
|
|
|
|
|
|
|
|
export default TabButtons
|