Merge remote-tracking branch 'origin/main' into main

This commit is contained in:
Tyler Shipe 2021-08-19 09:56:07 -04:00
commit d0abf9be6a
4 changed files with 86 additions and 105 deletions

View File

@ -1,7 +1,7 @@
import React, { FunctionComponent, useEffect, useState } from 'react' import React, { FunctionComponent, useEffect, useState } from 'react'
import { RadioGroup } from '@headlessui/react' import { RadioGroup } from '@headlessui/react'
import { CheckCircleIcon } from '@heroicons/react/solid' import { CheckCircleIcon } from '@heroicons/react/solid'
import { ChevronLeftIcon, PlusCircleIcon } from '@heroicons/react/outline' import { PlusCircleIcon } from '@heroicons/react/outline'
import useMangoStore from '../stores/useMangoStore' import useMangoStore from '../stores/useMangoStore'
import { import {
MangoAccount, MangoAccount,
@ -9,7 +9,7 @@ import {
MangoGroup, MangoGroup,
// ZERO_I80F48, // ZERO_I80F48,
} from '@blockworks-foundation/mango-client' } from '@blockworks-foundation/mango-client'
import { abbreviateAddress } from '../utils' import { abbreviateAddress, formatUsdValue } from '../utils'
import useLocalStorageState from '../hooks/useLocalStorageState' import useLocalStorageState from '../hooks/useLocalStorageState'
import Modal from './Modal' import Modal from './Modal'
import { ElementTitle } from './styles' import { ElementTitle } from './styles'
@ -157,11 +157,10 @@ const AccountsModal: FunctionComponent<AccountsModalProps> = ({
<> <>
<NewAccount onAccountCreation={handleNewAccountCreation} /> <NewAccount onAccountCreation={handleNewAccountCreation} />
<LinkButton <LinkButton
className="flex items-center mt-4 text-th-fgd-3" className="flex justify-center mt-4 text-th-fgd-3 w-full"
onClick={() => setShowNewAccountForm(false)} onClick={() => setShowNewAccountForm(false)}
> >
<ChevronLeftIcon className="h-5 w-5 mr-1" /> Cancel
Back
</LinkButton> </LinkButton>
</> </>
) )
@ -192,7 +191,7 @@ const AccountInfo = ({
return ( return (
<div className="text-th-fgd-3 text-xs"> <div className="text-th-fgd-3 text-xs">
${accountEquity.toFixed(2)} {formatUsdValue(accountEquity)}
{/* <span className="px-1.5 text-th-fgd-4">|</span> {/* <span className="px-1.5 text-th-fgd-4">|</span>
<span <span
className={ className={

View File

@ -5,6 +5,7 @@ import { EyeIcon, EyeOffIcon } from '@heroicons/react/outline'
import Modal from './Modal' import Modal from './Modal'
import useLocalStorageState from '../hooks/useLocalStorageState' import useLocalStorageState from '../hooks/useLocalStorageState'
import useMangoStore from '../stores/useMangoStore' import useMangoStore from '../stores/useMangoStore'
import { formatUsdValue } from '../utils'
import { LinkButton } from './Button' import { LinkButton } from './Button'
const StyledColumnHeader = styled.span` const StyledColumnHeader = styled.span`
@ -107,7 +108,7 @@ const MarketsModal = ({
</Link> </Link>
<div className="flex justify-between"> <div className="flex justify-between">
<span className="text-th-fgd-2 text-right w-20"> <span className="text-th-fgd-2 text-right w-20">
${mangoGroup.getPrice(index, mangoCache).toFixed(2)} {formatUsdValue(mangoGroup.getPrice(index, mangoCache))}
</span> </span>
{/* <span className="text-th-green text-right w-20">+2.44%</span> {/* <span className="text-th-green text-right w-20">+2.44%</span>
<span className="text-th-fgd-3 text-right w-20">$233m</span> */} <span className="text-th-fgd-3 text-right w-20">$233m</span> */}

View File

@ -27,12 +27,11 @@ interface NewAccountProps {
const NewAccount: FunctionComponent<NewAccountProps> = ({ const NewAccount: FunctionComponent<NewAccountProps> = ({
onAccountCreation, onAccountCreation,
}) => { }) => {
const [inputAmount, setInputAmount] = useState(0) const [inputAmount, setInputAmount] = useState(null)
const [submitting, setSubmitting] = useState(false) const [submitting, setSubmitting] = useState(false)
const [invalidAmountMessage, setInvalidAmountMessage] = useState('') const [invalidAmountMessage, setInvalidAmountMessage] = useState('')
const [sliderPercentage, setSliderPercentage] = useState(0) const [sliderPercentage, setSliderPercentage] = useState(0)
const [maxButtonTransition, setMaxButtonTransition] = useState(false) const [maxButtonTransition, setMaxButtonTransition] = useState(false)
const [showNewAccountName, setShowNewAccountName] = useState(true)
const [invalidNameMessage, setInvalidNameMessage] = useState('') const [invalidNameMessage, setInvalidNameMessage] = useState('')
const [name, setName] = useState('') const [name, setName] = useState('')
const walletTokens = useMangoStore((s) => s.wallet.tokens) const walletTokens = useMangoStore((s) => s.wallet.tokens)
@ -142,18 +141,14 @@ const NewAccount: FunctionComponent<NewAccountProps> = ({
return ( return (
<> <>
<ElementTitle noMarignBottom>New Account</ElementTitle> <ElementTitle className="pb-2">New Account</ElementTitle>
{showNewAccountName ? ( <div className="pb-4">
<> <div className="flex items-center pb-2 text-th-fgd-1">
<div className="flex items-center justify-center text-th-fgd-3 pb-4 pt-2"> Account Name <span className="ml-1 text-th-fgd-3">(Optional)</span>
Create a public nickname for your account
<Tooltip content="Account names are stored on-chain"> <Tooltip content="Account names are stored on-chain">
<InformationCircleIcon className="h-5 w-5 ml-2 text-th-primary" /> <InformationCircleIcon className="h-5 w-5 ml-2 text-th-primary" />
</Tooltip> </Tooltip>
</div> </div>
<div className="pb-2 text-th-fgd-1">
Account Name <span className="text-th-fgd-3">(Optional)</span>
</div>
<Input <Input
type="text" type="text"
className={`border border-th-fgd-4 flex-grow`} className={`border border-th-fgd-4 flex-grow`}
@ -169,18 +164,6 @@ const NewAccount: FunctionComponent<NewAccountProps> = ({
{invalidNameMessage} {invalidNameMessage}
</div> </div>
) : null} ) : null}
<Button
onClick={() => setShowNewAccountName(false)}
disabled={name.length >= 33}
className="mt-4 w-full"
>
Next
</Button>
</>
) : (
<>
<div className="text-th-fgd-3 text-center pb-4 pt-2">
Make a deposit to initialize your new account
</div> </div>
<AccountSelect <AccountSelect
accounts={walletTokens} accounts={walletTokens}
@ -204,7 +187,7 @@ const NewAccount: FunctionComponent<NewAccountProps> = ({
placeholder="0.00" placeholder="0.00"
error={!!invalidAmountMessage} error={!!invalidAmountMessage}
onBlur={(e) => validateAmountInput(e.target.value)} onBlur={(e) => validateAmountInput(e.target.value)}
value={inputAmount} value={inputAmount || ''}
onChange={(e) => onChangeAmountInput(e.target.value)} onChange={(e) => onChangeAmountInput(e.target.value)}
suffix={symbol} suffix={symbol}
/> />
@ -225,9 +208,7 @@ const NewAccount: FunctionComponent<NewAccountProps> = ({
</div> </div>
<div className={`pt-8 flex justify-center`}> <div className={`pt-8 flex justify-center`}>
<Button <Button
disabled={ disabled={inputAmount <= 0 || inputAmount > selectedAccount.uiBalance}
inputAmount <= 0 || inputAmount > selectedAccount.uiBalance
}
onClick={handleNewAccountDeposit} onClick={handleNewAccountDeposit}
className="w-full" className="w-full"
> >
@ -238,8 +219,6 @@ const NewAccount: FunctionComponent<NewAccountProps> = ({
</Button> </Button>
</div> </div>
</> </>
)}
</>
) )
} }

View File

@ -66,7 +66,9 @@ const TopBar = () => {
<div className="font-normal text-th-primary tiny-text"> <div className="font-normal text-th-primary tiny-text">
Account Account
</div> </div>
{abbreviateAddress(mangoAccount.publicKey)} {mangoAccount.name
? mangoAccount.name
: abbreviateAddress(mangoAccount.publicKey)}
</button> </button>
</div> </div>
) : null} ) : null}