mango-v4-ui/components/swap/TokenSelect.tsx

38 lines
1.3 KiB
TypeScript
Raw Normal View History

2023-07-04 21:40:47 -07:00
import { ChevronDownIcon } from '@heroicons/react/20/solid'
2022-11-18 11:11:06 -08:00
import useMangoGroup from 'hooks/useMangoGroup'
2022-11-21 20:20:05 -08:00
import { Bank } from '@blockworks-foundation/mango-v4'
2023-02-27 23:20:11 -08:00
import { Dispatch, SetStateAction } from 'react'
2023-04-16 18:04:13 -07:00
import { formatTokenSymbol } from 'utils/tokens'
2023-07-04 21:40:47 -07:00
import TokenLogo from '@components/shared/TokenLogo'
2022-07-05 20:37:49 -07:00
type TokenSelectProps = {
2022-11-21 20:20:05 -08:00
bank: Bank | undefined
2023-02-27 23:20:11 -08:00
showTokenList: Dispatch<SetStateAction<'input' | 'output' | undefined>>
2022-07-16 04:22:59 -07:00
type: 'input' | 'output'
2022-07-05 20:37:49 -07:00
}
2022-11-21 20:20:05 -08:00
const TokenSelect = ({ bank, showTokenList, type }: TokenSelectProps) => {
2022-11-18 11:11:06 -08:00
const { group } = useMangoGroup()
2022-07-05 20:37:49 -07:00
if (!group) return null
2022-07-05 20:37:49 -07:00
return (
<button
2022-07-22 23:15:51 -07:00
onClick={() => showTokenList(type)}
className="flex h-[56px] w-full items-center rounded-lg rounded-r-none bg-th-input-bkg py-2 px-3 text-th-fgd-2 focus-visible:bg-th-bkg-3 md:hover:cursor-pointer md:hover:bg-th-bkg-1 md:hover:text-th-fgd-1"
2022-07-22 23:15:51 -07:00
>
<div className="mr-2.5 flex min-w-[24px] items-center">
2023-07-04 21:40:47 -07:00
<TokenLogo bank={bank} />
</div>
2022-07-22 23:15:51 -07:00
<div className="flex w-full items-center justify-between">
2023-04-16 18:04:13 -07:00
<div className="text-xl font-bold text-th-fgd-1">
{formatTokenSymbol(bank!.name)}
</div>
2022-07-22 23:15:51 -07:00
<ChevronDownIcon className="h-6 w-6" />
</div>
</button>
2022-07-05 20:37:49 -07:00
)
}
export default TokenSelect