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

51 lines
1.4 KiB
TypeScript
Raw Normal View History

2022-09-06 21:36:35 -07:00
import {
ChevronDownIcon,
QuestionMarkCircleIcon,
} from '@heroicons/react/20/solid'
2022-07-05 20:37:49 -07:00
import Image from 'next/image'
2022-09-12 08:53:57 -07:00
import mangoStore from '@store/mangoStore'
2022-07-05 20:37:49 -07:00
type TokenSelectProps = {
tokenSymbol: string | undefined
2022-07-16 04:22:59 -07:00
showTokenList: (x: any) => void
type: 'input' | 'output'
2022-07-05 20:37:49 -07:00
}
const TokenSelect = ({
tokenSymbol,
showTokenList,
type,
}: TokenSelectProps) => {
2022-07-05 20:37:49 -07:00
const group = mangoStore((s) => s.group)
2022-08-15 19:41:06 -07:00
const jupiterTokens = mangoStore((s) => s.jupiterTokens)
2022-07-05 20:37:49 -07:00
if (!group) return null
2022-08-15 19:41:06 -07:00
let logoURI
if (jupiterTokens.length) {
logoURI = jupiterTokens.find((t) => t.symbol === tokenSymbol)!.logoURI
2022-08-15 19:41:06 -07:00
}
2022-07-05 20:37:49 -07:00
return (
2022-07-22 23:15:51 -07:00
<div
onClick={() => showTokenList(type)}
2022-08-15 04:28:36 -07:00
className="default-transition flex h-full items-center rounded-lg rounded-r-none p-3 text-th-fgd-2 hover:cursor-pointer hover:bg-th-bkg-2 hover:text-th-fgd-1"
2022-07-22 23:15:51 -07:00
role="button"
>
<div className="mr-2.5 flex min-w-[24px] items-center">
2022-08-15 19:41:06 -07:00
{logoURI ? (
<Image alt="" width="24" height="24" src={logoURI} />
) : (
<QuestionMarkCircleIcon className="h-7 w-7 text-th-fgd-3" />
)}
</div>
2022-07-22 23:15:51 -07:00
<div className="flex w-full items-center justify-between">
<div className="text-xl font-bold text-th-fgd-1">{tokenSymbol}</div>
2022-07-22 23:15:51 -07:00
<ChevronDownIcon className="h-6 w-6" />
</div>
</div>
2022-07-05 20:37:49 -07:00
)
}
export default TokenSelect